Changeset 925a21e in mainline for uspace/srv/hw


Ignore:
Timestamp:
2011-09-24T14:20:29Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5bf76c1
Parents:
867e2555 (diff), 1ab4aca (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:

Merge mainline changes.

Location:
uspace/srv/hw
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/bus/cuda_adb/cuda_adb.c

    r867e2555 r925a21e  
    4343#include <ddi.h>
    4444#include <libarch/ddi.h>
    45 #include <devmap.h>
     45#include <loc.h>
    4646#include <sysinfo.h>
    4747#include <errno.h>
    4848#include <ipc/adb.h>
    4949#include <async.h>
    50 #include <async_obsolete.h>
    5150#include <assert.h>
    5251#include "cuda_adb.h"
    5352
    54 // FIXME: remove this header
    55 #include <kernel/ipc/ipc_methods.h>
    56 
    57 #define NAME "cuda_adb"
     53#define NAME  "cuda_adb"
    5854
    5955static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    147143int main(int argc, char *argv[])
    148144{
    149         devmap_handle_t devmap_handle;
     145        service_id_t service_id;
    150146        int rc;
    151147        int i;
     
    154150
    155151        for (i = 0; i < ADB_MAX_ADDR; ++i) {
    156                 adb_dev[i].client_phone = -1;
    157                 adb_dev[i].devmap_handle = 0;
    158         }
    159 
    160         rc = devmap_driver_register(NAME, cuda_connection);
     152                adb_dev[i].client_sess = NULL;
     153                adb_dev[i].service_id = 0;
     154        }
     155
     156        rc = loc_server_register(NAME, cuda_connection);
    161157        if (rc < 0) {
    162                 printf(NAME ": Unable to register driver.\n");
     158                printf(NAME ": Unable to register server.\n");
    163159                return rc;
    164160        }
    165161
    166         rc = devmap_device_register("adb/kbd", &devmap_handle);
     162        rc = loc_service_register("adb/kbd", &service_id);
    167163        if (rc != EOK) {
    168                 printf(NAME ": Unable to register device %s.\n", "adb/kdb");
     164                printf(NAME ": Unable to register service %s.\n", "adb/kdb");
    169165                return rc;
    170166        }
    171167
    172         adb_dev[2].devmap_handle = devmap_handle;
    173         adb_dev[8].devmap_handle = devmap_handle;
    174 
    175         rc = devmap_device_register("adb/mouse", &devmap_handle);
     168        adb_dev[2].service_id = service_id;
     169        adb_dev[8].service_id = service_id;
     170
     171        rc = loc_service_register("adb/mouse", &service_id);
    176172        if (rc != EOK) {
    177                 printf(NAME ": Unable to register device %s.\n", "adb/mouse");
     173                printf(NAME ": Unable to register servise %s.\n", "adb/mouse");
    178174                return rc;
    179175        }
    180176
    181         adb_dev[9].devmap_handle = devmap_handle;
     177        adb_dev[9].service_id = service_id;
    182178
    183179        if (cuda_init() < 0) {
     
    198194        ipc_call_t call;
    199195        sysarg_t method;
    200         devmap_handle_t dh;
    201         int retval;
     196        service_id_t dsid;
    202197        int dev_addr, i;
    203198
    204199        /* Get the device handle. */
    205         dh = IPC_GET_ARG1(*icall);
     200        dsid = IPC_GET_ARG1(*icall);
    206201
    207202        /* Determine which disk device is the client connecting to. */
    208203        dev_addr = -1;
    209204        for (i = 0; i < ADB_MAX_ADDR; i++) {
    210                 if (adb_dev[i].devmap_handle == dh)
     205                if (adb_dev[i].service_id == dsid)
    211206                        dev_addr = i;
    212207        }
     
    220215        async_answer_0(iid, EOK);
    221216
    222         while (1) {
     217        while (true) {
    223218                callid = async_get_call(&call);
    224219                method = IPC_GET_IMETHOD(call);
     
    230225                }
    231226               
    232                 switch (method) {
    233                 case IPC_M_CONNECT_TO_ME:
    234                         if (adb_dev[dev_addr].client_phone != -1) {
    235                                 retval = ELIMIT;
    236                                 break;
    237                         }
    238                         adb_dev[dev_addr].client_phone = IPC_GET_ARG5(call);
    239                         /*
    240                          * A hack so that we send the data to the phone
    241                          * regardless of which address the device is on.
    242                          */
    243                         for (i = 0; i < ADB_MAX_ADDR; ++i) {
    244                                 if (adb_dev[i].devmap_handle == dh) {
    245                                         adb_dev[i].client_phone = IPC_GET_ARG5(call);
     227                async_sess_t *sess =
     228                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     229                if (sess != NULL) {
     230                        if (adb_dev[dev_addr].client_sess == NULL) {
     231                                adb_dev[dev_addr].client_sess = sess;
     232                               
     233                                /*
     234                                 * A hack so that we send the data to the session
     235                                 * regardless of which address the device is on.
     236                                 */
     237                                for (i = 0; i < ADB_MAX_ADDR; ++i) {
     238                                        if (adb_dev[i].service_id == dsid)
     239                                                adb_dev[i].client_sess = sess;
    246240                                }
    247                         }
    248                         retval = 0;
    249                         break;
    250                 default:
    251                         retval = EINVAL;
    252                         break;
    253                 }
    254                 async_answer_0(callid, retval);
     241                               
     242                                async_answer_0(callid, EOK);
     243                        } else
     244                                async_answer_0(callid, ELIMIT);
     245                } else
     246                        async_answer_0(callid, EINVAL);
    255247        }
    256248}
     
    483475        reg_val = ((uint16_t) data[1] << 8) | (uint16_t) data[2];
    484476
    485         if (adb_dev[dev_addr].client_phone == -1)
    486                 return;
    487 
    488         async_obsolete_msg_1(adb_dev[dev_addr].client_phone, ADB_REG_NOTIF, reg_val);
     477        if (adb_dev[dev_addr].client_sess == NULL)
     478                return;
     479
     480        async_exch_t *exch =
     481            async_exchange_begin(adb_dev[dev_addr].client_sess);
     482        async_msg_1(exch, ADB_REG_NOTIF, reg_val);
     483        async_exchange_end(exch);
    489484}
    490485
  • uspace/srv/hw/bus/cuda_adb/cuda_adb.h

    r867e2555 r925a21e  
    3838
    3939#include <sys/types.h>
    40 #include <ipc/devmap.h>
     40#include <async.h>
    4141#include <fibril_synch.h>
    4242
     
    104104
    105105typedef struct {
    106         devmap_handle_t devmap_handle;
    107         int client_phone;
     106        service_id_t service_id;
     107        async_sess_t *client_sess;
    108108} adb_dev_t;
    109109
  • uspace/srv/hw/char/i8042/i8042.c

    r867e2555 r925a21e  
    3232 * @ingroup kbd
    3333 * @{
    34  */ 
     34 */
    3535/** @file
    3636 * @brief i8042 PS/2 port driver.
     
    3939#include <ddi.h>
    4040#include <libarch/ddi.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <async.h>
    43 #include <async_obsolete.h>
    4443#include <unistd.h>
    4544#include <sysinfo.h>
     
    4948#include "i8042.h"
    5049
    51 // FIXME: remove this header
    52 #include <kernel/ipc/ipc_methods.h>
    53 
    54 #define NAME "i8042"
    55 #define NAMESPACE "char"
     50#define NAME       "i8042"
     51#define NAMESPACE  "char"
    5652
    5753/* Interesting bits for status register */
     
    135131        printf(NAME ": i8042 PS/2 port driver\n");
    136132
    137         rc = devmap_driver_register(NAME, i8042_connection);
     133        rc = loc_server_register(NAME, i8042_connection);
    138134        if (rc < 0) {
    139                 printf(NAME ": Unable to register driver.\n");
     135                printf(NAME ": Unable to register server.\n");
    140136                return rc;
    141137        }
     
    145141
    146142        for (i = 0; i < MAX_DEVS; i++) {
    147                 i8042_port[i].client_phone = -1;
     143                i8042_port[i].client_sess = NULL;
    148144
    149145                snprintf(name, 16, "%s/ps2%c", NAMESPACE, dchar[i]);
    150                 rc = devmap_device_register(name, &i8042_port[i].devmap_handle);
     146                rc = loc_service_register(name, &i8042_port[i].service_id);
    151147                if (rc != EOK) {
    152148                        printf(NAME ": Unable to register device %s.\n", name);
     
    221217        ipc_call_t call;
    222218        sysarg_t method;
    223         devmap_handle_t dh;
     219        service_id_t dsid;
    224220        int retval;
    225221        int dev_id, i;
     
    228224
    229225        /* Get the device handle. */
    230         dh = IPC_GET_ARG1(*icall);
     226        dsid = IPC_GET_ARG1(*icall);
    231227
    232228        /* Determine which disk device is the client connecting to. */
    233229        dev_id = -1;
    234230        for (i = 0; i < MAX_DEVS; i++) {
    235                 if (i8042_port[i].devmap_handle == dh)
     231                if (i8042_port[i].service_id == dsid)
    236232                        dev_id = i;
    237233        }
     
    257253                }
    258254               
    259                 switch (method) {
    260                 case IPC_M_CONNECT_TO_ME:
    261                         printf(NAME ": creating callback connection\n");
    262                         if (i8042_port[dev_id].client_phone != -1) {
     255                async_sess_t *sess =
     256                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     257                if (sess != NULL) {
     258                        if (i8042_port[dev_id].client_sess == NULL) {
     259                                i8042_port[dev_id].client_sess = sess;
     260                                retval = EOK;
     261                        } else
    263262                                retval = ELIMIT;
     263                } else {
     264                        switch (method) {
     265                        case IPC_FIRST_USER_METHOD:
     266                                printf(NAME ": write %" PRIun " to devid %d\n",
     267                                    IPC_GET_ARG1(call), dev_id);
     268                                i8042_port_write(dev_id, IPC_GET_ARG1(call));
     269                                retval = 0;
     270                                break;
     271                        default:
     272                                retval = EINVAL;
    264273                                break;
    265274                        }
    266                         i8042_port[dev_id].client_phone = IPC_GET_ARG5(call);
    267                         retval = 0;
    268                         break;
    269                 case IPC_FIRST_USER_METHOD:
    270                         printf(NAME ": write %" PRIun " to devid %d\n",
    271                             IPC_GET_ARG1(call), dev_id);
    272                         i8042_port_write(dev_id, IPC_GET_ARG1(call));
    273                         retval = 0;
    274                         break;
    275                 default:
    276                         retval = EINVAL;
    277                         break;
    278275                }
     276               
    279277                async_answer_0(callid, retval);
    280278        }
     
    305303        }
    306304
    307         if (i8042_port[devid].client_phone != -1) {
    308                 async_obsolete_msg_1(i8042_port[devid].client_phone,
    309                     IPC_FIRST_USER_METHOD, data);
     305        if (i8042_port[devid].client_sess != NULL) {
     306                async_exch_t *exch =
     307                    async_exchange_begin(i8042_port[devid].client_sess);
     308                async_msg_1(exch, IPC_FIRST_USER_METHOD, data);
     309                async_exchange_end(exch);
    310310        }
    311311}
  • uspace/srv/hw/char/i8042/i8042.h

    r867e2555 r925a21e  
    3939#define i8042_H_
    4040
     41#include <sys/types.h>
    4142#include <libarch/ddi.h>
    42 #include <libarch/types.h>
     43#include <async.h>
    4344
    4445/** i8042 HW I/O interface */
     
    5253/** Softstate structure, one for each serial port (primary and aux). */
    5354typedef struct {
    54         devmap_handle_t devmap_handle;
    55         int client_phone;
     55        service_id_t service_id;
     56        async_sess_t *client_sess;
    5657} i8042_port_t;
    5758
     
    6061/**
    6162 * @}
    62  */ 
     63 */
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c

    r867e2555 r925a21e  
    3939#include <ddi.h>
    4040#include <libarch/ddi.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <ipc/char.h>
    4343#include <async.h>
    44 #include <async_obsolete.h>
    4544#include <unistd.h>
    4645#include <stdio.h>
     
    5150#include "s3c24xx_uart.h"
    5251
    53 // FIXME: remove this header
    54 #include <kernel/ipc/ipc_methods.h>
    55 
    56 #define NAME "s3c24ser"
    57 #define NAMESPACE "char"
     52#define NAME       "s3c24ser"
     53#define NAMESPACE  "char"
    5854
    5955static irq_cmd_t uart_irq_cmds[] = {
     
    8379        printf(NAME ": S3C24xx on-chip UART driver\n");
    8480
    85         rc = devmap_driver_register(NAME, s3c24xx_uart_connection);
     81        rc = loc_server_register(NAME, s3c24xx_uart_connection);
    8682        if (rc < 0) {
    87                 printf(NAME ": Unable to register driver.\n");
     83                printf(NAME ": Unable to register server.\n");
    8884                return -1;
    8985        }
     
    9692                return -1;
    9793
    98         rc = devmap_device_register(NAMESPACE "/" NAME, &uart->devmap_handle);
     94        rc = loc_service_register(NAMESPACE "/" NAME, &uart->service_id);
    9995        if (rc != EOK) {
    10096                printf(NAME ": Unable to register device %s.\n",
     
    117113    void *arg)
    118114{
    119         ipc_callid_t callid;
    120         ipc_call_t call;
    121         sysarg_t method;
    122         int retval;
    123 
    124115        /* Answer the IPC_M_CONNECT_ME_TO call. */
    125116        async_answer_0(iid, EOK);
    126 
    127         while (1) {
    128                 callid = async_get_call(&call);
    129                 method = IPC_GET_IMETHOD(call);
     117       
     118        while (true) {
     119                ipc_call_t call;
     120                ipc_callid_t callid = async_get_call(&call);
     121                sysarg_t method = IPC_GET_IMETHOD(call);
    130122               
    131123                if (!method) {
     
    135127                }
    136128               
    137                 switch (method) {
    138                 case IPC_M_CONNECT_TO_ME:
    139                         printf(NAME ": creating callback connection\n");
    140                         uart->client_phone = IPC_GET_ARG5(call);
    141                         retval = 0;
    142                         break;
    143                 case CHAR_WRITE_BYTE:
    144                         printf(NAME ": write %" PRIun " to device\n",
    145                             IPC_GET_ARG1(call));
    146                         s3c24xx_uart_sendb(uart, (uint8_t) IPC_GET_ARG1(call));
    147                         retval = 0;
    148                         break;
    149                 default:
    150                         retval = EINVAL;
    151                         break;
     129                async_sess_t *sess =
     130                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     131                if (sess != NULL) {
     132                        if (uart->client_sess == NULL) {
     133                                uart->client_sess = sess;
     134                                async_answer_0(callid, EOK);
     135                        } else
     136                                async_answer_0(callid, ELIMIT);
     137                } else {
     138                        switch (method) {
     139                        case CHAR_WRITE_BYTE:
     140                                printf(NAME ": write %" PRIun " to device\n",
     141                                    IPC_GET_ARG1(call));
     142                                s3c24xx_uart_sendb(uart, (uint8_t) IPC_GET_ARG1(call));
     143                                async_answer_0(callid, EOK);
     144                                break;
     145                        default:
     146                                async_answer_0(callid, EINVAL);
     147                        }
    152148                }
    153                 async_answer_0(callid, retval);
    154149        }
    155150}
     
    163158                uint32_t status = pio_read_32(&uart->io->uerstat);
    164159
    165                 if (uart->client_phone != -1) {
    166                         async_obsolete_msg_1(uart->client_phone, CHAR_NOTIF_BYTE,
    167                             data);
     160                if (uart->client_sess != NULL) {
     161                        async_exch_t *exch = async_exchange_begin(uart->client_sess);
     162                        async_msg_1(exch, CHAR_NOTIF_BYTE, data);
     163                        async_exchange_end(exch);
    168164                }
    169165
     
    191187
    192188        uart->io = vaddr;
    193         uart->client_phone = -1;
     189        uart->client_sess = NULL;
    194190
    195191        printf(NAME ": device at physical address %p, inr %" PRIun ".\n",
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.h

    r867e2555 r925a21e  
    3939
    4040#include <sys/types.h>
     41#include <async.h>
    4142
    4243/** S3C24xx UART I/O */
     
    8485        s3c24xx_uart_io_t *io;
    8586
    86         /** Callback phone to the client */
    87         int client_phone;
     87        /** Callback session to the client */
     88        async_sess_t *client_sess;
    8889
    89         /** Device handle */
    90         devmap_handle_t devmap_handle;
     90        /** Service ID */
     91        service_id_t service_id;
    9192} s3c24xx_uart_t;
    9293
  • uspace/srv/hw/irc/apic/apic.c

    r867e2555 r925a21e  
    4242#include <as.h>
    4343#include <ddi.h>
    44 #include <libarch/ddi.h>
    45 #include <align.h>
    4644#include <bool.h>
    4745#include <errno.h>
    4846#include <async.h>
    49 #include <align.h>
    50 #include <async.h>
    5147#include <stdio.h>
    52 #include <ipc/devmap.h>
    5348
    5449#define NAME  "apic"
    5550
     51#define APIC_MAX_IRQ    15
     52
     53#define IOREGSEL  (0x00U / sizeof(uint32_t))
     54#define IOWIN     (0x10U / sizeof(uint32_t))
     55
     56#define IOREDTBL   0x10U
     57
     58/** I/O Register Select Register. */
     59typedef union {
     60        uint32_t value;
     61        struct {
     62                uint8_t reg_addr;       /**< APIC Register Address. */
     63                unsigned int : 24;      /**< Reserved. */
     64        } __attribute__ ((packed));
     65} io_regsel_t;
     66
     67/** I/O Redirection Register. */
     68typedef struct io_redirection_reg {
     69        union {
     70                uint32_t lo;
     71                struct {
     72                        uint8_t intvec;                 /**< Interrupt Vector. */
     73                        unsigned int delmod : 3;        /**< Delivery Mode. */
     74                        unsigned int destmod : 1;       /**< Destination mode. */
     75                        unsigned int delivs : 1;        /**< Delivery status (RO). */
     76                        unsigned int intpol : 1;        /**< Interrupt Input Pin Polarity. */
     77                        unsigned int irr : 1;           /**< Remote IRR (RO). */
     78                        unsigned int trigger_mode : 1;  /**< Trigger Mode. */
     79                        unsigned int masked : 1;        /**< Interrupt Mask. */
     80                        unsigned int : 15;              /**< Reserved. */
     81                } __attribute__ ((packed));
     82        };
     83        union {
     84                uint32_t hi;
     85                struct {
     86                        unsigned int : 24;      /**< Reserved. */
     87                        uint8_t dest : 8;       /**< Destination Field. */
     88                } __attribute__ ((packed));
     89        };
     90} __attribute__ ((packed)) io_redirection_reg_t;
     91
     92// FIXME: get the address from the kernel
     93#define IO_APIC_BASE    0xfec00000UL
     94#define IO_APIC_SIZE    20
     95
     96ioport32_t *io_apic = NULL;
     97
     98/** Read from IO APIC register.
     99 *
     100 * @param address IO APIC register address.
     101 *
     102 * @return Content of the addressed IO APIC register.
     103 *
     104 */
     105static uint32_t io_apic_read(uint8_t address)
     106{
     107        io_regsel_t regsel;
     108
     109        regsel.value = io_apic[IOREGSEL];
     110        regsel.reg_addr = address;
     111        io_apic[IOREGSEL] = regsel.value;
     112        return io_apic[IOWIN];
     113}
     114
     115/** Write to IO APIC register.
     116 *
     117 * @param address IO APIC register address.
     118 * @param val     Content to be written to the addressed IO APIC register.
     119 *
     120 */
     121static void io_apic_write(uint8_t address, uint32_t val)
     122{
     123        io_regsel_t regsel;
     124
     125        regsel.value = io_apic[IOREGSEL];
     126        regsel.reg_addr = address;
     127        io_apic[IOREGSEL] = regsel.value;
     128        io_apic[IOWIN] = val;
     129}
     130
     131static int irq_to_pin(int irq)
     132{
     133        // FIXME: get the map from the kernel, even though this may work
     134        //        for simple cases
     135        return irq;
     136}
     137
    56138static int apic_enable_irq(sysarg_t irq)
    57139{
    58         // FIXME: TODO
    59         return ENOTSUP;
     140        io_redirection_reg_t reg;
     141
     142        if (irq > APIC_MAX_IRQ)
     143                return ELIMIT;
     144
     145        int pin = irq_to_pin(irq);
     146        if (pin == -1)
     147                return ENOENT;
     148
     149        reg.lo = io_apic_read((uint8_t) (IOREDTBL + pin * 2));
     150        reg.masked = false;
     151        io_apic_write((uint8_t) (IOREDTBL + pin * 2), reg.lo);
     152
     153        return EOK;
    60154}
    61155
     
    111205                return false;
    112206        }
     207
     208        if (pio_enable((void *) IO_APIC_BASE, IO_APIC_SIZE,
     209            (void **) &io_apic) != EOK)
     210                return false;   
    113211       
    114212        async_set_client_connection(apic_connection);
  • uspace/srv/hw/irc/i8259/i8259.c

    r867e2555 r925a21e  
    5050#include <async.h>
    5151#include <stdio.h>
    52 #include <ipc/devmap.h>
     52#include <ipc/loc.h>
    5353
    5454#define NAME  "i8259"
  • uspace/srv/hw/irc/obio/obio.c

    r867e2555 r925a21e  
    5555#include <async.h>
    5656#include <stdio.h>
    57 #include <ipc/devmap.h>
     57#include <ipc/loc.h>
    5858
    5959#define NAME "obio"
Note: See TracChangeset for help on using the changeset viewer.