Ignore:
Timestamp:
2011-06-08T19:01:55Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/device/hw_res.c

    r764d71e r79ae36dd  
    3838#include <malloc.h>
    3939
    40 int hw_res_get_resource_list(int dev_phone, hw_resource_list_t *hw_resources)
     40int hw_res_get_resource_list(async_sess_t *sess,
     41    hw_resource_list_t *hw_resources)
    4142{
    4243        sysarg_t count = 0;
    43 
    44         int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     44       
     45        async_exch_t *exch = async_exchange_begin(sess);
     46        int rc = async_req_1_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    4547            HW_RES_GET_RESOURCE_LIST, &count);
    46 
    47         hw_resources->count = count;
    48         if (rc != EOK)
     48       
     49        if (rc != EOK) {
     50                async_exchange_end(exch);
    4951                return rc;
     52        }
    5053       
    5154        size_t size = count * sizeof(hw_resource_t);
    52         hw_resources->resources = (hw_resource_t *)malloc(size);
    53         if (!hw_resources->resources)
     55        hw_resource_t *resources = (hw_resource_t *) malloc(size);
     56        if (resources == NULL) {
     57                // FIXME: This is protocol violation
     58                async_exchange_end(exch);
    5459                return ENOMEM;
     60        }
    5561       
    56         rc = async_data_read_start(dev_phone, hw_resources->resources, size);
     62        rc = async_data_read_start(exch, resources, size);
     63        async_exchange_end(exch);
     64       
    5765        if (rc != EOK) {
    58                 free(hw_resources->resources);
    59                 hw_resources->resources = NULL;
     66                free(resources);
    6067                return rc;
    6168        }
     69       
     70        hw_resources->resources = resources;
     71        hw_resources->count = count;
    6272       
    6373        return EOK;
    6474}
    6575
    66 bool hw_res_enable_interrupt(int dev_phone)
     76bool hw_res_enable_interrupt(async_sess_t *sess)
    6777{
    68         int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     78        async_exch_t *exch = async_exchange_begin(sess);
     79        int rc = async_req_1_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    6980            HW_RES_ENABLE_INTERRUPT);
    70 
    71         return rc == EOK;
     81        async_exchange_end(exch);
     82       
     83        return (rc == EOK);
    7284}
    7385
Note: See TracChangeset for help on using the changeset viewer.