[MAJOR] Added platform-dependent functions table
Added table, which contains platform-dependent code. All platform-dependent functions must be called by using this table. There are no difference between kernels for any ARM platform. There are the only one kernel for any ARM platform.
This commit is contained in:
@@ -10,7 +10,8 @@ CPPFLAGS.subr_prf.c+= -Dputchar=kputc
|
||||
# Activate optional support, may be deactivated.
|
||||
CPPFLAGS.subr_prf.c+= -DLIBSA_PRINTF_LONGLONG_SUPPORT -DLIBSA_PRINTF_WIDTH_SUPPORT
|
||||
|
||||
.include "bsp/${BSP_NAME}/Makefile.inc"
|
||||
.include "bsp/omap/Makefile.inc"
|
||||
.include "bsp/rpi/Makefile.inc"
|
||||
|
||||
# some object files we give a symbol prefix (or namespace) of __k_unpaged_
|
||||
# that must live in their own unique namespace.
|
||||
@@ -22,7 +23,6 @@ UNPAGED_OBJS += unpaged_${unpaged_obj}
|
||||
ORIG_UNPAGED_OBJS += ${unpaged_obj}
|
||||
.endfor
|
||||
|
||||
|
||||
CLEANFILES+= ${ORIG_UNPAGED_OBJS}
|
||||
|
||||
SRCS+= mpx.S arch_clock.c arch_do_vmctl.c arch_system.c do_padconf.c \
|
||||
|
||||
@@ -25,14 +25,17 @@
|
||||
#include "bsp_timer.h"
|
||||
#include "bsp_intr.h"
|
||||
#include "cpufunc_timer.h"
|
||||
#include "bsp_table.h"
|
||||
|
||||
static unsigned tsc_per_ms[CONFIG_MAX_CPUS];
|
||||
static unsigned tsc_per_tick[CONFIG_MAX_CPUS];
|
||||
static uint64_t tsc_per_state[CONFIG_MAX_CPUS][CPUSTATES];
|
||||
|
||||
extern bsp_table *bsp_tb;
|
||||
|
||||
int init_local_timer(unsigned freq)
|
||||
{
|
||||
bsp_timer_init(freq);
|
||||
bsp_tb->bsp_timer_init(freq);
|
||||
|
||||
if (BOARD_IS_BBXM(machine.board_id)) {
|
||||
tsc_per_ms[0] = 16250;
|
||||
@@ -53,12 +56,12 @@ int init_local_timer(unsigned freq)
|
||||
|
||||
void stop_local_timer(void)
|
||||
{
|
||||
bsp_timer_stop();
|
||||
bsp_tb->bsp_timer_stop();
|
||||
}
|
||||
|
||||
void arch_timer_int_handler(void)
|
||||
{
|
||||
bsp_timer_int_handler();
|
||||
bsp_tb->bsp_timer_int_handler();
|
||||
}
|
||||
|
||||
void cycles_accounting_init(void)
|
||||
@@ -186,7 +189,7 @@ void restart_local_timer(void)
|
||||
|
||||
int register_local_timer_handler(const irq_handler_t handler)
|
||||
{
|
||||
return bsp_register_timer_handler(handler);
|
||||
return bsp_tb->bsp_register_timer_handler(handler);
|
||||
}
|
||||
|
||||
u64_t ms_2_cpu_time(unsigned ms)
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include "kernel/debug.h"
|
||||
#include "direct_utils.h"
|
||||
#include <machine/multiboot.h>
|
||||
#include "bsp_table.h"
|
||||
|
||||
extern bsp_table *bsp_tb;
|
||||
|
||||
void
|
||||
halt_cpu(void)
|
||||
@@ -35,7 +38,7 @@ halt_cpu(void)
|
||||
void
|
||||
reset(void)
|
||||
{
|
||||
bsp_reset(); /* should not exit */
|
||||
bsp_tb->bsp_reset(); /* should not exit */
|
||||
direct_print("Reset not supported.");
|
||||
while (1);
|
||||
}
|
||||
@@ -43,7 +46,7 @@ reset(void)
|
||||
void
|
||||
poweroff(void)
|
||||
{
|
||||
bsp_poweroff();
|
||||
bsp_tb->bsp_poweroff();
|
||||
/* fallback option: hang */
|
||||
direct_print("Unable to power-off this device.");
|
||||
while (1);
|
||||
@@ -76,7 +79,7 @@ arch_shutdown(int how)
|
||||
void
|
||||
ser_putc(char c)
|
||||
{
|
||||
bsp_ser_putc(c);
|
||||
bsp_tb->bsp_ser_putc(c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include "bsp_serial.h"
|
||||
|
||||
#include "glo.h"
|
||||
#include "bsp_table.h"
|
||||
|
||||
extern bsp_table *bsp_tb;
|
||||
|
||||
void * k_stacks;
|
||||
|
||||
@@ -128,7 +131,7 @@ void arch_init(void)
|
||||
/* enable cycle counter in user mode: ARM ARM B4.1.124 */
|
||||
value = PMU_PMUSERENR_EN;
|
||||
asm volatile ("MCR p15, 0, %0, c9, c14, 0\t\n": : "r" (value));
|
||||
bsp_init();
|
||||
bsp_tb->bsp_init();
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -182,7 +185,7 @@ void get_randomness(struct k_randomness *rand, int source)
|
||||
|
||||
void arch_ser_init(void)
|
||||
{
|
||||
bsp_ser_init();
|
||||
bsp_tb->bsp_ser_init();
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
#define _BSP_INIT_H_
|
||||
|
||||
/* BSP init */
|
||||
void bsp_init(void);
|
||||
#define INIT_GENERATE(name) \
|
||||
void name##_init (void);
|
||||
|
||||
INIT_GENERATE(rpi);
|
||||
INIT_GENERATE(omap);
|
||||
|
||||
#endif /* __BSP_INIT_H__ */
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
void bsp_irq_unmask(int irq);
|
||||
void bsp_irq_mask(int irq);
|
||||
void bsp_irq_handle(void);
|
||||
#define INTR_GENERATE(name) \
|
||||
void name##_irq_unmask (int irq); \
|
||||
void name##_irq_mask (int irq); \
|
||||
void name##_irq_handle (void); \
|
||||
int name##_intr_init(const int auto_eoi);
|
||||
|
||||
INTR_GENERATE(rpi);
|
||||
INTR_GENERATE(omap);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
void bsp_padconf_init(void);
|
||||
int bsp_padconf_set(u32_t padconf, u32_t mask, u32_t value);
|
||||
#define PADCONF_GENERATE(name) \
|
||||
void name##_padconf_init (void); \
|
||||
int name##_padconf_set (u32_t padconf, u32_t mask, u32_t value);
|
||||
|
||||
PADCONF_GENERATE(rpi);
|
||||
PADCONF_GENERATE(omap);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#ifndef _BSP_RESET_H_
|
||||
#define _BSP_RESET_H_
|
||||
|
||||
void bsp_reset_init(void);
|
||||
void bsp_reset(void);
|
||||
void bsp_poweroff(void);
|
||||
void bsp_disable_watchdog(void);
|
||||
#define RESET_GENERATE(name) \
|
||||
void name##_reset_init (void); \
|
||||
void name##_reset (void); \
|
||||
void name##_poweroff (void); \
|
||||
void name##_disable_watchdog (void);
|
||||
|
||||
RESET_GENERATE(rpi);
|
||||
RESET_GENERATE(omap);
|
||||
|
||||
#endif /* _BSP_RESET_H_ */
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#ifndef _BSP_SERIAL_H_
|
||||
#define _BSP_SERIAL_H_
|
||||
|
||||
void bsp_ser_init(void);
|
||||
void bsp_ser_putc(char c);
|
||||
#define SERIAL_GENERATE(name) \
|
||||
void name##_ser_init (void); \
|
||||
void name##_ser_putc (char c);
|
||||
|
||||
SERIAL_GENERATE(rpi);
|
||||
SERIAL_GENERATE(omap);
|
||||
|
||||
#endif /* _BSP_SERIAL_H_ */
|
||||
|
||||
@@ -3,10 +3,15 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
void bsp_timer_init(unsigned freq);
|
||||
void bsp_timer_stop(void);
|
||||
int bsp_register_timer_handler(const irq_handler_t handler);
|
||||
void bsp_timer_int_handler(void);
|
||||
#define TIMER_GENERATE(name) \
|
||||
void name##_timer_init (unsigned freq); \
|
||||
void name##_timer_stop (void); \
|
||||
int name##_register_timer_handler (const irq_handler_t handler); \
|
||||
void name##_timer_int_handler (void); \
|
||||
void name##_read_tsc_64 (u64_t * t)
|
||||
|
||||
TIMER_GENERATE(rpi);
|
||||
TIMER_GENERATE(omap);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
# BSP for TI hardware
|
||||
#
|
||||
|
||||
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/bsp/${BSP_NAME}
|
||||
|
||||
.for unpaged_obj in omap_serial.o omap_rtc.o omap_reset.o
|
||||
BSP_OBJS_UNPAGED += ${unpaged_obj}
|
||||
.endfor
|
||||
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/bsp/omap
|
||||
|
||||
SRCS+= omap_init.c omap_serial.c omap_timer.c omap_padconf.c omap_intr.c omap_rtc.c \
|
||||
omap_reset.c
|
||||
|
||||
@@ -5,18 +5,18 @@
|
||||
#include "bsp_reset.h"
|
||||
|
||||
void
|
||||
bsp_init(void)
|
||||
omap_init(void)
|
||||
{
|
||||
|
||||
/* map memory for padconf */
|
||||
bsp_padconf_init();
|
||||
omap_padconf_init();
|
||||
|
||||
/* map memory for rtc */
|
||||
omap3_rtc_init();
|
||||
|
||||
/* map memory for reset control */
|
||||
bsp_reset_init();
|
||||
omap_reset_init();
|
||||
|
||||
/* disable watchdog */
|
||||
bsp_disable_watchdog();
|
||||
omap_disable_watchdog();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ static struct omap_intr
|
||||
static kern_phys_map intr_phys_map;
|
||||
|
||||
int
|
||||
intr_init(const int auto_eoi)
|
||||
omap_intr_init(const int auto_eoi)
|
||||
{
|
||||
if (BOARD_IS_BBXM(machine.board_id)) {
|
||||
omap_intr.base = OMAP3_DM37XX_INTR_BASE;
|
||||
@@ -41,7 +41,7 @@ intr_init(const int auto_eoi)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_irq_handle(void)
|
||||
omap_irq_handle(void)
|
||||
{
|
||||
/* Function called from assembly to handle interrupts */
|
||||
|
||||
@@ -58,14 +58,14 @@ bsp_irq_handle(void)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_irq_unmask(int irq)
|
||||
omap_irq_unmask(int irq)
|
||||
{
|
||||
mmio_write(OMAP3_INTR_MIR_CLEAR(omap_intr.base, irq >> 5),
|
||||
1 << (irq & 0x1f));
|
||||
}
|
||||
|
||||
void
|
||||
bsp_irq_mask(const int irq)
|
||||
omap_irq_mask(const int irq)
|
||||
{
|
||||
mmio_write(OMAP3_INTR_MIR_SET(omap_intr.base, irq >> 5),
|
||||
1 << (irq & 0x1f));
|
||||
|
||||
@@ -47,7 +47,7 @@ static struct omap_padconf *omap_padconf;
|
||||
static kern_phys_map padconf_phys_map;
|
||||
|
||||
int
|
||||
bsp_padconf_set(u32_t padconf, u32_t mask, u32_t value)
|
||||
omap_padconf_set(u32_t padconf, u32_t mask, u32_t value)
|
||||
{
|
||||
/* check that the value will be inside the padconf memory range */
|
||||
if (padconf >= (omap_padconf->size - omap_padconf->offset)) {
|
||||
@@ -61,7 +61,7 @@ bsp_padconf_set(u32_t padconf, u32_t mask, u32_t value)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_padconf_init(void)
|
||||
omap_padconf_init(void)
|
||||
{
|
||||
int x;
|
||||
omap_padconf = NULL;
|
||||
|
||||
@@ -33,41 +33,41 @@ struct omap_reset
|
||||
vir_bytes size;
|
||||
};
|
||||
|
||||
static struct omap_reset omap_reset;
|
||||
static struct omap_reset omap_res;
|
||||
|
||||
static kern_phys_map reset_phys_map;
|
||||
|
||||
void
|
||||
bsp_reset_init(void)
|
||||
omap_reset_init(void)
|
||||
{
|
||||
if (BOARD_IS_BBXM(machine.board_id)) {
|
||||
omap_reset.base = DM37XX_CM_BASE;
|
||||
omap_reset.size = DM37XX_CM_SIZE;
|
||||
omap_res.base = DM37XX_CM_BASE;
|
||||
omap_res.size = DM37XX_CM_SIZE;
|
||||
} else if (BOARD_IS_BB(machine.board_id)) {
|
||||
omap_reset.base = AM335X_CM_BASE;
|
||||
omap_reset.size = AM335X_CM_SIZE;
|
||||
omap_res.base = AM335X_CM_BASE;
|
||||
omap_res.size = AM335X_CM_SIZE;
|
||||
}
|
||||
|
||||
kern_phys_map_ptr(omap_reset.base, omap_reset.size,
|
||||
kern_phys_map_ptr(omap_res.base, omap_res.size,
|
||||
VMMF_UNCACHED | VMMF_WRITE,
|
||||
&reset_phys_map, (vir_bytes) & omap_reset.base);
|
||||
&reset_phys_map, (vir_bytes) & omap_res.base);
|
||||
}
|
||||
|
||||
void
|
||||
bsp_reset(void)
|
||||
omap_reset(void)
|
||||
{
|
||||
if (BOARD_IS_BBXM(machine.board_id)) {
|
||||
mmio_set((omap_reset.base + DM37XX_PRM_RSTCTRL_REG),
|
||||
mmio_set((omap_res.base + DM37XX_PRM_RSTCTRL_REG),
|
||||
(1 << DM37XX_RST_DPLL3_BIT));
|
||||
} else if (BOARD_IS_BB(machine.board_id)) {
|
||||
mmio_set((omap_reset.base + AM335X_PRM_DEVICE_OFFSET +
|
||||
mmio_set((omap_res.base + AM335X_PRM_DEVICE_OFFSET +
|
||||
AM335X_PRM_RSTCTRL_REG),
|
||||
(1 << AM335X_RST_GLOBAL_WARM_SW_BIT));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bsp_poweroff(void)
|
||||
omap_poweroff(void)
|
||||
{
|
||||
|
||||
/*
|
||||
@@ -88,7 +88,7 @@ bsp_poweroff(void)
|
||||
}
|
||||
}
|
||||
|
||||
void bsp_disable_watchdog(void)
|
||||
void omap_disable_watchdog(void)
|
||||
{
|
||||
if(BOARD_IS_BB(machine.board_id)) {
|
||||
mmio_write(AM335X_WDT_BASE+AM335X_WDT_WSPR, 0xAAAA);
|
||||
|
||||
@@ -43,7 +43,7 @@ static kern_phys_map serial_phys_map;
|
||||
* in high memory so keep in mind there are two copies of this code in the kernel.
|
||||
*/
|
||||
void
|
||||
bsp_ser_init(void)
|
||||
omap_ser_init(void)
|
||||
{
|
||||
if (BOARD_IS_BBXM(machine.board_id)) {
|
||||
omap_serial.base = OMAP3_DM37XX_DEBUG_UART_BASE;
|
||||
@@ -59,7 +59,7 @@ bsp_ser_init(void)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_ser_putc(char c)
|
||||
omap_ser_putc(char c)
|
||||
{
|
||||
int i;
|
||||
assert(omap_serial.base);
|
||||
|
||||
@@ -133,7 +133,7 @@ static struct omap_timer *fr_timer;
|
||||
static int done = 0;
|
||||
|
||||
int
|
||||
bsp_register_timer_handler(const irq_handler_t handler)
|
||||
omap_register_timer_handler(const irq_handler_t handler)
|
||||
{
|
||||
/* Initialize the CLOCK's interrupt hook. */
|
||||
omap3_timer_hook.proc_nr_e = NONE;
|
||||
@@ -141,7 +141,7 @@ bsp_register_timer_handler(const irq_handler_t handler)
|
||||
|
||||
put_irq_handler(&omap3_timer_hook, timer->irq_nr, handler);
|
||||
/* only unmask interrupts after registering */
|
||||
bsp_irq_unmask(timer->irq_nr);
|
||||
omap_irq_unmask(timer->irq_nr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -264,7 +264,7 @@ omap3_frclock_stop(void)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_timer_init(unsigned freq)
|
||||
omap_timer_init(unsigned freq)
|
||||
{
|
||||
/* we only support 1ms resolution */
|
||||
u32_t tisr;
|
||||
@@ -328,7 +328,7 @@ bsp_timer_init(unsigned freq)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_timer_stop(void)
|
||||
omap_timer_stop(void)
|
||||
{
|
||||
mmio_clear(timer->base + timer->regs->TCLR, OMAP3_TCLR_ST);
|
||||
}
|
||||
@@ -369,7 +369,7 @@ frc_overflow_check(u32_t cur_frc)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_timer_int_handler(void)
|
||||
omap_timer_int_handler(void)
|
||||
{
|
||||
/* Clear all interrupts */
|
||||
u32_t tisr, now;
|
||||
@@ -387,7 +387,7 @@ bsp_timer_int_handler(void)
|
||||
|
||||
/* Use the free running clock as TSC */
|
||||
void
|
||||
read_tsc_64(u64_t * t)
|
||||
omap_read_tsc_64(u64_t * t)
|
||||
{
|
||||
u32_t now;
|
||||
now = read_frc();
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
# BSP for RPI hardware
|
||||
#
|
||||
|
||||
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/bsp/${BSP_NAME}
|
||||
|
||||
.for unpaged_obj in rpi_serial.o rpi_reset.o
|
||||
BSP_OBJS_UNPAGED += ${unpaged_obj}
|
||||
.endfor
|
||||
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/bsp/rpi
|
||||
|
||||
SRCS+= rpi_init.c rpi_serial.c rpi_timer.c rpi_padconf.c rpi_intr.c \
|
||||
rpi_reset.c
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
#include "bsp_reset.h"
|
||||
|
||||
void
|
||||
bsp_init()
|
||||
rpi_init()
|
||||
{
|
||||
/* map memory for padconf */
|
||||
bsp_padconf_init();
|
||||
rpi_padconf_init();
|
||||
|
||||
/* map memory for reset control */
|
||||
bsp_reset_init();
|
||||
rpi_reset_init();
|
||||
|
||||
/* disable watchdog */
|
||||
bsp_disable_watchdog();
|
||||
rpi_disable_watchdog();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ dummy_irq_handler()
|
||||
}
|
||||
|
||||
int
|
||||
intr_init(const int auto_eoi)
|
||||
rpi_intr_init(const int auto_eoi)
|
||||
{
|
||||
if (BOARD_IS_RPI_2_B(machine.board_id) ||
|
||||
BOARD_IS_RPI_3_B(machine.board_id)) {
|
||||
@@ -81,7 +81,7 @@ intr_init(const int auto_eoi)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_irq_handle(void)
|
||||
rpi_irq_handle(void)
|
||||
{
|
||||
/* Function called from assembly to handle interrupts */
|
||||
uint32_t irq_0_31 = mmio_read(rpi2_intr.core_base + QA7_CORE0INT);
|
||||
@@ -114,7 +114,7 @@ bsp_irq_handle(void)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_irq_unmask(int irq)
|
||||
rpi_irq_unmask(int irq)
|
||||
{
|
||||
if (irq < 32)
|
||||
/* Nothing to do */
|
||||
@@ -128,7 +128,7 @@ bsp_irq_unmask(int irq)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_irq_mask(const int irq)
|
||||
rpi_irq_mask(const int irq)
|
||||
{
|
||||
if (irq < 32)
|
||||
/* Nothing to do */
|
||||
|
||||
@@ -27,7 +27,7 @@ static struct rpi2_padconf rpi2_padconf;
|
||||
static kern_phys_map padconf_phys_map;
|
||||
|
||||
int
|
||||
bsp_padconf_set(u32_t padconf, u32_t mask, u32_t value)
|
||||
rpi_padconf_set(u32_t padconf, u32_t mask, u32_t value)
|
||||
{
|
||||
/* check that the value will be inside the padconf memory range */
|
||||
if (padconf >= (rpi2_padconf.size - rpi2_padconf.offset)) {
|
||||
@@ -41,7 +41,7 @@ bsp_padconf_set(u32_t padconf, u32_t mask, u32_t value)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_padconf_init(void)
|
||||
rpi_padconf_init(void)
|
||||
{
|
||||
if (BOARD_IS_RPI_2_B(machine.board_id) ||
|
||||
BOARD_IS_RPI_3_B(machine.board_id)) {
|
||||
|
||||
@@ -13,21 +13,21 @@
|
||||
#include "bsp_reset.h"
|
||||
|
||||
void
|
||||
bsp_reset_init(void)
|
||||
rpi_reset_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
bsp_reset(void)
|
||||
rpi_reset(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
bsp_poweroff(void)
|
||||
rpi_poweroff(void)
|
||||
{
|
||||
}
|
||||
|
||||
void bsp_disable_watchdog(void)
|
||||
void rpi_disable_watchdog(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ static kern_phys_map serial_phys_map;
|
||||
* in high memory so keep in mind there are two copies of this code in the kernel.
|
||||
*/
|
||||
void
|
||||
bsp_ser_init()
|
||||
rpi_ser_init()
|
||||
{
|
||||
if (BOARD_IS_RPI_2_B(machine.board_id) ||
|
||||
BOARD_IS_RPI_3_B(machine.board_id)) {
|
||||
@@ -71,7 +71,7 @@ bsp_ser_init()
|
||||
}
|
||||
|
||||
void
|
||||
bsp_ser_putc(char c)
|
||||
rpi_ser_putc(char c)
|
||||
{
|
||||
int i;
|
||||
assert(pl011_serial.base);
|
||||
|
||||
@@ -34,7 +34,7 @@ static kern_phys_map st_timer_phys_map;
|
||||
static kern_phys_map st_timer_user_phys_map;
|
||||
|
||||
int
|
||||
bsp_register_timer_handler(const irq_handler_t handler)
|
||||
rpi_register_timer_handler(const irq_handler_t handler)
|
||||
{
|
||||
/* Initialize the CLOCK's interrupt hook. */
|
||||
arm_timer_hook.proc_nr_e = NONE;
|
||||
@@ -43,10 +43,10 @@ bsp_register_timer_handler(const irq_handler_t handler)
|
||||
put_irq_handler(&arm_timer_hook, arm_timer.irq_nr, handler);
|
||||
|
||||
/* Prepare next firing of timer */
|
||||
bsp_timer_int_handler();
|
||||
rpi_timer_int_handler();
|
||||
|
||||
/* only unmask interrupts after registering */
|
||||
bsp_irq_unmask(arm_timer.irq_nr);
|
||||
rpi_irq_unmask(arm_timer.irq_nr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ kern_phys_st_user_mapped(vir_bytes id, phys_bytes address)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_timer_init(unsigned freq)
|
||||
rpi_timer_init(unsigned freq)
|
||||
{
|
||||
arm_timer.freq = freq;
|
||||
|
||||
@@ -103,13 +103,13 @@ bsp_timer_init(unsigned freq)
|
||||
}
|
||||
|
||||
void
|
||||
bsp_timer_stop()
|
||||
rpi_timer_stop()
|
||||
{
|
||||
bsp_irq_mask(arm_timer.irq_nr);
|
||||
rpi_irq_mask(arm_timer.irq_nr);
|
||||
}
|
||||
|
||||
void
|
||||
bsp_timer_int_handler()
|
||||
rpi_timer_int_handler()
|
||||
{
|
||||
if (arm_timer.st_workaround) {
|
||||
/* Arm next timer countdown and enable timer */
|
||||
@@ -129,7 +129,7 @@ bsp_timer_int_handler()
|
||||
|
||||
/* Use the free running clock as TSC */
|
||||
void
|
||||
read_tsc_64(u64_t * t)
|
||||
rpi_read_tsc_64(u64_t * t)
|
||||
{
|
||||
if (arm_timer.st_workaround)
|
||||
*t = read_cntv_cval();
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
#include "direct_utils.h"
|
||||
#include "bsp_serial.h"
|
||||
#include "glo.h"
|
||||
#include "bsp_table.h"
|
||||
|
||||
extern bsp_table *bsp_tb;
|
||||
|
||||
void direct_cls(void)
|
||||
{
|
||||
@@ -12,7 +15,7 @@ void direct_cls(void)
|
||||
void direct_print_char(char c)
|
||||
{
|
||||
if(c == '\n')
|
||||
bsp_ser_putc('\r');
|
||||
bsp_tb->bsp_ser_putc('\r');
|
||||
ser_putc(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
|
||||
/* get arch specific arch_padconf_set() */
|
||||
#include "bsp_padconf.h"
|
||||
#include "bsp_table.h"
|
||||
|
||||
extern bsp_table *bsp_tb;
|
||||
|
||||
/*===========================================================================*
|
||||
* do_padconf *
|
||||
*===========================================================================*/
|
||||
int do_padconf(struct proc *caller_ptr, message *m_ptr)
|
||||
{
|
||||
return bsp_padconf_set(m_ptr->PADCONF_PADCONF, m_ptr->PADCONF_MASK,
|
||||
return bsp_tb->bsp_padconf_set(m_ptr->PADCONF_PADCONF, m_ptr->PADCONF_MASK,
|
||||
m_ptr->PADCONF_VALUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
/* hw_intr handles the hardware dependent part of the interrupts */
|
||||
#include "hw_intr.h"
|
||||
#include "bsp_intr.h"
|
||||
#include "bsp_table.h"
|
||||
|
||||
extern bsp_table *bsp_tb;
|
||||
|
||||
void hw_intr_mask(int irq){
|
||||
bsp_irq_mask(irq);
|
||||
bsp_tb->bsp_irq_mask(irq);
|
||||
}
|
||||
|
||||
void hw_intr_unmask(int irq){
|
||||
bsp_irq_unmask(irq);
|
||||
bsp_tb->bsp_irq_unmask(irq);
|
||||
}
|
||||
|
||||
void hw_intr_ack(int irq){};
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef _BSP_TABLE_H
|
||||
#define _BSP_TABLE_H
|
||||
|
||||
#include "bsp_init.h"
|
||||
#include "bsp_intr.h"
|
||||
#include "bsp_serial.h"
|
||||
#include "bsp_timer.h"
|
||||
#include "bsp_padconf.h"
|
||||
#include "bsp_reset.h"
|
||||
|
||||
typedef struct {
|
||||
void (*bsp_init)(void);
|
||||
void (*bsp_irq_unmask)(int irq);
|
||||
void (*bsp_irq_mask)(int irq);
|
||||
void (*bsp_irq_handle)(void);
|
||||
void (*bsp_padconf_init)(void);
|
||||
int (*bsp_padconf_set)(u32_t padconf, u32_t mask, u32_t value);
|
||||
void (*bsp_reset_init)(void);
|
||||
void (*bsp_reset)(void);
|
||||
void (*bsp_poweroff)(void);
|
||||
void (*bsp_disable_watchdog)(void);
|
||||
void (*bsp_ser_init)(void);
|
||||
void (*bsp_ser_putc)(char c);
|
||||
void (*bsp_timer_init)(unsigned freq);
|
||||
void (*bsp_timer_stop)(void);
|
||||
int (*bsp_register_timer_handler)(const irq_handler_t handler);
|
||||
void (*bsp_timer_int_handler)(void);
|
||||
void (*read_tsc_64)(u64_t * t);
|
||||
int (*intr_init)(const int auto_eoi);
|
||||
} bsp_table;
|
||||
|
||||
#endif
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "arch_proto.h"
|
||||
#include "direct_utils.h"
|
||||
#include "bsp_serial.h"
|
||||
#include "bsp_table.h"
|
||||
#include "glo.h"
|
||||
#include <machine/multiboot.h>
|
||||
|
||||
@@ -36,6 +37,33 @@ int kernel_may_alloc = 1;
|
||||
extern u32_t _edata;
|
||||
extern u32_t _end;
|
||||
|
||||
#define BSP_TABLE_GENERATE(name) \
|
||||
bsp_table name##_bsp_table = { \
|
||||
.bsp_init = name##_init, \
|
||||
.bsp_irq_unmask = name##_irq_unmask, \
|
||||
.bsp_irq_mask = name##_irq_mask, \
|
||||
.bsp_irq_handle = name##_irq_handle, \
|
||||
.bsp_padconf_init = name##_padconf_init, \
|
||||
.bsp_padconf_set = name##_padconf_set, \
|
||||
.bsp_reset_init = name##_reset_init, \
|
||||
.bsp_reset = name##_reset, \
|
||||
.bsp_poweroff = name##_poweroff, \
|
||||
.bsp_disable_watchdog = name##_disable_watchdog, \
|
||||
.bsp_ser_init = name##_ser_init, \
|
||||
.bsp_ser_putc = name##_ser_putc, \
|
||||
.bsp_timer_init = name##_timer_init, \
|
||||
.bsp_timer_stop = name##_timer_stop, \
|
||||
.bsp_register_timer_handler = name##_register_timer_handler, \
|
||||
.bsp_timer_int_handler = name##_timer_int_handler, \
|
||||
.read_tsc_64 = name##_read_tsc_64, \
|
||||
.intr_init = name##_intr_init \
|
||||
}
|
||||
|
||||
BSP_TABLE_GENERATE(rpi);
|
||||
BSP_TABLE_GENERATE(omap);
|
||||
|
||||
bsp_table *bsp_tb;
|
||||
|
||||
/*
|
||||
* During low level init many things are not supposed to work
|
||||
* serial being one of them. We therefore can't rely on the
|
||||
@@ -376,6 +404,31 @@ void set_machine_id(char *cmdline)
|
||||
}
|
||||
}
|
||||
|
||||
void set_bsp_table ()
|
||||
{
|
||||
if (BOARD_IS_BB(machine.board_id) || BOARD_IS_BBXM(machine.board_id)) {
|
||||
bsp_tb = &omap_bsp_table;
|
||||
}
|
||||
else if (BOARD_IS_RPI_2_B(machine.board_id) || BOARD_IS_RPI_3_B(machine.board_id)) {
|
||||
bsp_tb = &rpi_bsp_table;
|
||||
}
|
||||
}
|
||||
|
||||
void read_tsc_64(u64_t * t)
|
||||
{
|
||||
bsp_tb->read_tsc_64(t);
|
||||
}
|
||||
|
||||
void bsp_irq_handle(void)
|
||||
{
|
||||
bsp_tb->bsp_irq_handle();
|
||||
}
|
||||
|
||||
int intr_init(const int auto_eoi)
|
||||
{
|
||||
return bsp_tb->intr_init (auto_eoi);
|
||||
}
|
||||
|
||||
kinfo_t *pre_init(int argc, char **argv)
|
||||
{
|
||||
char* bootargs;
|
||||
@@ -393,6 +446,7 @@ kinfo_t *pre_init(int argc, char **argv)
|
||||
|
||||
bootargs = argv[1];
|
||||
set_machine_id(bootargs);
|
||||
set_bsp_table();
|
||||
|
||||
/* Get our own copy boot params pointed to by r1.
|
||||
* Here we find out whether we should do serial output.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
: ${OBJ=../obj.${ARCH}-${BSP_NAME}}
|
||||
: ${OBJ=../obj.${ARCH}}
|
||||
: ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin}
|
||||
: ${CROSS_PREFIX=${CROSS_TOOLS}/${TOOLCHAIN_TRIPLET}}
|
||||
: ${JOBS=1}
|
||||
|
||||
Reference in New Issue
Block a user