Fork us on GitHub Follow us on Facebook Follow us on Twitter

Ticket #523: helenos_clean_against_1771.patch

File helenos_clean_against_1771.patch, 14.9 KB (added by Roc Vallès, 6 years ago)

Very basic (boot+uart write) support for the raspberry pi platform.

  • HelenOS.config

    === modified file 'HelenOS.config'
     
    6565@ "integratorcp" Integratorcp
    6666@ "beagleboardxm" BeagleBoard-xM
    6767@ "beaglebone" BeagleBone
     68@ "raspberrypi" RaspberryPi
    6869! [PLATFORM=arm32] MACHINE (choice)
    6970
    7071% CPU type
     
    9899@ "arm926ej_s" ARM926EJ-S
    99100! [PLATFORM=arm32&MACHINE=integratorcp] PROCESSOR (choice)
    100101
     102% CPU type
     103@ "arm1176jzf_s" ARM1176JZF-S
     104! [PLATFORM=arm32&MACHINE=raspberrypi] PROCESSOR (choice)
    101105
    102106# Add more ARMv4 CPUs
    103107% CPU arch
     
    109113@ "armv5" ARMv5
    110114! [PLATFORM=arm32&(PROCESSOR=arm926ej_s)] PROCESSOR_ARCH (choice)
    111115
     116# Add more ARMv6 CPUs
     117% CPU type
     118@ "armv6" ARMv6
     119! [PLATFORM=arm32&(PROCESSOR=arm1176jzf_s)] PROCESSOR_ARCH (choice)
     120
    112121# Add more ARMv7-A CPUs
    113122% CPU arch
    114123@ "armv7_a" ARMv7-A
     
    482491% Support for ARM926 on-chip UART
    483492! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=integratorcp] CONFIG_ARM926_UART (y/n)
    484493
     494% Support for BCM2835 on-chip UART
     495! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=raspberrypi] CONFIG_BCM2835_UART (y/n)
     496
    485497% Support for Samsung S3C24XX on-chip UART
    486498! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=gta02] CONFIG_S3C24XX_UART (y/n)
    487499
  • boot/arch/arm32/include/arch.h

    === modified file 'boot/arch/arm32/include/arch.h'
     
    4545#define BOOT_BASE       0x80000000
    4646#elif defined MACHINE_beaglebone
    4747#define BOOT_BASE       0x80000000
     48#elif defined MACHINE_raspberrypi
     49#define BOOT_BASE       0x80008000
    4850#else
    4951#define BOOT_BASE       0x00000000
    5052#endif
     
    5557        #define PA_OFFSET 0
    5658#elif defined MACHINE_beaglebone
    5759        #define PA_OFFSET 0
     60#elif defined MACHINE_raspberrypi
     61        #define PA_OFFSET 0
    5862#else
    5963        #define PA_OFFSET 0x80000000
    6064#endif
  • boot/arch/arm32/src/main.c

    === modified file 'boot/arch/arm32/src/main.c'
     
    139139                        halt();
    140140                }
    141141               
    142                 printf("%s ", components[i - 1].name);
     142                printf("%s@%p  ", components[i - 1].name, dest[i - 1]);
    143143               
    144144                int err = inflate(components[i - 1].start, components[i - 1].size,
    145145                    dest[i - 1], components[i - 1].inflated);
     
    151151        }
    152152       
    153153        printf(".\n");
    154        
    155         printf("Booting the kernel...\n");
    156         jump_to_kernel((void *) PA2KA(BOOT_OFFSET), &bootinfo);
     154        void *entry;
     155        entry = (void *) PA2KA(BOOT_OFFSET);
     156        printf("Booting the kernel at %p...",entry);
     157        jump_to_kernel(entry, &bootinfo);
    157158}
    158159
    159160/** @}
  • boot/arch/arm32/src/putchar.c

    === modified file 'boot/arch/arm32/src/putchar.c'
     
    121121
    122122#endif
    123123
     124#ifdef MACHINE_raspberrypi
     125
     126static void scons_sendb_rpi(uint8_t byte)
     127{
     128        /* Wait for the uart to be ready */
     129        while (*((volatile uint8_t *) 0x20201018) & (1 << 5));
     130        /* Send the byte */
     131        *((volatile uint8_t *) 0x20201000) = byte;
     132}
     133
     134#endif
     135
    124136/** Send a byte to the serial console.
    125137 *
    126138 * @param byte          Byte to send.
     
    139151#ifdef MACHINE_integratorcp
    140152        scons_sendb_icp(byte);
    141153#endif
     154#ifdef MACHINE_raspberrypi
     155        scons_sendb_rpi(byte);
     156#endif
    142157}
    143158
    144159/** Display a character
  • kernel/arch/arm32/Makefile.inc

    === modified file 'kernel/arch/arm32/Makefile.inc'
     
    8080        ARCH_SOURCES += arch/$(KARCH)/src/mach/integratorcp/integratorcp.c
    8181endif
    8282
     83ifeq ($(MACHINE),raspberrypi)
     84        ARCH_SOURCES += arch/$(KARCH)/src/mach/raspberrypi/raspberrypi.c
     85endif
     86
    8387ifeq ($(MACHINE),beagleboardxm)
    8488        ARCH_SOURCES += arch/$(KARCH)/src/mach/beagleboardxm/beagleboardxm.c
    8589endif
  • kernel/arch/arm32/_link.ld.in

    === modified file 'kernel/arch/arm32/_link.ld.in'
     
    1212#define KERNEL_LOAD_ADDRESS 0x80a00000
    1313#elif defined MACHINE_beaglebone
    1414#define KERNEL_LOAD_ADDRESS 0x80a00000
     15#elif defined MACHINE_raspberrypi
     16#define KERNEL_LOAD_ADDRESS 0x80a08000
    1517#else
    1618#define KERNEL_LOAD_ADDRESS 0x80a00000
    1719#endif
  • kernel/arch/arm32/include/arch/cp15.h

    === modified file 'kernel/arch/arm32/include/arch/cp15.h'
     
    222222        SCTLR_USPCE_WRITE_XN_EN_FLAG = 1 << 20, /* Only if virt. supported */
    223223        SCTLR_FAST_IRQ_EN_FLAG       = 1 << 21, /* Disable impl. specific feat*/
    224224        SCTLR_UNALIGNED_EN_FLAG      = 1 << 22, /* Must be 1 on armv7 */
     225        SCTLR_SUBPAGE_AP_FLAG        = 1 << 23, /* ARMv6 only. Must be 1 for ARMv7-style 2nd level pagetables. */
    225226        SCTLR_IRQ_VECTORS_EN_FLAG    = 1 << 24,
    226227        SCTLR_BIG_ENDIAN_EXC_FLAG    = 1 << 25,
    227228        SCTLR_NMFI_EN_FLAG           = 1 << 27,
  • kernel/arch/arm32/include/arch/mach/raspberrypi/raspberrypi.h

    === added directory 'kernel/arch/arm32/include/arch/mach/raspberrypi'
    === added file 'kernel/arch/arm32/include/arch/mach/raspberrypi/raspberrypi.h'
     
     1#include <arch/machine_func.h>
     2extern struct arm_machine_ops rpi_machine_ops;
     3
     4extern void rpi_init(void);
     5extern void rpi_output_init(void);
     6extern void rpi_input_init(void);
     7extern void rpi_timer_irq_start(void);
     8extern void rpi_cpu_halt(void);
     9extern void rpi_irq_exception(unsigned int, istate_t *);
     10extern void rpi_get_memory_extents(uintptr_t *, size_t *);
     11extern void rpi_frame_init(void);
     12extern size_t rpi_get_irq_count(void);
     13extern const char *rpi_get_platform_name(void);
     14 No newline at end of file
  • kernel/arch/arm32/include/arch/mm/frame.h

    === modified file 'kernel/arch/arm32/include/arch/mm/frame.h'
     
    6060#define PHYSMEM_START_ADDR       0x80000000
    6161#define BOOT_PAGE_TABLE_ADDRESS  0x80008000
    6262
     63#elif defined MACHINE_raspberrypi
     64
     65#define PHYSMEM_START_ADDR       0x80000000
     66#define BOOT_PAGE_TABLE_ADDRESS  0x80010000
     67
    6368#else
    6469
    6570#define PHYSMEM_START_ADDR       0x00000000
  • kernel/arch/arm32/include/arch/mm/page.h

    === modified file 'kernel/arch/arm32/include/arch/mm/page.h'
     
    4545#define PAGE_WIDTH      FRAME_WIDTH
    4646#define PAGE_SIZE       FRAME_SIZE
    4747
    48 #if (defined MACHINE_beagleboardxm) || (defined MACHINE_beaglebone)
     48#if (defined MACHINE_beagleboardxm) || (defined MACHINE_beaglebone) || (defined MACHINE_raspberrypi)
    4949#ifndef __ASM__
    5050#       define KA2PA(x) ((uintptr_t) (x))
    5151#       define PA2KA(x) ((uintptr_t) (x))
  • kernel/arch/arm32/src/arm32.c

    === modified file 'kernel/arch/arm32/src/arm32.c'
     
    4949#include <str.h>
    5050#include <arch/ras.h>
    5151#include <sysinfo/sysinfo.h>
     52#include <arch/cp15.h>
    5253
    5354/** Performs arm32-specific initialization before main_bsp() is called. */
    5455void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo)
     
    7273{
    7374        /* It is not assumed by default */
    7475        interrupts_disable();
     76#ifdef PROCESSOR_ARCH_armv6
     77        uint32_t control_reg = SCTLR_read();
     78        control_reg |= SCTLR_SUBPAGE_AP_FLAG; //ARMv6+ subpage table format
     79        SCTLR_write(control_reg);
     80#endif
    7581}
    7682
    77 /** Performs arm32 specific initialization afterr mm is initialized. */
     83/** Performs arm32 specific initialization after mm is initialized. */
    7884void arch_post_mm_init(void)
    7985{
    8086        machine_init();
  • kernel/arch/arm32/src/mach/raspberrypi/raspberrypi.c

    === added directory 'kernel/arch/arm32/src/mach/raspberrypi'
    === added file 'kernel/arch/arm32/src/mach/raspberrypi/raspberrypi.c'
     
     1#include <arch/mach/raspberrypi/raspberrypi.h>
     2#include <genarch/drivers/bcm2835_uart/bcm2835_uart.h>
     3#include <mm/frame.h>
     4
     5struct arm_machine_ops rpi_machine_ops = {
     6        rpi_init,
     7        rpi_timer_irq_start,
     8        rpi_cpu_halt,
     9        rpi_get_memory_extents,
     10        rpi_irq_exception,
     11        rpi_frame_init,
     12        rpi_output_init,
     13        rpi_input_init,
     14        rpi_get_irq_count,
     15        rpi_get_platform_name
     16};
     17
     18static struct {
     19        bcm2835_uart_t uart;
     20} rpi;
     21
     22void rpi_init(void)
     23{
     24        //*((int *)(0x20200028)) = 1<<16;
     25}
     26
     27void rpi_timer_irq_start(void)
     28{
     29}
     30
     31void rpi_cpu_halt(void)
     32{
     33        while(1);
     34}
     35
     36void rpi_get_memory_extents(uintptr_t *start, size_t *size)
     37{
     38        *start=PHYSMEM_START_ADDR;
     39        *size=0x08000000; //128MB FIXME: should likely depend on RAM reserved for GPU use.
     40}
     41
     42// FIXME: Handles interrupts.
     43void rpi_irq_exception(unsigned int exc_no, istate_t *istate)
     44{
     45}
     46
     47//?
     48void rpi_frame_init(void)
     49{
     50        frame_mark_unavailable(0x80000, 8);
     51}
     52
     53void rpi_output_init(void)
     54{
     55          if (bcm2835_uart_init(&rpi.uart, 0,
     56            0, sizeof(bcm2835_uart_regs_t)))
     57                stdout_wire(&rpi.uart.outdev);
     58}
     59
     60void rpi_input_init(void)
     61{
     62}
     63
     64size_t rpi_get_irq_count(void)
     65{
     66        return 0;
     67}
     68
     69const char *rpi_get_platform_name(void)
     70{
     71        return "raspberrypi";
     72}
     73 No newline at end of file
  • kernel/arch/arm32/src/machine_func.c

    === modified file 'kernel/arch/arm32/src/machine_func.c'
     
    4242#include <arch/mach/integratorcp/integratorcp.h>
    4343#include <arch/mach/beagleboardxm/beagleboardxm.h>
    4444#include <arch/mach/beaglebone/beaglebone.h>
     45#include <arch/mach/raspberrypi/raspberrypi.h>
    4546
    4647/** Pointer to machine_ops structure being used. */
    4748struct arm_machine_ops *machine_ops;
     
    5758        machine_ops = &bbxm_machine_ops;
    5859#elif defined(MACHINE_beaglebone)
    5960        machine_ops = &bbone_machine_ops;
     61#elif defined(MACHINE_raspberrypi)
     62        machine_ops = &rpi_machine_ops;
    6063#else
    6164#error Machine type not defined.
    6265#endif
  • kernel/genarch/Makefile.inc

    === modified file 'kernel/genarch/Makefile.inc'
     
    9595                genarch/src/drivers/arm926_uart/arm926_uart.c
    9696endif
    9797
     98ifeq ($(CONFIG_BCM2835_UART),y)
     99        GENARCH_SOURCES += \
     100                genarch/src/drivers/bcm2835_uart/bcm2835_uart.c
     101endif
     102
    98103ifeq ($(CONFIG_S3C24XX_IRQC),y)
    99104        GENARCH_SOURCES += \
    100105                genarch/src/drivers/s3c24xx_irqc/s3c24xx_irqc.c
  • kernel/genarch/include/genarch/drivers/bcm2835_uart/bcm2835_uart.h

    === added directory 'kernel/genarch/include/genarch/drivers/bcm2835_uart'
    === added file 'kernel/genarch/include/genarch/drivers/bcm2835_uart/bcm2835_uart.h'
     
     1/** @addtogroup genarch
     2 * @{
     3 */
     4/**
     5 * @file
     6 * @brief BCM2835 on-chip UART driver.
     7 */
     8
     9#ifndef KERN_BCM2835_UART_H_
     10#define KERN_BCM2836_UART_H_
     11
     12#include <ddi/irq.h>
     13#include <console/chardev.h>
     14#include <typedefs.h>
     15
     16#define BCM2835_UART0_BASE_ADDRESS   0x20201000
     17
     18/** ARM926 User Guide ch. A.1 (p. 124 in the pdf) */
     19/*#define ARM926_UART0_IRQ   1
     20#define ARM926_UART1_IRQ   2*/
     21
     22/** PrimeCell UART TRM ch. 3.3 (p. 49 in the pdf) */
     23typedef struct {
     24} bcm2835_uart_regs_t;
     25
     26typedef struct {
     27        //bcm2835_uart_regs_t *regs;
     28        volatile ioport8_t *regs;
     29        indev_t *indev;
     30        outdev_t outdev;
     31        irq_t irq;
     32} bcm2835_uart_t;
     33
     34bool bcm2835_uart_init(bcm2835_uart_t *, inr_t, uintptr_t, size_t);
     35void bcm2835_uart_input_wire(bcm2835_uart_t *, indev_t *);
     36
     37#endif
     38/**
     39 * @}
     40 */
  • kernel/genarch/src/drivers/bcm2835_uart/bcm2835_uart.c

    === added directory 'kernel/genarch/src/drivers/bcm2835_uart'
    === added file 'kernel/genarch/src/drivers/bcm2835_uart/bcm2835_uart.c'
     
     1/*
     2 * Copyright (c) 2012 Jan Vesely
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/** @addtogroup genarch
     30 * @{
     31 */
     32/**
     33 * @file
     34 * @brief ARM926 on-chip UART (PrimeCell UART, PL011) driver.
     35 */
     36
     37#include <genarch/drivers/bcm2835_uart/bcm2835_uart.h>
     38#include <console/chardev.h>
     39#include <console/console.h>
     40#include <ddi/device.h>
     41#include <arch/asm.h>
     42#include <mm/slab.h>
     43#include <mm/page.h>
     44#include <mm/km.h>
     45#include <sysinfo/sysinfo.h>
     46#include <str.h>
     47#include <../../ia64/include/arch/register.h>
     48
     49static volatile ioport8_t *ugly;
     50
     51static void bcm2835_uart_putchar(outdev_t *dev, wchar_t ch)
     52{
     53        bcm2835_uart_t *uart = dev->data;
     54        //volatile ioport8_t *regs = (void*)km_map(0x20201000, PAGE_SIZE, PAGE_READ | PAGE_WRITE | PAGE_NOT_CACHEABLE);
     55        //bcm2835_uart_t *uart = dev->data;
     56        /* Wait for the uart to be ready */
     57        while (pio_read_8(ugly) & (1 << 5));
     58        //while (*((volatile uint8_t *) 0x20201018) & (1 << 5));
     59        //while ((pio_read_8((ioport8_t*) 0x20201018)) & (1 << 5));
     60        /* Send the byte */
     61        pio_write_8((uint8_t *) uart->regs, ch);
     62        //pio_write_8((uint8_t *) 0x20201000, ch);
     63        //*((volatile uint8_t *) 0x20201000) = ch;
     64}
     65
     66static outdev_operations_t bcm2835_uart_ops = {
     67        .write = bcm2835_uart_putchar,
     68        .redraw = NULL,
     69};
     70
     71bool bcm2835_uart_init(
     72    bcm2835_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size)
     73{
     74        outdev_initialize("bcm2835_uart_dev", &uart->outdev, &bcm2835_uart_ops);
     75        uart->outdev.data = uart;
     76        uart->regs = (void*)km_map(0xA0201000, PAGE_SIZE, PAGE_NOT_CACHEABLE);
     77        ugly = (volatile ioport8_t *) km_map(0xA0201018, PAGE_SIZE, PAGE_NOT_CACHEABLE);
     78        return true;
     79}
     80
     81void bcm2835_uart_input_wire(bcm2835_uart_t *uart, indev_t *indev)
     82{
     83}
     84
     85/** @}
     86 */
     87