Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
minrt: restructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarLambda committed Nov 12, 2022
1 parent 40e9fcf commit e80384f
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 157 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Setup

```
meson setup --cross-file=cross/arm-none-eabi.txt --cross-file=cross/arm7tdmi.txt build
./meson-setup.sh
meson compile -C build
```

Expand Down
2 changes: 2 additions & 0 deletions examples/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ foreach bin : elfs
input: bin,
output: bin.name() + '.gba',
command: [makerom, '@INPUT@', '@OUTPUT@'],
# https://github.com/mesonbuild/meson/discussions/10981#discussioncomment-4034259
depends: [gbafix],
build_by_default: true)
endforeach
2 changes: 2 additions & 0 deletions meson-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
meson setup --cross-file=cross/arm-none-eabi.txt --cross-file=cross/arm7tdmi.txt build
13 changes: 12 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('sdk-seven', 'c',
version: '0.1.1',
version: '0.2.0',
license: 'Zlib',
meson_version: '>=0.56.0')

Expand All @@ -12,8 +12,19 @@ add_project_arguments(
add_project_link_arguments(
'-mthumb',
'-Wl,--gc-sections',
'-specs=nosys.specs',
language: 'c')

cc = meson.get_compiler('c')

# Detect newlib-nano
#
if cc.has_argument('-specs=nano.specs')
add_project_link_arguments(
'-specs=nano.specs',
language: 'c')
endif

subproject('libseven')
subproject('minrt')

Expand Down
3 changes: 2 additions & 1 deletion subprojects/libseven/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ libseven = static_library(
'seven',
sources,
include_directories: includes + 'src',
c_args: ['-mthumb', '-ffunction-sections', '-fdata-sections', '-ffreestanding'])
c_args: ['-mthumb', '-ffunction-sections', '-fdata-sections'])


libseven_dep = declare_dependency(
include_directories: includes,
Expand Down
File renamed without changes.
13 changes: 7 additions & 6 deletions subprojects/minrt/meson.build
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
project('minrt', 'c',
version: '0.1.1',
version: '0.2.0',
license: 'MPL-2.0',
default_options: ['warning_level=2', 'c_std=c99'])

sources = [
'src/crt0.s',
'src/ram.c',
'src/gba/rom_header.s',
'src/gba/crt0.s',
'src/gba/ram.c',
]

includes = ['include']

lib = meson.project_source_root() / 'lib'

link_args = ['-specs=' + lib / 'nocrt0.specs', '-L' + lib]
link_args = ['-specs=' + lib / 'nocrt0.specs', '-L' + lib / 'ldscripts']

minrt = static_library(
'minrt',
sources,
include_directories: includes + 'src',
c_args: ['-mthumb', '-ffunction-sections', '-fdata-sections', '-ffreestanding'])
include_directories: includes + 'src' + 'src/gba',
c_args: ['-mthumb', '-ffunction-sections', '-fdata-sections'])

minrt_dep = declare_dependency(
include_directories: includes,
Expand Down
24 changes: 3 additions & 21 deletions subprojects/minrt/src/crt0.s → subprojects/minrt/src/gba/crt0.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,14 @@
.syntax unified
.cpu arm7tdmi

.section .rom_header,"ax",%progbits
.align 2
.arm
_start:
b entrypoint @ ROM entry point
.include "header.s"
b entrypoint @ Multiboot entry point
_boot_type:
.zero 1 @ Boot type
_boot_client:
.zero 1 @ Client number
.zero 26 @ Reserved
b entrypoint @ JOY Bus entry point

.align 2
.arm
entrypoint:
add r0, pc, #1
bx r0
.thumb
@ IRQs off
ldr r3, =REG_IME
strh r3, [r3]

ldr r3, =REG_WRAMCNT
ldr r2, =__wramcnt
str r2, [r3]

ldr r3, =REG_DMA3

@ .iwram section
Expand Down Expand Up @@ -151,12 +131,14 @@ fini_skip:

pool: .pool

@ HACK: Reference a symbol from the header so it doesn't get dropped during link
.equiv KEEP_HEADER, __boot_type
.equiv REG_DMA3, 0x040000D4
.equiv REG_IME, 0x04000208
.equiv REG_WRAMCNT, 0x04000800
.equiv SVC_CPUSET, 11

.global _start, _exit, _boot_type, _boot_client
.global _start, _exit
.weak _exit

@ vim: ft=armv4 et sta sw=4 sts=8
File renamed without changes.
24 changes: 24 additions & 0 deletions subprojects/minrt/src/gba/rom_header.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@
@ This Source Code Form is subject to the terms of the Mozilla Public
@ License, v. 2.0. If a copy of the MPL was not distributed with this
@ file, You can obtain one at https://mozilla.org/MPL/2.0/.
@

.syntax unified
.cpu arm7tdmi

.section .rom_header,"ax",%progbits

b _start @ ROM entry point
.include "rom_header_data.s" @ ROM header information
b _start @ Multiboot entry point
__boot_type:
.zero 1 @ Link transfer boot type
__boot_client:
.zero 1 @ Multiplayer player number
.zero 26 @ Reserved
b _start @ JOY Bus entry point

.global __boot_type, __boot_client

@ vim: ft=armv4 et sta sw=4 sts=8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ NINTENDO LOGO DATA
@ Nintendo Logo Data
.byte 0x24, 0xFF, 0xAE, 0x51, 0x69, 0x9A, 0xA2, 0x21
.byte 0x3D, 0x84, 0x82, 0x0A, 0x84, 0xE4, 0x09, 0xAD
.byte 0x11, 0x24, 0x8B, 0x98, 0xC0, 0x81, 0x7F, 0x21
Expand All @@ -19,7 +19,7 @@
.byte 0x65, 0xC0, 0x7C, 0x63, 0x87, 0xF0, 0x3C, 0xAF
.byte 0xD6, 0x25, 0xE4, 0x8B, 0x38, 0x0A, 0xAC, 0x72
.byte 0x21, 0xD4, 0xF8, 0x07
@ CHECKSUM AREA BEGIN
@ Checksum Area Start
.zero 12 @ Game title
.zero 4 @ Game code
.zero 2 @ Maker code
Expand All @@ -28,7 +28,7 @@
.zero 1 @ Device type
.zero 7 @ Reserved
.zero 1 @ Game version
@ CHECKSUM AREA END
@ Checksum Area End
.byte 0x51 @ Checksum
.zero 2 @ Reserved

Expand Down
16 changes: 0 additions & 16 deletions subprojects/minrt/src/header-nologo.s

This file was deleted.

108 changes: 0 additions & 108 deletions subprojects/minrt/src/rsrt0.s

This file was deleted.

0 comments on commit e80384f

Please sign in to comment.