woking driver
This commit is contained in:
parent
9c682cd9e2
commit
d5d02f8b5b
10 changed files with 72 additions and 26 deletions
5
Makefile
5
Makefile
|
@ -10,7 +10,4 @@ firm.bin:
|
|||
./firmlink mtgos
|
||||
rm -rf mtgos.bin
|
||||
clean:
|
||||
find . -name '*.o' -delete
|
||||
find . -name '*.bin' -delete
|
||||
find . -name '*.firm' -delete
|
||||
find . -name '*.mod' -delete
|
||||
find . -name '*.o' -delete
|
|
@ -2,7 +2,11 @@
|
|||
#include "sdmmc.h"
|
||||
#include "fatfs/ff.h"
|
||||
char *lfb=(char*)0x18346500;
|
||||
#ifndef ARM9
|
||||
#define DIAGPXL(i) (lfb[6*(i)]=lfb[6*(i)+1]=lfb[6*(i)+2]=0xFF)
|
||||
#else
|
||||
#define DIAGPXL(i) (0)
|
||||
#endif
|
||||
/**
|
||||
* \struct FIRM_sect
|
||||
* \brief Contains one section of the FIRM format
|
||||
|
@ -33,14 +37,20 @@ struct FIRM_header {
|
|||
void *arm9modtable[64];
|
||||
void *arm11modtable[64];
|
||||
struct FIRM_header hdr;
|
||||
void init() {
|
||||
void doARM11() {
|
||||
DIAGPXL(0);
|
||||
hdr.arm11entry(arm11modtable);
|
||||
for(;;);
|
||||
}
|
||||
void init() {
|
||||
FATFS fs;
|
||||
FIL firm;
|
||||
f_mount(&fs, "0:", 0);
|
||||
unsigned int off=0x20000000;
|
||||
arm9modtable[0]=0x20000000;
|
||||
arm9modtable[1]=0;
|
||||
arm11modtable[0]=0;
|
||||
arm11modtable[0]=0x20000000;
|
||||
arm11modtable[1]=0;
|
||||
if(f_open(&firm, "mtgos.firm", FA_READ | FA_OPEN_EXISTING) == FR_OK) {
|
||||
DIAGPXL(1);
|
||||
unsigned int br;
|
||||
|
@ -61,11 +71,18 @@ void init() {
|
|||
DIAGPXL(i+8);
|
||||
}
|
||||
DIAGPXL(12);
|
||||
FIL dsp_txt;
|
||||
f_open(&dsp_txt, "dsp_txt.elf", FA_READ | FA_OPEN_EXISTING);
|
||||
f_read(&dsp_txt, (void*)0x20000000, f_size(&dsp_txt), &br);
|
||||
void(**a11fpointer)(void**)=(void(**)(void**))0x1FFFFFF8;
|
||||
*a11fpointer=hdr.arm11entry;
|
||||
FIL dsp_txt9;
|
||||
f_open(&dsp_txt9, "dsp_txt.neun", FA_READ | FA_OPEN_EXISTING);
|
||||
f_read(&dsp_txt9, (void*)off, f_size(&dsp_txt9), &br);
|
||||
off+=f_size(&dsp_txt9);
|
||||
FIL dsp_txt11;
|
||||
arm11modtable[0]=off;
|
||||
arm11modtable[1]=0;
|
||||
f_open(&dsp_txt11, "dsp_txt.elf", FA_READ | FA_OPEN_EXISTING);
|
||||
f_read(&dsp_txt11, (void*)off, f_size(&dsp_txt11), &br);
|
||||
off+=f_size(&dsp_txt11);
|
||||
void(**a11fpointer)(void)=(void(**)(void**))0x1FFFFFF8;
|
||||
*a11fpointer=&doARM11;
|
||||
hdr.entrypoint(arm9modtable); //Jump to kernel
|
||||
}
|
||||
for(;;);
|
||||
|
|
5
do.sh
5
do.sh
|
@ -2,8 +2,10 @@
|
|||
gmake clean
|
||||
gmake loader.bin
|
||||
gmake -C kernel
|
||||
gmake -C kernel clean
|
||||
gmake clean
|
||||
gmake -C modules
|
||||
gmake clean
|
||||
gmake -C modules subvar=11
|
||||
mv kernel/mtgos.elf .
|
||||
objcopy -O binary mtgos.elf mtgos.bin
|
||||
gmake -C kernel subvar=11
|
||||
|
@ -18,5 +20,6 @@ sudo rm mount/{arm9loaderhax.bin,mtgos.firm}
|
|||
sudo mv loader.bin mount/arm9loaderhax.bin
|
||||
sudo mv mtgos.firm mount/mtgos.firm
|
||||
sudo mv *.elf mount
|
||||
sudo mv *.neun mount
|
||||
sudo umount mount
|
||||
echo "Remove SD card!"
|
||||
|
|
|
@ -18,9 +18,11 @@ else
|
|||
PREFIX = arm-none-eabi-
|
||||
libpath = arm-none-eabi
|
||||
ifeq ($(subvar),9)
|
||||
ARCHFLAGS = -mcpu=arm946e-s -march=armv5te -mlittle-endian
|
||||
ARCHFLAGS = -mcpu=arm946e-s -march=armv5te -mlittle-endian -DARM9
|
||||
MOD_SUFF=neun
|
||||
else
|
||||
ARCHFLAGS = -mcpu=mpcore -mlittle-endian
|
||||
ARCHFLAGS = -mcpu=mpcore -mlittle-endian -DARM11
|
||||
MOD_SUFF=elf
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -10,7 +10,11 @@
|
|||
#define Elf_Phdr Elf32_Phdr
|
||||
#endif
|
||||
char *lfb=(char*)0x18346500;
|
||||
#ifndef ARM9
|
||||
#define DIAGPXL(i) (lfb[6*(i)]=lfb[6*(i)+1]=lfb[6*(i)+2]=0xFF)
|
||||
#else
|
||||
#define DIAGPXL(i) (0)
|
||||
#endif
|
||||
/** \brief beginning of constructor table */
|
||||
extern "C" void(*start_ctors)();
|
||||
/** \brief end of constructor table */
|
||||
|
@ -79,7 +83,12 @@ extern "C" void _start(void ** modtable) {
|
|||
DIAGPXL(21);
|
||||
((spawnAt_type)table[2])((void*)&out);
|
||||
DIAGPXL(22);
|
||||
out << "HI!\nbye!";
|
||||
out << "HI!\nbye!\n";
|
||||
#ifdef ARM9
|
||||
out << "Here arm9!\n";
|
||||
#else
|
||||
out << "Here arm11!\n";
|
||||
#endif
|
||||
}
|
||||
for(void(**i)()=&start_dtors;i<&end_dtors;i++)
|
||||
(*i)(); //Calling destructors
|
||||
|
|
|
@ -6,11 +6,11 @@ CPP = $(PREFIX)g++
|
|||
CC = $(PREFIX)gcc
|
||||
LD = $(PREFIX)g++
|
||||
|
||||
CFLAGS += -Wall -fno-stack-protector -nostdinc -Ic_include/ -I../../../../c_include -ffreestanding -std=c11 -fno-builtin -Werror -nostdlib -g -fpic
|
||||
CPPFLAGS += -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../../../c_include -I../../../../include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpic -Wno-reorder -fdump-class-hierarchy
|
||||
CFLAGS += -Wall -fno-stack-protector -nostdinc -Ic_include/ -I../../../../c_include -ffreestanding -std=c11 -fno-builtin -Werror -nostdlib -g -fPIC -pie
|
||||
CPPFLAGS += -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../../../c_include -I../../../../include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fPIC -pie -Wno-reorder -fdump-class-hierarchy
|
||||
LDFLAGS += -nostdlib -nodefaultlibs -nostdlib -fno-builtin -T ../../link.ld
|
||||
all: $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o ../../../../dsp_txt.elf $(OBJS) -lgcc
|
||||
$(LD) $(LDFLAGS) -o ../../../../dsp_txt.$(MOD_SUFF) $(OBJS) -lgcc
|
||||
%.o: %.cpp
|
||||
$(CPP) $(CPPFLAGS) -c -o $@ $^
|
||||
|
||||
|
|
|
@ -2,16 +2,26 @@
|
|||
#include <base/output.hpp>
|
||||
#include <modstubs.h>
|
||||
#include "stdfnt.h"
|
||||
#ifdef ARM9
|
||||
uint8_t* vmem = (uint8_t*)0x18300000;
|
||||
uint8_t* dmem = (uint8_t*)0x18346500;
|
||||
#else
|
||||
uint8_t* dmem = (uint8_t*)0x18300000;
|
||||
uint8_t* vmem = (uint8_t*)0x18346500;
|
||||
#endif
|
||||
static int x=0,y=0;
|
||||
#define DIAGPXL(i) (dmem[6*(i)]=dmem[6*(i)+1]=dmem[6*(i)+2]=0xFF)
|
||||
#define DIAGPXL(i) (debugNumber(i,i))
|
||||
#define CHR_HEIGHT 8
|
||||
#define CHR_WIDTH 8
|
||||
#define HEIGHT 29
|
||||
#ifdef ARM9
|
||||
#define WIDTH 50
|
||||
#else
|
||||
#define WIDTH 40
|
||||
#endif
|
||||
#define BYTESPP 3
|
||||
void debugNumber(unsigned int i, int start) {
|
||||
return;
|
||||
while(i) {
|
||||
if(i&1)
|
||||
dmem[(start*6)+5]=0xFF;
|
||||
|
@ -66,11 +76,13 @@ private:
|
|||
for(int cx=0;cx<CHR_WIDTH;cx++) {
|
||||
for(int cy=0;cy<CHR_HEIGHT;cy++) {
|
||||
if(font[c][cy]&(1<<cx)) {
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+((HEIGHT-y)*CHR_HEIGHT+cy))*BYTESPP]=0xFF;
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+((HEIGHT-y)*CHR_HEIGHT+cy))*BYTESPP+1]=0;
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+HEIGHT*CHR_HEIGHT-(y*CHR_HEIGHT+cy))*BYTESPP]=0xFF;
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+HEIGHT*CHR_HEIGHT-(y*CHR_HEIGHT+cy))*BYTESPP+1]=0xFF;
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+HEIGHT*CHR_HEIGHT-(y*CHR_HEIGHT+cy))*BYTESPP+2]=0xFF;
|
||||
}else {
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+((HEIGHT-y)*CHR_HEIGHT+cy))*BYTESPP+1]=0xFF;
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+((HEIGHT-y)*CHR_HEIGHT+cy))*BYTESPP]=0;
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+HEIGHT*CHR_HEIGHT-(y*CHR_HEIGHT+cy))*BYTESPP]=0;
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+HEIGHT*CHR_HEIGHT-(y*CHR_HEIGHT+cy))*BYTESPP+1]=0;
|
||||
vmem[((x*CHR_WIDTH+cx)*(HEIGHT+1)*8+HEIGHT*CHR_HEIGHT-(y*CHR_HEIGHT+cy))*BYTESPP+2]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,8 +94,8 @@ private:
|
|||
break;
|
||||
}
|
||||
debugNumber((unsigned int)y,532+8*8+64);
|
||||
//if(y>HEIGHT)
|
||||
// scroll();
|
||||
if(y>HEIGHT)
|
||||
scroll();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -28,5 +28,11 @@ SECTIONS
|
|||
*(.bss)
|
||||
*(COMMON)
|
||||
}
|
||||
.rel.plt : {
|
||||
*(.rel.plt)
|
||||
}
|
||||
.rel.dyn : {
|
||||
*(.rel.dyn)
|
||||
}
|
||||
module_end = .;
|
||||
}
|
||||
}
|
BIN
mount/arm9loaderhax.bin
Executable file
BIN
mount/arm9loaderhax.bin
Executable file
Binary file not shown.
BIN
mount/dsp_txt.neun
Executable file
BIN
mount/dsp_txt.neun
Executable file
Binary file not shown.
Loading…
Reference in a new issue