Changeset b366a6f4 in mainline
- Timestamp:
- 2011-06-24T15:58:01Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7250d2c
- Parents:
- ee2fa30a
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/mach/gta02/gta02.c
ree2fa30a rb366a6f4 158 158 { 159 159 #ifdef CONFIG_FB 160 parea_t fb_parea;161 162 160 fb_properties_t prop = { 163 161 .addr = GTA02_FB_BASE, … … 170 168 171 169 outdev_t *fb_dev = fb_init(&prop); 172 if (fb_dev) {170 if (fb_dev) 173 171 stdout_wire(fb_dev); 174 fb_parea.pbase = GTA02_FB_BASE;175 fb_parea.frames = 150;176 fb_parea.unpriv = false;177 ddi_parea_register(&fb_parea);178 }179 172 #endif 180 173 181 174 /* Initialize serial port of the debugging console. */ 182 s3c24xx_uart_io_t *scons_io; 183 184 scons_io = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE); 185 gta02_scons_dev = s3c24xx_uart_init(scons_io, S3C24XX_INT_UART2); 175 gta02_scons_dev = 176 s3c24xx_uart_init(GTA02_SCONS_BASE, S3C24XX_INT_UART2); 186 177 187 178 if (gta02_scons_dev) { -
kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
ree2fa30a rb366a6f4 53 53 54 54 #define SDRAM_SIZE (sdram[((*(uint32_t *)(ICP_CMCR+ICP_SDRAMCR_OFFSET) & ICP_SDRAM_MASK) >> 2)]) 55 static parea_t fb_parea;56 55 static icp_hw_map_t icp_hw_map; 57 56 static irq_t icp_timer_irq; … … 296 295 297 296 outdev_t *fbdev = fb_init(&prop); 298 if (fbdev) {297 if (fbdev) 299 298 stdout_wire(fbdev); 300 fb_parea.pbase = ICP_FB;301 fb_parea.frames = 300;302 fb_parea.unpriv = false;303 ddi_parea_register(&fb_parea);304 }305 299 #endif 306 300 } -
kernel/arch/ia64/src/drivers/ski.c
ree2fa30a rb366a6f4 57 57 }; 58 58 59 static void ski_putchar(outdev_t *, const wchar_t , bool);59 static void ski_putchar(outdev_t *, const wchar_t); 60 60 61 61 static outdev_operations_t skidev_ops = { … … 99 99 static void poll_keyboard(ski_instance_t *instance) 100 100 { 101 if (silent)102 return;103 104 101 int count = POLL_LIMIT; 105 102 … … 121 118 122 119 while (true) { 123 if (!silent) 120 // TODO FIXME: 121 // This currently breaks the kernel console 122 // before we get the override from uspace. 123 if (console_override) 124 124 poll_keyboard(instance); 125 125 … … 182 182 * @param dev Character device. 183 183 * @param ch Character to be printed. 184 * @param silent Whether the output should be silenced. 185 * 186 */ 187 static void ski_putchar(outdev_t *dev, const wchar_t ch, bool silent) 188 { 189 if (!silent) { 184 * 185 */ 186 static void ski_putchar(outdev_t *dev, const wchar_t ch) 187 { 188 // TODO FIXME: 189 // This currently breaks the kernel console 190 // before we get the override from uspace. 191 if (console_override) { 190 192 if (ascii_check(ch)) { 191 193 if (ch == '\n') … … 213 215 if (!fb_exported) { 214 216 /* 215 * This is the necessary evil until the userspace driver is entirely 217 * This is the necessary evil until 218 * the userspace driver is entirely 216 219 * self-sufficient. 217 220 */ -
kernel/arch/sparc64/include/drivers/sgcn.h
ree2fa30a rb366a6f4 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 40 40 #include <proc/thread.h> 41 41 #include <synch/spinlock.h> 42 #include <ddi/ddi.h> 42 43 43 44 /* number of bytes in the TOC magic, including the NULL-terminator */ … … 126 127 uintptr_t buffer_begin; 127 128 129 /** Physical memory area */ 130 parea_t parea; 131 128 132 /** 129 133 * Ensure that writing to the buffer and consequent -
kernel/arch/sparc64/src/drivers/niagara.c
ree2fa30a rb366a6f4 32 32 /** 33 33 * @file 34 * @brief 34 * @brief Niagara input/output driver based on hypervisor calls. 35 35 */ 36 36 … … 52 52 #include <genarch/srln/srln.h> 53 53 54 /* polling interval in miliseconds */54 /* Polling interval in miliseconds */ 55 55 #define POLL_INTERVAL 10000 56 56 57 /* device instance */57 /* Device instance */ 58 58 static niagara_instance_t *instance = NULL; 59 59 60 static void niagara_putchar(outdev_t *, const wchar_t , bool);61 62 /** character device operations */60 static void niagara_putchar(outdev_t *, const wchar_t); 61 62 /** Character device operations */ 63 63 static outdev_operations_t niagara_ops = { 64 64 .write = niagara_putchar, … … 66 66 }; 67 67 68 /* 68 /** 69 69 * The driver uses hypercalls to print characters to the console. Since the 70 70 * hypercall cannot be performed from the userspace, we do this: 71 * The kernel "little brother" driver (which will be present no matter what the 72 * DDI architecture is - as we need the kernel part for the kconsole) 71 * 72 * The kernel "little brother" driver (which will be present no matter what 73 * the DDI architecture is -- as we need the kernel part for the kconsole) 73 74 * defines a shared buffer. Kernel walks through the buffer (in the same thread 74 75 * which is used for polling the keyboard) and prints any pending characters 75 * to the console (using hypercalls). The userspace fb server maps this shared 76 * buffer to its address space and output operation it does is performed using 77 * the mapped buffer. The shared buffer definition follows. 78 */ 79 #define OUTPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 76 * to the console (using hypercalls). 77 * 78 * The userspace fb server maps this shared buffer to its address space and 79 * output operation it does is performed using the mapped buffer. The shared 80 * buffer definition follows. 81 */ 82 #define OUTPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 83 80 84 static volatile struct { 81 85 uint64_t read_ptr; 82 86 uint64_t write_ptr; 83 87 char data[OUTPUT_BUFFER_SIZE]; 84 } 85 __attribute__ ((packed)) 86 __attribute__ ((aligned(PAGE_SIZE))) 87 output_buffer; 88 } __attribute__ ((packed)) __attribute__ ((aligned(PAGE_SIZE))) output_buffer; 89 90 static parea_t outbuf_parea; 88 91 89 92 /** 90 93 * Analogous to the output_buffer, see the previous definition. 91 94 */ 92 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 95 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 96 93 97 static volatile struct { 94 98 uint64_t write_ptr; 95 99 uint64_t read_ptr; 96 100 char data[INPUT_BUFFER_SIZE]; 97 } 98 __attribute__ ((packed)) 99 __attribute__ ((aligned(PAGE_SIZE))) 100 input_buffer; 101 102 103 /** Writes a single character to the standard output. */ 101 } __attribute__ ((packed)) __attribute__ ((aligned(PAGE_SIZE))) input_buffer; 102 103 static parea_t inbuf_parea; 104 105 /** Write a single character to the standard output. */ 104 106 static inline void do_putchar(const char c) { 105 /* repeat until the buffer is non-full */ 106 while (__hypercall_fast1(CONS_PUTCHAR, c) == HV_EWOULDBLOCK) 107 ; 108 } 109 110 /** Writes a single character to the standard output. */ 111 static void niagara_putchar(outdev_t *dev, const wchar_t ch, bool silent) 112 { 113 if (silent) 114 return; 115 116 do_putchar(ch); 117 if (ch == '\n') 118 do_putchar('\r'); 119 } 120 121 /** 122 * Function regularly called by the keyboard polling thread. Asks the 123 * hypervisor whether there is any unread character. If so, it picks it up 124 * and sends it to the upper layers of HelenOS. 125 * 126 * Apart from that, it also checks whether the userspace output driver has 127 * pushed any characters to the output buffer. If so, it prints them. 128 */ 129 static void niagara_poll(niagara_instance_t *instance) 130 { 131 /* print any pending characters from the shared buffer to the console */ 107 /* Repeat until the buffer is non-full */ 108 while (__hypercall_fast1(CONS_PUTCHAR, c) == HV_EWOULDBLOCK); 109 } 110 111 /** Write a single character to the standard output. */ 112 static void niagara_putchar(outdev_t *dev, const wchar_t ch) 113 { 114 if ((!outbuf_parea.mapped) || (console_override)) { 115 do_putchar(ch); 116 if (ch == '\n') 117 do_putchar('\r'); 118 } 119 } 120 121 /** Poll keyboard and print pending characters. 122 * 123 * Ask the hypervisor whether there is any unread character. If so, 124 * pick it up and send it to the indev layer. 125 * 126 * Check whether the userspace output driver has pushed any 127 * characters to the output buffer and eventually print them. 128 * 129 */ 130 static void niagara_poll(void) 131 { 132 /* 133 * Print any pending characters from the 134 * shared buffer to the console. 135 */ 136 132 137 while (output_buffer.read_ptr != output_buffer.write_ptr) { 133 138 do_putchar(output_buffer.data[output_buffer.read_ptr]); 134 139 output_buffer.read_ptr = 135 ((output_buffer.read_ptr) + 1) % OUTPUT_BUFFER_SIZE; 136 } 137 140 ((output_buffer.read_ptr) + 1) % OUTPUT_BUFFER_SIZE; 141 } 142 143 /* 144 * Read character from keyboard. 145 */ 146 138 147 uint64_t c; 139 140 /* read character from keyboard, send it to upper layers of HelenOS */141 148 if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == HV_EOK) { 142 if (!silent) { 143 /* kconsole active, send the character to kernel */ 149 if ((!inbuf_parea.mapped) || (console_override)) { 150 /* 151 * Kernel console is active, send 152 * the character to kernel. 153 */ 144 154 indev_push_character(instance->srlnin, c); 145 155 } else { 146 /* kconsole inactive, send the character to uspace driver */ 156 /* 157 * Kernel console is inactive, send 158 * the character to uspace driver. 159 */ 147 160 input_buffer.data[input_buffer.write_ptr] = (char) c; 148 161 input_buffer.write_ptr = 149 162 ((input_buffer.write_ptr) + 1) % INPUT_BUFFER_SIZE; 150 163 } 151 164 } 152 165 } 153 166 154 /** 155 * Polling thread function.156 */ 157 static void kniagarapoll(void * instance) {167 /** Polling thread function. 168 * 169 */ 170 static void kniagarapoll(void *arg) { 158 171 while (true) { 159 niagara_poll( instance);172 niagara_poll(); 160 173 thread_usleep(POLL_INTERVAL); 161 174 } 162 175 } 163 176 164 /** 165 * Initializes the input/output subsystem so that the Niagara standard 166 * input/output is used. 177 /** Initialize the input/output subsystem 178 * 167 179 */ 168 180 static void niagara_init(void) … … 172 184 173 185 instance = malloc(sizeof(niagara_instance_t), FRAME_ATOMIC); 174 175 if (instance) { 176 instance->thread = thread_create(kniagarapoll, instance, TASK, 0, 177 "kniagarapoll", true); 178 179 if (!instance->thread) { 180 free(instance); 181 instance = NULL; 182 return; 183 } 184 } 185 186 instance->thread = thread_create(kniagarapoll, NULL, TASK, 0, 187 "kniagarapoll", true); 188 189 if (!instance->thread) { 190 free(instance); 191 instance = NULL; 192 return; 193 } 194 186 195 instance->srlnin = NULL; 187 196 188 197 output_buffer.read_ptr = 0; 189 198 output_buffer.write_ptr = 0; 190 199 input_buffer.write_ptr = 0; 191 200 input_buffer.read_ptr = 0; 192 201 193 202 /* 194 203 * Set sysinfos and pareas so that the userspace counterpart of the 195 204 * niagara fb and kbd driver can communicate with kernel using shared 196 205 * buffers. 197 198 206 */ 207 199 208 sysinfo_set_item_val("fb.kind", NULL, 5); 200 209 201 210 sysinfo_set_item_val("niagara.outbuf.address", NULL, 202 211 KA2PA(&output_buffer)); 203 212 sysinfo_set_item_val("niagara.outbuf.size", NULL, 204 213 PAGE_SIZE); 205 214 sysinfo_set_item_val("niagara.outbuf.datasize", NULL, 206 207 215 OUTPUT_BUFFER_SIZE); 216 208 217 sysinfo_set_item_val("niagara.inbuf.address", NULL, 209 218 KA2PA(&input_buffer)); 210 219 sysinfo_set_item_val("niagara.inbuf.size", NULL, 211 220 PAGE_SIZE); 212 221 sysinfo_set_item_val("niagara.inbuf.datasize", NULL, 213 INPUT_BUFFER_SIZE); 214 215 static parea_t outbuf_parea; 222 INPUT_BUFFER_SIZE); 223 216 224 outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer)); 217 225 outbuf_parea.frames = 1; 218 226 outbuf_parea.unpriv = false; 227 outbuf_parea.mapped = false; 219 228 ddi_parea_register(&outbuf_parea); 220 221 static parea_t inbuf_parea; 229 222 230 inbuf_parea.pbase = (uintptr_t) (KA2PA(&input_buffer)); 223 231 inbuf_parea.frames = 1; 224 232 inbuf_parea.unpriv = false; 233 inbuf_parea.mapped = false; 225 234 ddi_parea_register(&inbuf_parea); 226 235 227 236 outdev_t *niagara_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC); 228 237 outdev_initialize("niagara_dev", niagara_dev, &niagara_ops); … … 230 239 } 231 240 232 /** 233 * A public function which initializes input from the Niagara console.241 /** Initialize input from the Niagara console. 242 * 234 243 */ 235 244 niagara_instance_t *niagarain_init(void) 236 245 { 237 246 niagara_init(); 238 247 239 248 if (instance) { 240 249 srln_instance_t *srln_instance = srln_init(); … … 242 251 indev_t *sink = stdin_wire(); 243 252 indev_t *srln = srln_wire(srln_instance, sink); 244 245 // wire std. input to niagara 253 246 254 instance->srlnin = srln; 247 255 thread_ready(instance->thread); 248 256 } 249 257 } 258 250 259 return instance; 251 260 } -
kernel/arch/sparc64/src/drivers/sgcn.c
ree2fa30a rb366a6f4 102 102 #define SGCN_BUFFER_HEADER (SGCN_BUFFER(sgcn_buffer_header_t, 0)) 103 103 104 static void sgcn_putchar(outdev_t *, const wchar_t , bool);104 static void sgcn_putchar(outdev_t *, const wchar_t); 105 105 106 106 static outdev_operations_t sgcndev_ops = { … … 111 111 static sgcn_instance_t *instance = NULL; 112 112 113 /** 114 * Set some sysinfo values (SRAM address and SRAM size). 115 */ 116 static void register_sram(uintptr_t sram_begin_physical) 117 { 118 sysinfo_set_item_val("sram.area.size", NULL, MAPPED_AREA_SIZE); 119 sysinfo_set_item_val("sram.address.physical", NULL, 120 sram_begin_physical); 121 } 122 123 /** 124 * Initializes the starting address of SRAM. 113 /** Initialize the starting address of SRAM. 125 114 * 126 115 * The SRAM starts 0x900000 + C bytes behind the SBBC start in the … … 129 118 * be set to the virtual address which maps to the SRAM physical 130 119 * address. 120 * 131 121 */ 132 122 static void init_sram_begin(void) … … 149 139 instance->sram_begin = hw_map(sram_begin_physical, MAPPED_AREA_SIZE); 150 140 151 register_sram(sram_begin_physical); 152 } 153 154 /** 155 * Function regularly called by the keyboard polling thread. Finds out whether 156 * there are some unread characters in the input queue. If so, it picks them up 157 * and sends them to the upper layers of HelenOS. 141 link_initialize(&instance->parea.link); 142 instance->parea.pbase = sram_begin_physical; 143 instance->parea.frames = SIZE2FRAMES(MAPPED_AREA_SIZE); 144 instance->parea.unpriv = false; 145 instance->parea.mapped = false; 146 ddi_parea_register(&instance->parea); 147 148 sysinfo_set_item_val("sram.area.size", NULL, MAPPED_AREA_SIZE); 149 sysinfo_set_item_val("sram.address.physical", NULL, 150 sram_begin_physical); 151 } 152 153 /** Get unread characters from the input queue. 154 * 155 * Check for unread characters in the input queue. 156 * 158 157 */ 159 158 static void sgcn_poll(sgcn_instance_t *instance) … … 163 162 uint32_t size = end - begin; 164 163 165 if ( silent)164 if ((instance->parea.mapped) && (!console_override)) 166 165 return; 167 166 168 167 spinlock_lock(&instance->input_lock); 169 168 170 /* we need pointers to volatile variables */169 /* We need pointers to volatile variables */ 171 170 volatile char *buf_ptr = (volatile char *) 172 171 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); … … 186 185 } 187 186 188 /** 189 * Polling thread function.187 /** Polling thread function. 188 * 190 189 */ 191 190 static void ksgcnpoll(void *instance) { 192 191 while (true) { 193 if (!silent) 194 sgcn_poll(instance); 195 192 sgcn_poll(instance); 196 193 thread_usleep(POLL_INTERVAL); 197 194 } 198 195 } 199 196 200 /** 201 * Initializes the starting address of the SGCN buffer. 197 /** Initialize the starting address of the SGCN buffer. 202 198 * 203 199 * The offset of the SGCN buffer within SRAM is obtained from the 204 200 * SRAM table of contents. The table of contents contains 205 201 * information about several buffers, among which there is an OBP 206 * console buffer - this one will be used as the SGCN buffer.202 * console buffer -- this one will be used as the SGCN buffer. 207 203 * 208 204 * This function also writes the offset of the SGCN buffer within SRAM 209 205 * under the sram.buffer.offset sysinfo key. 206 * 210 207 */ 211 208 static void sgcn_init(void) … … 248 245 } 249 246 250 /** 251 * Writes a single character to the SGCN (circular) output buffer 252 * and updates the output write pointer so that SGCN gets to know 247 /** Write a single character to the SGCN output buffer 248 * 249 * Write a single character to the SGCN (circular) output buffer 250 * and update the output write pointer so that SGCN gets to know 253 251 * that the character has been written. 252 * 254 253 */ 255 254 static void sgcn_do_putchar(const char c) … … 286 285 } 287 286 288 /** 289 * SGCN output operation. Prints a single character to the SGCN. Newline 287 /** SGCN output operation 288 * 289 * Print a single character to the SGCN. Newline 290 290 * character is converted to CRLF. 291 */ 292 static void sgcn_putchar(outdev_t *dev, const wchar_t ch, bool silent) 293 { 294 if (!silent) { 291 * 292 */ 293 static void sgcn_putchar(outdev_t *dev, const wchar_t ch) 294 { 295 if ((!instance->parea.mapped) || (console_override)) { 295 296 spinlock_lock(&instance->output_lock); 296 297 … … 306 307 } 307 308 308 /** 309 * A public function which initializes input from the Serengeti console.309 /** Initialize input from the Serengeti console. 310 * 310 311 */ 311 312 sgcn_instance_t *sgcnin_init(void) … … 326 327 } 327 328 328 /** 329 * A public function which initializes output to the Serengeti console.329 /** Initialize output to the Serengeti console. 330 * 330 331 */ 331 332 outdev_t *sgcnout_init(void) -
kernel/genarch/include/drivers/s3c24xx_uart/s3c24xx_uart.h
ree2fa30a rb366a6f4 38 38 #define KERN_S3C24XX_UART_H_ 39 39 40 #include <ddi/ddi.h> 40 41 #include <ddi/irq.h> 41 42 #include <console/chardev.h> … … 83 84 indev_t *indev; 84 85 irq_t irq; 86 parea_t parea; 85 87 } s3c24xx_uart_t; 86 88 87 extern outdev_t *s3c24xx_uart_init( s3c24xx_uart_io_t *, inr_t inr);89 extern outdev_t *s3c24xx_uart_init(uintptr_t, inr_t inr); 88 90 extern void s3c24xx_uart_input_wire(s3c24xx_uart_t *, 89 91 indev_t *); -
kernel/genarch/src/drivers/dsrln/dsrlnout.c
ree2fa30a rb366a6f4 42 42 #include <sysinfo/sysinfo.h> 43 43 #include <str.h> 44 #include <ddi/ddi.h> 44 45 45 46 typedef struct { 47 parea_t parea; 46 48 ioport8_t *base; 47 49 } dsrlnout_instance_t; 48 50 49 static void dsrlnout_putchar(outdev_t *dev, const wchar_t ch , bool silent)51 static void dsrlnout_putchar(outdev_t *dev, const wchar_t ch) 50 52 { 51 53 dsrlnout_instance_t *instance = (dsrlnout_instance_t *) dev->data; 52 54 53 if ( !silent) {55 if ((!instance->parea.mapped) || (console_override)) { 54 56 if (ascii_check(ch)) 55 57 pio_write_8(instance->base, ch); … … 70 72 return NULL; 71 73 72 dsrlnout_instance_t *instance = malloc(sizeof(dsrlnout_instance_t), FRAME_ATOMIC); 74 dsrlnout_instance_t *instance = malloc(sizeof(dsrlnout_instance_t), 75 FRAME_ATOMIC); 73 76 if (!instance) { 74 77 free(dsrlndev); … … 80 83 81 84 instance->base = base; 85 link_initialize(&instance->parea.link); 86 instance->parea.pbase = KA2PA(base); 87 instance->parea.frames = 1; 88 instance->parea.unpriv = false; 89 instance->parea.mapped = false; 90 ddi_parea_register(&instance->parea); 82 91 83 92 if (!fb_exported) { 84 93 /* 85 * This is the necessary evil until the userspace driver is entirely 94 * This is the necessary evil until 95 * the userspace driver is entirely 86 96 * self-sufficient. 87 97 */ -
kernel/genarch/src/drivers/ega/ega.c
ree2fa30a rb366a6f4 64 64 IRQ_SPINLOCK_DECLARE(lock); 65 65 66 parea_t parea; 67 66 68 uint32_t cursor; 67 69 uint8_t *addr; … … 70 72 } ega_instance_t; 71 73 72 static void ega_putchar(outdev_t *, wchar_t , bool);74 static void ega_putchar(outdev_t *, wchar_t); 73 75 static void ega_redraw(outdev_t *); 74 76 … … 437 439 * This function takes care of scrolling. 438 440 */ 439 static void ega_check_cursor(ega_instance_t *instance , bool silent)441 static void ega_check_cursor(ega_instance_t *instance) 440 442 { 441 443 if (instance->cursor < EGA_SCREEN) … … 448 450 EGA_COLS, EMPTY_CHAR); 449 451 450 if ( !silent) {452 if ((!instance->parea.mapped) || (console_override)) { 451 453 memmove((void *) instance->addr, 452 454 (void *) (instance->addr + EGA_COLS * 2), … … 459 461 } 460 462 461 static void ega_show_cursor(ega_instance_t *instance , bool silent)462 { 463 if ( !silent) {463 static void ega_show_cursor(ega_instance_t *instance) 464 { 465 if ((!instance->parea.mapped) || (console_override)) { 464 466 pio_write_8(instance->base + EGA_INDEX_REG, 0x0a); 465 467 uint8_t stat = pio_read_8(instance->base + EGA_DATA_REG); … … 469 471 } 470 472 471 static void ega_move_cursor(ega_instance_t *instance , bool silent)472 { 473 if ( !silent) {473 static void ega_move_cursor(ega_instance_t *instance) 474 { 475 if ((!instance->parea.mapped) || (console_override)) { 474 476 pio_write_8(instance->base + EGA_INDEX_REG, 0x0e); 475 477 pio_write_8(instance->base + EGA_DATA_REG, … … 481 483 } 482 484 483 static void ega_sync_cursor(ega_instance_t *instance , bool silent)484 { 485 if ( !silent) {485 static void ega_sync_cursor(ega_instance_t *instance) 486 { 487 if ((!instance->parea.mapped) || (console_override)) { 486 488 pio_write_8(instance->base + EGA_INDEX_REG, 0x0e); 487 489 uint8_t hi = pio_read_8(instance->base + EGA_DATA_REG); … … 503 505 EGA_SCREEN - instance->cursor, EMPTY_CHAR); 504 506 505 if ( !silent)507 if ((!instance->parea.mapped) || (console_override)) 506 508 memsetw(instance->addr + instance->cursor * 2, 507 509 EGA_SCREEN - instance->cursor, EMPTY_CHAR); 508 510 509 ega_check_cursor(instance , silent);510 ega_move_cursor(instance , silent);511 ega_show_cursor(instance , silent);512 } 513 514 static void ega_display_char(ega_instance_t *instance, wchar_t ch , bool silent)511 ega_check_cursor(instance); 512 ega_move_cursor(instance); 513 ega_show_cursor(instance); 514 } 515 516 static void ega_display_char(ega_instance_t *instance, wchar_t ch) 515 517 { 516 518 uint16_t index = ega_oem_glyph(ch); … … 529 531 instance->backbuf[instance->cursor * 2 + 1] = style; 530 532 531 if ( !silent) {533 if ((!instance->parea.mapped) || (console_override)) { 532 534 instance->addr[instance->cursor * 2] = glyph; 533 535 instance->addr[instance->cursor * 2 + 1] = style; … … 535 537 } 536 538 537 static void ega_putchar(outdev_t *dev, wchar_t ch , bool silent)539 static void ega_putchar(outdev_t *dev, wchar_t ch) 538 540 { 539 541 ega_instance_t *instance = (ega_instance_t *) dev->data; … … 555 557 break; 556 558 default: 557 ega_display_char(instance, ch , silent);559 ega_display_char(instance, ch); 558 560 instance->cursor++; 559 561 break; 560 562 } 561 ega_check_cursor(instance , silent);562 ega_move_cursor(instance , silent);563 ega_check_cursor(instance); 564 ega_move_cursor(instance); 563 565 564 566 irq_spinlock_unlock(&instance->lock, true); … … 572 574 573 575 memcpy(instance->addr, instance->backbuf, EGA_VRAM_SIZE); 574 ega_move_cursor(instance , silent);575 ega_show_cursor(instance , silent);576 ega_move_cursor(instance); 577 ega_show_cursor(instance); 576 578 577 579 irq_spinlock_unlock(&instance->lock, true); … … 612 614 } 613 615 616 link_initialize(&instance->parea.link); 617 instance->parea.pbase = addr; 618 instance->parea.frames = SIZE2FRAMES(EGA_VRAM_SIZE); 619 instance->parea.unpriv = false; 620 instance->parea.mapped = false; 621 ddi_parea_register(&instance->parea); 622 614 623 /* Synchronize the back buffer and cursor position. */ 615 624 memcpy(instance->backbuf, instance->addr, EGA_VRAM_SIZE); 616 ega_sync_cursor(instance , silent);625 ega_sync_cursor(instance); 617 626 618 627 if (!fb_exported) { 619 628 /* 620 * This is the necessary evil until the userspace driver is entirely 621 * self-sufficient. 629 * We export the kernel framebuffer for uspace usage. 630 * This is used in the case the uspace framebuffer 631 * driver is not self-sufficient. 622 632 */ 623 633 sysinfo_set_item_val("fb", NULL, true); -
kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c
ree2fa30a rb366a6f4 44 44 #include <arch/asm.h> 45 45 #include <mm/slab.h> 46 #include <mm/page.h> 46 47 #include <sysinfo/sysinfo.h> 47 48 #include <str.h> … … 59 60 } 60 61 61 static void s3c24xx_uart_putchar(outdev_t *dev, wchar_t ch , bool silent)62 static void s3c24xx_uart_putchar(outdev_t *dev, wchar_t ch) 62 63 { 63 if (!silent) { 64 s3c24xx_uart_t *uart = 65 (s3c24xx_uart_t *) dev->data; 66 67 if ((!uart->parea.mapped) || (console_override)) { 64 68 if (!ascii_check(ch)) { 65 69 s3c24xx_uart_sendb(dev, U_SPECIAL); 66 70 } else { 67 71 if (ch == '\n') 68 72 s3c24xx_uart_sendb(dev, (uint8_t) '\r'); 69 73 s3c24xx_uart_sendb(dev, (uint8_t) ch); … … 93 97 }; 94 98 95 outdev_t *s3c24xx_uart_init( s3c24xx_uart_io_t *io, inr_t inr)99 outdev_t *s3c24xx_uart_init(uintptr_t paddr, inr_t inr) 96 100 { 97 101 outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC); … … 109 113 uart_dev->data = uart; 110 114 111 uart->io = io;115 uart->io = (s3c24xx_uart_io_t *) hw_map(paddr, PAGE_SIZE); 112 116 uart->indev = NULL; 113 117 … … 127 131 pio_write_32(&uart->io->ucon, 128 132 pio_read_32(&uart->io->ucon) & ~UCON_RX_INT_LEVEL); 129 133 134 link_initialize(&uart->parea.link); 135 uart->parea.pbase = paddr; 136 uart->parea.frames = 1; 137 uart->parea.unpriv = false; 138 uart->parea.mapped = false; 139 ddi_parea_register(&uart->parea); 140 130 141 if (!fb_exported) { 131 142 /* 132 * This is the necessary evil until the userspace driver is entirely 143 * This is the necessary evil until 144 * the userspace driver is entirely 133 145 * self-sufficient. 134 146 */ 135 147 sysinfo_set_item_val("fb", NULL, true); 136 148 sysinfo_set_item_val("fb.kind", NULL, 3); 137 sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(io));149 sysinfo_set_item_val("fb.address.physical", NULL, paddr); 138 150 139 151 fb_exported = true; -
kernel/genarch/src/fb/fb.c
ree2fa30a rb366a6f4 82 82 SPINLOCK_DECLARE(lock); 83 83 84 parea_t parea; 85 84 86 uint8_t *addr; 85 87 uint16_t *backbuf; … … 109 111 } fb_instance_t; 110 112 111 static void fb_putchar(outdev_t *dev, wchar_t ch , bool silent);113 static void fb_putchar(outdev_t *dev, wchar_t ch); 112 114 static void fb_redraw_internal(fb_instance_t *instance); 113 115 static void fb_redraw(outdev_t *dev); … … 215 217 * 216 218 */ 217 static void logo_hide(fb_instance_t *instance , bool silent)219 static void logo_hide(fb_instance_t *instance) 218 220 { 219 221 instance->ylogo = 0; … … 221 223 instance->rowtrim = instance->rows; 222 224 223 if ( !silent)225 if ((!instance->parea.mapped) || (console_override)) 224 226 fb_redraw_internal(instance); 225 227 } … … 229 231 */ 230 232 static void glyph_draw(fb_instance_t *instance, uint16_t glyph, 231 unsigned int col, unsigned int row, bool silent, booloverlay)233 unsigned int col, unsigned int row, bool overlay) 232 234 { 233 235 unsigned int x = COL2X(col); … … 236 238 237 239 if (y >= instance->ytrim) 238 logo_hide(instance , silent);240 logo_hide(instance); 239 241 240 242 if (!overlay) 241 243 instance->backbuf[BB_POS(instance, col, row)] = glyph; 242 244 243 if ( !silent) {245 if ((!instance->parea.mapped) || (console_override)) { 244 246 for (yd = 0; yd < FONT_SCANLINES; yd++) 245 247 memcpy(&instance->addr[FB_POS(instance, x, y + yd + instance->ylogo)], … … 253 255 * 254 256 */ 255 static void screen_scroll(fb_instance_t *instance , bool silent)257 static void screen_scroll(fb_instance_t *instance) 256 258 { 257 259 if (instance->ylogo > 0) { 258 logo_hide(instance , silent);260 logo_hide(instance); 259 261 return; 260 262 } 261 263 262 if ( !silent) {264 if ((!instance->parea.mapped) || (console_override)) { 263 265 unsigned int row; 264 266 … … 298 300 } 299 301 300 static void cursor_put(fb_instance_t *instance , bool silent)302 static void cursor_put(fb_instance_t *instance) 301 303 { 302 304 unsigned int col = instance->position % instance->cols; 303 305 unsigned int row = instance->position / instance->cols; 304 306 305 glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, silent,true);306 } 307 308 static void cursor_remove(fb_instance_t *instance , bool silent)307 glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, true); 308 } 309 310 static void cursor_remove(fb_instance_t *instance) 309 311 { 310 312 unsigned int col = instance->position % instance->cols; … … 312 314 313 315 glyph_draw(instance, instance->backbuf[BB_POS(instance, col, row)], 314 col, row, silent,true);316 col, row, true); 315 317 } 316 318 … … 362 364 * 363 365 */ 364 static void fb_putchar(outdev_t *dev, wchar_t ch , bool silent)366 static void fb_putchar(outdev_t *dev, wchar_t ch) 365 367 { 366 368 fb_instance_t *instance = (fb_instance_t *) dev->data; … … 369 371 switch (ch) { 370 372 case '\n': 371 cursor_remove(instance , silent);373 cursor_remove(instance); 372 374 instance->position += instance->cols; 373 375 instance->position -= instance->position % instance->cols; 374 376 break; 375 377 case '\r': 376 cursor_remove(instance , silent);378 cursor_remove(instance); 377 379 instance->position -= instance->position % instance->cols; 378 380 break; 379 381 case '\b': 380 cursor_remove(instance , silent);382 cursor_remove(instance); 381 383 if (instance->position % instance->cols) 382 384 instance->position--; 383 385 break; 384 386 case '\t': 385 cursor_remove(instance , silent);387 cursor_remove(instance); 386 388 do { 387 389 glyph_draw(instance, fb_font_glyph(' '), 388 390 instance->position % instance->cols, 389 instance->position / instance->cols, silent,false);391 instance->position / instance->cols, false); 390 392 instance->position++; 391 393 } while ((instance->position % 8) … … 395 397 glyph_draw(instance, fb_font_glyph(ch), 396 398 instance->position % instance->cols, 397 instance->position / instance->cols, silent,false);399 instance->position / instance->cols, false); 398 400 instance->position++; 399 401 } … … 401 403 if (instance->position >= instance->cols * instance->rows) { 402 404 instance->position -= instance->cols; 403 screen_scroll(instance , silent);404 } 405 406 cursor_put(instance , silent);405 screen_scroll(instance); 406 } 407 408 cursor_put(instance); 407 409 408 410 spinlock_unlock(&instance->lock); … … 555 557 556 558 spinlock_initialize(&instance->lock, "*fb.instance.lock"); 559 557 560 instance->rgb_conv = rgb_conv; 558 561 instance->pixelbytes = pixelbytes; … … 623 626 glyphs_render(instance); 624 627 628 link_initialize(&instance->parea.link); 629 instance->parea.pbase = props->addr; 630 instance->parea.frames = SIZE2FRAMES(fbsize); 631 instance->parea.unpriv = false; 632 instance->parea.mapped = false; 633 ddi_parea_register(&instance->parea); 634 625 635 if (!fb_exported) { 626 636 /* 627 * This is the necessary evil until the userspace driver is entirely 628 * self-sufficient. 637 * We export the kernel framebuffer for uspace usage. 638 * This is used in the case the uspace framebuffer 639 * driver is not self-sufficient. 629 640 */ 630 641 sysinfo_set_item_val("fb", NULL, true); -
kernel/generic/include/console/chardev.h
ree2fa30a rb366a6f4 73 73 typedef struct { 74 74 /** Write character to output. */ 75 void (* write)(struct outdev *, wchar_t , bool);75 void (* write)(struct outdev *, wchar_t); 76 76 77 77 /** Redraw any previously cached characters. */ -
kernel/generic/include/console/console.h
ree2fa30a rb366a6f4 72 72 extern void release_console(void); 73 73 74 extern sysarg_t sys_debug_enable_console(void); 75 extern sysarg_t sys_debug_disable_console(void); 74 extern sysarg_t sys_debug_activate_console(void); 76 75 77 76 #endif /* KERN_CONSOLE_H_ */ -
kernel/generic/include/ddi/ddi.h
ree2fa30a rb366a6f4 48 48 pfn_t frames; /**< Number of frames in the area. */ 49 49 bool unpriv; /**< Allow mapping by unprivileged tasks. */ 50 bool mapped; /**< Indicate whether the area is actually 51 mapped. */ 50 52 } parea_t; 51 53 -
kernel/generic/include/panic.h
ree2fa30a rb366a6f4 60 60 struct istate; 61 61 62 extern bool silent;62 extern bool console_override; 63 63 64 64 extern void panic_common(panic_category_t, struct istate *, int, -
kernel/generic/include/syscall/syscall.h
ree2fa30a rb366a6f4 94 94 SYS_SYSINFO_GET_DATA, 95 95 96 SYS_DEBUG_ENABLE_CONSOLE, 97 SYS_DEBUG_DISABLE_CONSOLE, 96 SYS_DEBUG_ACTIVATE_CONSOLE, 98 97 99 98 SYSCALL_END -
kernel/generic/src/console/console.c
ree2fa30a rb366a6f4 87 87 }; 88 88 89 static void stdout_write(outdev_t *, wchar_t , bool);89 static void stdout_write(outdev_t *, wchar_t); 90 90 static void stdout_redraw(outdev_t *); 91 91 … … 95 95 }; 96 96 97 /** Silence output */98 bool silent= false;97 /** Override kernel console lockout */ 98 bool console_override = false; 99 99 100 100 /** Standard input and output character devices */ … … 122 122 } 123 123 124 static void stdout_write(outdev_t *dev, wchar_t ch , bool silent)124 static void stdout_write(outdev_t *dev, wchar_t ch) 125 125 { 126 126 list_foreach(dev->list, cur) { 127 127 outdev_t *sink = list_get_instance(cur, outdev_t, link); 128 128 if ((sink) && (sink->op->write)) 129 sink->op->write(sink, ch , silent);129 sink->op->write(sink, ch); 130 130 } 131 131 } … … 156 156 klog_parea.frames = SIZE2FRAMES(sizeof(klog)); 157 157 klog_parea.unpriv = false; 158 klog_parea.mapped = false; 158 159 ddi_parea_register(&klog_parea); 159 160 … … 167 168 void grab_console(void) 168 169 { 169 bool prev = silent;170 171 silent = false;170 bool prev = console_override; 171 172 console_override = true; 172 173 if ((stdout) && (stdout->op->redraw)) 173 174 stdout->op->redraw(stdout); 174 175 175 if ((stdin) && ( prev)) {176 if ((stdin) && (!prev)) { 176 177 /* 177 178 * Force the console to print the prompt. … … 183 184 void release_console(void) 184 185 { 185 // FIXME arch_release_console 186 silent = true; 187 } 188 189 /** Tell kernel to get keyboard/console access again */ 190 sysarg_t sys_debug_enable_console(void) 186 console_override = false; 187 } 188 189 /** Activate kernel console override */ 190 sysarg_t sys_debug_activate_console(void) 191 191 { 192 192 #ifdef CONFIG_KCONSOLE … … 196 196 return false; 197 197 #endif 198 }199 200 /** Tell kernel to relinquish keyboard/console access */201 sysarg_t sys_debug_disable_console(void)202 {203 release_console();204 return true;205 198 } 206 199 … … 289 282 */ 290 283 spinlock_unlock(&klog_lock); 291 stdout->op->write(stdout, tmp , silent);284 stdout->op->write(stdout, tmp); 292 285 spinlock_lock(&klog_lock); 293 286 } … … 317 310 * it should be no longer buffered. 318 311 */ 319 stdout->op->write(stdout, ch , silent);312 stdout->op->write(stdout, ch); 320 313 } else { 321 314 /* -
kernel/generic/src/ddi/ddi.c
ree2fa30a rb366a6f4 122 122 backend_data.frames = pages; 123 123 124 /* Find the zone of the physical memory */ 124 /* 125 * Check if the memory region is explicitly enabled 126 * for mapping by any parea structure. 127 */ 128 129 mutex_lock(&parea_lock); 130 btree_node_t *nodep; 131 parea_t *parea = (parea_t *) btree_search(&parea_btree, 132 (btree_key_t) pf, &nodep); 133 134 if ((parea != NULL) && (parea->frames >= pages)) { 135 if ((!priv) && (!parea->unpriv)) { 136 mutex_unlock(&parea_lock); 137 return EPERM; 138 } 139 140 goto map; 141 } 142 143 parea = NULL; 144 mutex_unlock(&parea_lock); 145 146 /* 147 * Check if the memory region is part of physical 148 * memory generally enabled for mapping. 149 */ 150 125 151 irq_spinlock_lock(&zones.lock, true); 126 152 size_t znum = find_zone(ADDR2PFN(pf), pages, 0); … … 153 179 } 154 180 155 if (zone_flags_available(zones.info[znum].flags)) {156 /*157 * Frames are part of physical memory, check158 * if the memory region is enabled for mapping.159 */160 irq_spinlock_unlock(&zones.lock, true);161 162 mutex_lock(&parea_lock);163 btree_node_t *nodep;164 parea_t *parea = (parea_t *) btree_search(&parea_btree,165 (btree_key_t) pf, &nodep);166 167 if ((!parea) || (parea->frames < pages)) {168 mutex_unlock(&parea_lock);169 return ENOENT;170 }171 172 if (!priv) {173 if (!parea->unpriv) {174 mutex_unlock(&parea_lock);175 return EPERM;176 }177 }178 179 mutex_unlock(&parea_lock);180 goto map;181 }182 183 181 irq_spinlock_unlock(&zones.lock, true); 184 182 return ENOENT; … … 188 186 AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) { 189 187 /* 190 * The address space area could not have beencreated.188 * The address space area was not created. 191 189 * We report it using ENOMEM. 192 190 */ 191 192 if (parea != NULL) 193 mutex_unlock(&parea_lock); 194 193 195 return ENOMEM; 194 196 } … … 197 199 * Mapping is created on-demand during page fault. 198 200 */ 199 return 0; 201 202 if (parea != NULL) { 203 parea->mapped = true; 204 mutex_unlock(&parea_lock); 205 } 206 207 return EOK; 200 208 } 201 209 -
kernel/generic/src/ddi/irq.c
ree2fa30a rb366a6f4 275 275 { 276 276 /* 277 * If the kernel console is silenced, 278 * then try first the uspace handlers, 279 * eventually fall back to kernel handlers. 277 * If the kernel console override is on, 278 * then try first the kernel handlers 279 * and eventually fall back to uspace 280 * handlers. 280 281 * 281 * I f the kernel console is active,282 * then do it the other way around.282 * In the usual case the uspace handlers 283 * have precedence. 283 284 */ 284 if (silent) { 285 irq_t *irq = irq_dispatch_and_lock_uspace(inr); 285 286 if (console_override) { 287 irq_t *irq = irq_dispatch_and_lock_kernel(inr); 286 288 if (irq) 287 289 return irq; 288 290 289 return irq_dispatch_and_lock_ kernel(inr);290 } 291 292 irq_t *irq = irq_dispatch_and_lock_ kernel(inr);291 return irq_dispatch_and_lock_uspace(inr); 292 } 293 294 irq_t *irq = irq_dispatch_and_lock_uspace(inr); 293 295 if (irq) 294 296 return irq; 295 297 296 return irq_dispatch_and_lock_ uspace(inr);298 return irq_dispatch_and_lock_kernel(inr); 297 299 } 298 300 -
kernel/generic/src/debug/panic.c
ree2fa30a rb366a6f4 48 48 uintptr_t address, const char *fmt, ...) 49 49 { 50 va_list args; 51 52 silent = false; 50 console_override = true; 53 51 54 52 printf("\n%s Kernel panic ", BANNER_LEFT); … … 57 55 printf("due to "); 58 56 57 va_list args; 59 58 va_start(args, fmt); 60 59 if (cat == PANIC_ASSERT) { -
kernel/generic/src/lib/rd.c
ree2fa30a rb366a6f4 91 91 rd_parea.frames = SIZE2FRAMES(dsize); 92 92 rd_parea.unpriv = false; 93 rd_parea.mapped = false; 93 94 ddi_parea_register(&rd_parea); 94 95 -
kernel/generic/src/syscall/syscall.c
ree2fa30a rb366a6f4 186 186 (syshandler_t) sys_sysinfo_get_data, 187 187 188 /* Debug calls */ 189 (syshandler_t) sys_debug_enable_console, 190 (syshandler_t) sys_debug_disable_console 188 /* Kernel console syscalls. */ 189 (syshandler_t) sys_debug_activate_console 191 190 }; 192 191 -
kernel/generic/src/time/clock.c
ree2fa30a rb366a6f4 94 94 clock_parea.frames = 1; 95 95 clock_parea.unpriv = true; 96 clock_parea.mapped = false; 96 97 ddi_parea_register(&clock_parea); 97 98 -
uspace/app/trace/syscalls.c
ree2fa30a rb366a6f4 80 80 [SYS_SYSINFO_GET_DATA] = { "sysinfo_get_data", 5, V_ERRNO }, 81 81 82 [SYS_DEBUG_ ENABLE_CONSOLE] = { "debug_enable_console", 0, V_ERRNO },82 [SYS_DEBUG_ACTIVATE_CONSOLE] = { "debug_activate_console", 0, V_ERRNO }, 83 83 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 1, V_ERRNO } 84 84 }; -
uspace/lib/c/generic/io/console.c
ree2fa30a rb366a6f4 76 76 bool console_kcon(void) 77 77 { 78 #if 079 78 return __SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE); 80 #endif81 82 return false;83 79 } 84 80 -
uspace/lib/c/include/ipc/console.h
ree2fa30a rb366a6f4 48 48 CONSOLE_SET_COLOR, 49 49 CONSOLE_SET_RGB_COLOR, 50 CONSOLE_CURSOR_VISIBILITY, 51 CONSOLE_KCON_ENABLE 50 CONSOLE_CURSOR_VISIBILITY 52 51 } console_request_t; 53 52 -
uspace/srv/hid/console/console.c
ree2fa30a rb366a6f4 357 357 console_serialize_end(); 358 358 359 if ( __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {359 if (console_kcon()) { 360 360 prev_console = active_console; 361 361 active_console = kernel_console; … … 711 711 console_serialize_start(); 712 712 continue; 713 case CONSOLE_KCON_ENABLE:714 change_console(kernel_console);715 break;716 713 } 717 714 async_answer_3(callid, EOK, arg1, arg2, arg3); … … 833 830 } 834 831 835 /* Disable kernel output to the console */836 __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);837 838 832 /* Initialize the screen */ 839 833 console_serialize_start();
Note:
See TracChangeset
for help on using the changeset viewer.