From a381d2d1891a6624a65f46fcf62daa21d2b78cdc Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Sat, 20 Aug 2016 21:55:07 +0200 Subject: [PATCH] Did some stuff to prepare future interrupt handling --- Makefile | 6 +- boot/x86/boot.S | 44 ++++++++++ boot/x86_64/boot.S | 19 ++++- firm.bin | Bin 0 -> 6736 bytes include/interrupts.h | 16 ++++ include/moduleinterface.h | 2 +- kernel/init.cpp | 42 +++++---- modules/3ds/dsp/txt/.init.cpp.kate-swp | Bin 0 -> 388 bytes modules/3ds/dsp/txt/init.cpp | 113 +++++++++++++++++-------- 9 files changed, 182 insertions(+), 60 deletions(-) create mode 100644 firm.bin create mode 100644 include/interrupts.h create mode 100644 modules/3ds/dsp/txt/.init.cpp.kate-swp diff --git a/Makefile b/Makefile index d98f48e..ad648b1 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ -all: loader.bin firm.bin +all: loader.bin mtgos.firm $(MAKE) -C modules loader.bin: $(MAKE) -C boot mv boot/loader.bin . -firm.bin: +mtgos.firm: $(MAKE) -C kernel mv kernel/mtgos.elf . objcopy -O binary mtgos.elf mtgos.bin ./firmlink mtgos rm -rf mtgos.bin clean: - find . -name '*.o' -delete \ No newline at end of file + find . -name '*.o' -delete diff --git a/boot/x86/boot.S b/boot/x86/boot.S index 6d53da2..cb52bef 100644 --- a/boot/x86/boot.S +++ b/boot/x86/boot.S @@ -17,11 +17,55 @@ _start: mov $kernel_stack, %esp push %ebx push %eax + lgdt gdtr + mov $0x10, %eax + mov %ax, %ds + mov %ax, %es + mov %ax, %fs + mov %ax, %gs + mov %ax, %ss + ljmp $0x08,$_st +_st: call init _exit: cli hlt jmp _exit +.section .data +gdt: +//NULL-descriptor +.quad 0 +//code kernel +.word 0xFFFF +.word 0x0000 +.byte 0x00 +.byte 0x98 +.byte 0xCF +.byte 0x00 +//data kernel +.word 0xFFFF +.word 0x0000 +.byte 0x00 +.byte 0x92 +.byte 0xCF +.byte 00 +//code user +.word 0xFFFF +.word 0x0000 +.byte 0x00 +.byte 0xF8 +.byte 0xCF +.byte 0x00 +//data user +.word 0xFFFF +.word 0x0000 +.byte 0x00 +.byte 0xF2 +.byte 0xCF +.byte 00 +gdtr: + .word 5 * 8 + .int gdt .section .bss .space 8192 kernel_stack: \ No newline at end of file diff --git a/boot/x86_64/boot.S b/boot/x86_64/boot.S index 5db8ea1..99998e8 100644 --- a/boot/x86_64/boot.S +++ b/boot/x86_64/boot.S @@ -110,22 +110,35 @@ gdt: .byte 0x98 .byte 0xCF .byte 0x00 -//data +//data kernel .word 0xFFFF .word 0x0000 .byte 0x00 .byte 0x92 .byte 0xCF .byte 00 -//64-bit code +//64-bit code kernel .int 0 .byte 0 .byte 0x98 .byte 0x20 .byte 0 +//data user +.word 0xFFFF +.word 0x0000 +.byte 0x00 +.byte 0xF2 +.byte 0xCF +.byte 00 +//64-bit code user +.int 0 +.byte 0 +.byte 0xF8 +.byte 0x20 +.byte 0 gdtr: - .word 4 * 8 + .word 6 * 8 .int gdt pmfill: .int pagedirPT + 0x7 diff --git a/firm.bin b/firm.bin new file mode 100644 index 0000000000000000000000000000000000000000..f23df6033d1e437a2aa4261f540edfd1bbaa56e6 GIT binary patch literal 6736 zcmeHKZEO=|9KY*sa$8GV$YO>pGRO&=kg)1R8m6wWn?twIOo}9eFAGCNiE;GsB}|#e zU{8)}Kg>iD68&JJpN#))+F?ezYO_w0@J zzm&`M^PVgBpHT3SpVgRMlSSJ>uIdA2K3i4uRkCuwu{2fHD`sPvS5@mRJWRtL?ZgE_ z&0T^kA0qO2zdS(^$~;uP#C9mKLY{d4bxoe=8qO!(nmo>jv}%#aiRmJDktQdofjBi+ zUA#h0v@A_8`~WdATW9>t&U0!^>X#EVt+v*Lp2u;vk2Rj= znD7;~r?N#_TzkN_`>kw%J96N*uB$x)kz;CWjI-^2A{$MOS=^c&(?e>Hoyd{D*r&Ni z_)tDgiQy38Q3)*b0A>k|WF>Zs% zU(gEpQ*GVMq(KxJQT!WX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g7bf zOMsVV;u{Q{<~*LldouCby?J{CHQ#h7=<0LzyC|E+D&Y*@16xui_hrM@F34(t571a( z)2Ow}YT29TvfB3uE^CpRzsg!+sxPz_xq?=^tIuk2^;<<(uT@xWHf_ryUSobXi_~Ra zlSSHq{}X8p1Bk(ko#DDm4BjmIF7xIr(pvMYS){Vr)R9G8L;qDZj+NMyxpQ*voJ=0;i++) { + out << i << " "; + } + break; } + case ModType::none: + default: + out << "This is not a module I can load!\n"; + } } for(void(**i)()=&start_dtors;i<&end_dtors;i++) (*i)(); //Calling destructors diff --git a/modules/3ds/dsp/txt/.init.cpp.kate-swp b/modules/3ds/dsp/txt/.init.cpp.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..0c3f3a67d8f5dcb95dccb028820aed1af68d0fb0 GIT binary patch literal 388 zcmYk#D+|I<7=YnZOd_aYFu5SuhL<#(L5o4$(M@;1xF8q|f`7mu_{$7}|HNdn=sUjP zVDCB4zQL!IYR=PBVd!&uG-mrlVGPZ_QmX!X1kP<_-6x-SCGXfzZU4R&zn7;9cI8#6 z8ps7LkO`I`{YN5LFo^{ghy*4G1#J)r%00fI!Ne1kOSgh6lg&R|!G(z<7=yK709Jw? l(1I?%6l6zol97}oBqk9FNkDw!kuBK}mpEiiR#VNPr(a*gEfW9$ literal 0 HcmV?d00001 diff --git a/modules/3ds/dsp/txt/init.cpp b/modules/3ds/dsp/txt/init.cpp index 0c87c4c..da96eef 100644 --- a/modules/3ds/dsp/txt/init.cpp +++ b/modules/3ds/dsp/txt/init.cpp @@ -13,12 +13,23 @@ static int x=0,y=0; #define CHR_HEIGHT 8 #define CHR_WIDTH 8 #define HEIGHT 29 +#define PXHEIGHT 240 #ifndef ARM9 #define WIDTH 50 +#define PXWIDTH 400 #else #define WIDTH 40 +#define PXWIDTH 320 #endif #define BYTESPP 3 +#define CALCXY(x,y) ((x)*240+239-(y)) +#define TOPLFB 0x18000000 +#define BOTTOMLFB 0x18180000 +#ifdef ARM9 +#define LFB BOTTOMLFB +#else +#define LFB TOPLFB +#endif namespace MTGos { namespace { /** @@ -27,30 +38,73 @@ namespace { */ class Screen: public Base::Output { public: - Screen() {} - auto scroll() -> void { -#ifndef 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; + auto clrscr() -> void { + uint32_t* vmem = (uint32_t*)LFB; + for(int i=0;i void { + uint32_t* vmem = (uint32_t*)LFB; + for(int ly=0;ly<240;ly++) { + for(int lx=0;lx void{ -#ifndef 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 + uint32_t* vmem = (uint32_t*)LFB; c&=0xFF; switch(c) { case '\n': @@ -72,13 +126,9 @@ private: for(int cx=0;cx