[platform][realview-pb] first stab at working Realview Explore board

This target seems to be the best one to target for generic arm support
on current stock qemu builds.
This commit is contained in:
Travis Geiselbrecht
2012-12-30 17:57:06 -08:00
parent a9d6d42a99
commit d62c6977c4
10 changed files with 484 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2008-2012 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdarg.h>
#include <reg.h>
#include <printf.h>
#include <kernel/thread.h>
#include <platform/debug.h>
#include <platform/realview-pb.h>
#include <reg.h>
#define UART0 (0x10009000)
#define DR (0x00)
#define FR (0x18)
#define UARTREG(reg) (*REG32(UART0 + (reg)))
void platform_dputc(char c)
{
UARTREG(DR) = c;
}
int platform_dgetc(char *c, bool wait)
{
if (!wait) {
if (UARTREG(FR) & (1<<4)) {
/* fifo empty */
return -1;
}
*c = UARTREG(DR) & 0xff;
return 0;
} else {
while ((UARTREG(FR) & (1<<4))) {
// XXX actually block on interrupt
thread_yield();
}
*c = UARTREG(DR) & 0xff;
return 0;
}
}
void platform_halt(void)
{
arch_disable_ints();
for (;;);
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2012 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __REALVIEW_PB_H
#define __REALVIEW_PB_H
#include <reg.h>
/* hardware base addresses */
#define UART0 (0x10009000)
#define UART1 (0x1000a000)
#define UART2 (0x1000b000)
#define UART3 (0x1000c000)
#define TIMER0 (0x10011000)
#define TIMER1 (0x10011020)
#define TIMER2 (0x10012000)
#define TIMER3 (0x10012020)
#define TIMER4 (0x10018000)
#define TIMER5 (0x10018020)
#define TIMER6 (0x10019000)
#define TIMER7 (0x10019020)
#define GIC1 (0x1e000000)
#define GIC2 (0x1e010000)
#define GIC3 (0x1e020000)
#define GIC4 (0x1e030000)
#endif

View File

@@ -0,0 +1,135 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <err.h>
#include <sys/types.h>
#include <debug.h>
#include <reg.h>
#include <kernel/thread.h>
#include <kernel/debug.h>
#include <platform/interrupts.h>
#include <arch/ops.h>
#include <arch/arm.h>
#include "platform_p.h"
struct int_handler_struct {
int_handler handler;
void *arg;
};
//static struct int_handler_struct int_handler_table[PIC_MAX_INT];
void platform_init_interrupts(void)
{
// mask all the interrupts
// *REG32(PIC_MASK_LATCH) = 0xffffffff;
}
status_t mask_interrupt(unsigned int vector)
{
#if 0
if (vector >= PIC_MAX_INT)
return ERR_INVALID_ARGS;
// dprintf("%s: vector %d\n", __PRETTY_FUNCTION__, vector);
enter_critical_section();
*REG32(PIC_MASK_LATCH) = 1 << vector;
exit_critical_section();
#endif
PANIC_UNIMPLEMENTED;
return NO_ERROR;
}
status_t unmask_interrupt(unsigned int vector)
{
#if 0
if (vector >= PIC_MAX_INT)
return ERR_INVALID_ARGS;
// dprintf("%s: vector %d\n", __PRETTY_FUNCTION__, vector);
enter_critical_section();
*REG32(PIC_UNMASK_LATCH) = 1 << vector;
exit_critical_section();
#endif
PANIC_UNIMPLEMENTED;
return NO_ERROR;
}
enum handler_return platform_irq(struct arm_iframe *frame)
{
#if 0
// get the current vector
unsigned int vector = *REG32(PIC_CURRENT_NUM);
if (vector == 0xffffffff)
return INT_NO_RESCHEDULE;
THREAD_STATS_INC(interrupts);
KEVLOG_IRQ_ENTER(vector);
// printf("platform_irq: spsr 0x%x, pc 0x%x, currthread %p, vector %d\n", frame->spsr, frame->pc, current_thread, vector);
// deliver the interrupt
enum handler_return ret;
ret = INT_NO_RESCHEDULE;
if (int_handler_table[vector].handler)
ret = int_handler_table[vector].handler(int_handler_table[vector].arg);
// dprintf("platform_irq: exit %d\n", ret);
KEVLOG_IRQ_EXIT(vector);
return ret;
#endif
PANIC_UNIMPLEMENTED;
}
void platform_fiq(struct arm_iframe *frame)
{
PANIC_UNIMPLEMENTED;
}
void register_int_handler(unsigned int vector, int_handler handler, void *arg)
{
panic("FIQ: unimplemented\n");
#if 0
if (vector >= PIC_MAX_INT)
panic("register_int_handler: vector out of range %d\n", vector);
enter_critical_section();
int_handler_table[vector].handler = handler;
int_handler_table[vector].arg = arg;
exit_critical_section();
#endif
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2012 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <err.h>
#include <debug.h>
#include <platform.h>
#include "platform_p.h"
void platform_init_mmu_mappings(void)
{
}
void platform_early_init(void)
{
/* initialize the interrupt controller */
platform_init_interrupts();
/* initialize the timer block */
platform_init_timer();
}
void platform_init(void)
{
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2012 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __PLATFORM_P_H
#define __PLATFORM_P_H
void platform_init_interrupts(void);
void platform_init_timer(void);
#endif

View File

@@ -0,0 +1,27 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
MODULE := $(LOCAL_DIR)
ARCH := arm
ARM_CPU := cortex-a8
INCLUDES += \
-I$(LOCAL_DIR)/include
MODULE_SRCS += \
$(LOCAL_DIR)/debug.c \
$(LOCAL_DIR)/interrupts.c \
$(LOCAL_DIR)/platform.c \
$(LOCAL_DIR)/timer.c
MEMBASE := 0x0
MEMSIZE := 0x10000000 # 256MB
DEFINES += \
MEMBASE=$(MEMBASE) \
MEMSIZE=$(MEMSIZE)
LINKER_SCRIPT += \
$(BUILDDIR)/system-onesegment.ld
include make/module.mk

View File

@@ -0,0 +1,101 @@
/*
* Copyright (c) 2008-2012 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <sys/types.h>
#include <err.h>
#include <kernel/thread.h>
#include <platform.h>
#include <platform/interrupts.h>
#include <platform/timer.h>
#include <platform/realview-pb.h>
#include "platform_p.h"
static platform_timer_callback t_callback;
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, lk_time_t interval)
{
// PANIC_UNIMPLEMENTED;
#if 0
enter_critical_section();
t_callback = callback;
*REG(PIT_CLEAR) = 1;
*REG(PIT_INTERVAL) = interval;
*REG(PIT_START_PERIODIC) = 1;
unmask_interrupt(INT_PIT);
exit_critical_section();
#endif
return NO_ERROR;
}
lk_bigtime_t current_time_hires(void)
{
// PANIC_UNIMPLEMENTED;
#if 0
lk_bigtime_t time;
*REG(SYSINFO_TIME_LATCH) = 1;
time = *REG(SYSINFO_TIME_SECS) * 1000000ULL;
time += *REG(SYSINFO_TIME_USECS);
return time;
#endif
return 0;
}
lk_time_t current_time(void)
{
// PANIC_UNIMPLEMENTED;
#if 0
lk_time_t time;
*REG(SYSINFO_TIME_LATCH) = 1;
time = *REG(SYSINFO_TIME_SECS) * 1000;
time += *REG(SYSINFO_TIME_USECS) / 1000;
return time;
#endif
return 0;
}
static enum handler_return platform_tick(void *arg)
{
PANIC_UNIMPLEMENTED;
#if 0
*REG(PIT_CLEAR_INT) = 1;
if (t_callback) {
return t_callback(arg, current_time());
} else {
return INT_NO_RESCHEDULE;
}
#endif
PANIC_UNIMPLEMENTED;
}
void platform_init_timer(void)
{
// register_int_handler(INT_PIT, &platform_tick, NULL);
}

View File

@@ -0,0 +1,12 @@
# top level project rules for the armemu-test project
#
LOCAL_DIR := $(GET_LOCAL_DIR)
TARGET := realview-pb
MODULES += \
app/tests \
app/stringtests \
app/shell

4
scripts/do-qemuarm Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
make realview-pb-test -j4 &&
qemu-system-arm -machine realview-pb-a8 -kernel build-realview-pb-test/lk -nographic $@

View File

@@ -0,0 +1,15 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
#MODULE := $(LOCAL_DIR)
INCLUDES += \
-I$(LOCAL_DIR)/include
PLATFORM := realview-pb
MODULES += \
DEFINES += \
#include make/module.mk