Changeset 925a21e in mainline for uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
- Timestamp:
- 2011-09-24T14:20:29Z (13 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
r867e2555 r925a21e 39 39 #include <ddi.h> 40 40 #include <libarch/ddi.h> 41 #include < devmap.h>41 #include <loc.h> 42 42 #include <ipc/char.h> 43 43 #include <async.h> 44 #include <async_obsolete.h>45 44 #include <unistd.h> 46 45 #include <stdio.h> … … 51 50 #include "s3c24xx_uart.h" 52 51 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" 58 54 59 55 static irq_cmd_t uart_irq_cmds[] = { … … 83 79 printf(NAME ": S3C24xx on-chip UART driver\n"); 84 80 85 rc = devmap_driver_register(NAME, s3c24xx_uart_connection);81 rc = loc_server_register(NAME, s3c24xx_uart_connection); 86 82 if (rc < 0) { 87 printf(NAME ": Unable to register driver.\n");83 printf(NAME ": Unable to register server.\n"); 88 84 return -1; 89 85 } … … 96 92 return -1; 97 93 98 rc = devmap_device_register(NAMESPACE "/" NAME, &uart->devmap_handle);94 rc = loc_service_register(NAMESPACE "/" NAME, &uart->service_id); 99 95 if (rc != EOK) { 100 96 printf(NAME ": Unable to register device %s.\n", … … 117 113 void *arg) 118 114 { 119 ipc_callid_t callid;120 ipc_call_t call;121 sysarg_t method;122 int retval;123 124 115 /* Answer the IPC_M_CONNECT_ME_TO call. */ 125 116 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); 130 122 131 123 if (!method) { … … 135 127 } 136 128 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 } 152 148 } 153 async_answer_0(callid, retval);154 149 } 155 150 } … … 163 158 uint32_t status = pio_read_32(&uart->io->uerstat); 164 159 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); 168 164 } 169 165 … … 191 187 192 188 uart->io = vaddr; 193 uart->client_ phone = -1;189 uart->client_sess = NULL; 194 190 195 191 printf(NAME ": device at physical address %p, inr %" PRIun ".\n",
Note:
See TracChangeset
for help on using the changeset viewer.