update readme
This commit is contained in:
3
README
3
README
@@ -106,7 +106,8 @@ For each of these files, bootcode.bin and start.elf (NOT kernel.img,
|
||||
dont need it, too big)(loader.bin is no longer used/required). Click
|
||||
on the file name, it will go to another page then click on View Raw and
|
||||
it will let you download the file. For reference, I do not use nor
|
||||
have a config.txt file on my sd card. I only have the four files.
|
||||
have a config.txt file on my sd card. I only have the three files (
|
||||
bootcode.bin, start.elf, and then kernel.img from one of my examples).
|
||||
|
||||
My examples are basically the kernel.img file. Not a linux kernel,
|
||||
just bare metal programs. Since the GPU bootloader is looking for
|
||||
|
||||
40
svc01/Makefile
Normal file
40
svc01/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
ARMGNU ?= arm-none-eabi
|
||||
|
||||
COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding
|
||||
|
||||
gcc : svc01.hex svc01.bin
|
||||
|
||||
all : gcc
|
||||
|
||||
clean :
|
||||
rm -f *.o
|
||||
rm -f *.bin
|
||||
rm -f *.hex
|
||||
rm -f *.elf
|
||||
rm -f *.list
|
||||
rm -f *.img
|
||||
rm -f *.bc
|
||||
rm -f *.clang.opt.s
|
||||
|
||||
vectors.o : vectors.s
|
||||
$(ARMGNU)-as vectors.s -o vectors.o
|
||||
|
||||
svc01.o : svc01.c
|
||||
$(ARMGNU)-gcc $(COPS) -c svc01.c -o svc01.o
|
||||
|
||||
svc01.elf : memmap vectors.o svc01.o
|
||||
$(ARMGNU)-ld vectors.o svc01.o -T memmap -o svc01.elf
|
||||
$(ARMGNU)-objdump -D svc01.elf > svc01.list
|
||||
|
||||
svc01.bin : svc01.elf
|
||||
$(ARMGNU)-objcopy svc01.elf -O binary svc01.bin
|
||||
|
||||
svc01.hex : svc01.elf
|
||||
$(ARMGNU)-objcopy svc01.elf -O ihex svc01.hex
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
13
svc01/README
Normal file
13
svc01/README
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
See the top level README file for more information on documentation
|
||||
and how to run these programs.
|
||||
|
||||
Derived from blinker08 and uart04
|
||||
|
||||
this is based on a question about svc calls, how to find the swi/svc
|
||||
immediate.
|
||||
|
||||
Like interrupts I dont recommend using interrupts or svc calls unless
|
||||
you have a really good reason to. they should be the exception not the
|
||||
norm.
|
||||
|
||||
11
svc01/memmap
Normal file
11
svc01/memmap
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : ORIGIN = 0x8000, LENGTH = 0x1000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text*) } > ram
|
||||
.bss : { *(.bss*) } > ram
|
||||
}
|
||||
39
svc01/start.s
Normal file
39
svc01/start.s
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
;@-------------------------------------------------------------------------
|
||||
;@-------------------------------------------------------------------------
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
mov sp,#0x8000
|
||||
bl notmain
|
||||
hang: b hang
|
||||
|
||||
.globl PUT32
|
||||
PUT32:
|
||||
str r1,[r0]
|
||||
bx lr
|
||||
|
||||
.globl GET32
|
||||
GET32:
|
||||
ldr r0,[r0]
|
||||
bx lr
|
||||
|
||||
.globl dummy
|
||||
dummy:
|
||||
bx lr
|
||||
|
||||
;@-------------------------------------------------------------------------
|
||||
;@-------------------------------------------------------------------------
|
||||
|
||||
|
||||
;@-------------------------------------------------------------------------
|
||||
;@
|
||||
;@ Copyright (c) 2012 David Welch dwelch@dwelch.com
|
||||
;@
|
||||
;@ 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.
|
||||
;@
|
||||
;@-------------------------------------------------------------------------
|
||||
148
svc01/svc01.c
Normal file
148
svc01/svc01.c
Normal file
@@ -0,0 +1,148 @@
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
extern void PUT32 ( unsigned int, unsigned int );
|
||||
extern unsigned int GET32 ( unsigned int );
|
||||
extern void dummy ( unsigned int );
|
||||
extern void swi_test ( unsigned int );
|
||||
extern void swi_test_thumb ( unsigned int );
|
||||
|
||||
|
||||
#define GPFSEL1 0x20200004
|
||||
#define GPSET0 0x2020001C
|
||||
#define GPCLR0 0x20200028
|
||||
#define GPPUD 0x20200094
|
||||
#define GPPUDCLK0 0x20200098
|
||||
|
||||
#define AUX_ENABLES 0x20215004
|
||||
#define AUX_MU_IO_REG 0x20215040
|
||||
#define AUX_MU_IER_REG 0x20215044
|
||||
#define AUX_MU_IIR_REG 0x20215048
|
||||
#define AUX_MU_LCR_REG 0x2021504C
|
||||
#define AUX_MU_MCR_REG 0x20215050
|
||||
#define AUX_MU_LSR_REG 0x20215054
|
||||
#define AUX_MU_MSR_REG 0x20215058
|
||||
#define AUX_MU_SCRATCH 0x2021505C
|
||||
#define AUX_MU_CNTL_REG 0x20215060
|
||||
#define AUX_MU_STAT_REG 0x20215064
|
||||
#define AUX_MU_BAUD_REG 0x20215068
|
||||
|
||||
#define IRQ_BASIC 0x2000B200
|
||||
#define IRQ_PEND1 0x2000B204
|
||||
#define IRQ_PEND2 0x2000B208
|
||||
#define IRQ_FIQ_CONTROL 0x2000B210
|
||||
#define IRQ_ENABLE1 0x2000B210
|
||||
#define IRQ_ENABLE2 0x2000B214
|
||||
#define IRQ_ENABLE_BASIC 0x2000B218
|
||||
#define IRQ_DISABLE1 0x2000B21C
|
||||
#define IRQ_DISABLE2 0x2000B220
|
||||
#define IRQ_DISABLE_BASIC 0x2000B224
|
||||
|
||||
|
||||
//GPIO14 TXD0 and TXD1
|
||||
//GPIO15 RXD0 and RXD1
|
||||
//alt function 5 for uart1
|
||||
//alt function 0 for uart0
|
||||
|
||||
//((250,000,000/115200)/8)-1 = 270
|
||||
//------------------------------------------------------------------------
|
||||
void uart_init ( void )
|
||||
{
|
||||
unsigned int ra;
|
||||
|
||||
PUT32(AUX_ENABLES,1);
|
||||
PUT32(AUX_MU_IER_REG,0);
|
||||
PUT32(AUX_MU_CNTL_REG,0);
|
||||
PUT32(AUX_MU_LCR_REG,3);
|
||||
PUT32(AUX_MU_MCR_REG,0);
|
||||
PUT32(AUX_MU_IER_REG,0x5); //enable rx interrupts
|
||||
PUT32(AUX_MU_IIR_REG,0xC6);
|
||||
PUT32(AUX_MU_BAUD_REG,270);
|
||||
|
||||
ra=GET32(GPFSEL1);
|
||||
ra&=~(7<<12); //gpio14
|
||||
ra|=2<<12; //alt5
|
||||
ra&=~(7<<15); //gpio15
|
||||
ra|=2<<15; //alt5
|
||||
PUT32(GPFSEL1,ra);
|
||||
|
||||
PUT32(GPPUD,0);
|
||||
for(ra=0;ra<150;ra++) dummy(ra);
|
||||
PUT32(GPPUDCLK0,(1<<14)|(1<<15));
|
||||
for(ra=0;ra<150;ra++) dummy(ra);
|
||||
PUT32(GPPUDCLK0,0);
|
||||
|
||||
PUT32(AUX_MU_CNTL_REG,3);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void uart_putc ( unsigned int c )
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
if(GET32(AUX_MU_LSR_REG)&0x20) break;
|
||||
}
|
||||
PUT32(AUX_MU_IO_REG,c);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void hexstrings ( unsigned int d )
|
||||
{
|
||||
//unsigned int ra;
|
||||
unsigned int rb;
|
||||
unsigned int rc;
|
||||
|
||||
rb=32;
|
||||
while(1)
|
||||
{
|
||||
rb-=4;
|
||||
rc=(d>>rb)&0xF;
|
||||
if(rc>9) rc+=0x37; else rc+=0x30;
|
||||
uart_putc(rc);
|
||||
if(rb==0) break;
|
||||
}
|
||||
uart_putc(0x20);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void hexstring ( unsigned int d )
|
||||
{
|
||||
hexstrings(d);
|
||||
uart_putc(0x0D);
|
||||
uart_putc(0x0A);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
int notmain ( unsigned int earlypc )
|
||||
{
|
||||
unsigned int ra;
|
||||
|
||||
uart_init();
|
||||
|
||||
hexstring(0x12345678);
|
||||
for(ra=0;ra<20;ra++) hexstring(ra);
|
||||
hexstring(0x12345678);
|
||||
hexstring(earlypc);
|
||||
|
||||
for(ra=0x1000;ra<0x1010;ra++)
|
||||
{
|
||||
swi_test(ra);
|
||||
}
|
||||
for(ra=0x2000;ra<0x2010;ra++)
|
||||
{
|
||||
swi_test_thumb(ra);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2012 David Welch dwelch@dwelch.com
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
136
svc01/vectors.s
Normal file
136
svc01/vectors.s
Normal file
@@ -0,0 +1,136 @@
|
||||
|
||||
;@-------------------------------------------------------------------------
|
||||
;@-------------------------------------------------------------------------
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
ldr pc,reset_handler
|
||||
ldr pc,undefined_handler
|
||||
ldr pc,swi_handler
|
||||
ldr pc,prefetch_handler
|
||||
ldr pc,data_handler
|
||||
ldr pc,unused_handler
|
||||
ldr pc,irq_handler
|
||||
ldr pc,fiq_handler
|
||||
reset_handler: .word reset
|
||||
undefined_handler: .word hang
|
||||
swi_handler: .word swihand
|
||||
prefetch_handler: .word hang
|
||||
data_handler: .word hang
|
||||
unused_handler: .word hang
|
||||
irq_handler: .word hang
|
||||
fiq_handler: .word hang
|
||||
|
||||
reset:
|
||||
mov r0,#0x8000
|
||||
mov r1,#0x0000
|
||||
ldmia r0!,{r2,r3,r4,r5,r6,r7,r8,r9}
|
||||
stmia r1!,{r2,r3,r4,r5,r6,r7,r8,r9}
|
||||
ldmia r0!,{r2,r3,r4,r5,r6,r7,r8,r9}
|
||||
stmia r1!,{r2,r3,r4,r5,r6,r7,r8,r9}
|
||||
|
||||
;@ (PSR_IRQ_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS)
|
||||
mov r0,#0xD2
|
||||
msr cpsr_c,r0
|
||||
mov sp,#0x8000
|
||||
|
||||
;@ (PSR_FIQ_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS)
|
||||
mov r0,#0xD1
|
||||
msr cpsr_c,r0
|
||||
mov sp,#0x4000
|
||||
|
||||
;@ (PSR_SVC_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS)
|
||||
mov r0,#0xD3
|
||||
msr cpsr_c,r0
|
||||
mov sp,#0x8000000
|
||||
|
||||
;@ SVC MODE, IRQ ENABLED, FIQ DIS
|
||||
;@mov r0,#0x53
|
||||
;@msr cpsr_c, r0
|
||||
|
||||
bl notmain
|
||||
hang: b hang
|
||||
|
||||
.globl PUT32
|
||||
PUT32:
|
||||
str r1,[r0]
|
||||
bx lr
|
||||
|
||||
.globl PUT16
|
||||
PUT16:
|
||||
strh r1,[r0]
|
||||
bx lr
|
||||
|
||||
.globl PUT8
|
||||
PUT8:
|
||||
strb r1,[r0]
|
||||
bx lr
|
||||
|
||||
.globl GET32
|
||||
GET32:
|
||||
ldr r0,[r0]
|
||||
bx lr
|
||||
|
||||
.globl GETPC
|
||||
GETPC:
|
||||
mov r0,lr
|
||||
bx lr
|
||||
|
||||
.globl BRANCHTO
|
||||
BRANCHTO:
|
||||
bx r0
|
||||
|
||||
.globl dummy
|
||||
dummy:
|
||||
bx lr
|
||||
|
||||
.globl enable_irq
|
||||
enable_irq:
|
||||
mrs r0,cpsr
|
||||
bic r0,r0,#0x40
|
||||
msr cpsr_c,r0
|
||||
bx lr
|
||||
|
||||
swihand:
|
||||
push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,lr}
|
||||
mov r4,lr
|
||||
bl hexstrings
|
||||
mov r0,r4
|
||||
bl hexstrings
|
||||
ldr r0,[r4,#-4]
|
||||
bl hexstring
|
||||
pop {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,lr}
|
||||
movs pc,lr
|
||||
|
||||
|
||||
.globl swi_test
|
||||
swi_test:
|
||||
push {lr}
|
||||
swi 0x0D0000
|
||||
pop {lr}
|
||||
bx lr
|
||||
|
||||
.thumb
|
||||
.thumb_func
|
||||
.globl swi_test_thumb
|
||||
swi_test_thumb:
|
||||
push {lr}
|
||||
swi 13
|
||||
pop {r0}
|
||||
bx r0
|
||||
|
||||
;@-------------------------------------------------------------------------
|
||||
;@-------------------------------------------------------------------------
|
||||
|
||||
|
||||
;@-------------------------------------------------------------------------
|
||||
;@
|
||||
;@ Copyright (c) 2012 David Welch dwelch@dwelch.com
|
||||
;@
|
||||
;@ 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.
|
||||
;@
|
||||
;@-------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user