Changeset 2a37b9f in mainline for uspace/drv/platform/pc/pc.c


Ignore:
Timestamp:
2014-08-28T19:54:48Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0f2a9be
Parents:
0ddb84b
Message:

Reorganize platform drivers.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/platform/pc/pc.c

    r0ddb84b r2a37b9f  
    5252#include <ops/pio_window.h>
    5353
    54 #define NAME "rootpc"
    55 
    56 typedef struct rootpc_fun {
     54#define NAME "pc"
     55
     56typedef struct pc_fun {
    5757        hw_resource_list_t hw_resources;
    5858        pio_window_t pio_window;
    59 } rootpc_fun_t;
    60 
    61 static int rootpc_dev_add(ddf_dev_t *dev);
     59} pc_fun_t;
     60
     61static int pc_dev_add(ddf_dev_t *dev);
    6262static void root_pc_init(void);
    6363
    6464/** The root device driver's standard operations. */
    65 static driver_ops_t rootpc_ops = {
    66         .dev_add = &rootpc_dev_add
     65static driver_ops_t pc_ops = {
     66        .dev_add = &pc_dev_add
    6767};
    6868
    6969/** The root device driver structure. */
    70 static driver_t rootpc_driver = {
     70static driver_t pc_driver = {
    7171        .name = NAME,
    72         .driver_ops = &rootpc_ops
     72        .driver_ops = &pc_ops
    7373};
    7474
     
    9494};
    9595
    96 static rootpc_fun_t pci_data = {
     96static pc_fun_t pci_data = {
    9797        .hw_resources = {
    9898                sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]),
     
    112112
    113113/** Obtain function soft-state from DDF function node */
    114 static rootpc_fun_t *rootpc_fun(ddf_fun_t *fnode)
     114static pc_fun_t *pc_fun(ddf_fun_t *fnode)
    115115{
    116116        return ddf_fun_data_get(fnode);
    117117}
    118118
    119 static hw_resource_list_t *rootpc_get_resources(ddf_fun_t *fnode)
    120 {
    121         rootpc_fun_t *fun = rootpc_fun(fnode);
     119static hw_resource_list_t *pc_get_resources(ddf_fun_t *fnode)
     120{
     121        pc_fun_t *fun = pc_fun(fnode);
    122122       
    123123        assert(fun != NULL);
     
    125125}
    126126
    127 static bool rootpc_enable_interrupt(ddf_fun_t *fun)
     127static bool pc_enable_interrupt(ddf_fun_t *fun)
    128128{
    129129        /* TODO */
     
    132132}
    133133
    134 static pio_window_t *rootpc_get_pio_window(ddf_fun_t *fnode)
    135 {
    136         rootpc_fun_t *fun = rootpc_fun(fnode);
     134static pio_window_t *pc_get_pio_window(ddf_fun_t *fnode)
     135{
     136        pc_fun_t *fun = pc_fun(fnode);
    137137       
    138138        assert(fun != NULL);
     
    141141
    142142static 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,
    145145};
    146146
    147147static pio_window_ops_t fun_pio_window_ops = {
    148         .get_pio_window = &rootpc_get_pio_window
     148        .get_pio_window = &pc_get_pio_window
    149149};
    150150
    151151/* Initialized in root_pc_init() function. */
    152 static ddf_dev_ops_t rootpc_fun_ops;
     152static ddf_dev_ops_t pc_fun_ops;
    153153
    154154static bool
    155 rootpc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
    156     rootpc_fun_t *fun_proto)
     155pc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
     156    pc_fun_t *fun_proto)
    157157{
    158158        ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
     
    166166                goto failure;
    167167       
    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));
    169169        *fun = *fun_proto;
    170170       
     
    175175       
    176176        /* Set provided operations to the device. */
    177         ddf_fun_set_ops(fnode, &rootpc_fun_ops);
     177        ddf_fun_set_ops(fnode, &pc_fun_ops);
    178178       
    179179        /* Register function. */
     
    194194}
    195195
    196 static bool rootpc_add_functions(ddf_dev_t *dev)
    197 {
    198         return rootpc_add_fun(dev, "pci0", "intel_pci", &pci_data);
     196static bool pc_add_functions(ddf_dev_t *dev)
     197{
     198        return pc_add_fun(dev, "pci0", "intel_pci", &pci_data);
    199199}
    200200
     
    205205 * @return              Zero on success, negative error number otherwise.
    206206 */
    207 static int rootpc_dev_add(ddf_dev_t *dev)
    208 {
    209         ddf_msg(LVL_DEBUG, "rootpc_dev_add, device handle = %d",
     207static int pc_dev_add(ddf_dev_t *dev)
     208{
     209        ddf_msg(LVL_DEBUG, "pc_dev_add, device handle = %d",
    210210            (int)ddf_dev_get_handle(dev));
    211211       
    212212        /* Register functions. */
    213         if (!rootpc_add_functions(dev)) {
     213        if (!pc_add_functions(dev)) {
    214214                ddf_msg(LVL_ERROR, "Failed to add functions for PC platform.");
    215215        }
     
    221221{
    222222        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;
    225225}
    226226
     
    229229        printf(NAME ": HelenOS PC platform driver\n");
    230230        root_pc_init();
    231         return ddf_driver_main(&rootpc_driver);
     231        return ddf_driver_main(&pc_driver);
    232232}
    233233
Note: See TracChangeset for help on using the changeset viewer.