9a4a Interrupt allocation - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > FreeBSD Development

FreeBSD Development Kernel development, writing drivers, coding, and questions regarding FreeBSD internals.

Reply
 
Thread Tools Display Modes
  #1  
Old December 1st, 2008, 10:21
trandk1 trandk1 is offline
Junior Member
 
Join Date: Nov 2008
Location: Viet Nam
Posts: 2
Thanks: 0
Thanked 2 Times in 1 Post
Default Interrupt allocation

Hi all!

I'm porting device drivers from Linux to FreeBSD. I have been looking around for a way, how to register an interrupt service routine for the standard PC's serial port, i.e. 0x3f8/IRQ4, but have not found

I have ported succesfully a PCI card, where I have used bus_alloc_resource_any(), bus_setup_intr(), .. but haven't found the way for a correct registration of an non-bus interrupt, as there is no probe/attach and no device_t dev structure. Is there something like Linux's request_irq() on FreeBSD? Or how is the correct way to do that?

Thanks in advance!
Reply With Quote
  #2  
Old December 1st, 2008, 18:18
paulfrottawa's Avatar
paulfrottawa paulfrottawa is offline
Member
 
Join Date: Nov 2008
Posts: 238
Thanks: 68
Thanked 15 Times in 13 Posts
Default

I don't know if this is the right direction but I noticed some details from the configuration file. Near the bottom half about this sio(4)

I'm having problems too with an old computer
Reply With Quote
  #3  
Old December 3rd, 2008, 13:25
trandk1 trandk1 is offline
Junior Member
 
Join Date: Nov 2008
Location: Viet Nam
Posts: 2
Thanks: 0
Thanked 2 Times in 1 Post
Default

Hi,

thanks for the response but it's not what I was looking for. Nevertheless I have found the solution. I have read about the Newbus and understood that FreeBSD implemented the bus_space APIs, which is quite nice.

This implies that everything having a child is supposed to be a bus. In this case the serial port is considered to be a child of the ACPI. The API offers an unified way to allocate the resources. Please correct me if I'm wrong.

I have ported the drivers and have been testing without any problem. If you ever need to work with Profibus, here is an open solution: http://www.pbmaster.org .

This is a simple example how to attach a serial port (taken from sio and uart drivers /usr/src/sys):

Code:
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <isa/isavar.h>

static struct isa_pnp_id acpi_ns8250_ids[] = {
        {0x0005d041, "Standard PC COM port"},           /* PNP0500 */
        {0x0105d041, "16550A-compatible COM port"},     /* PNP0501 */
        {0}
};

static int
acpi_simple_probe(device_t dev)
{
        device_t parent;

        parent = device_get_parent(dev);

        if (!ISA_PNP_PROBE(parent, dev, acpi_ns8250_ids)) {
                return (BUS_PROBE_DEFAULT);
        }

        return (ENXIO);
}

static int
acpi_simple_attach(device_t dev)
{
        printf("attach\n");
        return (0);
}

static int
acpi_simple_detach(device_t dev)
{
        printf("detach\n");
        return 0;
}

static device_method_t acpi_simple_methods[] = {
        /* Device interface */
        DEVMETHOD(device_probe,         acpi_simple_probe),
        DEVMETHOD(device_attach,        acpi_simple_attach),
        DEVMETHOD(device_detach,        acpi_simple_detach),
        { 0, 0 }
};

struct acpi_simple_softc {
        int     a;
};

static driver_t acpi_simple_driver = {
        "acpi_simple",
        acpi_simple_methods,
        sizeof(struct acpi_simple_softc),
};

static devclass_t acpi_simple_devclass;

DRIVER_MODULE(acpi_simple, acpi, acpi_simple_driver, acpi_simple_devclass, 0, 0);
Reply With Quote
The Following 2 Users Say Thank You to trandk1 For This Useful Post:
Maledictus (December 4th, 2008), trasz@ (December 3rd, 2008)
Reply

Tags
interrupt serial port

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:41.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0