Changeset c2417bc in mainline for kernel/arch
- Timestamp:
- 2009-04-21T12:46:26Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f2d2c7ba
- Parents:
- 44b7783
- Location:
- kernel/arch
- Files:
-
- 4 deleted
- 20 edited
- 2 moved
-
amd64/src/amd64.c (modified) (1 diff)
-
arm32/Makefile.inc (modified) (1 diff)
-
arm32/include/console.h (deleted)
-
arm32/src/arm32.c (modified) (4 diffs)
-
ia32/src/ia32.c (modified) (2 diffs)
-
ia64/Makefile.inc (modified) (1 diff)
-
ia64/include/arch.h (modified) (2 diffs)
-
ia64/include/drivers/ski.h (moved) (moved from kernel/arch/ia64/include/ski/ski.h ) (2 diffs)
-
ia64/src/drivers/ski.c (moved) (moved from kernel/arch/ia64/src/ski/ski.c ) (7 diffs)
-
ia64/src/ia64.c (modified) (6 diffs)
-
ia64/src/smp/smp.c (modified) (1 diff)
-
mips32/Makefile.inc (modified) (1 diff)
-
mips32/include/console.h (deleted)
-
mips32/src/console.c (deleted)
-
mips32/src/mips32.c (modified) (4 diffs)
-
ppc32/Makefile.inc (modified) (1 diff)
-
ppc32/include/drivers/pic.h (modified) (3 diffs)
-
ppc32/src/drivers/cuda.c (deleted)
-
ppc32/src/drivers/pic.c (modified) (4 diffs)
-
ppc32/src/dummy.s (modified) (2 diffs)
-
ppc32/src/interrupt.c (modified) (3 diffs)
-
ppc32/src/ppc32.c (modified) (4 diffs)
-
sparc64/include/drivers/kbd.h (modified) (2 diffs)
-
sparc64/src/console.c (modified) (3 diffs)
-
sparc64/src/drivers/kbd.c (modified) (2 diffs)
-
sparc64/src/drivers/sgcn.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/amd64.c
r44b7783 rc2417bc 198 198 * module and connect it to i8042. Enable keyboard interrupts. 199 199 */ 200 indev_t *kbrdin = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); 201 if (kbrdin) { 202 kbrd_init(kbrdin); 203 trap_virtual_enable_irqs(1 << IRQ_KBD); 200 i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); 201 if (i8042_instance) { 202 kbrd_instance_t *kbrd_instance = kbrd_init(); 203 if (kbrd_instance) { 204 indev_t *sink = stdin_wire(); 205 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 206 i8042_wire(i8042_instance, kbrd); 207 trap_virtual_enable_irqs(1 << IRQ_KBD); 208 } 204 209 } 205 210 -
kernel/arch/arm32/Makefile.inc
r44b7783 rc2417bc 52 52 arch/$(KARCH)/src/ddi/ddi.c \ 53 53 arch/$(KARCH)/src/interrupt.c \ 54 arch/$(KARCH)/src/console.c \55 54 arch/$(KARCH)/src/exception.c \ 56 55 arch/$(KARCH)/src/userspace.c \ -
kernel/arch/arm32/src/arm32.c
r44b7783 rc2417bc 36 36 #include <arch.h> 37 37 #include <config.h> 38 #include <arch/console.h>39 38 #include <genarch/fb/fb.h> 40 39 #include <genarch/fb/visuals.h> … … 43 42 #include <genarch/srln/srln.h> 44 43 #include <sysinfo/sysinfo.h> 44 #include <console/console.h> 45 45 #include <ddi/irq.h> 46 46 #include <arch/drivers/gxemul.h> … … 130 130 /* 131 131 * Initialize the GXemul keyboard port. Then initialize the serial line 132 * module and connect it to the GXemul keyboard. Enable keyboard interrupts.132 * module and connect it to the GXemul keyboard. 133 133 */ 134 indev_t *kbrdin = dsrlnin_init((dsrlnin_t *) gxemul_kbd, GXEMUL_KBD_IRQ); 135 if (kbrdin) 136 srln_init(kbrdin); 134 dsrlnin_instance_t *dsrlnin_instance 135 = dsrlnin_init((dsrlnin_t *) gxemul_kbd, GXEMUL_KBD_IRQ); 136 if (dsrlnin_instance) { 137 srln_instance_t *srln_instance = srln_init(); 138 if (srln_instance) { 139 indev_t *sink = stdin_wire(); 140 indev_t *srln = srln_wire(srln_instance, sink); 141 dsrlnin_wire(dsrlnin_instance, srln); 142 } 143 } 137 144 138 145 /* … … 202 209 } 203 210 211 /** Acquire console back for kernel. */ 212 void arch_grab_console(void) 213 { 214 #ifdef CONFIG_FB 215 fb_redraw(); 216 #endif 217 } 218 219 /** Return console to userspace. */ 220 void arch_release_console(void) 221 { 222 } 223 204 224 /** @} 205 225 */ -
kernel/arch/ia32/src/ia32.c
r44b7783 rc2417bc 81 81 { 82 82 /* Parse multiboot information obtained from the bootloader. */ 83 multiboot_info_parse(signature, mi); 83 multiboot_info_parse(signature, mi); 84 84 85 85 #ifdef CONFIG_SMP … … 156 156 * module and connect it to i8042. Enable keyboard interrupts. 157 157 */ 158 indev_t *kbrdin = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); 159 if (kbrdin) { 160 kbrd_init(kbrdin); 161 trap_virtual_enable_irqs(1 << IRQ_KBD); 158 i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); 159 if (i8042_instance) { 160 kbrd_instance_t *kbrd_instance = kbrd_init(); 161 if (kbrd_instance) { 162 indev_t *sink = stdin_wire(); 163 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 164 i8042_wire(i8042_instance, kbrd); 165 trap_virtual_enable_irqs(1 << IRQ_KBD); 166 } 162 167 } 163 168 -
kernel/arch/ia64/Makefile.inc
r44b7783 rc2417bc 65 65 66 66 ifeq ($(MACHINE),ski) 67 ARCH_SOURCES += arch/$(KARCH)/src/ski/ski.c 68 DEFS += -DSKI 67 ARCH_SOURCES += arch/$(KARCH)/src/drivers/ski.c 69 68 BFD = binary 70 69 endif -
kernel/arch/ia64/include/arch.h
r44b7783 rc2417bc 27 27 */ 28 28 29 /** @addtogroup ia64 29 /** @addtogroup ia64 30 30 * @{ 31 31 */ … … 38 38 #define LOADED_PROG_STACK_PAGES_NO 2 39 39 40 #include <arch/ ski/ski.h>40 #include <arch/drivers/ski.h> 41 41 42 42 extern void arch_pre_main(void); -
kernel/arch/ia64/include/drivers/ski.h
r44b7783 rc2417bc 27 27 */ 28 28 29 /** @addtogroup ia64 29 /** @addtogroup ia64 30 30 * @{ 31 31 */ … … 37 37 38 38 #include <console/chardev.h> 39 #include <proc/thread.h> 39 40 40 #define SKI_INIT_CONSOLE 20 41 #define SKI_GETCHAR 21 42 #define SKI_PUTCHAR 31 41 typedef struct { 42 thread_t *thread; 43 indev_t *srlnin; 44 } ski_instance_t; 43 45 44 extern indev_t *skiin_init(void);45 46 extern void skiout_init(void); 47 48 extern ski_instance_t *skiin_init(void); 49 extern void skiin_wire(ski_instance_t *, indev_t *); 46 50 extern void ski_kbd_grab(void); 47 51 extern void ski_kbd_release(void); -
kernel/arch/ia64/src/drivers/ski.c
r44b7783 rc2417bc 33 33 */ 34 34 35 #include <arch/ ski/ski.h>35 #include <arch/drivers/ski.h> 36 36 #include <console/console.h> 37 37 #include <console/chardev.h> … … 45 45 #include <arch.h> 46 46 47 static indev_t skiin; /**< Ski input device. */ 48 static outdev_t skiout; /**< Ski output device. */ 49 50 static bool kbd_disabled; 47 #define POLL_INTERVAL 10000 /* 10 ms */ 48 49 #define SKI_INIT_CONSOLE 20 50 #define SKI_GETCHAR 21 51 #define SKI_PUTCHAR 31 52 53 static void ski_putchar(outdev_t *, const wchar_t, bool); 54 55 static outdev_operations_t skiout_ops = { 56 .write = ski_putchar 57 }; 58 59 static outdev_t skiout; /**< Ski output device. */ 60 static bool initialized = false; 61 static bool kbd_disabled = false; 62 63 /** Initialize debug console 64 * 65 * Issue SSC (Simulator System Call) to 66 * to open debug console. 67 * 68 */ 69 static void ski_init(void) 70 { 71 if (initialized) 72 return; 73 74 asm volatile ( 75 "mov r15 = %0\n" 76 "break 0x80000\n" 77 : 78 : "i" (SKI_INIT_CONSOLE) 79 : "r15", "r8" 80 ); 81 82 initialized = true; 83 } 51 84 52 85 static void ski_do_putchar(const wchar_t ch) … … 55 88 "mov r15 = %[cmd]\n" 56 89 "mov r32 = %[ch]\n" /* r32 is in0 */ 57 "break 0x80000\n" /* modifies r8 */90 "break 0x80000\n" /* modifies r8 */ 58 91 : 59 92 : [cmd] "i" (SKI_PUTCHAR), [ch] "r" (ch) … … 67 100 * display character on debug console. 68 101 * 69 * @param d Character device. 70 * @param ch Character to be printed. 71 */ 72 static void ski_putchar(outdev_t *d, const wchar_t ch, bool silent) 102 * @param dev Character device. 103 * @param ch Character to be printed. 104 * @param silent Whether the output should be silenced. 105 * 106 */ 107 static void ski_putchar(outdev_t *dev, const wchar_t ch, bool silent) 73 108 { 74 109 if (!silent) { … … 79 114 ski_do_putchar(ch); 80 115 } else 81 ski_do_putchar( SPECIAL);116 ski_do_putchar(U_SPECIAL); 82 117 } 83 118 } 84 119 85 static indev_operations_t skiin_ops = { 86 .poll = NULL 87 }; 88 89 static outdev_operations_t skiout_ops = { 90 .write = ski_putchar 91 }; 120 void skiout_init(void) 121 { 122 ski_init(); 123 124 outdev_initialize("skiout", &skiout, &skiout_ops); 125 stdout = &skiout; 126 127 sysinfo_set_item_val("fb", NULL, false); 128 } 92 129 93 130 /** Ask debug console if a key was pressed. … … 99 136 * 100 137 * @return ASCII code of pressed key or 0 if no key pressed. 101 */ 102 static int32_t ski_getchar(void) 138 * 139 */ 140 static wchar_t ski_getchar(void) 103 141 { 104 142 uint64_t ch; … … 106 144 asm volatile ( 107 145 "mov r15 = %1\n" 108 "break 0x80000;;\n" /* modifies r8 */109 "mov %0 = r8;;\n" 110 146 "break 0x80000;;\n" /* modifies r8 */ 147 "mov %0 = r8;;\n" 148 111 149 : "=r" (ch) 112 150 : "i" (SKI_GETCHAR) 113 151 : "r15", "r8" 114 152 ); 115 116 return ( int32_t) ch;153 154 return (wchar_t) ch; 117 155 } 118 156 119 157 /** Ask keyboard if a key was pressed. */ 120 static void poll_keyboard(void) 121 { 122 char ch; 123 158 static void poll_keyboard(ski_instance_t *instance) 159 { 124 160 if (kbd_disabled) 125 161 return; 126 ch = ski_getchar(); 127 if(ch == '\r') 128 ch = '\n'; 129 if (ch) { 130 indev_push_character(&skiin, ch); 131 return; 132 } 133 } 134 135 #define POLL_INTERVAL 10000 /* 10 ms */ 162 163 wchar_t ch = ski_getchar(); 164 165 if (ch != 0) 166 indev_push_character(instance->srlnin, ch); 167 } 136 168 137 169 /** Kernel thread for polling keyboard. */ 138 static void kkbdpoll(void *arg) 139 { 140 while (1) { 141 if (!silent) { 142 poll_keyboard(); 143 } 170 static void kskipoll(void *arg) 171 { 172 ski_instance_t *instance = (ski_instance_t *) arg; 173 174 while (true) { 175 if (!silent) 176 poll_keyboard(instance); 177 144 178 thread_usleep(POLL_INTERVAL); 145 179 } 146 180 } 147 181 148 /** Initialize debug console 149 * 150 * Issue SSC (Simulator System Call) to 151 * to open debug console. 152 */ 153 static void ski_init(void) 154 { 155 static bool initialized; 156 157 if (initialized) 158 return; 159 160 asm volatile ( 161 "mov r15 = %0\n" 162 "break 0x80000\n" 163 : 164 : "i" (SKI_INIT_CONSOLE) 165 : "r15", "r8" 166 ); 167 168 initialized = true; 169 } 170 171 indev_t *skiin_init(void) 182 ski_instance_t *skiin_init(void) 172 183 { 173 184 ski_init(); 174 175 indev_initialize("skiin", &skiin, &skiin_ops); 176 thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); 177 if (t) 178 thread_ready(t); 179 else 180 return NULL; 181 185 186 ski_instance_t *instance 187 = malloc(sizeof(ski_instance_t), FRAME_ATOMIC); 188 189 if (instance) { 190 instance->thread = thread_create(kskipoll, (void *) instance, TASK, 0, "kskipoll", true); 191 192 if (!instance->thread) { 193 free(instance); 194 return NULL; 195 } 196 197 instance->srlnin = NULL; 198 } 199 200 return instance; 201 } 202 203 void skiin_wire(ski_instance_t *instance, indev_t *srlnin) 204 { 205 ASSERT(instance); 206 ASSERT(srlnin); 207 208 instance->srlnin = srlnin; 209 thread_ready(instance->thread); 210 182 211 sysinfo_set_item_val("kbd", NULL, true); 183 212 sysinfo_set_item_val("kbd.type", NULL, KBD_SKI); 184 185 return &skiin;186 }187 188 189 void skiout_init(void)190 {191 ski_init();192 193 outdev_initialize("skiout", &skiout, &skiout_ops);194 stdout = &skiout;195 196 sysinfo_set_item_val("fb", NULL, false);197 213 } 198 214 -
kernel/arch/ia64/src/ia64.c
r44b7783 rc2417bc 34 34 35 35 #include <arch.h> 36 #include <arch/ ski/ski.h>36 #include <arch/drivers/ski.h> 37 37 #include <arch/drivers/it.h> 38 38 #include <arch/interrupt.h> … … 149 149 void arch_post_smp_init(void) 150 150 { 151 #ifdef SKI 152 indev_t *in; 153 in = skiin_init(); 154 if (in) 155 srln_init(in); 151 #ifdef MACHINE_ski 152 ski_instance_t *ski_instance = skiin_init(); 153 if (ski_instance) { 154 srln_instance_t *srln_instance = srln_init(); 155 if (srln_instance) { 156 indev_t *sink = stdin_wire(); 157 indev_t *srln = srln_wire(srln_instance, sink); 158 skiin_wire(ski_instance, srln); 159 } 160 } 161 156 162 skiout_init(); 157 163 #endif … … 162 168 163 169 #ifdef CONFIG_NS16550 164 indev_t *kbrdin_ns16550170 ns16550_instance_t *ns16550_instance 165 171 = ns16550_init((ns16550_t *) NS16550_BASE, NS16550_IRQ, NULL, NULL); 166 if (kbrdin_ns16550) 167 srln_init(kbrdin_ns16550); 172 if (ns16550_instance) { 173 srln_instance_t *srln_instance = srln_init(); 174 if (srln_instance) { 175 indev_t *sink = stdin_wire(); 176 indev_t *srln = srln_wire(srln_instance, sink); 177 ns16550_wire(ns16550_instance, srln); 178 } 179 } 168 180 169 181 sysinfo_set_item_val("kbd", NULL, true); … … 177 189 178 190 #ifdef CONFIG_I8042 179 indev_t *kbrdin_i8042 = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); 180 if (kbrdin_i8042) 181 kbrd_init(kbrdin_i8042); 191 i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); 192 if (i8042_instance) { 193 kbrd_instance_t *kbrd_instance = kbrd_init(); 194 if (kbrd_instance) { 195 indev_t *sink = stdin_wire(); 196 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 197 i8042_wire(i8042_instance, kbrd); 198 } 199 } 182 200 183 201 sysinfo_set_item_val("kbd", NULL, true); … … 239 257 void arch_grab_console(void) 240 258 { 241 #ifdef SKI259 #ifdef MACHINE_ski 242 260 ski_kbd_grab(); 243 261 #endif … … 249 267 void arch_release_console(void) 250 268 { 251 #ifdef SKI269 #ifdef MACHINE_ski 252 270 ski_kbd_release(); 253 271 #endif -
kernel/arch/ia64/src/smp/smp.c
r44b7783 rc2417bc 34 34 35 35 #include <arch.h> 36 #include <arch/ ski/ski.h>36 #include <arch/drivers/ski.h> 37 37 #include <arch/drivers/it.h> 38 38 #include <arch/interrupt.h> -
kernel/arch/mips32/Makefile.inc
r44b7783 rc2417bc 61 61 arch/$(KARCH)/src/panic.S \ 62 62 arch/$(KARCH)/src/mips32.c \ 63 arch/$(KARCH)/src/console.c \64 63 arch/$(KARCH)/src/asm.S \ 65 64 arch/$(KARCH)/src/exception.c \ -
kernel/arch/mips32/src/mips32.c
r44b7783 rc2417bc 37 37 #include <arch/exception.h> 38 38 #include <mm/as.h> 39 40 39 #include <userspace.h> 41 #include <arch/console.h>42 40 #include <memstr.h> 43 41 #include <proc/thread.h> 44 42 #include <proc/uarg.h> 45 43 #include <print.h> 44 #include <console/console.h> 46 45 #include <syscall/syscall.h> 47 46 #include <sysinfo/sysinfo.h> 48 49 47 #include <arch/interrupt.h> 50 48 #include <console/chardev.h> … … 60 58 #include <string.h> 61 59 #include <arch/drivers/msim.h> 62 63 60 #include <arch/asm/regname.h> 64 61 … … 170 167 * module and connect it to the msim/GXemul keyboard. Enable keyboard interrupts. 171 168 */ 172 indev_t *kbrdin = dsrlnin_init((dsrlnin_t *) MSIM_KBD_ADDRESS, MSIM_KBD_IRQ); 173 if (kbrdin) { 174 srln_init(kbrdin); 175 cp0_unmask_int(MSIM_KBD_IRQ); 169 dsrlnin_instance_t *dsrlnin_instance 170 = dsrlnin_init((dsrlnin_t *) MSIM_KBD_ADDRESS, MSIM_KBD_IRQ); 171 if (dsrlnin_instance) { 172 srln_instance_t *srln_instance = srln_init(); 173 if (srln_instance) { 174 indev_t *sink = stdin_wire(); 175 indev_t *srln = srln_wire(srln_instance, sink); 176 dsrlnin_wire(dsrlnin_instance, srln); 177 cp0_unmask_int(MSIM_KBD_IRQ); 178 } 176 179 } 177 180 … … 249 252 } 250 253 254 void arch_grab_console(void) 255 { 256 #ifdef CONFIG_FB 257 fb_redraw(); 258 #endif 259 } 260 261 /** Return console to userspace 262 * 263 */ 264 void arch_release_console(void) 265 { 266 } 267 251 268 /** @} 252 269 */ -
kernel/arch/ppc32/Makefile.inc
r44b7783 rc2417bc 55 55 arch/$(KARCH)/src/proc/scheduler.c \ 56 56 arch/$(KARCH)/src/ddi/ddi.c \ 57 arch/$(KARCH)/src/drivers/cuda.c \58 57 arch/$(KARCH)/src/mm/as.c \ 59 58 arch/$(KARCH)/src/mm/frame.c \ -
kernel/arch/ppc32/include/drivers/pic.h
r44b7783 rc2417bc 27 27 */ 28 28 29 /** @addtogroup ppc32 29 /** @addtogroup ppc32 30 30 * @{ 31 31 */ … … 37 37 38 38 #include <arch/types.h> 39 #include <ddi/irq.h> 39 40 40 41 #define PIC_PENDING_LOW 8 … … 45 46 #define PIC_ACK_HIGH 6 46 47 47 void pic_init(uintptr_t base, size_t size);48 void pic_enable_interrupt(int intnum);49 void pic_disable_interrupt(int intnum);50 void pic_ack_interrupt(int intnum);51 int pic_get_pending(void);48 extern void pic_init(uintptr_t base, size_t size, cir_t *cir, void **cir_arg); 49 extern void pic_enable_interrupt(inr_t intnum); 50 extern void pic_disable_interrupt(inr_t intnum); 51 extern void pic_ack_interrupt(void *arg, inr_t intnum); 52 extern int pic_get_pending(void); 52 53 53 54 #endif -
kernel/arch/ppc32/src/drivers/pic.c
r44b7783 rc2417bc 27 27 */ 28 28 29 /** @addtogroup ppc32 29 /** @addtogroup ppc32 30 30 * @{ 31 31 */ … … 41 41 static volatile uint32_t *pic = NULL; 42 42 43 void pic_init(uintptr_t base, size_t size )43 void pic_init(uintptr_t base, size_t size, cir_t *cir, void **cir_arg) 44 44 { 45 45 pic = (uint32_t *) hw_map(base, size); 46 *cir = pic_ack_interrupt; 47 *cir_arg = NULL; 46 48 } 47 49 48 void pic_enable_interrupt(in t intnum)50 void pic_enable_interrupt(inr_t intnum) 49 51 { 50 52 if (pic) { … … 57 59 } 58 60 59 void pic_disable_interrupt(in t intnum)61 void pic_disable_interrupt(inr_t intnum) 60 62 { 61 63 if (pic) { … … 67 69 } 68 70 69 void pic_ack_interrupt( int intnum)71 void pic_ack_interrupt(void *arg, inr_t intnum) 70 72 { 71 73 if (pic) { -
kernel/arch/ppc32/src/dummy.s
r44b7783 rc2417bc 31 31 .global asm_delay_loop 32 32 .global sys_tls_set 33 .global cpu_halt 33 34 34 35 sys_tls_set: … … 37 38 asm_delay_loop: 38 39 blr 40 41 cpu_halt: 42 b cpu_halt -
kernel/arch/ppc32/src/interrupt.c
r44b7783 rc2417bc 61 61 62 62 while ((inum = pic_get_pending()) != -1) { 63 bool ack = false;64 63 irq_t *irq = irq_dispatch_and_lock(inum); 65 64 if (irq) { … … 70 69 if (irq->preack) { 71 70 /* Acknowledge the interrupt before processing */ 72 pic_ack_interrupt(inum);73 ack = true;71 if (irq->cir) 72 irq->cir(irq->cir_arg, irq->inr); 74 73 } 75 74 76 75 irq->handler(irq); 76 77 if (!irq->preack) { 78 if (irq->cir) 79 irq->cir(irq->cir_arg, irq->inr); 80 } 81 77 82 spinlock_unlock(&irq->lock); 78 83 } else { … … 84 89 #endif 85 90 } 86 87 if (!ack)88 pic_ack_interrupt(inum);89 91 } 90 92 } -
kernel/arch/ppc32/src/ppc32.c
r44b7783 rc2417bc 36 36 #include <arch.h> 37 37 #include <arch/boot/boot.h> 38 #include < arch/drivers/cuda.h>38 #include <genarch/drivers/via-cuda/cuda.h> 39 39 #include <arch/interrupt.h> 40 40 #include <genarch/fb/fb.h> … … 45 45 #include <ddi/irq.h> 46 46 #include <arch/drivers/pic.h> 47 #include <align.h> 47 48 #include <macros.h> 48 49 #include <string.h> 49 50 50 51 #define IRQ_COUNT 64 52 #define IRQ_CUDA 10 51 53 52 54 bootinfo_t bootinfo; … … 118 120 if (bootinfo.macio.addr) { 119 121 /* Initialize PIC */ 120 pic_init(bootinfo.macio.addr, PAGE_SIZE); 122 cir_t cir; 123 void *cir_arg; 124 pic_init(bootinfo.macio.addr, PAGE_SIZE, &cir, &cir_arg); 125 126 #ifdef CONFIG_VIA_CUDA 127 uintptr_t pa = bootinfo.macio.addr + 0x16000; 128 uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); 129 size_t offset = pa - aligned_addr; 130 size_t size = 2 * PAGE_SIZE; 131 132 cuda_t *cuda = (cuda_t *) 133 (hw_map(aligned_addr, offset + size) + offset); 121 134 122 135 /* Initialize I/O controller */ 123 cuda_init(bootinfo.macio.addr + 0x16000, 2 * PAGE_SIZE); 136 cuda_instance_t *cuda_instance = 137 cuda_init(cuda, IRQ_CUDA, cir, cir_arg); 138 if (cuda_instance) { 139 indev_t *sink = stdin_wire(); 140 cuda_wire(cuda_instance, sink); 141 } 142 #endif 124 143 } 125 144 … … 187 206 } 188 207 208 void arch_reboot(void) 209 { 210 // TODO 211 while (1); 212 } 213 189 214 /** @} 190 215 */ -
kernel/arch/sparc64/include/drivers/kbd.h
r44b7783 rc2417bc 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 39 39 #include <genarch/ofw/ofw_tree.h> 40 40 41 typedef enum {42 KBD_UNKNOWN,43 KBD_Z8530,44 KBD_NS16550,45 KBD_SGCN46 } kbd_type_t;47 48 extern kbd_type_t kbd_type;49 50 41 extern void kbd_init(ofw_tree_node_t *node); 51 42 -
kernel/arch/sparc64/src/console.c
r44b7783 rc2417bc 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 136 136 #endif 137 137 138 switch (kbd_type) {139 138 #ifdef CONFIG_SGCN_KBD 140 case KBD_SGCN: 141 sgcn_grab(); 142 break; 139 sgcn_grab(); 143 140 #endif 144 default:145 break;146 }147 141 } 148 142 … … 152 146 void arch_release_console(void) 153 147 { 154 switch (kbd_type) {155 148 #ifdef CONFIG_SGCN_KBD 156 case KBD_SGCN: 157 sgcn_release(); 158 break; 149 sgcn_release(); 159 150 #endif 160 default:161 break;162 }163 151 } 164 152 -
kernel/arch/sparc64/src/drivers/kbd.c
r44b7783 rc2417bc 55 55 #include <sysinfo/sysinfo.h> 56 56 57 kbd_type_t kbd_type = KBD_UNKNOWN;58 59 57 #ifdef CONFIG_SUN_KBD 60 58 61 /** Initialize keyboard. 62 * 63 * Traverse OpenFirmware device tree in order to find necessary 64 * info about the keyboard device. 65 * 66 * @param node Keyboard device node. 67 */ 68 void kbd_init(ofw_tree_node_t *node) 59 #ifdef CONFIG_Z8530 60 61 static bool kbd_z8530_init(ofw_tree_node_t *node) 69 62 { 70 size_t offset; 71 uintptr_t aligned_addr; 72 ofw_tree_property_t *prop; 73 const char *name; 63 const char *name = ofw_tree_node_name(node); 64 65 if (str_cmp(name, "zs") != 0) 66 return false; 67 68 /* 69 * Read 'interrupts' property. 70 */ 71 ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts"); 72 if ((!prop) || (!prop->value)) { 73 printf("z8530: Unable to find interrupts property\n"); 74 return false; 75 } 76 77 uint32_t interrupts = *((uint32_t *) prop->value); 78 79 /* 80 * Read 'reg' property. 81 */ 82 prop = ofw_tree_getprop(node, "reg"); 83 if ((!prop) || (!prop->value)) { 84 printf("z8530: Unable to find reg property\n"); 85 return false; 86 } 87 88 size_t size = ((ofw_fhc_reg_t *) prop->value)->size; 89 90 uintptr_t pa; 91 if (!ofw_fhc_apply_ranges(node->parent, 92 ((ofw_fhc_reg_t *) prop->value), &pa)) { 93 printf("z8530: Failed to determine address\n"); 94 return false; 95 } 96 97 inr_t inr; 74 98 cir_t cir; 75 99 void *cir_arg; 76 77 #ifdef CONFIG_NS16550 78 ns16550_t *ns16550; 79 #endif 80 #ifdef CONFIG_Z8530 81 z8530_t *z8530; 82 #endif 83 84 name = ofw_tree_node_name(node); 85 86 /* 87 * Determine keyboard serial controller type. 88 */ 89 if (str_cmp(name, "zs") == 0) 90 kbd_type = KBD_Z8530; 91 else if (str_cmp(name, "su") == 0) 92 kbd_type = KBD_NS16550; 93 94 if (kbd_type == KBD_UNKNOWN) { 95 printf("Unknown keyboard device.\n"); 96 return; 97 } 98 99 /* 100 * Read 'interrupts' property. 101 */ 102 uint32_t interrupts; 103 prop = ofw_tree_getprop(node, "interrupts"); 104 if ((!prop) || (!prop->value)) 105 panic("Cannot find 'interrupt' property."); 106 interrupts = *((uint32_t *) prop->value); 107 108 /* 109 * Read 'reg' property. 110 */ 111 prop = ofw_tree_getprop(node, "reg"); 112 if ((!prop) || (!prop->value)) 113 panic("Cannot find 'reg' property."); 114 115 uintptr_t pa; 116 size_t size; 117 inr_t inr; 118 119 switch (kbd_type) { 120 case KBD_Z8530: 121 size = ((ofw_fhc_reg_t *) prop->value)->size; 122 if (!ofw_fhc_apply_ranges(node->parent, 123 ((ofw_fhc_reg_t *) prop->value), &pa)) { 124 printf("Failed to determine keyboard address.\n"); 125 return; 126 } 127 if (!ofw_fhc_map_interrupt(node->parent, 128 ((ofw_fhc_reg_t *) prop->value), interrupts, &inr, &cir, 129 &cir_arg)) { 130 printf("Failed to determine keyboard interrupt.\n"); 131 return; 132 } 133 break; 134 135 case KBD_NS16550: 136 size = ((ofw_ebus_reg_t *) prop->value)->size; 137 if (!ofw_ebus_apply_ranges(node->parent, 138 ((ofw_ebus_reg_t *) prop->value), &pa)) { 139 printf("Failed to determine keyboard address.\n"); 140 return; 141 } 142 if (!ofw_ebus_map_interrupt(node->parent, 143 ((ofw_ebus_reg_t *) prop->value), interrupts, &inr, &cir, 144 &cir_arg)) { 145 printf("Failed to determine keyboard interrupt.\n"); 146 return; 147 }; 148 break; 149 default: 150 panic("Unexpected keyboard type."); 100 if (!ofw_fhc_map_interrupt(node->parent, 101 ((ofw_fhc_reg_t *) prop->value), interrupts, &inr, &cir, 102 &cir_arg)) { 103 printf("z8530: Failed to determine interrupt\n"); 104 return false; 151 105 } 152 106 … … 157 111 * underlying controller. 158 112 */ 159 aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); 160 offset = pa - aligned_addr; 161 162 switch (kbd_type) { 113 uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); 114 size_t offset = pa - aligned_addr; 115 116 z8530_t *z8530 = (z8530_t *) 117 (hw_map(aligned_addr, offset + size) + offset); 118 119 z8530_instance_t *z8530_instance = z8530_init(z8530, inr, cir, cir_arg); 120 if (z8530_instance) { 121 kbrd_instance_t *kbrd_instance = kbrd_init(); 122 if (kbrd_instance) { 123 indev_t *sink = stdin_wire(); 124 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 125 z8530_wire(z8530_instance, kbrd); 126 } 127 } 128 129 /* 130 * This is the necessary evil until the userspace drivers are 131 * entirely self-sufficient. 132 */ 133 sysinfo_set_item_val("kbd", NULL, true); 134 sysinfo_set_item_val("kbd.inr", NULL, inr); 135 sysinfo_set_item_val("kbd.address.kernel", NULL, 136 (uintptr_t) z8530); 137 sysinfo_set_item_val("kbd.address.physical", NULL, pa); 138 sysinfo_set_item_val("kbd.type.z8530", NULL, true); 139 140 return true; 141 } 142 143 #endif /* CONFIG_Z8530 */ 144 145 #ifdef CONFIG_NS16550 146 147 static bool kbd_ns16550_init(ofw_tree_node_t *node) 148 { 149 const char *name = ofw_tree_node_name(node); 150 151 if (str_cmp(name, "su") != 0) 152 return false; 153 154 /* 155 * Read 'interrupts' property. 156 */ 157 ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts"); 158 if ((!prop) || (!prop->value)) { 159 printf("ns16550: Unable to find interrupts property\n"); 160 return false; 161 } 162 163 uint32_t interrupts = *((uint32_t *) prop->value); 164 165 /* 166 * Read 'reg' property. 167 */ 168 prop = ofw_tree_getprop(node, "reg"); 169 if ((!prop) || (!prop->value)) { 170 printf("ns16550: Unable to find reg property\n"); 171 return false; 172 } 173 174 size_t size = ((ofw_ebus_reg_t *) prop->value)->size; 175 176 uintptr_t pa; 177 if (!ofw_ebus_apply_ranges(node->parent, 178 ((ofw_ebus_reg_t *) prop->value), &pa)) { 179 printf("ns16550: Failed to determine address\n"); 180 return false; 181 } 182 183 inr_t inr; 184 cir_t cir; 185 void *cir_arg; 186 if (!ofw_ebus_map_interrupt(node->parent, 187 ((ofw_ebus_reg_t *) prop->value), interrupts, &inr, &cir, 188 &cir_arg)) { 189 printf("ns16550: Failed to determine interrupt\n"); 190 return false; 191 } 192 193 /* 194 * We need to pass aligned address to hw_map(). 195 * However, the physical keyboard address can 196 * be pretty much unaligned, depending on the 197 * underlying controller. 198 */ 199 uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); 200 size_t offset = pa - aligned_addr; 201 202 ns16550_t *ns16550 = (ns16550_t *) 203 (hw_map(aligned_addr, offset + size) + offset); 204 205 ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir, cir_arg); 206 if (ns16550_instance) { 207 kbrd_instance_t *kbrd_instance = kbrd_init(); 208 if (kbrd_instance) { 209 indev_t *sink = stdin_wire(); 210 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 211 ns16550_wire(ns16550_instance, kbrd); 212 } 213 } 214 215 /* 216 * This is the necessary evil until the userspace drivers are 217 * entirely self-sufficient. 218 */ 219 sysinfo_set_item_val("kbd", NULL, true); 220 sysinfo_set_item_val("kbd.inr", NULL, inr); 221 sysinfo_set_item_val("kbd.address.kernel", NULL, 222 (uintptr_t) ns16550); 223 sysinfo_set_item_val("kbd.address.physical", NULL, pa); 224 sysinfo_set_item_val("kbd.type.ns16550", NULL, true); 225 226 return true; 227 } 228 229 #endif /* CONFIG_NS16550 */ 230 231 /** Initialize keyboard. 232 * 233 * Traverse OpenFirmware device tree in order to find necessary 234 * info about the keyboard device. 235 * 236 * @param node Keyboard device node. 237 * 238 */ 239 void kbd_init(ofw_tree_node_t *node) 240 { 163 241 #ifdef CONFIG_Z8530 164 case KBD_Z8530: 165 z8530 = (z8530_t *) 166 (hw_map(aligned_addr, offset + size) + offset); 167 168 indev_t *kbrdin_z8530 = z8530_init(z8530, inr, cir, cir_arg); 169 if (kbrdin_z8530) 170 kbrd_init(kbrdin_z8530); 171 172 /* 173 * This is the necessary evil until the userspace drivers are 174 * entirely self-sufficient. 175 */ 176 sysinfo_set_item_val("kbd", NULL, true); 177 sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530); 178 sysinfo_set_item_val("kbd.inr", NULL, inr); 179 sysinfo_set_item_val("kbd.address.kernel", NULL, 180 (uintptr_t) z8530); 181 sysinfo_set_item_val("kbd.address.physical", NULL, pa); 182 break; 183 #endif 242 kbd_z8530_init(node); 243 #endif 244 184 245 #ifdef CONFIG_NS16550 185 case KBD_NS16550: 186 ns16550 = (ns16550_t *) 187 (hw_map(aligned_addr, offset + size) + offset); 188 189 indev_t *kbrdin_ns16550 = ns16550_init(ns16550, inr, cir, cir_arg); 190 if (kbrdin_ns16550) 191 kbrd_init(kbrdin_ns16550); 192 193 /* 194 * This is the necessary evil until the userspace driver is 195 * entirely self-sufficient. 196 */ 197 sysinfo_set_item_val("kbd", NULL, true); 198 sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); 199 sysinfo_set_item_val("kbd.inr", NULL, inr); 200 sysinfo_set_item_val("kbd.address.kernel", NULL, 201 (uintptr_t) ns16550); 202 sysinfo_set_item_val("kbd.address.physical", NULL, pa); 203 break; 204 #endif 205 default: 206 printf("Kernel is not compiled with the necessary keyboard " 207 "driver this machine requires.\n"); 208 } 246 kbd_ns16550_init(node); 247 #endif 209 248 } 210 249 211 #endif 250 #endif /* CONFIG_SUN_KBD */ 212 251 213 252 /** @} -
kernel/arch/sparc64/src/drivers/sgcn.c
r44b7783 rc2417bc 101 101 /** Returns a pointer to the console buffer header. */ 102 102 #define SGCN_BUFFER_HEADER (SGCN_BUFFER(sgcn_buffer_header_t, 0)) 103 104 /** defined in drivers/kbd.c */105 extern kbd_type_t kbd_type;106 103 107 104 /** starting address of SRAM, will be set by the init_sram_begin function */ … … 354 351 sgcn_buffer_begin_init(); 355 352 356 kbd_type = KBD_SGCN;357 358 353 sysinfo_set_item_val("kbd", NULL, true); 359 sysinfo_set_item_val("kbd.type", NULL, KBD_SGCN);360 354 361 355 thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true);
Note:
See TracChangeset
for help on using the changeset viewer.
