Changeset a71c158 in mainline for kernel/arch
- Timestamp:
- 2009-08-21T14:12:45Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0e6dce8, b50b5af2, e5792d1
- Parents:
- 90c8b8d
- Location:
- kernel/arch
- Files:
-
- 21 edited
-
amd64/src/amd64.c (modified) (2 diffs)
-
arm32/include/mach/integratorcp/integratorcp.h (modified) (1 diff)
-
arm32/include/mach/testarm/testarm.h (modified) (1 diff)
-
arm32/include/machine_func.h (modified) (4 diffs)
-
arm32/src/arm32.c (modified) (2 diffs)
-
arm32/src/mach/integratorcp/integratorcp.c (modified) (4 diffs)
-
arm32/src/mach/testarm/testarm.c (modified) (4 diffs)
-
arm32/src/machine_func.c (modified) (3 diffs)
-
ia32/include/drivers/vesa.h (modified) (1 diff)
-
ia32/src/drivers/vesa.c (modified) (5 diffs)
-
ia32/src/ia32.c (modified) (2 diffs)
-
ia64/include/drivers/ski.h (modified) (1 diff)
-
ia64/src/drivers/ski.c (modified) (6 diffs)
-
ia64/src/ia64.c (modified) (2 diffs)
-
mips32/src/mips32.c (modified) (2 diffs)
-
ppc32/src/ppc32.c (modified) (2 diffs)
-
sparc64/include/drivers/scr.h (modified) (2 diffs)
-
sparc64/include/drivers/sgcn.h (modified) (4 diffs)
-
sparc64/src/console.c (modified) (2 diffs)
-
sparc64/src/drivers/scr.c (modified) (2 diffs)
-
sparc64/src/drivers/sgcn.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/amd64.c
r90c8b8d ra71c158 151 151 i8254_init(); 152 152 153 #if (defined(CONFIG_FB) || defined(CONFIG_EGA)) 154 bool vesa = false; 155 #endif 156 153 157 #ifdef CONFIG_FB 154 if (vesa_present()) 155 vesa_init(); 156 else 157 #endif 158 vesa = vesa_init(); 159 #endif 160 158 161 #ifdef CONFIG_EGA 159 ega_init(EGA_BASE, EGA_VIDEORAM); /* video */ 160 #else 161 {} 162 if (!vesa) { 163 outdev_t *egadev = ega_init(EGA_BASE, EGA_VIDEORAM); 164 if (egadev) 165 stdout_wire(egadev); 166 } 162 167 #endif 163 168 … … 249 254 } 250 255 251 /** Acquire console back for kernel252 *253 */254 void arch_grab_console(void)255 {256 #ifdef CONFIG_FB257 if (vesa_present())258 vesa_redraw();259 else260 #endif261 #ifdef CONFIG_EGA262 ega_redraw();263 #else264 {}265 #endif266 }267 268 /** Return console to userspace269 *270 */271 void arch_release_console(void)272 {273 }274 275 256 /** Construct function pointer 276 257 * -
kernel/arch/arm32/include/mach/integratorcp/integratorcp.h
r90c8b8d ra71c158 98 98 99 99 extern void icp_init(void); 100 extern void icp_fb_init(void);101 100 extern void icp_output_init(void); 102 101 extern void icp_input_init(void); 103 extern void icp_release_console(void);104 extern void icp_grab_console(void);105 102 extern void icp_timer_irq_start(void); 106 103 extern void icp_cpu_halt(void); 107 104 extern void icp_irq_exception(int exc_no, istate_t *istate); 108 105 extern uintptr_t icp_get_memory_size(void); 109 extern uintptr_t icp_get_fb_address(void);110 extern void icp_fb_init(void);111 106 extern void icp_frame_init(void); 112 107 -
kernel/arch/arm32/include/mach/testarm/testarm.h
r90c8b8d ra71c158 68 68 69 69 extern void gxemul_init(void); 70 extern void gxemul_fb_init(void);71 70 extern void gxemul_output_init(void); 72 71 extern void gxemul_input_init(void); 73 extern void gxemul_release_console(void);74 extern void gxemul_grab_console(void);75 72 extern void gxemul_timer_irq_start(void); 76 73 extern void gxemul_cpu_halt(void); 77 74 extern void gxemul_irq_exception(int exc_no, istate_t *istate); 78 75 extern uintptr_t gxemul_get_memory_size(void); 79 extern uintptr_t gxemul_get_fb_address(void);80 extern void gxemul_fb_init(void);81 76 extern void gxemul_frame_init(void); 82 77 -
kernel/arch/arm32/include/machine_func.h
r90c8b8d ra71c158 49 49 50 50 struct arm_machine_ops { 51 void (*machine_grab_console)(void);52 void (*machine_release_console)(void);53 51 void (*machine_init)(void); 54 52 void (*machine_timer_irq_start)(void); 55 53 void (*machine_cpu_halt)(void); 56 54 uintptr_t (*machine_get_memory_size)(void); 57 void (*machine_fb_init)(void);58 55 void (*machine_irq_exception)(int, istate_t*); 59 uintptr_t (*machine_get_fb_address)(void);60 56 void (*machine_frame_init)(void); 61 57 void (*machine_output_init)(void); … … 64 60 65 61 extern struct arm_machine_ops machine_ops; 66 67 68 /** Acquire console back for kernel. */69 extern void machine_grab_console(void);70 71 /** Return console to userspace. */72 extern void machine_release_console(void);73 62 74 63 … … 91 80 extern uintptr_t machine_get_memory_size(void); 92 81 93 /** Initializes the Frame Buffer94 *95 */96 extern void machine_fb_init(void);97 98 82 99 83 /** Interrupt exception handler. … … 104 88 extern void machine_irq_exception(int exc_no, istate_t *istate); 105 89 106 107 /** Returns address of framebuffer device.108 *109 * @return Address of framebuffer device.110 */111 extern uintptr_t machine_get_fb_address(void);112 90 113 91 /* -
kernel/arch/arm32/src/arm32.c
r90c8b8d ra71c158 89 89 interrupt_init(); 90 90 91 #ifdef CONFIG_FB92 machine_fb_init();93 #else94 #ifdef CONFIG_ARM_PRN95 91 machine_output_init(); 96 #endif /* CONFIG_ARM_PRN */97 #endif /* CONFIG_FB */98 92 } 99 93 … … 182 176 } 183 177 184 /** Acquire console back for kernel. */185 void arch_grab_console(void)186 {187 machine_grab_console();188 #ifdef CONFIG_FB189 fb_redraw();190 #endif191 }192 193 /** Return console to userspace. */194 void arch_release_console(void)195 {196 machine_release_console();197 }198 199 178 /** @} 200 179 */ -
kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
r90c8b8d ra71c158 57 57 static irq_t icp_timer_irq; 58 58 struct arm_machine_ops machine_ops = { 59 MACHINE_GENFUNC,60 MACHINE_GENFUNC,61 59 icp_init, 62 60 icp_timer_irq_start, 63 61 icp_cpu_halt, 64 62 icp_get_memory_size, 65 icp_fb_init,66 63 icp_irq_exception, 67 icp_get_fb_address,68 64 icp_frame_init, 69 65 icp_output_init, … … 128 124 } 129 125 130 /** Initializes the icp frame buffer */131 void icp_fb_init(void)132 {133 fb_properties_t prop = {134 .addr = 0,135 .offset = 0,136 .x = 640,137 .y = 480,138 .scan = 2560,139 .visual = VISUAL_BGR_0_8_8_8,140 };141 prop.addr = icp_get_fb_address();142 fb_init(&prop);143 fb_parea.pbase = ICP_FB;144 fb_parea.frames = 300;145 ddi_parea_register(&fb_parea);146 }147 148 126 /** Initializes icp_hw_map. */ 149 127 void icp_init(void) … … 172 150 } 173 151 174 175 /** Acquire console back for kernel. */176 void icp_grab_console(void)177 {178 }179 180 /** Return console to userspace. */181 void icp_release_console(void)182 {183 }184 185 152 /** Starts icp Real Time Clock device, which asserts regular interrupts. 186 * 153 * 187 154 * @param frequency Interrupts frequency (0 disables RTC). 188 155 */ … … 296 263 } 297 264 298 /** Returns address of framebuffer device. 299 * 300 * @return Address of framebuffer device. 301 */ 302 uintptr_t icp_get_fb_address(void) 303 { 265 /* 266 * Integrator specific frame initialization 267 */ 268 void 269 icp_frame_init(void) 270 { 271 frame_mark_unavailable(ICP_FB_FRAME, ICP_FB_NUM_FRAME); 272 frame_mark_unavailable(0, 256); 273 } 274 275 void icp_output_init(void) 276 { 277 #ifdef CONFIG_FB 304 278 if (!vga_init) { 305 279 icp_vga_init(); 306 280 vga_init = true; 307 281 } 308 return (uintptr_t) ICP_FB; 309 } 310 311 /* 312 * Integrator specific frame initialization 313 */ 314 void 315 icp_frame_init(void) 316 { 317 frame_mark_unavailable(ICP_FB_FRAME, ICP_FB_NUM_FRAME); 318 frame_mark_unavailable(0, 256); 319 } 320 321 void icp_output_init(void) 322 { 282 283 fb_properties_t prop = { 284 .addr = ICP_FB, 285 .offset = 0, 286 .x = 640, 287 .y = 480, 288 .scan = 2560, 289 .visual = VISUAL_BGR_0_8_8_8, 290 }; 291 292 outdev_t *fbdev = fb_init(&prop); 293 if (fbdev) { 294 stdout_wire(fbdev); 295 fb_parea.pbase = ICP_FB; 296 fb_parea.frames = 300; 297 ddi_parea_register(&fb_parea); 298 } 299 #endif 323 300 } 324 301 -
kernel/arch/arm32/src/mach/testarm/testarm.c
r90c8b8d ra71c158 57 57 58 58 struct arm_machine_ops machine_ops = { 59 MACHINE_GENFUNC,60 MACHINE_GENFUNC,61 59 gxemul_init, 62 60 gxemul_timer_irq_start, 63 61 gxemul_cpu_halt, 64 62 gxemul_get_memory_size, 65 gxemul_fb_init,66 63 gxemul_irq_exception, 67 gxemul_get_fb_address,68 64 gxemul_frame_init, 69 65 gxemul_output_init, … … 78 74 } 79 75 80 void gxemul_fb_init(void) 81 { 76 void gxemul_output_init(void) 77 { 78 #ifdef CONFIG_FB 82 79 fb_properties_t prop = { 83 80 .addr = GXEMUL_FB_ADDRESS, … … 88 85 .visual = VISUAL_RGB_8_8_8, 89 86 }; 90 fb_init(&prop); 91 } 92 93 void gxemul_output_init(void) 94 { 95 dsrlnout_init((ioport8_t *) gxemul_kbd); 87 88 outdev_t *fbdev = fb_init(&prop); 89 if (fbdev) 90 stdout_wire(fbdev); 91 #endif 92 93 #ifdef CONFIG_ARM_PRN 94 outdev_t *dsrlndev = dsrlnout_init((ioport8_t *) gxemul_kbd); 95 if (dsrlndev) 96 stdout_wire(dsrlndev); 97 #endif 96 98 } 97 99 … … 233 235 } 234 236 235 uintptr_t gxemul_get_fb_address()236 {237 return ((uintptr_t)GXEMUL_FB_ADDRESS);238 }239 240 241 237 /** @} 242 238 */ -
kernel/arch/arm32/src/machine_func.c
r90c8b8d ra71c158 41 41 42 42 43 /** Acquire console back for kernel. */44 void machine_grab_console(void)45 {46 (machine_ops.machine_grab_console)();47 }48 49 /** Return console to userspace. */50 void machine_release_console(void)51 {52 (machine_ops.machine_release_console)();53 }54 55 56 43 /** Maps HW devices to the kernel address space using #hw_map. */ 57 44 void machine_init(void) … … 84 71 } 85 72 86 /** Initializes the Frame Buffer87 *88 */89 void machine_fb_init(void)90 {91 (machine_ops.machine_fb_init)();92 }93 94 95 73 /** Interrupt exception handler. 96 74 * … … 103 81 } 104 82 105 106 /** Returns address of framebuffer device.107 *108 * @return Address of framebuffer device.109 */110 uintptr_t machine_get_fb_address(void)111 {112 return (machine_ops.machine_get_fb_address)();113 }114 83 115 84 /* -
kernel/arch/ia32/include/drivers/vesa.h
r90c8b8d ra71c158 36 36 #define KERN_ia32_VESA_H_ 37 37 38 extern int vesa_present(void); 39 extern void vesa_redraw(void); 40 extern voidvesa_init(void);38 #include <arch/types.h> 39 40 extern bool vesa_init(void); 41 41 42 42 #endif -
kernel/arch/ia32/src/drivers/vesa.c
r90c8b8d ra71c158 27 27 */ 28 28 29 /** @addtogroup ia32 29 /** @addtogroup ia32 30 30 * @{ 31 31 */ … … 40 40 #include <genarch/fb/visuals.h> 41 41 #include <arch/drivers/vesa.h> 42 #include <console/chardev.h> 43 #include <console/console.h> 42 44 #include <putchar.h> 43 45 #include <mm/page.h> … … 66 68 uint8_t vesa_blue_pos; 67 69 68 int vesa_present(void)70 bool vesa_init(void) 69 71 { 70 if ((vesa_width != 0xffff) && (vesa_height != 0xffff))71 return true;72 if ((vesa_width == 0xffff) || (vesa_height == 0xffff)) 73 return false; 72 74 73 return false; 74 } 75 76 void vesa_init(void) 77 { 78 unsigned int visual; 75 visual_t visual; 79 76 80 77 switch (vesa_bpp) { … … 97 94 break; 98 95 default: 99 panic("Unsupported bits per pixel."); 96 LOG("Unsupported bits per pixel."); 97 return false; 100 98 } 101 99 … … 108 106 .visual = visual, 109 107 }; 110 fb_init(&vesa_props); 111 } 112 113 void vesa_redraw(void) 114 { 115 fb_redraw(); 108 109 outdev_t *fbdev = fb_init(&vesa_props); 110 if (!fbdev) 111 return false; 112 113 stdout_wire(fbdev); 114 return true; 116 115 } 117 116 -
kernel/arch/ia32/src/ia32.c
r90c8b8d ra71c158 112 112 i8254_init(); 113 113 114 #if (defined(CONFIG_FB) || defined(CONFIG_EGA)) 115 bool vesa = false; 116 #endif 117 114 118 #ifdef CONFIG_FB 115 if (vesa_present()) 116 vesa_init(); 117 else 118 #endif 119 vesa = vesa_init(); 120 #endif 121 119 122 #ifdef CONFIG_EGA 120 ega_init(EGA_BASE, EGA_VIDEORAM); /* video */ 121 #else 122 {} 123 if (!vesa) { 124 outdev_t *egadev = ega_init(EGA_BASE, EGA_VIDEORAM); 125 if (egadev) 126 stdout_wire(egadev); 127 } 123 128 #endif 124 129 … … 201 206 THREAD->arch.tls = addr; 202 207 set_tls_desc(addr); 203 208 204 209 return 0; 205 }206 207 /** Acquire console back for kernel208 *209 */210 void arch_grab_console(void)211 {212 #ifdef CONFIG_FB213 if (vesa_present())214 vesa_redraw();215 else216 #endif217 #ifdef CONFIG_EGA218 ega_redraw();219 #else220 {}221 #endif222 }223 224 /** Return console to userspace225 *226 */227 void arch_release_console(void)228 {229 210 } 230 211 -
kernel/arch/ia64/include/drivers/ski.h
r90c8b8d ra71c158 44 44 } ski_instance_t; 45 45 46 extern voidskiout_init(void);46 extern outdev_t *skiout_init(void); 47 47 48 48 extern ski_instance_t *skiin_init(void); 49 49 extern void skiin_wire(ski_instance_t *, indev_t *); 50 extern void ski_kbd_grab(void);51 extern void ski_kbd_release(void);52 50 53 51 #endif -
kernel/arch/ia64/src/drivers/ski.c
r90c8b8d ra71c158 47 47 enum { 48 48 /** Interval between polling in microseconds */ 49 POLL_INTERVAL = 10000, /* 0.01 s */50 49 POLL_INTERVAL = 10000, /* 0.01 s */ 50 51 51 /** Max. number of characters to pull out at a time */ 52 POLL_LIMIT =30,53 54 SKI_INIT_CONSOLE = 20,55 SKI_GETCHAR = 21,56 SKI_PUTCHAR = 3152 POLL_LIMIT = 30, 53 54 SKI_INIT_CONSOLE = 20, 55 SKI_GETCHAR = 21, 56 SKI_PUTCHAR = 31 57 57 }; 58 58 59 59 static void ski_putchar(outdev_t *, const wchar_t, bool); 60 60 61 static outdev_operations_t skiout_ops = { 62 .write = ski_putchar 61 static outdev_operations_t skidev_ops = { 62 .write = ski_putchar, 63 .redraw = NULL 63 64 }; 64 65 65 static outdev_t skiout; /**< Ski output device. */ 66 static bool initialized = false; 67 static bool kbd_disabled = false; 66 static ski_instance_t *instance = NULL; 67 68 /** Ask debug console if a key was pressed. 69 * 70 * Use SSC (Simulator System Call) to 71 * get character from debug console. 72 * 73 * This call is non-blocking. 74 * 75 * @return ASCII code of pressed key or 0 if no key pressed. 76 * 77 */ 78 static wchar_t ski_getchar(void) 79 { 80 uint64_t ch; 81 82 asm volatile ( 83 "mov r15 = %1\n" 84 "break 0x80000;;\n" /* modifies r8 */ 85 "mov %0 = r8;;\n" 86 87 : "=r" (ch) 88 : "i" (SKI_GETCHAR) 89 : "r15", "r8" 90 ); 91 92 return (wchar_t) ch; 93 } 94 95 /** Ask keyboard if a key was pressed. 96 * 97 * If so, it will repeat and pull up to POLL_LIMIT characters. 98 */ 99 static void poll_keyboard(ski_instance_t *instance) 100 { 101 if (silent) 102 return; 103 104 int count = POLL_LIMIT; 105 106 while (count > 0) { 107 wchar_t ch = ski_getchar(); 108 109 if (ch == '\0') 110 break; 111 112 indev_push_character(instance->srlnin, ch); 113 --count; 114 } 115 } 116 117 /** Kernel thread for polling keyboard. */ 118 static void kskipoll(void *arg) 119 { 120 ski_instance_t *instance = (ski_instance_t *) arg; 121 122 while (true) { 123 if (!silent) 124 poll_keyboard(instance); 125 126 thread_usleep(POLL_INTERVAL); 127 } 128 } 68 129 69 130 /** Initialize debug console … … 75 136 static void ski_init(void) 76 137 { 77 if (in itialized)138 if (instance) 78 139 return; 79 140 … … 86 147 ); 87 148 88 initialized = true; 149 instance = malloc(sizeof(ski_instance_t), FRAME_ATOMIC); 150 151 if (instance) { 152 instance->thread = thread_create(kskipoll, instance, TASK, 0, 153 "kskipoll", true); 154 155 if (!instance->thread) { 156 free(instance); 157 instance = NULL; 158 return; 159 } 160 161 instance->srlnin = NULL; 162 } 89 163 } 90 164 … … 124 198 } 125 199 126 voidskiout_init(void)200 outdev_t *skiout_init(void) 127 201 { 128 202 ski_init(); 129 130 outdev_initialize("skiout", &skiout, &skiout_ops); 131 stdout_wire(&skiout); 132 133 sysinfo_set_item_val("fb", NULL, false); 134 } 135 136 /** Ask debug console if a key was pressed. 137 * 138 * Use SSC (Simulator System Call) to 139 * get character from debug console. 140 * 141 * This call is non-blocking. 142 * 143 * @return ASCII code of pressed key or 0 if no key pressed. 144 * 145 */ 146 static wchar_t ski_getchar(void) 147 { 148 uint64_t ch; 149 150 asm volatile ( 151 "mov r15 = %1\n" 152 "break 0x80000;;\n" /* modifies r8 */ 153 "mov %0 = r8;;\n" 154 155 : "=r" (ch) 156 : "i" (SKI_GETCHAR) 157 : "r15", "r8" 158 ); 159 160 return (wchar_t) ch; 161 } 162 163 /** Ask keyboard if a key was pressed. 164 * 165 * If so, it will repeat and pull up to POLL_LIMIT characters. 166 */ 167 static void poll_keyboard(ski_instance_t *instance) 168 { 169 wchar_t ch; 170 int count; 171 172 if (kbd_disabled) 173 return; 174 175 count = POLL_LIMIT; 176 177 while (count > 0) { 178 ch = ski_getchar(); 179 180 if (ch == '\0') 181 break; 182 183 indev_push_character(instance->srlnin, ch); 184 --count; 185 } 186 } 187 188 /** Kernel thread for polling keyboard. */ 189 static void kskipoll(void *arg) 190 { 191 ski_instance_t *instance = (ski_instance_t *) arg; 192 193 while (true) { 194 if (!silent) 195 poll_keyboard(instance); 196 197 thread_usleep(POLL_INTERVAL); 198 } 203 if (!instance) 204 return NULL; 205 206 outdev_t *skidev = malloc(sizeof(outdev_t), FRAME_ATOMIC); 207 if (!skidev) 208 return NULL; 209 210 outdev_initialize("skidev", skidev, &skidev_ops); 211 skidev->data = instance; 212 213 if (!fb_exported) { 214 /* 215 * This is the necessary evil until the userspace driver is entirely 216 * self-sufficient. 217 */ 218 sysinfo_set_item_val("fb", NULL, false); 219 220 fb_exported = true; 221 } 222 223 return skidev; 199 224 } 200 225 … … 202 227 { 203 228 ski_init(); 204 205 ski_instance_t *instance =206 malloc(sizeof(ski_instance_t), FRAME_ATOMIC);207 208 if (instance) {209 instance->thread = thread_create(kskipoll, instance, TASK, 0,210 "kskipoll", true);211 212 if (!instance->thread) {213 free(instance);214 return NULL;215 }216 217 instance->srlnin = NULL;218 }219 220 229 return instance; 221 230 } … … 233 242 } 234 243 235 void ski_kbd_grab(void)236 {237 kbd_disabled = false;238 }239 240 void ski_kbd_release(void)241 {242 kbd_disabled = true;243 }244 245 244 /** @} 246 245 */ -
kernel/arch/ia64/src/ia64.c
r90c8b8d ra71c158 160 160 } 161 161 162 skiout_init(); 162 outdev_t *skidev = skiout_init(); 163 if (skidev) 164 stdout_wire(skidev); 163 165 #endif 164 166 165 167 #ifdef CONFIG_EGA 166 ega_init(EGA_BASE, EGA_VIDEORAM); 168 outdev_t *egadev = ega_init(EGA_BASE, EGA_VIDEORAM); 169 if (egadev) 170 stdout_wire(egadev); 167 171 #endif 168 172 … … 249 253 unative_t sys_tls_set(unative_t addr) 250 254 { 251 return 0; 252 } 253 254 /** Acquire console back for kernel 255 * 256 */ 257 void arch_grab_console(void) 258 { 259 #ifdef MACHINE_ski 260 ski_kbd_grab(); 261 #endif 262 } 263 264 /** Return console to userspace 265 * 266 */ 267 void arch_release_console(void) 268 { 269 #ifdef MACHINE_ski 270 ski_kbd_release(); 271 #endif 255 return 0; 272 256 } 273 257 -
kernel/arch/mips32/src/mips32.c
r90c8b8d ra71c158 144 144 .visual = VISUAL_RGB_8_8_8, 145 145 }; 146 fb_init(&gxemul_prop); 147 #else 146 147 outdev_t *fbdev = fb_init(&gxemul_prop); 148 if (fbdev) 149 stdout_wire(fbdev); 150 #endif 151 148 152 #ifdef CONFIG_MIPS_PRN 149 dsrlnout_init((ioport8_t *) MSIM_KBD_ADDRESS); 150 #endif /* CONFIG_MIPS_PRN */ 151 #endif /* CONFIG_FB */ 153 outdev_t *dsrlndev = dsrlnout_init((ioport8_t *) MSIM_KBD_ADDRESS); 154 if (dsrlndev) 155 stdout_wire(dsrlndev); 156 #endif 152 157 } 153 158 … … 252 257 } 253 258 254 void arch_grab_console(void)255 {256 #ifdef CONFIG_FB257 fb_redraw();258 #endif259 }260 261 /** Return console to userspace262 *263 */264 void arch_release_console(void)265 {266 }267 268 259 /** @} 269 260 */ -
kernel/arch/ppc32/src/ppc32.c
r90c8b8d ra71c158 143 143 .visual = visual, 144 144 }; 145 fb_init(&fb_prop); 146 } 147 148 /* Consider only a single device for now */ 149 return false; 145 146 outdev_t *fbdev = fb_init(&fb_prop); 147 if (fbdev) 148 stdout_wire(fbdev); 149 } 150 151 return true; 150 152 } 151 153 … … 235 237 } 236 238 237 /** Acquire console back for kernel238 *239 */240 void arch_grab_console(void)241 {242 #ifdef CONFIG_FB243 fb_redraw();244 #endif245 }246 247 /** Return console to userspace248 *249 */250 void arch_release_console(void)251 {252 }253 254 239 /** Construct function pointer 255 240 * -
kernel/arch/sparc64/include/drivers/scr.h
r90c8b8d ra71c158 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 50 50 51 51 extern void scr_init(ofw_tree_node_t *node); 52 extern void scr_redraw(void);53 52 54 53 #endif -
kernel/arch/sparc64/include/drivers/sgcn.h
r90c8b8d ra71c158 39 39 #include <console/chardev.h> 40 40 #include <proc/thread.h> 41 #include <synch/spinlock.h> 41 42 42 43 /* number of bytes in the TOC magic, including the NULL-terminator */ 43 #define TOC_MAGIC_BYTES 844 #define TOC_MAGIC_BYTES 8 44 45 45 46 /* number of bytes in the TOC key, including the NULL-terminator */ 46 #define TOC_KEY_SIZE 847 #define TOC_KEY_SIZE 8 47 48 48 49 /* maximum number of entries in the SRAM table of contents */ 49 #define MAX_TOC_ENTRIES 3250 #define MAX_TOC_ENTRIES 32 50 51 51 52 /* number of bytes in the SGCN buffer magic, including the NULL-terminator */ 52 #define SGCN_MAGIC_BYTES 453 #define SGCN_MAGIC_BYTES 4 53 54 54 55 /** 55 56 * Entry in the SRAM table of contents. Describes one segment of the SRAM 56 57 * which serves a particular purpose (e.g. OBP serial console, Solaris serial 57 * console, Solaris mailbox,...). 58 * console, Solaris mailbox,...). 58 59 */ 59 60 typedef struct { … … 84 85 /** 85 86 * SGCN buffer header. It is placed at the very beginning of the SGCN 86 * buffer. 87 * buffer. 87 88 */ 88 89 typedef struct { … … 104 105 /** offset within the SGCN buffer of the input buffer write pointer */ 105 106 uint32_t in_wrptr; 106 107 107 108 /** offset within the SGCN buffer of the output buffer start */ 108 109 uint32_t out_begin; … … 119 120 120 121 typedef struct { 122 /** Starting address of SRAM */ 123 uintptr_t sram_begin; 124 125 /** Starting address of the SGCN buffer */ 126 uintptr_t buffer_begin; 127 128 /** 129 * Ensure that writing to the buffer and consequent 130 * update of the write pointer are one atomic operation. 131 */ 132 SPINLOCK_DECLARE(output_lock); 133 134 /** 135 * Prevent the input buffer read/write pointers from 136 * getting to inconsistent state. 137 */ 138 SPINLOCK_DECLARE(input_lock); 139 121 140 thread_t *thread; 122 141 indev_t *srlnin; 123 142 } sgcn_instance_t; 124 143 125 extern void sgcn_grab(void);126 extern void sgcn_release(void);127 144 extern sgcn_instance_t *sgcnin_init(void); 128 145 extern void sgcnin_wire(sgcn_instance_t *, indev_t *); 129 extern voidsgcnout_init(void);146 extern outdev_t *sgcnout_init(void); 130 147 131 148 #endif -
kernel/arch/sparc64/src/console.c
r90c8b8d ra71c158 103 103 } 104 104 #endif 105 105 106 #ifdef CONFIG_SGCN_PRN 106 sgcnout_init(); 107 outdev_t *sgcndev = sgcnout_init(); 108 if (sgcndev) 109 stdout_wire(sgcndev); 107 110 #endif 108 111 } … … 131 134 } 132 135 133 134 /** Acquire console back for kernel135 *136 */137 void arch_grab_console(void)138 {139 #ifdef CONFIG_FB140 scr_redraw();141 #endif142 143 #ifdef CONFIG_SGCN_KBD144 sgcn_grab();145 #endif146 }147 148 /** Return console to userspace149 *150 */151 void arch_release_console(void)152 {153 #ifdef CONFIG_SGCN_KBD154 sgcn_release();155 #endif156 }157 158 136 /** @} 159 137 */ -
kernel/arch/sparc64/src/drivers/scr.c
r90c8b8d ra71c158 40 40 #include <genarch/fb/fb.h> 41 41 #include <genarch/fb/visuals.h> 42 #include <console/chardev.h> 43 #include <console/console.h> 42 44 #include <arch/types.h> 43 45 #include <string.h> … … 238 240 .visual = visual, 239 241 }; 240 fb_init(&props); 242 243 outdev_t *fbdev = fb_init(&props); 244 if (fbdev) 245 stdout_wire(fbdev); 241 246 } 242 247 243 void scr_redraw(void)244 {245 fb_redraw();246 }247 248 248 /** @} 249 249 */ -
kernel/arch/sparc64/src/drivers/sgcn.c
r90c8b8d ra71c158 49 49 #include <synch/spinlock.h> 50 50 51 #define POLL_INTERVAL 1000051 #define POLL_INTERVAL 10000 52 52 53 53 /* … … 57 57 * not sure whether this value is valid generally. 58 58 */ 59 #define SBBC_START 0x6300000000059 #define SBBC_START 0x63000000000 60 60 61 61 /* offset of SRAM within the SBBC memory */ 62 #define SBBC_SRAM_OFFSET 0x90000062 #define SBBC_SRAM_OFFSET 0x900000 63 63 64 64 /* size (in bytes) of the physical memory area which will be mapped */ 65 #define MAPPED_AREA_SIZE (128 * 1024)65 #define MAPPED_AREA_SIZE (128 * 1024) 66 66 67 67 /* magic string contained at the beginning of SRAM */ 68 #define SRAM_TOC_MAGIC "TOCSRAM"68 #define SRAM_TOC_MAGIC "TOCSRAM" 69 69 70 70 /* … … 78 78 * Therefore HelenOS needs to make no such arrangements any more. 79 79 */ 80 #define CONSOLE_KEY "OBPCONS"80 #define CONSOLE_KEY "OBPCONS" 81 81 82 82 /* magic string contained at the beginning of the console buffer */ 83 #define SGCN_BUFFER_MAGIC "CON"83 #define SGCN_BUFFER_MAGIC "CON" 84 84 85 85 /* … … 87 87 * offset from the SRAM beginning. 88 88 */ 89 #define SRAM(type, offset) ((type *) (sram_begin + (offset)))89 #define SRAM(type, offset) ((type *) (instance->sram_begin + (offset))) 90 90 91 91 /* Returns a pointer to the SRAM table of contents. */ 92 #define SRAM_TOC (SRAM(iosram_toc_t, 0))92 #define SRAM_TOC (SRAM(iosram_toc_t, 0)) 93 93 94 94 /* … … 97 97 */ 98 98 #define SGCN_BUFFER(type, offset) \ 99 ((type *) ( sgcn_buffer_begin + (offset)))99 ((type *) (instance->buffer_begin + (offset))) 100 100 101 101 /** Returns a pointer to the console buffer header. */ 102 #define SGCN_BUFFER_HEADER (SGCN_BUFFER(sgcn_buffer_header_t, 0)) 103 104 /** starting address of SRAM, will be set by the init_sram_begin function */ 105 static uintptr_t sram_begin; 106 107 /** 108 * starting address of the SGCN buffer, will be set by the 109 * init_sgcn_buffer_begin function 110 */ 111 static uintptr_t sgcn_buffer_begin; 112 113 /* true iff the kernel driver should ignore pressed keys */ 114 static bool kbd_disabled; 115 116 /* 117 * Ensures that writing to the buffer and consequent update of the write pointer 118 * are together one atomic operation. 119 */ 120 SPINLOCK_INITIALIZE(sgcn_output_lock); 121 122 /* 123 * Prevents the input buffer read/write pointers from getting to inconsistent 124 * state. 125 */ 126 SPINLOCK_INITIALIZE(sgcn_input_lock); 127 128 129 /* functions referenced from definitions of I/O operations structures */ 102 #define SGCN_BUFFER_HEADER (SGCN_BUFFER(sgcn_buffer_header_t, 0)) 103 130 104 static void sgcn_putchar(outdev_t *, const wchar_t, bool); 131 105 132 /** SGCN output device operations */ 133 static outdev_operations_t sgcnout_ops = { 134 . write = sgcn_putchar106 static outdev_operations_t sgcndev_ops = { 107 .write = sgcn_putchar, 108 .redraw = NULL 135 109 }; 136 110 137 static outdev_t sgcnout; /**< SGCN output device. */111 static sgcn_instance_t *instance = NULL; 138 112 139 113 /** … … 158 132 static void init_sram_begin(void) 159 133 { 160 ofw_tree_node_t *chosen; 161 ofw_tree_property_t *iosram_toc; 162 uintptr_t sram_begin_physical; 163 164 chosen = ofw_tree_lookup("/chosen"); 134 ASSERT(instance) 135 136 ofw_tree_node_t *chosen = ofw_tree_lookup("/chosen"); 165 137 if (!chosen) 166 138 panic("Cannot find '/chosen'."); 167 168 iosram_toc = ofw_tree_getprop(chosen, "iosram-toc"); 139 140 ofw_tree_property_t *iosram_toc = 141 ofw_tree_getprop(chosen, "iosram-toc"); 169 142 if (!iosram_toc) 170 143 panic("Cannot find property 'iosram-toc'."); 171 144 if (!iosram_toc->value) 172 145 panic("Cannot find SRAM TOC."); 173 174 sram_begin_physical = SBBC_START + SBBC_SRAM_OFFSET146 147 uintptr_t sram_begin_physical = SBBC_START + SBBC_SRAM_OFFSET 175 148 + *((uint32_t *) iosram_toc->value); 176 sram_begin = hw_map(sram_begin_physical, MAPPED_AREA_SIZE);149 instance->sram_begin = hw_map(sram_begin_physical, MAPPED_AREA_SIZE); 177 150 178 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. 158 */ 159 static void sgcn_poll(sgcn_instance_t *instance) 160 { 161 uint32_t begin = SGCN_BUFFER_HEADER->in_begin; 162 uint32_t end = SGCN_BUFFER_HEADER->in_end; 163 uint32_t size = end - begin; 164 165 if (silent) 166 return; 167 168 spinlock_lock(&instance->input_lock); 169 170 /* we need pointers to volatile variables */ 171 volatile char *buf_ptr = (volatile char *) 172 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); 173 volatile uint32_t *in_wrptr_ptr = &(SGCN_BUFFER_HEADER->in_wrptr); 174 volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr); 175 176 while (*in_rdptr_ptr != *in_wrptr_ptr) { 177 buf_ptr = (volatile char *) 178 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); 179 char c = *buf_ptr; 180 *in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin; 181 182 indev_push_character(instance->srlnin, c); 183 } 184 185 spinlock_unlock(&instance->input_lock); 186 } 187 188 /** 189 * Polling thread function. 190 */ 191 static void ksgcnpoll(void *instance) { 192 while (true) { 193 if (!silent) 194 sgcn_poll(instance); 195 196 thread_usleep(POLL_INTERVAL); 197 } 179 198 } 180 199 … … 190 209 * under the sram.buffer.offset sysinfo key. 191 210 */ 192 static void sgcn_buffer_begin_init(void) 193 { 194 static bool initialized; 195 196 if (initialized) 211 static void sgcn_init(void) 212 { 213 if (instance) 197 214 return; 198 199 init_sram_begin(); 200 201 ASSERT(str_cmp(SRAM_TOC->magic, SRAM_TOC_MAGIC) == 0); 202 203 /* lookup TOC entry with the correct key */ 204 uint32_t i; 205 for (i = 0; i < MAX_TOC_ENTRIES; i++) { 206 if (str_cmp(SRAM_TOC->keys[i].key, CONSOLE_KEY) == 0) 207 break; 208 } 209 ASSERT(i < MAX_TOC_ENTRIES); 210 211 sgcn_buffer_begin = sram_begin + SRAM_TOC->keys[i].offset; 212 213 sysinfo_set_item_val("sram.buffer.offset", NULL, 214 SRAM_TOC->keys[i].offset); 215 216 initialized = true; 215 216 instance = malloc(sizeof(sgcn_instance_t), FRAME_ATOMIC); 217 218 if (instance) { 219 instance->thread = thread_create(ksgcnpoll, instance, TASK, 0, 220 "ksgcnpoll", true); 221 222 if (!instance->thread) { 223 free(instance); 224 instance = NULL; 225 return; 226 } 227 228 init_sram_begin(); 229 230 ASSERT(str_cmp(SRAM_TOC->magic, SRAM_TOC_MAGIC) == 0); 231 232 /* Lookup TOC entry with the correct key */ 233 uint32_t i; 234 for (i = 0; i < MAX_TOC_ENTRIES; i++) { 235 if (str_cmp(SRAM_TOC->keys[i].key, CONSOLE_KEY) == 0) 236 break; 237 } 238 ASSERT(i < MAX_TOC_ENTRIES); 239 240 instance->buffer_begin = 241 instance->sram_begin + SRAM_TOC->keys[i].offset; 242 243 sysinfo_set_item_val("sram.buffer.offset", NULL, 244 SRAM_TOC->keys[i].offset); 245 246 instance->srlnin = NULL; 247 } 217 248 } 218 249 … … 228 259 uint32_t size = end - begin; 229 260 230 /* we need pointers to volatile variables */261 /* We need pointers to volatile variables */ 231 262 volatile char *buf_ptr = (volatile char *) 232 263 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->out_wrptr); 233 264 volatile uint32_t *out_wrptr_ptr = &(SGCN_BUFFER_HEADER->out_wrptr); 234 265 volatile uint32_t *out_rdptr_ptr = &(SGCN_BUFFER_HEADER->out_rdptr); 235 266 236 267 /* 237 268 * Write the character and increment the write pointer modulo the … … 249 280 */ 250 281 uint32_t new_wrptr = (((*out_wrptr_ptr) - begin + 1) % size) + begin; 251 while (*out_rdptr_ptr == new_wrptr) 252 ;282 while (*out_rdptr_ptr == new_wrptr); 283 253 284 *buf_ptr = c; 254 285 *out_wrptr_ptr = new_wrptr; … … 259 290 * character is converted to CRLF. 260 291 */ 261 static void sgcn_putchar(outdev_t * od, const wchar_t ch, bool silent)292 static void sgcn_putchar(outdev_t *dev, const wchar_t ch, bool silent) 262 293 { 263 294 if (!silent) { 264 spinlock_lock(& sgcn_output_lock);295 spinlock_lock(&instance->output_lock); 265 296 266 297 if (ascii_check(ch)) { … … 271 302 sgcn_do_putchar(U_SPECIAL); 272 303 273 spinlock_unlock(&sgcn_output_lock); 274 } 275 } 276 277 /** 278 * Grabs the input for kernel. 279 */ 280 void sgcn_grab(void) 281 { 282 kbd_disabled = false; 283 } 284 285 /** 286 * Releases the input so that userspace can use it. 287 */ 288 void sgcn_release(void) 289 { 290 kbd_disabled = true; 291 } 292 293 /** 294 * Function regularly called by the keyboard polling thread. Finds out whether 295 * there are some unread characters in the input queue. If so, it picks them up 296 * and sends them to the upper layers of HelenOS. 297 */ 298 static void sgcn_poll(sgcn_instance_t *instance) 299 { 300 uint32_t begin = SGCN_BUFFER_HEADER->in_begin; 301 uint32_t end = SGCN_BUFFER_HEADER->in_end; 302 uint32_t size = end - begin; 303 304 if (kbd_disabled) 305 return; 306 307 spinlock_lock(&sgcn_input_lock); 308 309 /* we need pointers to volatile variables */ 310 volatile char *buf_ptr = (volatile char *) 311 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); 312 volatile uint32_t *in_wrptr_ptr = &(SGCN_BUFFER_HEADER->in_wrptr); 313 volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr); 314 315 while (*in_rdptr_ptr != *in_wrptr_ptr) { 316 buf_ptr = (volatile char *) 317 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); 318 char c = *buf_ptr; 319 *in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin; 320 321 indev_push_character(instance->srlnin, c); 322 } 323 324 spinlock_unlock(&sgcn_input_lock); 325 } 326 327 /** 328 * Polling thread function. 329 */ 330 static void ksgcnpoll(void *instance) { 331 while (1) { 332 if (!silent) 333 sgcn_poll(instance); 334 thread_usleep(POLL_INTERVAL); 304 spinlock_unlock(&instance->output_lock); 335 305 } 336 306 } … … 341 311 sgcn_instance_t *sgcnin_init(void) 342 312 { 343 sgcn_buffer_begin_init(); 344 345 sgcn_instance_t *instance = 346 malloc(sizeof(sgcn_instance_t), FRAME_ATOMIC); 347 348 if (instance) { 349 instance->srlnin = NULL; 350 instance->thread = thread_create(ksgcnpoll, instance, TASK, 0, 351 "ksgcnpoll", true); 352 353 if (!instance->thread) { 354 free(instance); 355 return NULL; 356 } 357 } 358 313 sgcn_init(); 359 314 return instance; 360 315 } … … 364 319 ASSERT(instance); 365 320 ASSERT(srlnin); 366 321 367 322 instance->srlnin = srlnin; 368 323 thread_ready(instance->thread); 369 324 370 325 sysinfo_set_item_val("kbd", NULL, true); 371 326 } … … 374 329 * A public function which initializes output to the Serengeti console. 375 330 */ 376 void sgcnout_init(void) 377 { 378 sgcn_buffer_begin_init(); 379 380 sysinfo_set_item_val("fb.kind", NULL, 4); 381 382 outdev_initialize("sgcnout", &sgcnout, &sgcnout_ops); 383 stdout_wire(&sgcnout); 331 outdev_t *sgcnout_init(void) 332 { 333 sgcn_init(); 334 if (!instance) 335 return NULL; 336 337 outdev_t *sgcndev = malloc(sizeof(outdev_t), FRAME_ATOMIC); 338 if (!sgcndev) 339 return NULL; 340 341 outdev_initialize("sgcndev", sgcndev, &sgcndev_ops); 342 sgcndev->data = instance; 343 344 if (!fb_exported) { 345 /* 346 * This is the necessary evil until the userspace driver is entirely 347 * self-sufficient. 348 */ 349 sysinfo_set_item_val("fb.kind", NULL, 4); 350 351 fb_exported = true; 352 } 353 354 return sgcndev; 384 355 } 385 356
Note:
See TracChangeset
for help on using the changeset viewer.
