Changeset b9ccc46 in mainline
- Timestamp:
- 2010-10-23T13:07:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 667eac4
- Parents:
- 5291411
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/rootia32/rootia32.c
r5291411 rb9ccc46 56 56 57 57 typedef struct rootia32_child_dev_data { 58 hw_resource_list_t hw_resources; 58 hw_resource_list_t hw_resources; 59 59 } rootia32_child_dev_data_t; 60 60 … … 62 62 static void root_ia32_init(void); 63 63 64 /** The root device driver's standard operations. 65 */ 64 /** The root device driver's standard operations. */ 66 65 static driver_ops_t rootia32_ops = { 67 66 .add_device = &rootia32_add_device 68 67 }; 69 68 70 /** The root device driver structure. 71 */ 69 /** The root device driver structure. */ 72 70 static driver_t rootia32_driver = { 73 71 .name = NAME, … … 80 78 .address = 0xCF8, 81 79 .size = 8, 82 .endianness = LITTLE_ENDIAN 83 } 80 .endianness = LITTLE_ENDIAN 81 } 84 82 }; 85 83 86 84 static rootia32_child_dev_data_t pci_data = { 87 85 .hw_resources = { 88 1, 86 1, 89 87 &pci_conf_regs 90 88 } 91 89 }; 92 90 93 static hw_resource_list_t * rootia32_get_child_resources(device_t *dev) 94 { 95 rootia32_child_dev_data_t *data = (rootia32_child_dev_data_t *)dev->driver_data; 96 if (NULL == data) { 91 static hw_resource_list_t *rootia32_get_child_resources(device_t *dev) 92 { 93 rootia32_child_dev_data_t *data; 94 95 data = (rootia32_child_dev_data_t *) dev->driver_data; 96 if (NULL == data) 97 97 return NULL; 98 }98 99 99 return &data->hw_resources; 100 100 } 101 101 102 static bool rootia32_enable_child_interrupt(device_t *dev) 103 { 104 / / TODO102 static bool rootia32_enable_child_interrupt(device_t *dev) 103 { 104 /* TODO */ 105 105 106 106 return false; … … 109 109 static resource_iface_t child_res_iface = { 110 110 &rootia32_get_child_resources, 111 &rootia32_enable_child_interrupt 112 }; 113 114 / / initialized in root_ia32_init() function111 &rootia32_enable_child_interrupt 112 }; 113 114 /* Initialized in root_ia32_init() function. */ 115 115 static device_ops_t rootia32_child_ops; 116 116 117 static bool rootia32_add_child(118 device_t *parent, const char *name, const char *str_match_id, 119 rootia32_child_dev_data_t *drv_data) 117 static bool 118 rootia32_add_child(device_t *parent, const char *name, const char *str_match_id, 119 rootia32_child_dev_data_t *drv_data) 120 120 { 121 121 printf(NAME ": adding new child device '%s'.\n", name); 122 122 123 123 device_t *child = NULL; 124 match_id_t *match_id = NULL; 125 126 // create new device 127 if (NULL == (child = create_device())) { 124 match_id_t *match_id = NULL; 125 126 /* Create new device. */ 127 child = create_device(); 128 if (NULL == child) 128 129 goto failure; 129 }130 130 131 131 child->name = name; 132 132 child->driver_data = drv_data; 133 133 134 // initialize match id list 135 if (NULL == (match_id = create_match_id())) { 134 /* Initialize match id list */ 135 match_id = create_match_id(); 136 if (NULL == match_id) 136 137 goto failure; 137 }138 138 139 match_id->id = str_match_id; 139 140 match_id->score = 100; 140 add_match_id(&child->match_ids, match_id); 141 142 / / set provided operations to the device141 add_match_id(&child->match_ids, match_id); 142 143 /* Set provided operations to the device. */ 143 144 child->ops = &rootia32_child_ops; 144 145 145 / / register child device146 if (EOK != child_device_register(child, parent)) {146 /* Register child device. */ 147 if (EOK != child_device_register(child, parent)) 147 148 goto failure; 148 }149 149 150 150 return true; 151 151 152 152 failure: 153 if (NULL != match_id) {153 if (NULL != match_id) 154 154 match_id->id = NULL; 155 }156 155 157 156 if (NULL != child) { 158 157 child->name = NULL; 159 delete_device(child); 158 delete_device(child); 160 159 } 161 160 162 161 printf(NAME ": failed to add child device '%s'.\n", name); 163 162 164 return false; 165 } 166 167 static bool rootia32_add_children(device_t *dev) 163 return false; 164 } 165 166 static bool rootia32_add_children(device_t *dev) 168 167 { 169 168 return rootia32_add_child(dev, "pci0", "intel_pci", &pci_data); … … 171 170 172 171 /** Get the root device. 173 * 174 * @param dev the device which is root of the whole device tree (both of HW and pseudo devices). 175 * @return 0 on success, negative error number otherwise. 176 */ 177 static int rootia32_add_device(device_t *dev) 172 * 173 * @param dev The device which is root of the whole device tree (both 174 * of HW and pseudo devices). 175 * @return Zero on success, negative error number otherwise. 176 */ 177 static int rootia32_add_device(device_t *dev) 178 178 { 179 179 printf(NAME ": rootia32_add_device, device handle = %d\n", dev->handle); 180 180 181 / / register child devices181 /* Register child devices. */ 182 182 if (!rootia32_add_children(dev)) { 183 printf(NAME ": failed to add child devices for platform ia32.\n"); 183 printf(NAME ": failed to add child devices for platform " 184 "ia32.\n"); 184 185 } 185 186 … … 187 188 } 188 189 189 static void root_ia32_init() { 190 static void root_ia32_init(void) 191 { 190 192 rootia32_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface; 191 193 } … … 193 195 int main(int argc, char *argv[]) 194 196 { 195 printf(NAME ": HelenOS rootia32 device driver\n"); 197 printf(NAME ": HelenOS rootia32 device driver\n"); 196 198 root_ia32_init(); 197 199 return driver_main(&rootia32_driver); … … 201 203 * @} 202 204 */ 203
Note:
See TracChangeset
for help on using the changeset viewer.