Changeset 2a77841d in mainline
- Timestamp:
- 2009-07-02T19:39:29Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d68e4d5
- Parents:
- bb8dc88
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
rbb8dc88 r2a77841d 397 397 ! [(CONFIG_HID_IN=generic|CONFIG_HID_IN=keyboard)&PLATFORM=sparc64&MACHINE=generic&(CONFIG_NS16550=y|CONFIG_Z8530=y)] CONFIG_SUN_KBD (y) 398 398 399 % Macintosh ADB keyboard support 400 ! [(CONFIG_HID_IN=generic|CONFIG_HID_IN=keyboard)&PLATFORM=ppc32&(CONFIG_VIA_CUDA=y)] CONFIG_MAC_KBD (y) 401 399 402 % Dummy serial line input 400 403 ! [CONFIG_MIPS_KBD=y|CONFIG_ARM_KBD=y] CONFIG_DSRLNIN (y) -
kernel/arch/ppc32/src/ppc32.c
rbb8dc88 r2a77841d 37 37 #include <arch/boot/boot.h> 38 38 #include <genarch/drivers/via-cuda/cuda.h> 39 #include <genarch/kbrd/kbrd.h> 39 40 #include <arch/interrupt.h> 40 41 #include <genarch/fb/fb.h> … … 118 119 irq_init(IRQ_COUNT, IRQ_COUNT); 119 120 120 if (bootinfo.macio.addr) {121 /* Initialize PIC */122 cir_t cir;123 void *cir_arg;124 pic_init(bootinfo.macio.addr, PAGE_SIZE, &cir, &cir_arg);125 126 #ifdef CONFIG_VIA_CUDA127 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);134 135 /* Initialize I/O controller */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 #endif143 }144 145 121 /* Merge all zones to 1 big zone */ 146 122 zone_merge_all(); … … 158 134 void arch_post_smp_init(void) 159 135 { 136 if (bootinfo.macio.addr) { 137 /* Initialize PIC */ 138 cir_t cir; 139 void *cir_arg; 140 pic_init(bootinfo.macio.addr, PAGE_SIZE, &cir, &cir_arg); 141 142 #ifdef CONFIG_MAC_KBD 143 uintptr_t pa = bootinfo.macio.addr + 0x16000; 144 uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); 145 size_t offset = pa - aligned_addr; 146 size_t size = 2 * PAGE_SIZE; 147 148 cuda_t *cuda = (cuda_t *) 149 (hw_map(aligned_addr, offset + size) + offset); 150 151 /* Initialize I/O controller */ 152 cuda_instance_t *cuda_instance = 153 cuda_init(cuda, IRQ_CUDA, cir, cir_arg); 154 if (cuda_instance) { 155 kbrd_instance_t *kbrd_instance = kbrd_init(); 156 if (kbrd_instance) { 157 indev_t *sink = stdin_wire(); 158 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 159 cuda_wire(cuda_instance, kbrd); 160 pic_enable_interrupt(IRQ_CUDA); 161 } 162 } 163 #endif 164 } 160 165 } 161 166 -
kernel/genarch/Makefile.inc
rbb8dc88 r2a77841d 111 111 endif 112 112 113 ifeq ($(CONFIG_MAC_KBD),y) 114 GENARCH_SOURCES += \ 115 genarch/src/kbrd/kbrd.c \ 116 genarch/src/kbrd/scanc_mac.c 117 endif 118 113 119 ifeq ($(CONFIG_SRLN),y) 114 120 GENARCH_SOURCES += \ -
kernel/genarch/include/drivers/via-cuda/cuda.h
rbb8dc88 r2a77841d 39 39 #include <arch/types.h> 40 40 #include <console/chardev.h> 41 #include <synch/spinlock.h> 41 42 42 43 typedef struct { 44 uint8_t b; 45 uint8_t pad0[0x1ff]; 46 47 uint8_t a; 48 uint8_t pad1[0x1ff]; 49 50 uint8_t dirb; 51 uint8_t pad2[0x1ff]; 52 53 uint8_t dira; 54 uint8_t pad3[0x1ff]; 55 56 uint8_t t1cl; 57 uint8_t pad4[0x1ff]; 58 59 uint8_t t1ch; 60 uint8_t pad5[0x1ff]; 61 62 uint8_t t1ll; 63 uint8_t pad6[0x1ff]; 64 65 uint8_t t1lh; 66 uint8_t pad7[0x1ff]; 67 68 uint8_t t2cl; 69 uint8_t pad8[0x1ff]; 70 71 uint8_t t2ch; 72 uint8_t pad9[0x1ff]; 73 74 uint8_t sr; 75 uint8_t pad10[0x1ff]; 76 77 uint8_t acr; 78 uint8_t pad11[0x1ff]; 79 80 uint8_t pcr; 81 uint8_t pad12[0x1ff]; 82 83 uint8_t ifr; 84 uint8_t pad13[0x1ff]; 85 86 uint8_t ier; 87 uint8_t pad14[0x1ff]; 88 89 uint8_t anh; 90 uint8_t pad15[0x1ff]; 43 91 } cuda_t; 92 93 enum { 94 CUDA_RCV_BUF_SIZE = 5 95 }; 44 96 45 97 typedef struct { … … 47 99 cuda_t *cuda; 48 100 indev_t *kbrdin; 101 uint8_t rcv_buf[CUDA_RCV_BUF_SIZE]; 102 SPINLOCK_DECLARE(dev_lock); 49 103 } cuda_instance_t; 50 104 -
kernel/genarch/src/drivers/via-cuda/cuda.c
rbb8dc88 r2a77841d 1 1 /* 2 2 * Copyright (c) 2006 Martin Decky 3 * Copyright (c) 2009 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 39 40 #include <mm/slab.h> 40 41 #include <ddi/device.h> 42 #include <synch/spinlock.h> 43 44 static void cuda_packet_handle(cuda_instance_t *instance, size_t len); 45 46 /** B register fields */ 47 enum { 48 TREQ = 0x08, 49 TACK = 0x10, 50 TIP = 0x20 51 }; 52 53 /** IER register fields */ 54 enum { 55 IER_SET = 0x80, 56 SR_INT = 0x04 57 }; 41 58 42 59 static irq_ownership_t cuda_claim(irq_t *irq) 43 60 { 44 return IRQ_DECLINE; 61 cuda_instance_t *instance = irq->instance; 62 cuda_t *dev = instance->cuda; 63 uint8_t ifr; 64 65 ifr = pio_read_8(&dev->ifr); 66 67 if ((ifr & SR_INT) != 0) 68 return IRQ_ACCEPT; 69 else 70 return IRQ_DECLINE; 45 71 } 46 72 47 73 static void cuda_irq_handler(irq_t *irq) 48 74 { 75 cuda_instance_t *instance = irq->instance; 76 cuda_t *dev = instance->cuda; 77 uint8_t b, data; 78 size_t pos; 79 80 spinlock_lock(&instance->dev_lock); 81 82 /* We have received one or more CUDA packets. Process them all. */ 83 while (true) { 84 b = pio_read_8(&dev->b); 85 86 if ((b & TREQ) != 0) 87 break; /* No data */ 88 89 pio_write_8(&dev->b, b & ~TIP); 90 91 /* Read one packet. */ 92 93 pos = 0; 94 do { 95 data = pio_read_8(&dev->sr); 96 b = pio_read_8(&dev->b); 97 pio_write_8(&dev->b, b ^ TACK); 98 99 if (pos < CUDA_RCV_BUF_SIZE) 100 instance->rcv_buf[pos++] = data; 101 } while ((b & TREQ) == 0); 102 103 pio_write_8(&dev->b, b | TACK | TIP); 104 105 cuda_packet_handle(instance, pos); 106 } 107 108 spinlock_unlock(&instance->dev_lock); 109 } 110 111 static void cuda_packet_handle(cuda_instance_t *instance, size_t len) 112 { 113 uint8_t *data = instance->rcv_buf; 114 115 if (data[0] != 0x00 || data[1] != 0x40 || data[2] != 0x2c) 116 return; 117 118 /* The packet contains one or two scancodes. */ 119 if (data[3] != 0xff) 120 indev_push_character(instance->kbrdin, data[3]); 121 if (data[4] != 0xff) 122 indev_push_character(instance->kbrdin, data[4]); 49 123 } 50 124 … … 56 130 instance->cuda = dev; 57 131 instance->kbrdin = NULL; 58 132 133 spinlock_initialize(&instance->dev_lock, "cuda_dev"); 134 59 135 irq_initialize(&instance->irq); 60 136 instance->irq.devno = device_assign_devno(); … … 72 148 void cuda_wire(cuda_instance_t *instance, indev_t *kbrdin) 73 149 { 150 ASSERT(instance); 151 ASSERT(kbrdin); 152 153 instance->kbrdin = kbrdin; 154 irq_register(&instance->irq); 155 156 /* Enable SR interrupt. */ 157 pio_write_8(&instance->cuda->ier, IER_SET | SR_INT); 74 158 } 75 76 159 77 160 /** @} -
kernel/genarch/src/kbrd/kbrd.c
rbb8dc88 r2a77841d 44 44 #ifdef CONFIG_SUN_KBD 45 45 #include <genarch/kbrd/scanc_sun.h> 46 #endif 47 48 #ifdef CONFIG_MAC_KBD 49 #include <genarch/kbrd/scanc_mac.h> 46 50 #endif 47 51
Note:
See TracChangeset
for help on using the changeset viewer.