Changeset 5f4c41b2 in mainline for uspace/drv/char/sun4v-con/sun4v-con.c
- Timestamp:
- 2017-11-26T02:41:55Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4cfd271
- Parents:
- 9940ce0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/sun4v-con/sun4v-con.c
r9940ce0 r5f4c41b2 38 38 #include <io/chardev_srv.h> 39 39 #include <stdbool.h> 40 #include < thread.h>40 #include <sysinfo.h> 41 41 42 42 #include "sun4v-con.h" … … 59 59 } __attribute__((packed)) __attribute__((aligned(PAGE_SIZE))) *input_buffer_t; 60 60 61 #define OUTPUT_FIFO_SIZE ((PAGE_SIZE) - 2 * sizeof(uint64_t)) 62 63 typedef volatile struct { 64 uint64_t read_ptr; 65 uint64_t write_ptr; 66 char data[OUTPUT_FIFO_SIZE]; 67 } __attribute__((packed)) output_fifo_t; 68 61 69 /* virtual address of the shared buffer */ 62 70 static input_buffer_t input_buffer; 71 static output_fifo_t *output_fifo; 63 72 64 73 static int sun4v_con_read(chardev_srv_t *, void *, size_t, size_t *); … … 72 81 static void sun4v_con_putchar(sun4v_con_t *con, uint8_t data) 73 82 { 74 (void) con; 75 (void) data; 83 if (data == '\n') 84 sun4v_con_putchar(con, '\r'); 85 86 while (output_fifo->write_ptr == 87 (output_fifo->read_ptr + OUTPUT_FIFO_SIZE - 1) 88 % OUTPUT_FIFO_SIZE); 89 90 output_fifo->data[output_fifo->write_ptr] = data; 91 output_fifo->write_ptr = 92 ((output_fifo->write_ptr) + 1) % OUTPUT_FIFO_SIZE; 76 93 } 77 94 … … 105 122 } 106 123 124 sysarg_t paddr; 125 rc = sysinfo_get_value("niagara.outbuf.address", &paddr); 126 if (rc != EOK) { 127 ddf_msg(LVL_ERROR, "Outbuf address information not found"); 128 return rc; 129 } 130 131 output_fifo = (output_fifo_t *) AS_AREA_ANY; 132 133 rc = physmem_map(paddr, 1, AS_AREA_READ | AS_AREA_WRITE, 134 (void *) &output_fifo); 135 if (rc != EOK) { 136 ddf_msg(LVL_ERROR, "Error mapping memory: %d", rc); 137 return rc; 138 } 139 107 140 rc = ddf_fun_bind(fun); 108 141 if (rc != EOK) { … … 111 144 } 112 145 146 ddf_fun_add_to_category(fun, "console"); 147 113 148 return EOK; 114 149 error: 115 /* XXX Clean up thread */116 117 150 if (input_buffer != (input_buffer_t) AS_AREA_ANY) 118 151 physmem_unmap((void *) input_buffer);
Note:
See TracChangeset
for help on using the changeset viewer.