Changeset 973ef9fc in mainline for uspace/drv
- Timestamp:
- 2010-12-25T21:20:28Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 631ee0c
- Parents:
- 1bfd3d3 (diff), 09178b7f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/drv
- Files:
-
- 11 added
- 1 deleted
- 4 edited
- 4 moved
-
isa/isa.c (modified) (2 diffs)
-
ns8250/ns8250.c (modified) (6 diffs)
-
pciintel/pci.c (modified) (4 diffs)
-
root/root.c (modified) (6 diffs)
-
rootia32/rootia32.ma (deleted)
-
rootpc/Makefile (moved) (moved from uspace/drv/rootia32/Makefile ) (1 diff)
-
rootpc/rootpc.c (moved) (moved from uspace/drv/rootia32/rootia32.c ) (10 diffs)
-
rootpc/rootpc.ma (added)
-
rootvirt/Makefile (added)
-
rootvirt/devices.def (added)
-
rootvirt/rootvirt.c (added)
-
rootvirt/rootvirt.ma (added)
-
test1/Makefile (added)
-
test1/char.c (moved) (moved from uspace/lib/packet/include/packet_local.h ) (2 diffs)
-
test1/test1.c (added)
-
test1/test1.h (moved) (moved from kernel/generic/include/syscall/sysarg64.h ) (2 diffs)
-
test1/test1.ma (added)
-
test2/Makefile (added)
-
test2/test2.c (added)
-
test2/test2.ma (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/isa/isa.c
r1bfd3d3 r973ef9fc 282 282 283 283 printf(NAME ": added io range (addr=0x%x, size=0x%x) to " 284 "device %s\n", addr, len, dev->name); 284 "device %s\n", (unsigned int) addr, (unsigned int) len, 285 dev->name); 285 286 } 286 287 } … … 489 490 static int isa_add_device(device_t *dev) 490 491 { 491 printf(NAME ": isa_add_device, device handle = %d\n", dev->handle); 492 printf(NAME ": isa_add_device, device handle = %d\n", 493 (int) dev->handle); 492 494 493 495 /* Add child devices. */ 494 496 add_legacy_children(dev); 495 printf(NAME ": finished the enumeration of legacy devices\n", 496 dev->handle); 497 printf(NAME ": finished the enumeration of legacy devices\n"); 497 498 498 499 return EOK; -
uspace/drv/ns8250/ns8250.c
r1bfd3d3 r973ef9fc 274 274 275 275 /* Gain control over port's registers. */ 276 if (pio_enable((void *) data->io_addr, REG_COUNT,276 if (pio_enable((void *)(uintptr_t) data->io_addr, REG_COUNT, 277 277 (void **) &data->port)) { 278 printf(NAME ": error - cannot gain the port % lxfor device "278 printf(NAME ": error - cannot gain the port %#" PRIx32 " for device " 279 279 "%s.\n", data->io_addr, dev->name); 280 280 return false; … … 342 342 printf(NAME ": failed to connect to the parent driver of the " 343 343 "device %s.\n", dev->name); 344 ret = EPARTY; /* FIXME: use another EC */344 ret = dev->parent_phone; 345 345 goto failed; 346 346 } 347 347 348 348 /* Get hw resources. */ 349 if (!get_hw_resources(dev->parent_phone, &hw_resources)) { 349 ret = get_hw_resources(dev->parent_phone, &hw_resources); 350 if (ret != EOK) { 350 351 printf(NAME ": failed to get hw resources for the device " 351 352 "%s.\n", dev->name); 352 ret = EPARTY; /* FIXME: use another EC */353 353 goto failed; 354 354 } … … 374 374 printf(NAME ": i/o range assigned to the device " 375 375 "%s is too small.\n", dev->name); 376 ret = E PARTY; /* FIXME: use another EC */376 ret = ELIMIT; 377 377 goto failed; 378 378 } … … 390 390 printf(NAME ": missing hw resource(s) for the device %s.\n", 391 391 dev->name); 392 ret = E PARTY; /* FIXME: use another EC */392 ret = ENOENT; 393 393 goto failed; 394 394 } … … 727 727 { 728 728 printf(NAME ": ns8250_add_device %s (handle = %d)\n", 729 dev->name, dev->handle);729 dev->name, (int) dev->handle); 730 730 731 731 int res = ns8250_dev_initialize(dev); … … 887 887 ipc_call_t *call) 888 888 { 889 ipcarg_t method = IPC_GET_METHOD(*call);889 sysarg_t method = IPC_GET_IMETHOD(*call); 890 890 int ret; 891 891 unsigned int baud_rate, parity, word_length, stop_bits; -
uspace/drv/pciintel/pci.c
r1bfd3d3 r973ef9fc 323 323 if (range_addr != 0) { 324 324 printf(NAME ": device %s : ", dev->name); 325 printf("address = % x", range_addr);326 printf(", size = %x\n", range_size);325 printf("address = %" PRIx64, range_addr); 326 printf(", size = %x\n", (unsigned int) range_size); 327 327 } 328 328 … … 452 452 static int pci_add_device(device_t *dev) 453 453 { 454 int rc; 455 454 456 printf(NAME ": pci_add_device\n"); 455 457 … … 466 468 "parent's driver.\n"); 467 469 delete_pci_bus_data(bus_data); 468 return EPARTY; /* FIXME: use another EC */470 return dev->parent_phone; 469 471 } 470 472 471 473 hw_resource_list_t hw_resources; 472 474 473 if (!get_hw_resources(dev->parent_phone, &hw_resources)) { 475 rc = get_hw_resources(dev->parent_phone, &hw_resources); 476 if (rc != EOK) { 474 477 printf(NAME ": pci_add_device failed to get hw resources for " 475 478 "the device.\n"); 476 479 delete_pci_bus_data(bus_data); 477 480 ipc_hangup(dev->parent_phone); 478 return EPARTY; /* FIXME: use another EC */481 return rc; 479 482 } 480 483 481 printf(NAME ": conf_addr = % x.\n",484 printf(NAME ": conf_addr = %" PRIx64 ".\n", 482 485 hw_resources.resources[0].res.io_range.address); 483 486 … … 489 492 (uint32_t) hw_resources.resources[0].res.io_range.address; 490 493 491 if (pio_enable((void *) bus_data->conf_io_addr, 8,494 if (pio_enable((void *)(uintptr_t)bus_data->conf_io_addr, 8, 492 495 &bus_data->conf_addr_port)) { 493 496 printf(NAME ": failed to enable configuration ports.\n"); -
uspace/drv/root/root.c
r1bfd3d3 r973ef9fc 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2010 Vojtech Horky 3 4 * All rights reserved. 4 5 * … … 45 46 #include <ctype.h> 46 47 #include <macros.h> 48 #include <inttypes.h> 49 #include <sysinfo.h> 47 50 48 51 #include <driver.h> … … 51 54 52 55 #define NAME "root" 56 57 #define PLATFORM_DEVICE_NAME "hw" 58 #define PLATFORM_DEVICE_MATCH_ID_FMT "platform/%s" 59 #define PLATFORM_DEVICE_MATCH_SCORE 100 60 61 #define VIRTUAL_DEVICE_NAME "virt" 62 #define VIRTUAL_DEVICE_MATCH_ID "rootvirt" 63 #define VIRTUAL_DEVICE_MATCH_SCORE 100 53 64 54 65 static int root_add_device(device_t *dev); … … 65 76 }; 66 77 78 /** Create the device which represents the root of virtual device tree. 79 * 80 * @param parent Parent of the newly created device. 81 * @return Error code. 82 */ 83 static int add_virtual_root_child(device_t *parent) 84 { 85 printf(NAME ": adding new child for virtual devices.\n"); 86 printf(NAME ": device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME, 87 VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID); 88 89 int res = child_device_register_wrapper(parent, VIRTUAL_DEVICE_NAME, 90 VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE); 91 92 return res; 93 } 94 67 95 /** Create the device which represents the root of HW device tree. 68 96 * … … 72 100 static int add_platform_child(device_t *parent) 73 101 { 102 char *match_id; 103 char *platform; 104 size_t platform_size; 105 int res; 106 107 /* Get platform name from sysinfo. */ 108 109 platform = sysinfo_get_data("platform", &platform_size); 110 if (platform == NULL) { 111 printf(NAME ": Failed to obtain platform name.\n"); 112 return ENOENT; 113 } 114 115 /* Null-terminate string. */ 116 platform = realloc(platform, platform_size + 1); 117 if (platform == NULL) { 118 printf(NAME ": Memory allocation failed.\n"); 119 return ENOMEM; 120 } 121 122 platform[platform_size] = '\0'; 123 124 /* Construct match ID. */ 125 126 if (asprintf(&match_id, PLATFORM_DEVICE_MATCH_ID_FMT, platform) == -1) { 127 printf(NAME ": Memory allocation failed.\n"); 128 return ENOMEM; 129 } 130 131 /* Add child. */ 132 74 133 printf(NAME ": adding new child for platform device.\n"); 75 76 int res = EOK; 77 device_t *platform = NULL; 78 match_id_t *match_id = NULL; 79 80 /* Create new device. */ 81 platform = create_device(); 82 if (NULL == platform) { 83 res = ENOMEM; 84 goto failure; 85 } 86 87 platform->name = "hw"; 88 printf(NAME ": the new device's name is %s.\n", platform->name); 89 90 /* Initialize match id list. */ 91 match_id = create_match_id(); 92 if (NULL == match_id) { 93 res = ENOMEM; 94 goto failure; 95 } 96 97 /* TODO - replace this with some better solution (sysinfo ?) */ 98 match_id->id = STRING(UARCH); 99 match_id->score = 100; 100 add_match_id(&platform->match_ids, match_id); 101 102 /* Register child device. */ 103 res = child_device_register(platform, parent); 104 if (EOK != res) 105 goto failure; 106 107 return res; 108 109 failure: 110 if (NULL != match_id) 111 match_id->id = NULL; 112 113 if (NULL != platform) { 114 platform->name = NULL; 115 delete_device(platform); 116 } 117 134 printf(NAME ": device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME, 135 PLATFORM_DEVICE_MATCH_SCORE, match_id); 136 137 res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME, 138 match_id, PLATFORM_DEVICE_MATCH_SCORE); 139 118 140 return res; 119 141 } … … 126 148 static int root_add_device(device_t *dev) 127 149 { 128 printf(NAME ": root_add_device, device handle = %d\n", dev->handle); 150 printf(NAME ": root_add_device, device handle=%" PRIun "\n", 151 dev->handle); 129 152 153 /* 154 * Register virtual devices root. 155 * We ignore error occurrence because virtual devices shall not be 156 * vital for the system. 157 */ 158 add_virtual_root_child(dev); 159 130 160 /* Register root device's children. */ 131 161 int res = add_platform_child(dev); -
uspace/drv/rootpc/Makefile
r1bfd3d3 r973ef9fc 30 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a 31 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include 32 BINARY = root ia3232 BINARY = rootpc 33 33 34 34 SOURCES = \ 35 root ia32.c35 rootpc.c 36 36 37 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/rootpc/rootpc.c
r1bfd3d3 r973ef9fc 28 28 29 29 /** 30 * @defgroup root_ ia32 Root HW device driver for ia32 platform.31 * @brief HelenOS root HW device driver for ia32 platform.30 * @defgroup root_pc PC platform driver. 31 * @brief HelenOS PC platform driver. 32 32 * @{ 33 33 */ … … 53 53 #include <device/hw_res.h> 54 54 55 #define NAME "root ia32"56 57 typedef struct root ia32_child_dev_data {55 #define NAME "rootpc" 56 57 typedef struct rootpc_child_dev_data { 58 58 hw_resource_list_t hw_resources; 59 } root ia32_child_dev_data_t;60 61 static int root ia32_add_device(device_t *dev);62 static void root_ ia32_init(void);59 } rootpc_child_dev_data_t; 60 61 static int rootpc_add_device(device_t *dev); 62 static void root_pc_init(void); 63 63 64 64 /** The root device driver's standard operations. */ 65 static driver_ops_t root ia32_ops = {66 .add_device = &root ia32_add_device65 static driver_ops_t rootpc_ops = { 66 .add_device = &rootpc_add_device 67 67 }; 68 68 69 69 /** The root device driver structure. */ 70 static driver_t root ia32_driver = {70 static driver_t rootpc_driver = { 71 71 .name = NAME, 72 .driver_ops = &root ia32_ops72 .driver_ops = &rootpc_ops 73 73 }; 74 74 … … 82 82 }; 83 83 84 static root ia32_child_dev_data_t pci_data = {84 static rootpc_child_dev_data_t pci_data = { 85 85 .hw_resources = { 86 86 1, … … 89 89 }; 90 90 91 static hw_resource_list_t *root ia32_get_child_resources(device_t *dev)92 { 93 root ia32_child_dev_data_t *data;94 95 data = (root ia32_child_dev_data_t *) dev->driver_data;91 static hw_resource_list_t *rootpc_get_child_resources(device_t *dev) 92 { 93 rootpc_child_dev_data_t *data; 94 95 data = (rootpc_child_dev_data_t *) dev->driver_data; 96 96 if (NULL == data) 97 97 return NULL; … … 100 100 } 101 101 102 static bool root ia32_enable_child_interrupt(device_t *dev)102 static bool rootpc_enable_child_interrupt(device_t *dev) 103 103 { 104 104 /* TODO */ … … 108 108 109 109 static resource_iface_t child_res_iface = { 110 &root ia32_get_child_resources,111 &root ia32_enable_child_interrupt112 }; 113 114 /* Initialized in root_ ia32_init() function. */115 static device_ops_t root ia32_child_ops;110 &rootpc_get_child_resources, 111 &rootpc_enable_child_interrupt 112 }; 113 114 /* Initialized in root_pc_init() function. */ 115 static device_ops_t rootpc_child_ops; 116 116 117 117 static bool 118 root ia32_add_child(device_t *parent, const char *name, const char *str_match_id,119 root ia32_child_dev_data_t *drv_data)118 rootpc_add_child(device_t *parent, const char *name, const char *str_match_id, 119 rootpc_child_dev_data_t *drv_data) 120 120 { 121 121 printf(NAME ": adding new child device '%s'.\n", name); … … 142 142 143 143 /* Set provided operations to the device. */ 144 child->ops = &root ia32_child_ops;144 child->ops = &rootpc_child_ops; 145 145 146 146 /* Register child device. */ … … 164 164 } 165 165 166 static bool root ia32_add_children(device_t *dev)167 { 168 return root ia32_add_child(dev, "pci0", "intel_pci", &pci_data);166 static bool rootpc_add_children(device_t *dev) 167 { 168 return rootpc_add_child(dev, "pci0", "intel_pci", &pci_data); 169 169 } 170 170 … … 175 175 * @return Zero on success, negative error number otherwise. 176 176 */ 177 static int rootia32_add_device(device_t *dev) 178 { 179 printf(NAME ": rootia32_add_device, device handle = %d\n", dev->handle); 177 static int rootpc_add_device(device_t *dev) 178 { 179 printf(NAME ": rootpc_add_device, device handle = %d\n", 180 (int)dev->handle); 180 181 181 182 /* Register child devices. */ 182 if (!rootia32_add_children(dev)) { 183 printf(NAME ": failed to add child devices for platform " 184 "ia32.\n"); 183 if (!rootpc_add_children(dev)) { 184 printf(NAME ": failed to add child devices for PC platform.\n"); 185 185 } 186 186 … … 188 188 } 189 189 190 static void root_ ia32_init(void)191 { 192 root ia32_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface;190 static void root_pc_init(void) 191 { 192 rootpc_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface; 193 193 } 194 194 195 195 int main(int argc, char *argv[]) 196 196 { 197 printf(NAME ": HelenOS rootia32 devicedriver\n");198 root_ ia32_init();199 return driver_main(&root ia32_driver);197 printf(NAME ": HelenOS PC platform driver\n"); 198 root_pc_init(); 199 return driver_main(&rootpc_driver); 200 200 } 201 201 -
uspace/drv/test1/char.c
r1bfd3d3 r973ef9fc 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2010 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libpacket30 * @{31 */32 33 29 /** @file 34 30 */ 35 31 36 #ifndef LIBPACKET_PACKET_LOCAL_H_ 37 #define LIBPACKET_PACKET_LOCAL_H_ 32 #include <assert.h> 33 #include <errno.h> 34 #include <mem.h> 35 #include <char.h> 38 36 39 #include <net/packet.h>37 #include "test1.h" 40 38 41 /** @name Packet local interface 42 */ 43 /*@{*/ 39 static int impl_char_read(device_t *dev, char *buf, size_t count) { 40 memset(buf, 0, count); 41 return count; 42 } 44 43 45 extern int packet_translate_local(int, packet_t *, packet_id_t); 46 extern packet_t packet_get_4_local(int, size_t, size_t, size_t, size_t); 47 extern packet_t packet_get_1_local(int, size_t); 48 extern void pq_release_local(int, packet_id_t); 44 static int imp_char_write(device_t *dev, char *buf, size_t count) { 45 return count; 46 } 49 47 50 /*@}*/ 48 static char_iface_t char_interface = { 49 .read = &impl_char_read, 50 .write = &imp_char_write 51 }; 51 52 52 #endif 53 device_ops_t char_device_ops = { 54 .interfaces[CHAR_DEV_IFACE] = &char_interface 55 }; 53 56 54 /** @}55 */ -
uspace/drv/test1/test1.h
r1bfd3d3 r973ef9fc 1 1 /* 2 * Copyright (c) 20 06 Jakub Jermar2 * Copyright (c) 2010 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup generic 30 * @{ 29 /** @file 31 30 */ 31 #ifndef DRV_TEST1_TEST1_H_ 32 #define DRV_TEST1_TEST1_H_ 32 33 33 /** 34 * @file 35 * @brief Wrapper for explicit 64-bit arguments passed to syscalls. 36 */ 34 #include <driver.h> 37 35 38 #ifndef KERN_SYSARG64_H_ 39 #define KERN_SYSARG64_H_ 36 #define NAME "test1" 40 37 41 typedef struct { 42 unsigned long long value; 43 } sysarg64_t; 38 extern device_ops_t char_device_ops; 44 39 45 40 #endif 46 47 /** @}48 */
Note:
See TracChangeset
for help on using the changeset viewer.
