Changeset e47ed05 in mainline


Ignore:
Timestamp:
2013-12-27T18:18:13Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f6f22cdb
Parents:
96b9724
Message:

code review
coding style changes, removal of debugging prints
simplify directory structure

Location:
kernel
Files:
2 edited
4 moved

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc32/src/machine/leon3/leon3.c

    r96b9724 re47ed05  
    4141#include <arch/machine/leon3/leon3.h>
    4242
    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>
    4545#include <genarch/srln/srln.h>
    4646
  • kernel/genarch/Makefile.inc

    r96b9724 re47ed05  
    112112ifeq ($(CONFIG_GRLIB_UART),y)
    113113        GENARCH_SOURCES += \
    114                 genarch/src/drivers/grlib_uart/grlib_uart.c
     114                genarch/src/drivers/grlib/uart.c
    115115endif
    116116
    117117ifeq ($(CONFIG_GRLIB_IRQMP),y)
    118118        GENARCH_SOURCES += \
    119                 genarch/src/drivers/grlib_irqmp/grlib_irqmp.c
     119                genarch/src/drivers/grlib/irqmp.c
    120120endif
    121121
  • kernel/genarch/include/genarch/drivers/grlib/irqmp.h

    r96b9724 re47ed05  
    4141#include <arch.h>
    4242
    43 #define GRLIB_IRQMP_MASK_OFFSET         0x40
    44 #define GRLIB_IRQMP_FORCE_OFFSET        0x80
     43#define GRLIB_IRQMP_MASK_OFFSET   0x40
     44#define GRLIB_IRQMP_FORCE_OFFSET  0x80
    4545
    4646/** IRQMP registers */
     
    5656/** LEON3 interrupt assignments */
    5757enum grlib_irq_source {
    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
     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
    6767};
    6868
     
    7373extern void grlib_irqmp_init(grlib_irqmp_t *, bootinfo_t *);
    7474extern 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);
     75extern void grlib_irqmp_clear(grlib_irqmp_t *, unsigned int);
     76extern void grlib_irqmp_mask(grlib_irqmp_t *, unsigned int);
     77extern void grlib_irqmp_unmask(grlib_irqmp_t *, unsigned int);
    7878
    7979#endif
  • kernel/genarch/include/genarch/drivers/grlib/uart.h

    r96b9724 re47ed05  
    9797} grlib_uart_t;
    9898
    99 extern outdev_t *grlib_uart_init(uintptr_t, inr_t inr);
     99extern outdev_t *grlib_uart_init(uintptr_t, inr_t);
    100100extern void grlib_uart_input_wire(grlib_uart_t *,
    101101    indev_t *);
  • kernel/genarch/src/drivers/grlib/irqmp.c

    r96b9724 re47ed05  
    3535 */
    3636
    37 #include <genarch/drivers/grlib_irqmp/grlib_irqmp.h>
     37#include <genarch/drivers/grlib/irqmp.h>
    3838#include <arch/asm.h>
    3939#include <mm/km.h>
     
    4343        irqc->regs = (void *) km_map(bootinfo->intc_base, PAGE_SIZE,
    4444            PAGE_NOT_CACHEABLE);
    45 
    46         printf("irqmp regs: %p\n", irqc->regs);
    47 
     45       
    4846        /* 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);
    5048}
    5149
    5250int grlib_irqmp_inum_get(grlib_irqmp_t *irqc)
    5351{
    54         int i;
    5552        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++) {
    5855                if (pending & (1 << i))
    5956                        return i;
    6057        }
    61 
     58       
    6259        return -1;
    6360}
    6461
    65 void grlib_irqmp_clear(grlib_irqmp_t *irqc, int inum)
     62void grlib_irqmp_clear(grlib_irqmp_t *irqc, unsigned int inum)
    6663{
    6764        inum++;
     
    6966}
    7067
    71 void grlib_irqmp_mask(grlib_irqmp_t *irqc, int src)
     68void grlib_irqmp_mask(grlib_irqmp_t *irqc, unsigned int src)
    7269{
    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       
    7573        src++;
    7674        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);
    7977}
    8078
    81 void grlib_irqmp_unmask(grlib_irqmp_t *irqc, int src)
     79void grlib_irqmp_unmask(grlib_irqmp_t *irqc, unsigned int src)
    8280{
    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       
    8584        src++;
    8685        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);
    8988}
    9089
  • kernel/genarch/src/drivers/grlib/uart.c

    r96b9724 re47ed05  
    3737 */
    3838
    39 #include <genarch/drivers/grlib_uart/grlib_uart.h>
     39#include <genarch/drivers/grlib/uart.h>
    4040#include <console/chardev.h>
    4141#include <console/console.h>
     
    5050static void grlib_uart_sendb(outdev_t *dev, uint8_t byte)
    5151{
    52         uint32_t reg;
    5352        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       
    5755        /* Wait for space becoming available in Tx FIFO. */
    5856        do {
    59                 reg = pio_read_32(&uart->io->status);
    60                 status = (grlib_uart_status_t *)&reg;
     57                uint32_t reg = pio_read_32(&uart->io->status);
     58                status = (grlib_uart_status_t *) &reg;
    6159        } while (status->tf != 0);
    62 
     60       
    6361        pio_write_32(&uart->io->data, byte);
    6462}
     
    6664static void grlib_uart_putchar(outdev_t *dev, wchar_t ch)
    6765{
    68         grlib_uart_t *uart =
    69             (grlib_uart_t *) dev->data;
     66        grlib_uart_t *uart = (grlib_uart_t *) dev->data;
    7067       
    7168        if ((!uart->parea.mapped) || (console_override)) {
     
    7572                        if (ch == '\n')
    7673                                grlib_uart_sendb(dev, (uint8_t) '\r');
     74                       
    7775                        grlib_uart_sendb(dev, (uint8_t) ch);
    7876                }
     
    8785static void grlib_uart_irq_handler(irq_t *irq)
    8886{
    89         uint32_t reg;
    9087        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 *)&reg;
    95 
     88       
     89        uint32_t reg = pio_read_32(&uart->io->status);
     90        grlib_uart_status_t *status = (grlib_uart_status_t *) &reg;
     91       
    9692        while (status->dr != 0) {
    9793                uint32_t data = pio_read_32(&uart->io->data);
    9894                reg = pio_read_32(&uart->io->status);
    99                 status = (grlib_uart_status_t *)&reg;
     95                status = (grlib_uart_status_t *) &reg;
    10096                indev_push_character(uart->indev, data & 0xff);
    10197        }
     
    109105outdev_t *grlib_uart_init(uintptr_t paddr, inr_t inr)
    110106{
    111         printf("grlib_uart_init: paddr=0x%08x\n", paddr);
    112 
    113107        outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
    114108        if (!uart_dev)
    115109                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);
    119112        if (!uart) {
    120113                free(uart_dev);
    121114                return NULL;
    122115        }
    123 
     116       
    124117        outdev_initialize("grlib_uart_dev", uart_dev, &grlib_uart_ops);
    125118        uart_dev->data = uart;
    126 
     119       
    127120        uart->io = (grlib_uart_io_t *) km_map(paddr, PAGE_SIZE,
    128121            PAGE_WRITE | PAGE_NOT_CACHEABLE);
    129122        uart->indev = NULL;
    130 
     123       
    131124        /* Initialize IRQ structure. */
    132125        irq_initialize(&uart->irq);
     
    136129        uart->irq.handler = grlib_uart_irq_handler;
    137130        uart->irq.instance = uart;
    138 
     131       
    139132        /* 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;
    145143        pio_write_32(&uart->io->control, *reg);
    146 
     144       
    147145        link_initialize(&uart->parea.link);
    148146        uart->parea.pbase = paddr;
     
    159157        ASSERT(uart);
    160158        ASSERT(indev);
    161 
     159       
    162160        uart->indev = indev;
    163161        irq_register(&uart->irq);
Note: See TracChangeset for help on using the changeset viewer.