FreeBSD Device Drivers by Kong Joseph

FreeBSD Device Drivers by Kong Joseph

Author:Kong, Joseph [Joseph Kong]
Language: eng
Format: epub
Tags: COMPUTERS / Operating Systems / UNIX
ISBN: 9781593274368
Publisher: No Starch Press
Published: 2012-04-29T16:00:00+00:00


Before I describe the functions defined in Example 10-1, note that the constant LED_IO_ADDR is defined as 0x404c and that the constant LED_NUM is defined as 2.

The following sections describe the functions defined in Example 10-1 in the order they would roughly execute.

led_identify Function

The led_identify function is the device_identify implementation for this driver. This function is required because the ISA bus cannot identify its children unaided. Here is the function definition for led_identify (again):

static void led_identify(driver_t *driver, device_t parent) { device_t child; child = device_find_child(parent, "led", −1); if (!child) { child = BUS_ADD_CHILD(parent, 0, "led", −1); bus_set_resource(child, SYS_RES_IOPORT, 0, LED_IO_ADDR, 1); } }

This function first determines if the ISA bus has identified a child device named "led". If it has not, then "led" is appended to the ISA bus’s catalog of identified children. Afterward, bus_set_resource is called to specify that I/O port access for "led" starts at LED_IO_ADDR.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.