Ignore:
Timestamp:
2011-11-06T22:21:05Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
898e847
Parents:
2bdf8313 (diff), 7b5f4c9 (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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c

    r2bdf8313 rb0f00a9  
    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>
     
    4848#include <errno.h>
    4949#include <inttypes.h>
    50 
    5150#include "s3c24xx_uart.h"
    5251
    53 #define NAME "s3c24ser"
    54 #define NAMESPACE "char"
     52#define NAME       "s3c24ser"
     53#define NAMESPACE  "char"
    5554
    5655static irq_cmd_t uart_irq_cmds[] = {
     
    6867static s3c24xx_uart_t *uart;
    6968
    70 static void s3c24xx_uart_connection(ipc_callid_t iid, ipc_call_t *icall);
     69static void s3c24xx_uart_connection(ipc_callid_t iid, ipc_call_t *icall,
     70    void *arg);
    7171static void s3c24xx_uart_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    7272static int s3c24xx_uart_init(s3c24xx_uart_t *uart);
     
    7979        printf(NAME ": S3C24xx on-chip UART driver\n");
    8080
    81         rc = devmap_driver_register(NAME, s3c24xx_uart_connection);
     81        rc = loc_server_register(NAME, s3c24xx_uart_connection);
    8282        if (rc < 0) {
    83                 printf(NAME ": Unable to register driver.\n");
     83                printf(NAME ": Unable to register server.\n");
    8484                return -1;
    8585        }
     
    9292                return -1;
    9393
    94         rc = devmap_device_register(NAMESPACE "/" NAME, &uart->devmap_handle);
     94        rc = loc_service_register(NAMESPACE "/" NAME, &uart->service_id);
    9595        if (rc != EOK) {
    9696                printf(NAME ": Unable to register device %s.\n",
     
    110110
    111111/** Character device connection handler. */
    112 static void s3c24xx_uart_connection(ipc_callid_t iid, ipc_call_t *icall)
    113 {
    114         ipc_callid_t callid;
    115         ipc_call_t call;
    116         sysarg_t method;
    117         int retval;
    118 
     112static void s3c24xx_uart_connection(ipc_callid_t iid, ipc_call_t *icall,
     113    void *arg)
     114{
    119115        /* Answer the IPC_M_CONNECT_ME_TO call. */
    120116        async_answer_0(iid, EOK);
    121 
    122         while (1) {
    123                 callid = async_get_call(&call);
    124                 method = IPC_GET_IMETHOD(call);
    125                 switch (method) {
    126                 case IPC_M_PHONE_HUNGUP:
     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);
     122               
     123                if (!method) {
    127124                        /* The other side has hung up. */
    128125                        async_answer_0(callid, EOK);
    129126                        return;
    130                 case IPC_M_CONNECT_TO_ME:
    131                         printf(NAME ": creating callback connection\n");
    132                         uart->client_phone = IPC_GET_ARG5(call);
    133                         retval = 0;
    134                         break;
    135                 case CHAR_WRITE_BYTE:
    136                         printf(NAME ": write %" PRIun " to device\n",
    137                             IPC_GET_ARG1(call));
    138                         s3c24xx_uart_sendb(uart, (uint8_t) IPC_GET_ARG1(call));
    139                         retval = 0;
    140                         break;
    141                 default:
    142                         retval = EINVAL;
    143                         break;
    144127                }
    145                 async_answer_0(callid, retval);
     128               
     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                        }
     148                }
    146149        }
    147150}
     
    155158                uint32_t status = pio_read_32(&uart->io->uerstat);
    156159
    157                 if (uart->client_phone != -1) {
    158                         async_msg_1(uart->client_phone, CHAR_NOTIF_BYTE,
    159                             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);
    160164                }
    161165
     
    183187
    184188        uart->io = vaddr;
    185         uart->client_phone = -1;
     189        uart->client_sess = NULL;
    186190
    187191        printf(NAME ": device at physical address %p, inr %" PRIun ".\n",
Note: See TracChangeset for help on using the changeset viewer.