1 #include "driver.h"
2
3 sb16_dev_t device;
4
5 const char* devs[2] = {
6 NULL, NULL
7 };
8
9 const char** publish_devices(void); /* Just to silence compiler */
10
11 static status_t
extract_driver_settings(void * settings,sb16_dev_t * sb16)12 extract_driver_settings(void* settings, sb16_dev_t* sb16)
13 {
14 const char* port;
15 const char* irq;
16 const char* dma8;
17 const char* dma16;
18 const char* midiport;
19 status_t rc;
20
21 if ((port=get_driver_parameter(settings, "port", "220", NULL)) != NULL &&
22 (irq=get_driver_parameter(settings, "irq", "5", NULL)) != NULL &&
23 (dma8=get_driver_parameter(settings, "dma8", "1", NULL)) != NULL &&
24 (dma16=get_driver_parameter(settings, "dma16", "5", NULL)) != NULL &&
25 (midiport=get_driver_parameter(settings, "midiport", "330", NULL)) != NULL) {
26 sb16->port = strtol(port, NULL, 16);
27 sb16->irq = strtol(irq, NULL, 16);
28 sb16->dma8 = strtol(dma8, NULL, 16);
29 sb16->dma16 = strtol(dma16, NULL, 16);
30 sb16->midiport = strtol(midiport, NULL, 16);
31
32 rc = B_OK;
33 } else {
34 rc = B_BAD_VALUE;
35 }
36
37 return rc;
38 }
39
40 //#pragma mark --
41
42 int32 api_version = B_CUR_DRIVER_API_VERSION;
43
44 status_t
init_hardware(void)45 init_hardware(void)
46 {
47 return B_OK;
48 }
49
50 status_t
init_driver(void)51 init_driver (void)
52 {
53 void* settings = load_driver_settings("sb16");
54 status_t rc;
55
56 if (settings != NULL) {
57 rc = extract_driver_settings(settings, &device);
58 if (rc == B_OK) {
59 devs[0] = DEVFS_PATH "/sb16/0";
60 dprintf("%s: publishing %s\n", __func__, devs[0]);
61 }
62 } else
63 rc = ENODEV;
64
65 return rc;
66 }
67
68 void
uninit_driver(void)69 uninit_driver (void)
70 {
71 }
72
73 const char**
publish_devices(void)74 publish_devices(void)
75 {
76 return devs;
77 }
78
79 device_hooks*
find_device(const char * name)80 find_device(const char* name)
81 {
82 return &driver_hooks;
83 }
84