Changeset 8e7c9fe in mainline for uspace/drv/platform/pc/pc.c
- Timestamp:
- 2014-09-12T03:45:25Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/platform/pc/pc.c
r3eb0c85 r8e7c9fe 28 28 29 29 /** 30 * @defgroup root_pc PC platform driver.30 * @defgroup pc PC platform driver. 31 31 * @brief HelenOS PC platform driver. 32 32 * @{ … … 52 52 #include <ops/pio_window.h> 53 53 54 #define NAME " rootpc"55 56 typedef struct rootpc_fun {54 #define NAME "pc" 55 56 typedef struct pc_fun { 57 57 hw_resource_list_t hw_resources; 58 58 pio_window_t pio_window; 59 } rootpc_fun_t;60 61 static int rootpc_dev_add(ddf_dev_t *dev);62 static void root_pc_init(void);59 } pc_fun_t; 60 61 static int pc_dev_add(ddf_dev_t *dev); 62 static void pc_init(void); 63 63 64 64 /** The root device driver's standard operations. */ 65 static driver_ops_t rootpc_ops = {66 .dev_add = & rootpc_dev_add65 static driver_ops_t pc_ops = { 66 .dev_add = &pc_dev_add 67 67 }; 68 68 69 69 /** The root device driver structure. */ 70 static driver_t rootpc_driver = {70 static driver_t pc_driver = { 71 71 .name = NAME, 72 .driver_ops = & rootpc_ops72 .driver_ops = &pc_ops 73 73 }; 74 74 … … 94 94 }; 95 95 96 static rootpc_fun_t pci_data = {96 static pc_fun_t pci_data = { 97 97 .hw_resources = { 98 98 sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]), … … 112 112 113 113 /** Obtain function soft-state from DDF function node */ 114 static rootpc_fun_t *rootpc_fun(ddf_fun_t *fnode)114 static pc_fun_t *pc_fun(ddf_fun_t *fnode) 115 115 { 116 116 return ddf_fun_data_get(fnode); 117 117 } 118 118 119 static hw_resource_list_t * rootpc_get_resources(ddf_fun_t *fnode)120 { 121 rootpc_fun_t *fun = rootpc_fun(fnode);119 static hw_resource_list_t *pc_get_resources(ddf_fun_t *fnode) 120 { 121 pc_fun_t *fun = pc_fun(fnode); 122 122 123 123 assert(fun != NULL); … … 125 125 } 126 126 127 static bool rootpc_enable_interrupt(ddf_fun_t *fun)127 static bool pc_enable_interrupt(ddf_fun_t *fun) 128 128 { 129 129 /* TODO */ … … 132 132 } 133 133 134 static pio_window_t * rootpc_get_pio_window(ddf_fun_t *fnode)135 { 136 rootpc_fun_t *fun = rootpc_fun(fnode);134 static pio_window_t *pc_get_pio_window(ddf_fun_t *fnode) 135 { 136 pc_fun_t *fun = pc_fun(fnode); 137 137 138 138 assert(fun != NULL); … … 141 141 142 142 static hw_res_ops_t fun_hw_res_ops = { 143 .get_resource_list = & rootpc_get_resources,144 .enable_interrupt = & rootpc_enable_interrupt,143 .get_resource_list = &pc_get_resources, 144 .enable_interrupt = &pc_enable_interrupt, 145 145 }; 146 146 147 147 static pio_window_ops_t fun_pio_window_ops = { 148 .get_pio_window = & rootpc_get_pio_window149 }; 150 151 /* Initialized in root_pc_init() function. */152 static ddf_dev_ops_t rootpc_fun_ops;148 .get_pio_window = &pc_get_pio_window 149 }; 150 151 /* Initialized in pc_init() function. */ 152 static ddf_dev_ops_t pc_fun_ops; 153 153 154 154 static bool 155 rootpc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,156 rootpc_fun_t *fun_proto)155 pc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id, 156 pc_fun_t *fun_proto) 157 157 { 158 158 ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name); … … 166 166 goto failure; 167 167 168 rootpc_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(rootpc_fun_t));168 pc_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(pc_fun_t)); 169 169 *fun = *fun_proto; 170 170 … … 175 175 176 176 /* Set provided operations to the device. */ 177 ddf_fun_set_ops(fnode, & rootpc_fun_ops);177 ddf_fun_set_ops(fnode, &pc_fun_ops); 178 178 179 179 /* Register function. */ … … 194 194 } 195 195 196 static bool rootpc_add_functions(ddf_dev_t *dev)197 { 198 return rootpc_add_fun(dev, "pci0", "intel_pci", &pci_data);196 static bool pc_add_functions(ddf_dev_t *dev) 197 { 198 return pc_add_fun(dev, "pci0", "intel_pci", &pci_data); 199 199 } 200 200 … … 205 205 * @return Zero on success, negative error number otherwise. 206 206 */ 207 static int rootpc_dev_add(ddf_dev_t *dev)208 { 209 ddf_msg(LVL_DEBUG, " rootpc_dev_add, device handle = %d",207 static int pc_dev_add(ddf_dev_t *dev) 208 { 209 ddf_msg(LVL_DEBUG, "pc_dev_add, device handle = %d", 210 210 (int)ddf_dev_get_handle(dev)); 211 211 212 212 /* Register functions. */ 213 if (! rootpc_add_functions(dev)) {213 if (!pc_add_functions(dev)) { 214 214 ddf_msg(LVL_ERROR, "Failed to add functions for PC platform."); 215 215 } … … 218 218 } 219 219 220 static void root_pc_init(void)220 static void pc_init(void) 221 221 { 222 222 ddf_log_init(NAME); 223 rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;224 rootpc_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops;223 pc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops; 224 pc_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops; 225 225 } 226 226 … … 228 228 { 229 229 printf(NAME ": HelenOS PC platform driver\n"); 230 root_pc_init();231 return ddf_driver_main(& rootpc_driver);230 pc_init(); 231 return ddf_driver_main(&pc_driver); 232 232 } 233 233
Note:
See TracChangeset
for help on using the changeset viewer.