Changeset dafe675 in mainline
- Timestamp:
- 2010-04-30T08:54:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 25a7e11d
- Parents:
- 2300b9d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/drivers/serial/serial.c
r2300b9d rdafe675 121 121 } 122 122 123 static bool serial_received(ioport8_t *port) 124 { 125 return (pio_read_8(port + 5) & 1) != 0; 126 } 127 128 static uint8_t serial_read_8(ioport8_t *port) 129 { 130 return pio_read_8(port); 131 } 132 133 static bool is_transmit_empty(ioport8_t *port) 134 { 135 return (pio_read_8(port + 5) & 0x20) != 0; 136 } 137 138 static void serial_write_8(ioport8_t *port, uint8_t c) 139 { 140 while (!is_transmit_empty(port)) 141 ; 142 143 pio_write_8(port, c); 144 } 145 123 146 static bool serial_pio_enable(device_t *dev) 124 147 { … … 219 242 ioport = true; 220 243 printf(NAME ": the %s device was asigned i/o address = 0x%x.\n", dev->name, data->io_addr); 221 break; 244 break; 245 default: 246 break; 222 247 } 223 248 } … … 273 298 static void serial_read_from_device(device_t *dev) 274 299 { 275 // TODO 300 serial_dev_data_t *data = (serial_dev_data_t *)dev->driver_data; 301 ioport8_t *port = data->port; 302 bool cont = true; 303 304 while (cont) { 305 if (cont = serial_received(port)) { 306 uint8_t val = serial_read_8(port); 307 printf(NAME ": character %c read from %s.\n", val, dev->name); 308 309 fibril_mutex_lock(&data->mutex); 310 if (data->client_connected) { 311 if (!buf_push_back(&(data->input_buffer), val)) { 312 printf(NAME ": buffer overflow on %s.\n", dev->name); 313 } else { 314 printf(NAME ": the character %c saved to the buffer of %s.\n", val, dev->name); 315 } 316 } else { 317 printf(NAME ": no client is connected to %s, discarding the character which was read.\n", dev->name); 318 } 319 fibril_mutex_unlock(&data->mutex); 320 } 321 322 } 276 323 } 277 324 278 325 static inline void serial_interrupt_handler(device_t *dev, ipc_callid_t iid, ipc_call_t *icall) 279 326 { 280 printf(NAME ": interrupt received.\n");281 327 serial_read_from_device(dev); 282 328 }
Note:
See TracChangeset
for help on using the changeset viewer.