Changeset f401312 in mainline for uspace/drv


Ignore:
Timestamp:
2011-01-14T12:34:42Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
45019865
Parents:
b2a6fcfe (diff), 6610565b (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.
Message:

Merged development into lelian/hidd

Location:
uspace/drv
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/isa/isa.c

    rb2a6fcfe rf401312  
    5151
    5252#include <driver.h>
    53 #include <resource.h>
     53#include <ops/hw_res.h>
    5454
    5555#include <devman.h>
     
    8484}
    8585
    86 static resource_iface_t isa_child_res_iface = {
     86static hw_res_ops_t isa_child_hw_res_ops = {
    8787        &isa_get_child_resources,
    8888        &isa_enable_child_interrupt
     
    502502static void isa_init()
    503503{
    504         isa_child_dev_ops.interfaces[HW_RES_DEV_IFACE] = &isa_child_res_iface;
     504        isa_child_dev_ops.interfaces[HW_RES_DEV_IFACE] = &isa_child_hw_res_ops;
    505505}
    506506
  • uspace/drv/ns8250/ns8250.c

    rb2a6fcfe rf401312  
    5353
    5454#include <driver.h>
    55 #include <char.h>
    56 #include <resource.h>
     55#include <ops/char_dev.h>
    5756
    5857#include <devman.h>
     
    227226
    228227/** The character interface's callbacks. */
    229 static char_iface_t ns8250_char_iface = {
     228static char_dev_ops_t ns8250_char_dev_ops = {
    230229        .read = &ns8250_read,
    231230        .write = &ns8250_write
     
    347346       
    348347        /* Get hw resources. */
    349         ret = get_hw_resources(dev->parent_phone, &hw_resources);
     348        ret = hw_res_get_resource_list(dev->parent_phone, &hw_resources);
    350349        if (ret != EOK) {
    351350                printf(NAME ": failed to get hw resources for the device "
     
    394393        }
    395394       
    396         clean_hw_resource_list(&hw_resources);
     395        hw_res_clean_resource_list(&hw_resources);
    397396        return ret;
    398397       
    399398failed:
    400399        ns8250_dev_cleanup(dev);
    401         clean_hw_resource_list(&hw_resources);
     400        hw_res_clean_resource_list(&hw_resources);
    402401        return ret;
    403402}
     
    924923        ns8250_dev_ops.close = &ns8250_close;
    925924       
    926         ns8250_dev_ops.interfaces[CHAR_DEV_IFACE] = &ns8250_char_iface;
     925        ns8250_dev_ops.interfaces[CHAR_DEV_IFACE] = &ns8250_char_dev_ops;
    927926        ns8250_dev_ops.default_handler = &ns8250_default_handler;
    928927}
  • uspace/drv/pciintel/pci.c

    rb2a6fcfe rf401312  
    4949#include <ipc/devman.h>
    5050#include <ipc/dev_iface.h>
    51 #include <resource.h>
     51#include <ops/hw_res.h>
    5252#include <device/hw_res.h>
    5353#include <ddi.h>
     
    7777}
    7878
    79 static resource_iface_t pciintel_child_res_iface = {
     79static hw_res_ops_t pciintel_child_hw_res_ops = {
    8080        &pciintel_get_child_resources,
    8181        &pciintel_enable_child_interrupt
     
    473473        hw_resource_list_t hw_resources;
    474474       
    475         rc = get_hw_resources(dev->parent_phone, &hw_resources);
     475        rc = hw_res_get_resource_list(dev->parent_phone, &hw_resources);
    476476        if (rc != EOK) {
    477477                printf(NAME ": pci_add_device failed to get hw resources for "
     
    497497                delete_pci_bus_data(bus_data);
    498498                ipc_hangup(dev->parent_phone);
    499                 clean_hw_resource_list(&hw_resources);
     499                hw_res_clean_resource_list(&hw_resources);
    500500                return EADDRNOTAVAIL;
    501501        }
     
    508508        pci_bus_scan(dev, 0);
    509509       
    510         clean_hw_resource_list(&hw_resources);
     510        hw_res_clean_resource_list(&hw_resources);
    511511       
    512512        return EOK;
     
    515515static void pciintel_init(void)
    516516{
    517         pci_child_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_child_res_iface;
     517        pci_child_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_child_hw_res_ops;
    518518}
    519519
     
    537537{
    538538        if (dev_data != NULL) {
    539                 clean_hw_resource_list(&dev_data->hw_resources);
     539                hw_res_clean_resource_list(&dev_data->hw_resources);
    540540                free(dev_data);
    541541        }
  • uspace/drv/rootpc/rootpc.c

    rb2a6fcfe rf401312  
    5050#include <ipc/devman.h>
    5151#include <ipc/dev_iface.h>
    52 #include <resource.h>
     52#include <ops/hw_res.h>
    5353#include <device/hw_res.h>
    5454
     
    107107}
    108108
    109 static resource_iface_t child_res_iface = {
     109static hw_res_ops_t child_hw_res_ops = {
    110110        &rootpc_get_child_resources,
    111111        &rootpc_enable_child_interrupt
     
    190190static void root_pc_init(void)
    191191{
    192         rootpc_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface;
     192        rootpc_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_hw_res_ops;
    193193}
    194194
  • uspace/drv/test1/char.c

    rb2a6fcfe rf401312  
    3333#include <errno.h>
    3434#include <mem.h>
    35 #include <char.h>
     35#include <ops/char_dev.h>
    3636
    3737#include "test1.h"
     
    4646}
    4747
    48 static char_iface_t char_interface = {
     48static char_dev_ops_t char_dev_ops = {
    4949        .read = &impl_char_read,
    5050        .write = &imp_char_write
     
    5252
    5353device_ops_t char_device_ops = {
    54         .interfaces[CHAR_DEV_IFACE] = &char_interface
     54        .interfaces[CHAR_DEV_IFACE] = &char_dev_ops
    5555};
    5656
  • uspace/drv/usbhub/main.c

    rb2a6fcfe rf401312  
    3838
    3939usb_general_list_t usb_hub_list;
     40futex_t usb_hub_list_lock;
    4041
    4142static driver_ops_t hub_driver_ops = {
     
    6061{
    6162        usb_dprintf_enable(NAME,1);
     63        futex_initialize(&usb_hub_list_lock, 0);
    6264        usb_lst_init(&usb_hub_list);
     65        futex_up(&usb_hub_list_lock);
    6366        fid_t fid = fibril_create(usb_hub_control_loop, NULL);
    6467        if (fid == 0) {
  • uspace/drv/usbhub/usbhub.c

    rb2a6fcfe rf401312  
    7575        //get some hub info
    7676        usb_address_t addr = usb_drv_get_my_address(hc, device);
    77         dprintf(1,"[usb_hub] addres of newly created hub = %d", addr);
     77        dprintf(1,"[usb_hub] address of newly created hub = %d", addr);
    7878        /*if(addr<0){
    7979                //return result;
     
    174174                dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE");
    175175        }
     176        /// \TODO check other configurations
    176177        usb_standard_configuration_descriptor_t config_descriptor;
    177178        opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
     
    194195        }
    195196
    196 
    197197        for (port = 1; port < hub_info->port_count+1; ++port) {
    198198                usb_hub_set_power_port_request(&request, port);
     
    205205        //ports powered, hub seems to be enabled
    206206
    207 
    208207        ipc_hangup(hc);
    209208
    210209        //add the hub to list
     210        futex_down(&usb_hub_list_lock);
    211211        usb_lst_append(&usb_hub_list, hub_info);
     212        futex_up(&usb_hub_list_lock);
     213
    212214        dprintf(1,"[usb_hub] hub info added to list");
    213215        //(void)hub_info;
     
    233235//
    234236//*********************************************
     237
     238/**
     239 * convenience function for releasing default address and writing debug info
     240 * (these few lines are used too often to be written again and again)
     241 * @param hc
     242 * @return
     243 */
     244inline static int usb_hub_release_default_address(int hc){
     245        int opResult;
     246        dprintf(1,"[usb_hub] releasing default address");
     247        opResult = usb_drv_release_default_address(hc);
     248        if (opResult != EOK) {
     249                dprintf(1,"[usb_hub] failed to release default address");
     250        }
     251        return opResult;
     252}
    235253
    236254/**
     
    259277        if (opResult != EOK) {
    260278                dprintf(1,"[usb_hub] something went wrong when reseting a port");
    261         }
    262 }
    263 
    264 /**
    265  * convenience function for releasing default address and writing debug info
    266  * (these few lines are used too often to be written again and again)
    267  * @param hc
    268  * @return
    269  */
    270 inline static int usb_hub_release_default_address(int hc){
    271         int opResult;
    272         dprintf(1,"[usb_hub] releasing default address");
    273         opResult = usb_drv_release_default_address(hc);
    274         if (opResult != EOK) {
    275                 dprintf(1,"[usb_hub] failed to release default address");
    276         }
    277         return opResult;
    278 }
    279 
     279                usb_hub_release_default_address(hc);
     280        }
     281}
    280282
    281283/**
     
    343345
    344346/**
    345  * unregister device address in hc, close the port
     347 * unregister device address in hc
    346348 * @param hc
    347349 * @param port
     
    352354        //usb_device_request_setup_packet_t request;
    353355        int opResult;
    354         //disable port
    355         /*usb_hub_set_disable_port_request(&request, port);
    356         opResult = usb_drv_sync_control_write(
    357                         hc, target,
    358                         &request,
    359                         NULL, 0
    360                         );
    361         if (opResult != EOK) {
    362                 //continue;
    363                 printf("[usb_hub] something went wrong when disabling a port\n");
    364         }*/
     356       
    365357        /// \TODO remove device
    366358
     
    457449         */
    458450        usb_general_list_t * lst_item;
     451        futex_down(&usb_hub_list_lock);
    459452        for (lst_item = usb_hub_list.next;
    460453                        lst_item != &usb_hub_list;
    461454                        lst_item = lst_item->next) {
     455                futex_up(&usb_hub_list_lock);
    462456                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
    463457                /*
     
    510504                        }
    511505                }
     506                free(change_bitmap);
    512507
    513508                ipc_hangup(hc);
    514         }
     509                futex_down(&usb_hub_list_lock);
     510        }
     511        futex_up(&usb_hub_list_lock);
    515512}
    516513
  • uspace/drv/usbhub/usbhub_private.h

    rb2a6fcfe rf401312  
    4343#include <bool.h>
    4444#include <driver.h>
     45#include <futex.h>
     46
    4547#include <usb/usb.h>
    4648#include <usb/usbdrv.h>
     
    6668
    6769/**
    68  * @brief create hub structure instance
     70 * create hub structure instance
    6971 *
    7072 * Set the address and port count information most importantly.
     
    7981extern usb_general_list_t usb_hub_list;
    8082
     83/** lock for hub list*/
     84extern futex_t usb_hub_list_lock;
     85
    8186
    8287/**
    83  * @brief perform complete control read transaction
     88 * perform complete control read transaction
    8489 *
    8590 * manages all three steps of transaction: setup, read and finalize
     
    99104
    100105/**
    101  * @brief perform complete control write transaction
     106 * perform complete control write transaction
    102107 *
    103  * maanges all three steps of transaction: setup, write and finalize
     108 * manages all three steps of transaction: setup, write and finalize
    104109 * @param phone
    105110 * @param target
     
    114119    void * sent_buffer, size_t sent_size
    115120);
    116 
    117 
    118 /**
    119  * set the device request to be a set address request
    120  * @param request
    121  * @param addr
    122  * \TODO this will be obsolete see usb/dev_req.h
    123  */
    124 static inline void usb_hub_set_set_address_request(
    125 usb_device_request_setup_packet_t * request, uint16_t addr
    126 ){
    127         request->index = 0;
    128         request->request_type = 0;/// \TODO this is not very nice sollution, we ned constant
    129         request->request = USB_DEVREQ_SET_ADDRESS;
    130         request->value = addr;
    131         request->length = 0;
    132 }
    133121
    134122/**
  • uspace/drv/usbhub/utils.c

    rb2a6fcfe rf401312  
    200200
    201201
    202 /*
    203  * method for testing port status bitmap
    204  
    205 static void usb_hub_test_port_status(void) {
    206         printf("[usb_hub] -------------port status test---------\n");
    207         usb_port_status_t status = 0;
    208 
    209         //printf("original status %d (should be 0)\n",(uint32_t)status);
    210         usb_port_set_bit(&status, 1, 1);
    211         //printf("%d =?= 2\n",(uint32_t)status);
    212         if (status != 2) {
    213                 printf("[usb_port_status] test failed: wrong set of bit 1\n");
    214                 return;
    215         }
    216         usb_port_set_bit(&status, 3, 1);
    217         if (status != 10) {
    218                 printf("[usb_port_status] test failed: wrong set of bit 3\n");
    219                 return;
    220         }
    221 
    222         usb_port_set_bit(&status, 15, 1);
    223         if (status != 10 + (1 << 15)) {
    224                 printf("[usb_port_status] test failed: wrong set of bit 15\n");
    225                 return;
    226         }
    227         usb_port_set_bit(&status, 1, 0);
    228         if (status != 8 + (1 << 15)) {
    229                 printf("[usb_port_status] test failed: wrong unset of bit 1\n");
    230                 return;
    231         }
    232         int i;
    233         for (i = 0; i < 32; ++i) {
    234                 if (i == 3 || i == 15) {
    235                         if (!usb_port_get_bit(&status, i)) {
    236                                 printf("[usb_port_status] test failed: wrong bit at %d\n", i);
    237                         }
    238                 } else {
    239                         if (usb_port_get_bit(&status, i)) {
    240                                 printf("[usb_port_status] test failed: wrong bit at %d\n", i);
    241                         }
    242                 }
    243         }
    244 
    245         printf("test ok\n");
    246 
    247 
    248         //printf("%d =?= 10\n",(uint32_t)status);
    249 
    250         //printf("this should be 0: %d \n",usb_port_get_bit(&status,0));
    251         //printf("this should be 1: %d \n",usb_port_get_bit(&status,1));
    252         //printf("this should be 0: %d \n",usb_port_get_bit(&status,2));
    253         //printf("this should be 1: %d \n",usb_port_get_bit(&status,3));
    254         //printf("this should be 0: %d \n",usb_port_get_bit(&status,4));
    255 
    256 }
    257 */
     202
    258203
    259204
  • uspace/drv/usbkbd/main.c

    rb2a6fcfe rf401312  
    7979}
    8080
     81#if 0
    8182static void send_key(int key, int type, wchar_t c) {
    8283        async_msg_4(console_callback_phone, KBD_EVENT, type, key,
    8384            KM_NUM_LOCK, c);
    8485}
    85 
    86 static void send_alnum(int key, wchar_t c) {
    87         printf(NAME ": sending key '%lc' to console\n", (wint_t) c);
    88         send_key(key, KEY_PRESS, c);
    89         send_key(key, KEY_RELEASE, c);
    90 }
     86#endif
    9187
    9288/*
     
    230226        callbacks->keyboard = usbkbd_process_keycodes;
    231227
    232         if (console_callback_phone != -1) {
    233                 static size_t counter = 0;
    234                 counter++;
    235                 if (counter > 3) {
    236                         counter = 0;
    237                         send_alnum(KC_A, L'a');
    238                 }
    239         }
    240 
    241228        usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks,
    242229            NULL);
  • uspace/drv/vhc/hcd.c

    rb2a6fcfe rf401312  
    8686        dev->ops = &vhc_ops;
    8787
     88        devman_add_device_to_class(dev->handle, "usbhc");
     89
    8890        /*
    8991         * Initialize our hub and announce its presence.
Note: See TracChangeset for help on using the changeset viewer.