Changeset 00aece0 in mainline for uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (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
rbd5f3b7 r00aece0 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 <abi/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[] = { … … 64 60 65 61 static irq_code_t uart_irq_code = { 62 0, 63 NULL, 66 64 sizeof(uart_irq_cmds) / sizeof(irq_cmd_t), 67 65 uart_irq_cmds … … 83 81 printf(NAME ": S3C24xx on-chip UART driver\n"); 84 82 85 rc = loc_server_register(NAME, s3c24xx_uart_connection); 83 async_set_client_connection(s3c24xx_uart_connection); 84 rc = loc_server_register(NAME); 86 85 if (rc < 0) { 87 86 printf(NAME ": Unable to register server.\n"); … … 117 116 void *arg) 118 117 { 119 ipc_callid_t callid;120 ipc_call_t call;121 sysarg_t method;122 int retval;123 124 118 /* Answer the IPC_M_CONNECT_ME_TO call. */ 125 119 async_answer_0(iid, EOK); 126 127 while (1) { 128 callid = async_get_call(&call); 129 method = IPC_GET_IMETHOD(call); 120 121 while (true) { 122 ipc_call_t call; 123 ipc_callid_t callid = async_get_call(&call); 124 sysarg_t method = IPC_GET_IMETHOD(call); 130 125 131 126 if (!method) { … … 135 130 } 136 131 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; 132 async_sess_t *sess = 133 async_callback_receive_start(EXCHANGE_SERIALIZE, &call); 134 if (sess != NULL) { 135 if (uart->client_sess == NULL) { 136 uart->client_sess = sess; 137 async_answer_0(callid, EOK); 138 } else 139 async_answer_0(callid, ELIMIT); 140 } else { 141 switch (method) { 142 case CHAR_WRITE_BYTE: 143 printf(NAME ": write %" PRIun " to device\n", 144 IPC_GET_ARG1(call)); 145 s3c24xx_uart_sendb(uart, (uint8_t) IPC_GET_ARG1(call)); 146 async_answer_0(callid, EOK); 147 break; 148 default: 149 async_answer_0(callid, EINVAL); 150 } 152 151 } 153 async_answer_0(callid, retval);154 152 } 155 153 } … … 163 161 uint32_t status = pio_read_32(&uart->io->uerstat); 164 162 165 if (uart->client_phone != -1) { 166 async_obsolete_msg_1(uart->client_phone, CHAR_NOTIF_BYTE, 167 data); 163 if (uart->client_sess != NULL) { 164 async_exch_t *exch = async_exchange_begin(uart->client_sess); 165 async_msg_1(exch, CHAR_NOTIF_BYTE, data); 166 async_exchange_end(exch); 168 167 } 169 168 … … 191 190 192 191 uart->io = vaddr; 193 uart->client_ phone = -1;192 uart->client_sess = NULL; 194 193 195 194 printf(NAME ": device at physical address %p, inr %" PRIun ".\n", … … 198 197 async_set_interrupt_received(s3c24xx_uart_irq_handler); 199 198 200 register_irq(inr, device_assign_devno(), 0, &uart_irq_code);199 irq_register(inr, device_assign_devno(), 0, &uart_irq_code); 201 200 202 201 /* Enable FIFO, Tx trigger level: empty, Rx trigger level: 1 byte. */
Note:
See TracChangeset
for help on using the changeset viewer.