Skip to content

Commit

Permalink
m3sd: rebase to libnds 1.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lifehackerhansol committed Oct 18, 2023
1 parent 623fc91 commit ca97840
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 352 deletions.
38 changes: 17 additions & 21 deletions staging/m3sd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif

include $(DEVKITARM)/ds_rules
Expand All @@ -21,7 +21,6 @@ BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
SPECS := specs


#---------------------------------------------------------------------------------
Expand All @@ -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)) \
Expand Down Expand Up @@ -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
#---------------------------------------------------------------------------------
Expand All @@ -126,11 +122,11 @@ $(OUTPUT).elf : $(OFILES)
%.dldi: %.elf
@$(OBJCOPY) -O binary $< $@
@echo built ... $(notdir $@)


-include $(DEPENDS)


#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------
98 changes: 0 additions & 98 deletions staging/m3sd/source/disc_io.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
#include <nds/arm9/dldi_asm.h>

@---------------------------------------------------------------------------------
.section ".init"
.section ".crt0","ax"
@---------------------------------------------------------------------------------
.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 DLDI_SIZE_4KB
.byte FIX_GOT | FIX_BSS @ Sections to fix
.byte 0x00 @ padding
.byte 0x00 @ Space allocated in the application, not important here.

@---------------------------------------------------------------------------------
@ Text identifier - can be anything up to 47 chars + terminating null -- 48 bytes
.align 4
.asciz "M3 Adapter (SD Card)"

@---------------------------------------------------------------------------------
@ Offsets to important sections within the data -- 32 bytes
.align 6
Expand All @@ -45,15 +35,15 @@

@---------------------------------------------------------------------------------
@ IO_INTERFACE data -- 32 bytes
.ascii "M3SD"
.ascii "M3SD" @ ioType
.word FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_SLOT_GBA
.word _M3SD_startUp @
.word _M3SD_isInserted @
.word _M3SD_readSectors @ Function pointers to standard device driver functions
.word _M3SD_writeSectors @
.word _M3SD_clearStatus @
.word _M3SD_shutdown @

@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions staging/m3sd/source/io_m3_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <nds/ndstypes.h>

#include "io_m3_common.h"

static u16 _M3_readHalfword (u32 addr) {
Expand Down
2 changes: 1 addition & 1 deletion staging/m3sd/source/io_m3_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#ifndef IO_M3_COMMON_H
#define IO_M3_COMMON_H

#include "disc_io.h"
#include <nds/ndstypes.h>

// Values for changing mode
#define M3_MODE_ROM 0x00400004
Expand Down
20 changes: 19 additions & 1 deletion staging/m3sd/source/io_m3sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,25 @@
* Moved the SD initialization to a common function
*/

#include "disc_io.h"
// When compiling for NDS, make sure NDS is defined
#ifndef NDS
#if defined ARM9 || defined ARM7
#define NDS
#endif
#endif

#ifdef NDS
#include <nds/ndstypes.h>
#else
#include "gba_types.h"
#endif

#define BYTES_PER_READ 512

#ifndef NULL
#define NULL 0
#endif

#include "io_sd_common.h"
#include "io_m3_common.h"

Expand Down
2 changes: 1 addition & 1 deletion staging/m3sd/source/io_sd_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#ifndef IO_SD_COMMON_H
#define IO_SD_COMMON_H

#include "disc_io.h"
#include <nds/ndstypes.h>

/* SD commands */
#define GO_IDLE_STATE 0
Expand Down
22 changes: 0 additions & 22 deletions staging/m3sd/specs/Makefile

This file was deleted.

Loading

0 comments on commit ca97840

Please sign in to comment.