mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-14 07:53:40 +00:00
targets: add support for GameBoy Advance
Only tested in an emulator (mGBA). Almost nothing is supported, but drawing to the screen works.
This commit is contained in:
committed by
Ron Evans
parent
9878f7ebc4
commit
9846c062b3
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"llvm-target": "thumb4-none-eabi",
|
||||
"cpu": "arm7tdmi",
|
||||
"build-tags": ["gameboyadvance", "arm7tdmi", "baremetal", "linux", "arm"],
|
||||
"goos": "linux",
|
||||
"goarch": "arm",
|
||||
"compiler": "clang",
|
||||
"linker": "ld.lld",
|
||||
"cflags": [
|
||||
"-g",
|
||||
"--target=thumb4-none-eabi",
|
||||
"-mcpu=arm7tdmi",
|
||||
"-Oz",
|
||||
"-Werror",
|
||||
"-fshort-enums",
|
||||
"-Wno-macro-redefined",
|
||||
"-Qunused-arguments",
|
||||
"-fno-exceptions", "-fno-unwind-tables",
|
||||
"-ffunction-sections", "-fdata-sections"
|
||||
],
|
||||
"ldflags": [
|
||||
"--gc-sections",
|
||||
"-Ttargets/gameboy-advance.ld"
|
||||
],
|
||||
"extra-files": [
|
||||
"targets/gameboy-advance.s"
|
||||
],
|
||||
"emulator": ["mgba-qt"]
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_start)
|
||||
|
||||
MEMORY {
|
||||
ewram : ORIGIN = 0x02000000, LENGTH = 256K /* on-board work RAM (2 wait states) */
|
||||
iwram : ORIGIN = 0x03000000, LENGTH = 32K /* in-chip work RAM (faster) */
|
||||
rom : ORIGIN = 0x08000000, LENGTH = 32M /* flash ROM */
|
||||
}
|
||||
|
||||
__iwram_top = ORIGIN(iwram) + LENGTH(iwram);;
|
||||
_stack_size = 3K;
|
||||
__sp_irq = _stack_top;
|
||||
__sp_usr = _stack_top - 1K;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP (*(.init))
|
||||
*(.text)
|
||||
. = ALIGN(4);
|
||||
} >rom
|
||||
|
||||
/* Put the stack at the bottom of RAM, so that the application will
|
||||
* crash on stack overflow instead of silently corrupting memory.
|
||||
* See: http://blog.japaric.io/stack-overflow-protection/ */
|
||||
.stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. += _stack_size;
|
||||
_stack_top = .;
|
||||
} >iwram
|
||||
|
||||
/* Start address (in flash) of .data, used by startup code. */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
/* Globals with initial value */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* used by startup code */
|
||||
*(.data)
|
||||
*(.data*)
|
||||
*(.iwram .iwram.*)
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* used by startup code */
|
||||
} >iwram AT>rom
|
||||
|
||||
/* Zero-initialized globals */
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sbss = .; /* used by startup code */
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* used by startup code */
|
||||
} >iwram
|
||||
|
||||
/DISCARD/ :
|
||||
{
|
||||
*(.ARM.exidx) /* causes 'no memory region specified' error in lld */
|
||||
*(.ARM.exidx.*) /* causes spurious 'undefined reference' errors */
|
||||
}
|
||||
}
|
||||
|
||||
/* For the memory allocator. */
|
||||
_heap_start = ORIGIN(ewram);
|
||||
_heap_end = ORIGIN(ewram) + LENGTH(ewram);
|
||||
_globals_start = _sdata;
|
||||
_globals_end = _ebss;
|
||||
@@ -0,0 +1,33 @@
|
||||
.section .init
|
||||
.global _start
|
||||
.align
|
||||
.arm
|
||||
|
||||
_start:
|
||||
b start_vector
|
||||
.fill 156,1,0 // Nintendo Logo Character Data (8000004h)
|
||||
.fill 16,1,0 // Game Title
|
||||
.byte 0x30,0x31 // Maker Code (80000B0h)
|
||||
.byte 0x96 // Fixed Value (80000B2h)
|
||||
.byte 0x00 // Main Unit Code (80000B3h)
|
||||
.byte 0x00 // Device Type (80000B4h)
|
||||
.fill 7,1,0 // unused
|
||||
.byte 0x00 // Software Version No (80000BCh)
|
||||
.byte 0xf0 // Complement Check (80000BDh)
|
||||
.byte 0x00,0x00 // Checksum (80000BEh)
|
||||
|
||||
start_vector:
|
||||
mov r0, #0x4000000 // REG_BASE
|
||||
str r0, [r0, #0x208]
|
||||
|
||||
mov r0, #0x12 // Switch to IRQ Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_irq // Set IRQ stack
|
||||
mov r0, #0x1f // Switch to System Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_usr // Set user stack
|
||||
|
||||
// Jump to user code (switching to Thumb mode)
|
||||
ldr r3, =main
|
||||
bx r3
|
||||
|
||||
Reference in New Issue
Block a user