diff --git a/staging/scsd/Makefile b/staging/scsd/Makefile index cabe207..d29189a 100644 --- a/staging/scsd/Makefile +++ b/staging/scsd/Makefile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------------- ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") endif include $(DEVKITARM)/ds_rules @@ -21,7 +21,6 @@ BUILD := build SOURCES := source DATA := data INCLUDES := include -SPECS := specs #--------------------------------------------------------------------------------- @@ -34,29 +33,29 @@ CFLAGS := -g -Wall -O2\ -ffast-math \ $(ARCH) -CFLAGS += $(INCLUDE) -DARM9 -fPIC +CFLAGS += $(INCLUDE) -DARM7 -fPIC CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(CURDIR)/../$(SPECS)/dldi.specs -T $(CURDIR)/../$(SPECS)/dldi.ld -g $(ARCH) -mno-fpu -Wl,-Map,$(TARGET).map +ASFLAGS := -g $(ARCH) $(INCLUDE) +LDFLAGS = -nostartfiles -nostdlib -T dldi.ld -g $(ARCH) -Wl,-Map,$(TARGET).map -LIBS := -lnds9 +LIBS := #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- LIBDIRS := $(LIBNDS) - - + + #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional # rules for different file extensions #--------------------------------------------------------------------------------- ifneq ($(BUILD),$(notdir $(CURDIR))) #--------------------------------------------------------------------------------- - + export OUTPUT := $(CURDIR)/$(TARGET) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ @@ -93,28 +92,25 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) .PHONY: $(BUILD) clean all - + #--------------------------------------------------------------------------------- all: $(BUILD) $(BUILD): @[ -d $@ ] || mkdir -p $@ - @make -C $(SPECS) - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + #--------------------------------------------------------------------------------- clean: @echo clean ... @rm -fr $(BUILD) $(TARGET).dldi $(TARGET).elf - @make -C $(SPECS) clean - - + #--------------------------------------------------------------------------------- else - + DEPENDS := $(OFILES:.o=.d) - + #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- @@ -126,11 +122,11 @@ $(OUTPUT).elf : $(OFILES) %.dldi: %.elf @$(OBJCOPY) -O binary $< $@ @echo built ... $(notdir $@) - + -include $(DEPENDS) - + #--------------------------------------------------------------------------------------- endif -#--------------------------------------------------------------------------------------- \ No newline at end of file +#--------------------------------------------------------------------------------------- diff --git a/staging/scsd/source/disc_io.h b/staging/scsd/source/disc_io.h index 95c62b9..7726abd 100644 --- a/staging/scsd/source/disc_io.h +++ b/staging/scsd/source/disc_io.h @@ -44,7 +44,7 @@ #endif #ifdef NDS - #include + #include #else #include "gba_types.h" #endif @@ -67,7 +67,7 @@ #define _IO_ALLOW_UNALIGNED #if defined _IO_USE_DMA && defined _IO_ALLOW_UNALIGNED - #error You can't use both DMA and unaligned memory + #error You cannot use both DMA and unaligned memory #endif #define FEATURE_MEDIUM_CANREAD 0x00000001 diff --git a/staging/scsd/source/dldi_header.s b/staging/scsd/source/dldi_header.s new file mode 100644 index 0000000..91d2f52 --- /dev/null +++ b/staging/scsd/source/dldi_header.s @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: Zlib +// +// Copyright (C) 2006-2016 Michael Chisholm (Chishm) +// Copyright (C) 2006-2016 Dave Murphy (WinterMute) + +#include + + .section ".crt0","ax" + .global _start + .align 4 + .arm + +@ Driver patch file standard header -- 16 bytes + + .word 0xBF8DA5ED @ Magic number to identify this region + .asciz " Chishm" @ Identifying Magic string (8 bytes with null terminator) + .byte 0x01 @ Version number + .byte DLDI_SIZE_4KB @ Log [base-2] of the size of this driver in bytes. + .byte FIX_GOT | FIX_BSS | FIX_GLUE @ Sections to fix + .byte 0x00 @ Space allocated in the application, leave empty. + +@ Text identifier - can be anything up to 47 chars + terminating null -- 48 bytes + + .align 4 + .asciz "SuperCard (SD Card)" + +@ Offsets to important sections within the data -- 32 bytes + + .align 6 + .word __text_start @ data start + .word __data_end @ data end + .word __glue_start @ Interworking glue start -- Needs address fixing + .word __glue_end @ Interworking glue end + .word __got_start @ GOT start -- Needs address fixing + .word __got_end @ GOT end + .word __bss_start @ bss start -- Needs setting to zero + .word __bss_end @ bss end + +@ IO_INTERFACE data -- 32 bytes + + .ascii "XXXX" @ ioType (Normally "DLDI") + .word FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_SLOT_GBA + .word _SCSD_startUp @ Function pointers to standard device driver functions + .word _SCSD_isInserted + .word _SCSD_readSectors + .word _SCSD_writeSectors + .word _SCSD_clearStatus + .word _SCSD_shutdown + +_start: + + .align + .pool + .end diff --git a/staging/scsd/specs/Makefile b/staging/scsd/specs/Makefile deleted file mode 100644 index 94718b5..0000000 --- a/staging/scsd/specs/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) -endif - --include $(DEVKITARM)/ds_rules - -all: - @echo -n Compiling dldi_crt0... - @$(CC) -x assembler-with-cpp -marm -mthumb-interwork -c dldi_crt0.s -o dldi_crt0.o - @echo done. - - @echo -n Rewriting specs file... - @echo '*startfile:' > dldi.specs - @echo -n $(shell pwd -W) >> dldi.specs - @echo '/../specs/dldi_crt0%O%s crti%O%s crtbegin%O%s' >> dldi.specs - @echo done. - -clean: - @echo Clean... - rm -f dldi.specs dldi_crt0.o - @echo done. - \ No newline at end of file diff --git a/staging/scsd/specs/dldi.ld b/staging/scsd/specs/dldi.ld deleted file mode 100644 index d3c6b78..0000000 --- a/staging/scsd/specs/dldi.ld +++ /dev/null @@ -1,189 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(_start) - -MEMORY { - /* This base address is chosen to be a reserved instruction in THUMB mode, - and SWILT in ARM mode, with an impossible SWI value. This should allow - the patcher / linker to find all shifted addresses within each section. - Changed sections are: glue_7, got - */ - ddmem : ORIGIN = 0xBF800000, LENGTH = 4K -} - - -SECTIONS -{ - .init : - { - __text_start = . ; - KEEP (*(.init)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ddmem = 0xff - - .text : /* ALIGN (4): */ - { - *(.text.*) - *(.stub) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t*) - __glue_start = ABSOLUTE(.); - *(.glue_7) - *(.glue_7t) - __glue_end = ABSOLUTE(.); - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ddmem = 0xff - - .fini : - { - KEEP (*(.fini)) - } >ddmem =0xff - - __text_end = . ; - - .rodata : - { - *(.rodata) - *all.rodata*(*) - *(.roda) - *(.rodata.*) - *(.gnu.linkonce.r*) - SORT(CONSTRUCTORS) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ddmem = 0xff - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ddmem - __exidx_start = .; - .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ddmem - __exidx_end = .; - -/* Ensure the __preinit_array_start label is properly aligned. We - could instead move the label definition inside the section, but - the linker would then create the section even if it turns out to - be empty, which isn't pretty. */ - . = ALIGN(32 / 8); - PROVIDE (__preinit_array_start = .); - .preinit_array : { KEEP (*(.preinit_array)) } >ddmem = 0xff - PROVIDE (__preinit_array_end = .); - PROVIDE (__init_array_start = .); - .init_array : { KEEP (*(.init_array)) } >ddmem = 0xff - PROVIDE (__init_array_end = .); - PROVIDE (__fini_array_start = .); - .fini_array : { KEEP (*(.fini_array)) } >ddmem = 0xff - PROVIDE (__fini_array_end = .); - - .ctors : - { - /* gcc uses crtbegin.o to find the start of the constructors, so - we make sure it is first. Because this is a wildcard, it - doesn't matter if the user does not actually link against - crtbegin.o; the linker won't look for a file to match a - wildcard. The wildcard also means that it doesn't matter which - directory crtbegin.o is in. */ - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ddmem = 0xff - - .dtors : - { - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ddmem = 0xff - - .eh_frame : - { - KEEP (*(.eh_frame)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ddmem = 0xff - - .gcc_except_table : - { - *(.gcc_except_table) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ddmem = 0xff - .jcr : { KEEP (*(.jcr)) } >ddmem = 0 - - - __got_start = . ; - .got : - { - *(.got.plt) - *(.got) - *(.rel.got) - } >ddmem = 0 - __got_end = . ; - - - .data ALIGN(4) : { - __data_start = ABSOLUTE(.); - *(.data) - *(.data.*) - *(.gnu.linkonce.d*) - CONSTRUCTORS - . = ALIGN(4); - __data_end = ABSOLUTE(.) ; - } >ddmem = 0xff - - __data_end = . ; - - .bss ALIGN(4) : - { - __bss_start = ABSOLUTE(.); - __bss_start__ = ABSOLUTE(.); - *(.dynbss) - *(.gnu.linkonce.b*) - *(.bss*) - *(COMMON) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ddmem - - __bss_end = . ; - __bss_end__ = . ; - - _end = . ; - __end__ = . ; - PROVIDE (end = _end); - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - .stack 0x80000 : { _stack = .; *(.stack) } - /* These must appear regardless of . */ -} diff --git a/staging/scsd/specs/dldi_crt0.s b/staging/scsd/specs/dldi_crt0.s deleted file mode 100644 index 1bca0fd..0000000 --- a/staging/scsd/specs/dldi_crt0.s +++ /dev/null @@ -1,63 +0,0 @@ -@--------------------------------------------------------------------------------- - .section ".init" -@--------------------------------------------------------------------------------- - .global _start - .align 4 - .arm - -@--------------------------------------------------------------------------------- -.equ FEATURE_MEDIUM_CANREAD, 0x00000001 -.equ FEATURE_MEDIUM_CANWRITE, 0x00000002 -.equ FEATURE_SLOT_GBA, 0x00000010 -.equ FEATURE_SLOT_NDS, 0x00000020 - -.equ FIX_ALL, 0x01 -.equ FIX_GLUE, 0x02 -.equ FIX_GOT, 0x04 -.equ FIX_BSS, 0x08 - - -@--------------------------------------------------------------------------------- -@ Driver patch file standard header -- 16 bytes - .word 0xBF8DA5ED @ Magic number to identify this region - .asciz " Chishm" @ Identifying Magic string (8 bytes with null terminator) - .byte 0x01 @ Version number - .byte 0x0C @4KiB @ Log [base-2] of the maximum size of this driver in bytes. - .byte FIX_GOT | FIX_BSS @ Sections to fix - .byte 0x00 @ padding - -@--------------------------------------------------------------------------------- -@ Text identifier - can be anything up to 47 chars + terminating null -- 48 bytes - .align 4 - .asciz "SuperCard (SD Card)" - -@--------------------------------------------------------------------------------- -@ Offsets to important sections within the data -- 32 bytes - .align 6 - .word __text_start @ data start - .word __data_end @ data end - .word __glue_start @ Interworking glue start -- Needs address fixing - .word __glue_end @ Interworking glue end - .word __got_start @ GOT start -- Needs address fixing - .word __got_end @ GOT end - .word __bss_start @ bss start -- Needs setting to zero - .word __bss_end @ bss end - -@--------------------------------------------------------------------------------- -@ IO_INTERFACE data -- 32 bytes - .ascii "SCSD" - .word FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_SLOT_GBA - .word _SCSD_startUp @ - .word _SCSD_isInserted @ - .word _SCSD_readSectors @ Function pointers to standard device driver functions - .word _SCSD_writeSectors @ - .word _SCSD_clearStatus @ - .word _SCSD_shutdown @ - -@--------------------------------------------------------------------------------- -_start: -@--------------------------------------------------------------------------------- - .align - .pool - .end -@---------------------------------------------------------------------------------