Changeset 0b414b5 in mainline
- Timestamp:
- 2006-10-02T21:07:23Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 233af8c5
- Parents:
- 36db5ac
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/genarch/ofw_tree.c
r36db5ac r0b414b5 97 97 current_node->properties = 0; 98 98 current_node->property = NULL; 99 current_node->device = NULL; 99 100 100 101 /* -
boot/genarch/ofw_tree.h
r36db5ac r0b414b5 50 50 unsigned properties; /**< Number of properties. */ 51 51 ofw_tree_property_t *property; 52 53 void *device; /**< Member used solely by the kernel. */ 52 54 }; 53 55 -
kernel/arch/sparc64/include/drivers/fhc.h
r36db5ac r0b414b5 37 37 38 38 #include <arch/types.h> 39 #include <genarch/ofw/ofw_tree.h> 39 40 40 extern volatile uint32_t *fhc; 41 typedef struct { 42 volatile uint32_t *uart_imap; 43 } fhc_t; 41 44 42 extern void fhc_init(void); 43 extern void fhc_uart_reset(void); 45 extern fhc_t *central_fhc; 46 47 extern fhc_t *fhc_init(ofw_tree_node_t *node); 48 extern void fhc_enable_interrupt(fhc_t *fhc, int ino); 49 extern void fhc_clear_interrupt(fhc_t *fhc, int ino); 44 50 45 51 #endif -
kernel/arch/sparc64/src/drivers/fhc.c
r36db5ac r0b414b5 42 42 #include <arch/drivers/fhc.h> 43 43 #include <arch/mm/page.h> 44 #include <mm/slab.h> 44 45 #include <arch/types.h> 45 46 #include <typedefs.h> 46 47 #include <genarch/ofw/ofw_tree.h> 47 48 #include <genarch/kbd/z8530.h> 48 49 49 volatile uint32_t *fhc = NULL;50 fhc_t *central_fhc = NULL; 50 51 51 #define FHC_UART_ADDR 0x1fff8808000ULL /* hardcoded for Simics simulation */ 52 /** 53 * I suspect this must be hardcoded in the FHC. 54 * If it is not, than we can read all IMAP registers 55 * and get the complete mapping. 56 */ 57 #define FHC_UART_INO 0x39 52 58 53 59 #define FHC_UART_IMAP 0x0 54 60 #define FHC_UART_ICLR 0x4 55 61 56 void fhc_init(void) 62 #define UART_IMAP_REG 4 63 64 fhc_t *fhc_init(ofw_tree_node_t *node) 57 65 { 58 fhc = (void *) hw_map(FHC_UART_ADDR, PAGE_SIZE); 66 fhc_t *fhc; 67 ofw_tree_property_t *prop; 59 68 60 fhc[FHC_UART_ICLR] = 0; 61 fhc[FHC_UART_IMAP] = 0x80000000; 69 prop = ofw_tree_getprop(node, "reg"); 70 71 if (!prop || !prop->value) 72 return NULL; 73 74 count_t regs = prop->size / sizeof(ofw_central_reg_t); 75 if (regs + 1 < UART_IMAP_REG) 76 return NULL; 77 78 ofw_central_reg_t *reg = &((ofw_central_reg_t *) prop->value)[UART_IMAP_REG]; 79 80 uintptr_t paddr; 81 if (!ofw_central_apply_ranges(node->parent, reg, &paddr)) 82 return NULL; 83 84 fhc = (fhc_t *) malloc(sizeof(fhc_t), FRAME_ATOMIC); 85 if (!fhc) 86 return NULL; 87 88 fhc->uart_imap = (uint32_t *) hw_map(paddr, reg->size); 89 90 return fhc; 62 91 } 63 92 64 void fhc_ uart_reset(void)93 void fhc_enable_interrupt(fhc_t *fhc, int ino) 65 94 { 66 fhc[FHC_UART_ICLR] = 0; 95 switch (ino) { 96 case FHC_UART_INO: 97 fhc->uart_imap[FHC_UART_ICLR] = 0x0; 98 fhc->uart_imap[FHC_UART_IMAP] = 0x80000000; 99 break; 100 default: 101 panic("Unexpected INO (%d)\n", ino); 102 break; 103 } 104 } 105 106 void fhc_clear_interrupt(fhc_t *fhc, int ino) 107 { 108 ASSERT(fhc->uart_imap); 109 110 switch (ino) { 111 case FHC_UART_INO: 112 fhc->uart_imap[FHC_UART_ICLR] = 0; 113 break; 114 default: 115 panic("Unexpected INO (%d)\n", ino); 116 break; 117 } 67 118 } 68 119 -
kernel/arch/sparc64/src/drivers/kbd.c
r36db5ac r0b414b5 69 69 name = ofw_tree_node_name(node); 70 70 71 /* 72 * Determine keyboard serial controller type. 73 */ 71 74 if (strcmp(name, "zs") == 0) 72 75 kbd_type = KBD_Z8530; … … 79 82 } 80 83 84 /* 85 * Read 'interrupts' property. 86 */ 87 uint32_t interrupts; 88 prop = ofw_tree_getprop(node, "interrupts"); 89 if (!prop || !prop->value) 90 panic("Can't find \"interrupts\" property.\n"); 91 interrupts = *((uint32_t *) prop->value); 92 93 /* 94 * Read 'reg' property. 95 */ 81 96 prop = ofw_tree_getprop(node, "reg"); 82 if (!prop )97 if (!prop || !prop->value) 83 98 panic("Can't find \"reg\" property.\n"); 84 99 85 100 uintptr_t pa; 86 101 size_t size; 102 int ino; 87 103 88 104 switch (kbd_type) { … … 93 109 return; 94 110 } 111 if (!ofw_fhc_map_interrupts(node->parent, ((ofw_fhc_reg_t *) prop->value), interrupts, &ino)) { 112 printf("Failed to determine keyboard interrupts.\n"); 113 return; 114 } 95 115 break; 96 116 case KBD_NS16550: … … 98 118 if (!ofw_ebus_apply_ranges(node->parent, ((ofw_ebus_reg_t *) prop->value) , &pa)) { 99 119 printf("Failed to determine keyboard address.\n"); 120 return; 121 } 122 if (!ofw_ebus_map_interrupts(node->parent, ((ofw_ebus_reg_t *) prop->value), interrupts, &ino)) { 123 printf("Failed to determine keyboard interrupts.\n"); 100 124 return; 101 125 } -
kernel/arch/sparc64/src/trap/interrupt.c
r36db5ac r0b414b5 97 97 else 98 98 ipc_irq_send_notif(0); 99 fhc_ uart_reset();99 fhc_clear_interrupt(central_fhc, data0); 100 100 break; 101 101 -
kernel/genarch/include/ofw/ofw_tree.h
r36db5ac r0b414b5 50 50 unsigned properties; /**< Number of properties. */ 51 51 ofw_tree_property_t *property; 52 53 /** 54 * Pointer to a structure representing respective device. 55 * Its semantics is device dependent. 56 */ 57 void *device; 52 58 }; 53 59 … … 105 111 typedef struct ofw_ebus_range ofw_ebus_range_t; 106 112 113 struct ofw_ebus_intr_map { 114 uint32_t space; 115 uint32_t addr; 116 uint32_t intr; 117 uint32_t controller_handle; 118 uint32_t controller_ino; 119 } __attribute__ ((packed)); 120 typedef struct ofw_ebus_intr_map ofw_ebus_intr_map_t; 121 122 struct ofw_ebus_intr_mask { 123 uint32_t space_mask; 124 uint32_t addr_mask; 125 uint32_t intr_mask; 126 } __attribute__ ((packed)); 127 typedef struct ofw_ebus_intr_mask ofw_ebus_intr_mask_t; 128 107 129 struct ofw_pci_reg { 108 uint32_t space; /* needs to masked to obtain pure space id */130 uint32_t space; /* needs to be masked to obtain pure space id */ 109 131 uint64_t addr; /* group phys.mid and phys.lo together */ 110 132 uint64_t size; … … 144 166 extern bool ofw_pci_reg_absolutize(ofw_tree_node_t *node, ofw_pci_reg_t *reg, ofw_pci_reg_t *out); 145 167 168 extern bool ofw_fhc_map_interrupts(ofw_tree_node_t *node, ofw_fhc_reg_t *reg, uint32_t interrupt, int *ino); 169 extern bool ofw_ebus_map_interrupts(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uint32_t interrupt, int *ino); 170 146 171 #endif -
kernel/genarch/src/kbd/z8530.c
r36db5ac r0b414b5 39 39 #include <genarch/kbd/scanc.h> 40 40 #include <genarch/kbd/scanc_sun.h> 41 #include <arch/drivers/fhc.h>42 41 #include <arch/drivers/z8530.h> 43 42 #include <arch/interrupt.h> … … 107 106 108 107 z8530_write_a(WR9, WR9_MIE); /* Master Interrupt Enable. */ 109 110 /*111 * We need to initialize the FireHose Controller,112 * to which is this z8530 attached. Otherwise113 * interrupts generated by the z8530 would not114 * be forwarded to the CPU.115 */116 fhc_init();117 108 } 118 109 -
kernel/genarch/src/ofw/ebus.c
r36db5ac r0b414b5 40 40 #include <func.h> 41 41 #include <panic.h> 42 #include <debug.h> 42 43 #include <macros.h> 43 44 … … 74 75 } 75 76 77 bool ofw_ebus_map_interrupts(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uint32_t interrupt, int *ino) 78 { 79 ofw_tree_property_t *prop; 80 ofw_tree_node_t *controller; 81 82 prop = ofw_tree_getprop(node, "interrupt-map"); 83 if (!prop || !prop->value) 84 return false; 85 86 ofw_ebus_intr_map_t *intr_map = prop->value; 87 count_t count = prop->size / sizeof(ofw_ebus_intr_map_t); 88 89 ASSERT(count); 90 91 prop = ofw_tree_getprop(node, "interrupt-map-mask"); 92 if (!prop || !prop->value) 93 return false; 94 95 ofw_ebus_intr_mask_t *intr_mask = prop->value; 96 97 ASSERT(prop->size == sizeof(ofw_ebus_intr_mask_t)); 98 99 uint32_t space = reg->space & intr_mask->space_mask; 100 uint32_t addr = reg->addr & intr_mask->addr_mask; 101 uint32_t intr = interrupt & intr_mask->intr_mask; 102 103 int i; 104 for (i = 0; i < count; i++) { 105 if ((intr_map[i].space == space) && (intr_map[i].addr == addr) 106 && (intr_map[i].intr == intr)) 107 goto found; 108 } 109 return false; 110 111 found: 112 /* 113 * We found the device that functions as an interrupt controller 114 * for the interrupt. We also found mapping from interrupt to INO. 115 */ 116 117 controller = ofw_tree_find_node_by_handle(ofw_tree_lookup("/"), intr_map[i].controller_handle); 118 119 *ino = intr_map[i].controller_ino; 120 return true; 121 } 122 76 123 /** @} 77 124 */ -
kernel/genarch/src/ofw/fhc.c
r36db5ac r0b414b5 37 37 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <arch/drivers/fhc.h> 39 40 #include <arch/memstr.h> 40 41 #include <func.h> … … 109 110 } 110 111 112 bool ofw_fhc_map_interrupts(ofw_tree_node_t *node, ofw_fhc_reg_t *reg, uint32_t interrupt, int *ino) 113 { 114 fhc_t *fhc = NULL; 115 if (!node->device) { 116 fhc = fhc_init(node); 117 if (!fhc) 118 return false; 119 node->device = fhc; 120 central_fhc = fhc; 121 } 122 123 /* 124 * The interrupt controller for the interrupt is the FHC itself. 125 */ 126 fhc_enable_interrupt(fhc, interrupt); 127 128 *ino = interrupt; 129 return true; 130 } 131 111 132 /** @} 112 133 */
Note:
See TracChangeset
for help on using the changeset viewer.