Build binaries that will run bare metal. Add enough syscall library to init the uart and write text.
--HG-- branch : dtrg-videocore rename : plat/rpi/libsys/libsys.h => plat/rpi/libsys/libsysasm.h rename : plat/rpi/libsys/_sys_rawread.s => plat/rpi/libsys/phys_to_user.s rename : plat/rpi/libsys/_sys_rawread.s => plat/rpi/libsys/uart.s rename : plat/rpi/libsys/_sys_rawread.s => plat/rpi/libsys/user_to_phys.s
This commit is contained in:
parent
472f778342
commit
ec25fec145
|
@ -19,14 +19,17 @@
|
||||||
#define STACKSIZE 16*1024
|
#define STACKSIZE 16*1024
|
||||||
|
|
||||||
! MAIN ENTRY POINT
|
! MAIN ENTRY POINT
|
||||||
!
|
|
||||||
! When running as a kernel, our parameters are passed in in r0-r5, so
|
|
||||||
! the startup sequence mustn't disturb these.
|
|
||||||
|
|
||||||
begtext:
|
begtext:
|
||||||
|
! This empty space is required by the boot loader.
|
||||||
|
|
||||||
|
b start
|
||||||
|
.space 508 ! 512 minus space needed for branch instruction
|
||||||
|
|
||||||
! Wipe the bss. This must happen absolutely first, because we need
|
! Wipe the bss. This must happen absolutely first, because we need
|
||||||
! to store the old system registers into it.
|
! to store the old system registers into it.
|
||||||
|
|
||||||
|
start:
|
||||||
lea r6, begbss
|
lea r6, begbss
|
||||||
lea r7, endbss
|
lea r7, endbss
|
||||||
mov r8, #0
|
mov r8, #0
|
||||||
|
@ -79,6 +82,7 @@ _1:
|
||||||
|
|
||||||
.define __exit
|
.define __exit
|
||||||
__exit:
|
__exit:
|
||||||
|
mov r0, sr
|
||||||
ld fp, .returnfp
|
ld fp, .returnfp
|
||||||
ld sp, .returnsp
|
ld sp, .returnsp
|
||||||
ld lr, .returnlr
|
ld lr, .returnlr
|
||||||
|
|
|
@ -13,10 +13,15 @@ D := plat/rpi/
|
||||||
|
|
||||||
platform-headers := \
|
platform-headers := \
|
||||||
unistd.h \
|
unistd.h \
|
||||||
|
pi.h \
|
||||||
ack/config.h
|
ack/config.h
|
||||||
|
|
||||||
platform-libsys := \
|
platform-libsys := \
|
||||||
_hol0.s \
|
_hol0.s \
|
||||||
|
phys_to_user.s \
|
||||||
|
user_to_phys.s \
|
||||||
|
uart.s \
|
||||||
|
write.c \
|
||||||
|
|
||||||
ifeq (x,y)
|
ifeq (x,y)
|
||||||
errno.s \
|
errno.s \
|
||||||
|
@ -26,7 +31,6 @@ ifeq (x,y)
|
||||||
creat.c \
|
creat.c \
|
||||||
close.c \
|
close.c \
|
||||||
read.c \
|
read.c \
|
||||||
write.c \
|
|
||||||
brk.c \
|
brk.c \
|
||||||
getpid.c \
|
getpid.c \
|
||||||
kill.c \
|
kill.c \
|
||||||
|
|
21
plat/rpi/include/pi.h
Normal file
21
plat/rpi/include/pi.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Raspberry Pi support library for the ACK
|
||||||
|
* © 2013 David Given
|
||||||
|
* This file is redistributable under the terms of the 3-clause BSD license.
|
||||||
|
* See the file 'Copying' in the root of the distribution for the full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PI_H
|
||||||
|
#define PI_H
|
||||||
|
|
||||||
|
/* Initialise the mini UART (only do this if running on bare metal! */
|
||||||
|
extern void init_uart(void);
|
||||||
|
|
||||||
|
/* Converts a pointer from a physical address to a user address. */
|
||||||
|
extern void* phys_to_user(void* ptr);
|
||||||
|
|
||||||
|
/* Converts a pointer from a user address to a physical address. */
|
||||||
|
extern void* user_to_phys(void* ptr);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
20
plat/rpi/libsys/libsysasm.h
Normal file
20
plat/rpi/libsys/libsysasm.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Raspberry Pi support library for the ACK
|
||||||
|
* © 2013 David Given
|
||||||
|
* This file is redistributable under the terms of the 3-clause BSD license.
|
||||||
|
* See the file 'Copying' in the root of the distribution for the full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBSYSASM_H
|
||||||
|
#define LIBSYSASM_H
|
||||||
|
|
||||||
|
! Declare segments (the order is important).
|
||||||
|
|
||||||
|
.sect .text
|
||||||
|
.sect .rom
|
||||||
|
.sect .data
|
||||||
|
.sect .bss
|
||||||
|
|
||||||
|
#define gp r15
|
||||||
|
|
||||||
|
#endif
|
20
plat/rpi/libsys/phys_to_user.s
Normal file
20
plat/rpi/libsys/phys_to_user.s
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#
|
||||||
|
/*
|
||||||
|
* Raspberry Pi support library for the ACK
|
||||||
|
* © 2013 David Given
|
||||||
|
* This file is redistributable under the terms of the 3-clause BSD license.
|
||||||
|
* See the file 'Copying' in the root of the distribution for the full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libsysasm.h"
|
||||||
|
|
||||||
|
.sect .text
|
||||||
|
|
||||||
|
! Transforms a physical address into a user address.
|
||||||
|
|
||||||
|
.define _phys_to_user
|
||||||
|
_phys_to_user:
|
||||||
|
ld r0, 0 (sp)
|
||||||
|
sub r0, gp
|
||||||
|
b lr
|
||||||
|
|
135
plat/rpi/libsys/uart.s
Normal file
135
plat/rpi/libsys/uart.s
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
#
|
||||||
|
/*
|
||||||
|
* Raspberry Pi support library for the ACK
|
||||||
|
* © 2013 David Given
|
||||||
|
* This file is redistributable under the terms of the 3-clause BSD license.
|
||||||
|
* See the file 'Copying' in the root of the distribution for the full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libsysasm.h"
|
||||||
|
|
||||||
|
.sect .text
|
||||||
|
|
||||||
|
! Because of the low system clock rate, this baud rate might be inaccurate
|
||||||
|
! So be careful with your serial/terminal, some adjustment may be necessary.
|
||||||
|
TARGET_BAUD_RATE = 115200
|
||||||
|
|
||||||
|
! System clock is running directly off the 19.2MHz crystal at initial reset
|
||||||
|
SYSTEM_CLOCK = 19200000
|
||||||
|
|
||||||
|
GPFSEL1 = 0x7e200004
|
||||||
|
GPSET0 = 0x7e20001C
|
||||||
|
GPCLR0 = 0x7e200028
|
||||||
|
GPPUD = 0x7e200094
|
||||||
|
GPPUDCLK0 = 0x7e200098
|
||||||
|
|
||||||
|
AUX_ENABLES = 0x7e215004
|
||||||
|
AUX_MU_IO_REG = 0x7e215040
|
||||||
|
AUX_MU_IER_REG = 0x7e215044
|
||||||
|
AUX_MU_IIR_REG = 0x7e215048
|
||||||
|
AUX_MU_LCR_REG = 0x7e21504C
|
||||||
|
AUX_MU_MCR_REG = 0x7e215050
|
||||||
|
AUX_MU_LSR_REG = 0x7e215054
|
||||||
|
AUX_MU_MSR_REG = 0x7e215058
|
||||||
|
AUX_MU_SCRATCH = 0x7e21505C
|
||||||
|
AUX_MU_CNTL_REG = 0x7e215060
|
||||||
|
AUX_MU_STAT_REG = 0x7e215064
|
||||||
|
AUX_MU_BAUD_REG = 0x7e215068
|
||||||
|
|
||||||
|
! Sets up the mini UART for use as a console.
|
||||||
|
|
||||||
|
.define _init_uart
|
||||||
|
_init_uart:
|
||||||
|
! Configure TX and RX GPIO pins for Mini Uart function.
|
||||||
|
mov r1, #GPFSEL1
|
||||||
|
ld r0, (r1)
|
||||||
|
and r0, #~[7<<12]
|
||||||
|
or r0, #2<<12
|
||||||
|
and r0, #~[7<<15]
|
||||||
|
or r0, #2<<15
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #GPPUD
|
||||||
|
mov r0, #0
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
delay1:
|
||||||
|
add r0, #1
|
||||||
|
cmp r0, #150
|
||||||
|
b.ne delay1
|
||||||
|
|
||||||
|
mov r1, #GPPUDCLK0
|
||||||
|
mov r0, #[1<<14]|[1<<15]
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r0, #0
|
||||||
|
delay2:
|
||||||
|
add r0, #1
|
||||||
|
cmp r0, #150
|
||||||
|
b.ne delay2
|
||||||
|
|
||||||
|
mov r1, #GPPUDCLK0
|
||||||
|
mov r0, #0
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
! Set up serial port
|
||||||
|
mov r1, #AUX_ENABLES
|
||||||
|
mov r0, #1
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_IER_REG
|
||||||
|
mov r0, #0
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_CNTL_REG
|
||||||
|
mov r0, #0
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_LCR_REG
|
||||||
|
mov r0, #3
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_MCR_REG
|
||||||
|
mov r0, #0
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_IER_REG
|
||||||
|
mov r0, #0
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_IIR_REG
|
||||||
|
mov r0, #0xC6
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_BAUD_REG
|
||||||
|
mov r0, #[[SYSTEM_CLOCK/[TARGET_BAUD_RATE*8]]-1]
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_LCR_REG
|
||||||
|
mov r0, #3
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_CNTL_REG
|
||||||
|
mov r0, #3
|
||||||
|
st r0, (r1)
|
||||||
|
|
||||||
|
b lr
|
||||||
|
|
||||||
|
! Send a single byte.
|
||||||
|
|
||||||
|
.define __sys_rawwrite
|
||||||
|
__sys_rawwrite:
|
||||||
|
ld r0, (sp)
|
||||||
|
mov r1, #AUX_MU_LSR_REG
|
||||||
|
! loop until space available in Tx buffer
|
||||||
|
sendwait:
|
||||||
|
ld r2, (r1)
|
||||||
|
and r2, #0x20
|
||||||
|
cmp r2, #0x20
|
||||||
|
b.ne sendwait
|
||||||
|
|
||||||
|
mov r1, #AUX_MU_IO_REG
|
||||||
|
stb r0, (r1)
|
||||||
|
|
||||||
|
b lr
|
||||||
|
|
20
plat/rpi/libsys/user_to_phys.s
Normal file
20
plat/rpi/libsys/user_to_phys.s
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#
|
||||||
|
/*
|
||||||
|
* Raspberry Pi support library for the ACK
|
||||||
|
* © 2013 David Given
|
||||||
|
* This file is redistributable under the terms of the 3-clause BSD license.
|
||||||
|
* See the file 'Copying' in the root of the distribution for the full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libsysasm.h"
|
||||||
|
|
||||||
|
.sect .text
|
||||||
|
|
||||||
|
! Transforms a user address into a physical address.
|
||||||
|
|
||||||
|
.define _user_to_phys
|
||||||
|
_user_to_phys:
|
||||||
|
ld r0, 0 (sp)
|
||||||
|
add r0, gp
|
||||||
|
b lr
|
||||||
|
|
Loading…
Reference in a new issue