Changeset e47ed05 in mainline
- Timestamp:
- 2013-12-27T18:18:13Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f6f22cdb
- Parents:
- 96b9724
- Location:
- kernel
- Files:
-
- 2 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc32/src/machine/leon3/leon3.c
r96b9724 re47ed05 41 41 #include <arch/machine/leon3/leon3.h> 42 42 43 #include <genarch/drivers/grlib _uart/grlib_uart.h>44 #include <genarch/drivers/grlib _irqmp/grlib_irqmp.h>43 #include <genarch/drivers/grlib/uart.h> 44 #include <genarch/drivers/grlib/irqmp.h> 45 45 #include <genarch/srln/srln.h> 46 46 -
kernel/genarch/Makefile.inc
r96b9724 re47ed05 112 112 ifeq ($(CONFIG_GRLIB_UART),y) 113 113 GENARCH_SOURCES += \ 114 genarch/src/drivers/grlib _uart/grlib_uart.c114 genarch/src/drivers/grlib/uart.c 115 115 endif 116 116 117 117 ifeq ($(CONFIG_GRLIB_IRQMP),y) 118 118 GENARCH_SOURCES += \ 119 genarch/src/drivers/grlib _irqmp/grlib_irqmp.c119 genarch/src/drivers/grlib/irqmp.c 120 120 endif 121 121 -
kernel/genarch/include/genarch/drivers/grlib/irqmp.h
r96b9724 re47ed05 41 41 #include <arch.h> 42 42 43 #define GRLIB_IRQMP_MASK_OFFSET 44 #define GRLIB_IRQMP_FORCE_OFFSET0x8043 #define GRLIB_IRQMP_MASK_OFFSET 0x40 44 #define GRLIB_IRQMP_FORCE_OFFSET 0x80 45 45 46 46 /** IRQMP registers */ … … 56 56 /** LEON3 interrupt assignments */ 57 57 enum grlib_irq_source { 58 GRLIB_INT_AHBERROR 59 GRLIB_INT_UART1 60 GRLIB_INT_PCIDMA 61 GRLIB_INT_CAN 62 GRLIB_INT_TIMER0 63 GRLIB_INT_TIMER1 64 GRLIB_INT_TIMER2 65 GRLIB_INT_TIMER3 66 GRLIB_INT_ETHERNET 58 GRLIB_INT_AHBERROR = 1, 59 GRLIB_INT_UART1 = 2, 60 GRLIB_INT_PCIDMA = 4, 61 GRLIB_INT_CAN = 5, 62 GRLIB_INT_TIMER0 = 6, 63 GRLIB_INT_TIMER1 = 7, 64 GRLIB_INT_TIMER2 = 8, 65 GRLIB_INT_TIMER3 = 9, 66 GRLIB_INT_ETHERNET = 14 67 67 }; 68 68 … … 73 73 extern void grlib_irqmp_init(grlib_irqmp_t *, bootinfo_t *); 74 74 extern int grlib_irqmp_inum_get(grlib_irqmp_t *); 75 extern void grlib_irqmp_clear(grlib_irqmp_t *, int);76 extern void grlib_irqmp_mask(grlib_irqmp_t *, int);77 extern void grlib_irqmp_unmask(grlib_irqmp_t *, int);75 extern void grlib_irqmp_clear(grlib_irqmp_t *, unsigned int); 76 extern void grlib_irqmp_mask(grlib_irqmp_t *, unsigned int); 77 extern void grlib_irqmp_unmask(grlib_irqmp_t *, unsigned int); 78 78 79 79 #endif -
kernel/genarch/include/genarch/drivers/grlib/uart.h
r96b9724 re47ed05 97 97 } grlib_uart_t; 98 98 99 extern outdev_t *grlib_uart_init(uintptr_t, inr_t inr);99 extern outdev_t *grlib_uart_init(uintptr_t, inr_t); 100 100 extern void grlib_uart_input_wire(grlib_uart_t *, 101 101 indev_t *); -
kernel/genarch/src/drivers/grlib/irqmp.c
r96b9724 re47ed05 35 35 */ 36 36 37 #include <genarch/drivers/grlib _irqmp/grlib_irqmp.h>37 #include <genarch/drivers/grlib/irqmp.h> 38 38 #include <arch/asm.h> 39 39 #include <mm/km.h> … … 43 43 irqc->regs = (void *) km_map(bootinfo->intc_base, PAGE_SIZE, 44 44 PAGE_NOT_CACHEABLE); 45 46 printf("irqmp regs: %p\n", irqc->regs); 47 45 48 46 /* Mask all interrupts */ 49 pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, 0x8);47 pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, 0x8); 50 48 } 51 49 52 50 int grlib_irqmp_inum_get(grlib_irqmp_t *irqc) 53 51 { 54 int i;55 52 uint32_t pending = pio_read_32(&irqc->regs->pending); 56 57 for ( i = 1; i < 16; i++) {53 54 for (unsigned int i = 1; i < 16; i++) { 58 55 if (pending & (1 << i)) 59 56 return i; 60 57 } 61 58 62 59 return -1; 63 60 } 64 61 65 void grlib_irqmp_clear(grlib_irqmp_t *irqc, int inum)62 void grlib_irqmp_clear(grlib_irqmp_t *irqc, unsigned int inum) 66 63 { 67 64 inum++; … … 69 66 } 70 67 71 void grlib_irqmp_mask(grlib_irqmp_t *irqc, int src)68 void grlib_irqmp_mask(grlib_irqmp_t *irqc, unsigned int src) 72 69 { 73 uint32_t mask = pio_read_32((void *)irqc->regs + GRLIB_IRQMP_MASK_OFFSET); 74 70 uint32_t mask = pio_read_32((void *) irqc->regs + 71 GRLIB_IRQMP_MASK_OFFSET); 72 75 73 src++; 76 74 mask &= ~(1 << src); 77 78 pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, mask);75 76 pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, mask); 79 77 } 80 78 81 void grlib_irqmp_unmask(grlib_irqmp_t *irqc, int src)79 void grlib_irqmp_unmask(grlib_irqmp_t *irqc, unsigned int src) 82 80 { 83 uint32_t mask = pio_read_32((void *)irqc->regs + GRLIB_IRQMP_MASK_OFFSET); 84 81 uint32_t mask = pio_read_32((void *) irqc->regs + 82 GRLIB_IRQMP_MASK_OFFSET); 83 85 84 src++; 86 85 mask |= (1 << src); 87 88 pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, mask);86 87 pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, mask); 89 88 } 90 89 -
kernel/genarch/src/drivers/grlib/uart.c
r96b9724 re47ed05 37 37 */ 38 38 39 #include <genarch/drivers/grlib _uart/grlib_uart.h>39 #include <genarch/drivers/grlib/uart.h> 40 40 #include <console/chardev.h> 41 41 #include <console/console.h> … … 50 50 static void grlib_uart_sendb(outdev_t *dev, uint8_t byte) 51 51 { 52 uint32_t reg;53 52 grlib_uart_status_t *status; 54 grlib_uart_t *uart = 55 (grlib_uart_t *) dev->data; 56 53 grlib_uart_t *uart = (grlib_uart_t *) dev->data; 54 57 55 /* Wait for space becoming available in Tx FIFO. */ 58 56 do { 59 reg = pio_read_32(&uart->io->status);60 status = (grlib_uart_status_t *) ®57 uint32_t reg = pio_read_32(&uart->io->status); 58 status = (grlib_uart_status_t *) ® 61 59 } while (status->tf != 0); 62 60 63 61 pio_write_32(&uart->io->data, byte); 64 62 } … … 66 64 static void grlib_uart_putchar(outdev_t *dev, wchar_t ch) 67 65 { 68 grlib_uart_t *uart = 69 (grlib_uart_t *) dev->data; 66 grlib_uart_t *uart = (grlib_uart_t *) dev->data; 70 67 71 68 if ((!uart->parea.mapped) || (console_override)) { … … 75 72 if (ch == '\n') 76 73 grlib_uart_sendb(dev, (uint8_t) '\r'); 74 77 75 grlib_uart_sendb(dev, (uint8_t) ch); 78 76 } … … 87 85 static void grlib_uart_irq_handler(irq_t *irq) 88 86 { 89 uint32_t reg;90 87 grlib_uart_t *uart = irq->instance; 91 grlib_uart_status_t *status; 92 93 reg = pio_read_32(&uart->io->status); 94 status = (grlib_uart_status_t *)® 95 88 89 uint32_t reg = pio_read_32(&uart->io->status); 90 grlib_uart_status_t *status = (grlib_uart_status_t *) ® 91 96 92 while (status->dr != 0) { 97 93 uint32_t data = pio_read_32(&uart->io->data); 98 94 reg = pio_read_32(&uart->io->status); 99 status = (grlib_uart_status_t *) ®95 status = (grlib_uart_status_t *) ® 100 96 indev_push_character(uart->indev, data & 0xff); 101 97 } … … 109 105 outdev_t *grlib_uart_init(uintptr_t paddr, inr_t inr) 110 106 { 111 printf("grlib_uart_init: paddr=0x%08x\n", paddr);112 113 107 outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC); 114 108 if (!uart_dev) 115 109 return NULL; 116 117 grlib_uart_t *uart = 118 malloc(sizeof(grlib_uart_t), FRAME_ATOMIC); 110 111 grlib_uart_t *uart = malloc(sizeof(grlib_uart_t), FRAME_ATOMIC); 119 112 if (!uart) { 120 113 free(uart_dev); 121 114 return NULL; 122 115 } 123 116 124 117 outdev_initialize("grlib_uart_dev", uart_dev, &grlib_uart_ops); 125 118 uart_dev->data = uart; 126 119 127 120 uart->io = (grlib_uart_io_t *) km_map(paddr, PAGE_SIZE, 128 121 PAGE_WRITE | PAGE_NOT_CACHEABLE); 129 122 uart->indev = NULL; 130 123 131 124 /* Initialize IRQ structure. */ 132 125 irq_initialize(&uart->irq); … … 136 129 uart->irq.handler = grlib_uart_irq_handler; 137 130 uart->irq.instance = uart; 138 131 139 132 /* Enable FIFO, Tx trigger level: empty, Rx trigger level: 1 byte. */ 140 grlib_uart_control_t control = 141 { .fa = 1, .rf = 1, .tf = 1, .ri = 1, 142 .te = 1, .re = 1}; 143 144 uint32_t *reg = (uint32_t *)&control; 133 grlib_uart_control_t control = { 134 .fa = 1, 135 .rf = 1, 136 .tf = 1, 137 .ri = 1, 138 .te = 1, 139 .re = 1 140 }; 141 142 uint32_t *reg = (uint32_t *) &control; 145 143 pio_write_32(&uart->io->control, *reg); 146 144 147 145 link_initialize(&uart->parea.link); 148 146 uart->parea.pbase = paddr; … … 159 157 ASSERT(uart); 160 158 ASSERT(indev); 161 159 162 160 uart->indev = indev; 163 161 irq_register(&uart->irq);
Note:
See TracChangeset
for help on using the changeset viewer.