Skip to content

Commit

Permalink
MAJOR FeOS API RESTRUCTURING AND KERNEL CLEANUP, see details:
Browse files Browse the repository at this point in the history
- Fake module structure simplified into two big blocks:
  FEOSKRNL - Platform-"independent" FeOS API
  FEOSDSHW - DS-specific FeOS API
- FeOS_ prefix replaced by NT-like function categories:
  Ke  - General kernel functions
  Ldr - Module loading
  Io  - Input/output
  DS  - DS-specific functions
- Console mode IO region block lifted - many SWI thunks removed
- Module export table is now searched using binary search
- Kernel iprintf() is overriden to save space
- Major code cleanup and reorganization
  • Loading branch information
fincs committed Aug 10, 2013
1 parent 3330fb1 commit a53ba81
Show file tree
Hide file tree
Showing 61 changed files with 1,908 additions and 2,253 deletions.
20 changes: 4 additions & 16 deletions .gitignore
Expand Up @@ -20,22 +20,10 @@ build/
/sdk/bin/fartool
/sdk/bin/fpkgtool
/sdk/bin/fmantool
/sdk/source/FEOSBASE/*
!/sdk/source/FEOSBASE/Makefile
/sdk/source/FEOSSTDIO/*
!/sdk/source/FEOSSTDIO/Makefile
/sdk/source/FEOSPOSIXEMU/*
!/sdk/source/FEOSPOSIXEMU/Makefile
/sdk/source/FEOSMATH/*
!/sdk/source/FEOSMATH/Makefile
/sdk/source/FEOSDSAPI/*
!/sdk/source/FEOSDSAPI/Makefile
/sdk/source/FEOSDSSPR/*
!/sdk/source/FEOSDSSPR/Makefile
/sdk/source/FEOSDSBG/*
!/sdk/source/FEOSDSBG/Makefile
/sdk/source/FEOSARM7/*
!/sdk/source/FEOSARM7/Makefile
/sdk/source/FEOSKRNL/*
!/sdk/source/FEOSKRNL/Makefile
/sdk/source/FEOSDSHW/*
!/sdk/source/FEOSDSHW/Makefile
/sdk/source7/FEOS7/*
!/sdk/source7/FEOS7/Makefile
/sdk/userlib/*
Expand Down
4 changes: 2 additions & 2 deletions arm7/source/feos.h
@@ -1,10 +1,10 @@
#pragma once
#include <nds.h>
#include "../../kernel/source/feos.h"
#include "../../kernel/source/fxe.h"
#include "../../kernel/source/loader.h"
#include "../../kernel/source/feosfifo.h"

void FeOS_VBlankFunc();
void Ke7VBlankISR();

void coopFifoSetDatamsgHandler(int channel, FifoDatamsgHandlerFunc handler, void* userdata);
void coopFifoSetValue32Handler(int channel, FifoValue32HandlerFunc handler, void* userdata);
Expand Down
1 change: 0 additions & 1 deletion arm7/source/feosirq.arm.c

This file was deleted.

1 change: 1 addition & 0 deletions arm7/source/interrupt.arm.c
@@ -0,0 +1 @@
#include "../../kernel/source/interrupt.arm.c"
14 changes: 7 additions & 7 deletions arm7/source/feos.c → arm7/source/kernel7.c
Expand Up @@ -30,7 +30,7 @@ void installFeOSFIFO()
}

static FeOSLoadStruct* ldSt = NULL;
static instance_t freeMod = NULL;
static module_t freeMod = NULL;
static int freeChn;

static volatile int oldPower;
Expand Down Expand Up @@ -102,13 +102,13 @@ void __wrap_systemSleep()
__real_systemSleep();
}

static void FeOS_LoadModule();
static void Ke7LoadModule();

void FeOS_VBlankFunc()
void Ke7VBlankISR()
{
if (ldSt)
{
FeOS_LoadModule();
Ke7LoadModule();
ldSt = NULL;
}
if (freeMod)
Expand All @@ -121,9 +121,9 @@ void FeOS_VBlankFunc()
}
}

bool FeOS_ResolveImp(word_t* addr, const char* name);
bool Ke7ResolveImp(word_t* addr, const char* name);

void FeOS_LoadModule()
void Ke7LoadModule()
{
FeOSFifoMsg msg;
msg.type = FEOS_ARM7_RETURN_MODULE;
Expand Down Expand Up @@ -166,7 +166,7 @@ void FeOS_LoadModule()
word_t* addr = (word_t*)(imps[i].address + (word_t)hModule);
const char* name = (const char*)(imps[i].nameoffset + (word_t) imps);

if (!FeOS_ResolveImp(addr, name))
if (!Ke7ResolveImp(addr, name))
{
free(hModule);
freeFifoChannel(msg.fifoCh);
Expand Down
108 changes: 54 additions & 54 deletions arm7/source/lib.c
Expand Up @@ -12,8 +12,8 @@ unsigned long long __aeabi_uldivmod(unsigned long long, unsigned long long);

long long __aeabi_lmul(long long, long long);

#define ADD_FUNC(FUNC) {{(word_t)#FUNC}, {(word_t)FUNC}}
#define ADD_FUNC_ALIAS(FUNC, NAME) {{(word_t)#NAME}, {(word_t)FUNC}}
#define ADD_FUNC_(FUNC) {{(word_t)#FUNC}, {(word_t)FUNC}}
#define ADD_ALIAS(NAME, FUNC) {{(word_t)#NAME}, {(word_t)FUNC}}

#define arm7_func_count (sizeof(arm7_funcs) / sizeof(fxe2_export_t))

Expand All @@ -32,61 +32,61 @@ void coopTimerStart(int timer, ClockDivider divider, u16 ticks, VoidFn callback)

static const fxe2_export_t arm7_funcs[] =
{
ADD_FUNC_ALIAS(coopWaitForVBlank, swiWaitForVBlank),
ADD_FUNC(irqSet),
ADD_FUNC(irqClear),
ADD_FUNC(irqEnable),
ADD_FUNC(irqDisable),
ADD_FUNC(writePowerManagement),
ADD_FUNC(timerStart),
ADD_FUNC(timerPause),
ADD_FUNC(timerStop),
ADD_FUNC(timerElapsed),
ADD_FUNC(micSetAmp),
ADD_FUNC(micReadData8),
ADD_FUNC(micReadData12),
ADD_FUNC(fifoSendAddress),
ADD_FUNC(fifoSendValue32),
ADD_FUNC(fifoSendDatamsg),
ADD_FUNC(fifoSetAddressHandler),
ADD_FUNC(fifoSetValue32Handler),
ADD_FUNC(fifoSetDatamsgHandler),
ADD_FUNC(fifoCheckAddress),
ADD_FUNC(fifoCheckValue32),
ADD_FUNC(fifoCheckDatamsg),
ADD_FUNC(fifoCheckDatamsgLength),
ADD_FUNC(fifoGetAddress),
ADD_FUNC(fifoGetValue32),
ADD_FUNC(fifoGetDatamsg),
ADD_FUNC(swiDelay),
ADD_FUNC_ALIAS(coop_swiIntrWaitCompat, swiIntrWait),
ADD_FUNC(memcpy),
ADD_FUNC(memcmp),
ADD_FUNC(memset),
ADD_FUNC(strcpy),
ADD_FUNC(strcmp),
ADD_FUNC(strncpy),
ADD_FUNC(strncmp),
ADD_FUNC(malloc),
ADD_FUNC(free),
ADD_FUNC(__aeabi_idiv),
ADD_FUNC(__aeabi_idivmod),
ADD_FUNC(__aeabi_uidiv),
ADD_FUNC(__aeabi_uidivmod),
ADD_FUNC(__aeabi_ldivmod),
ADD_FUNC(__aeabi_uldivmod),
ADD_FUNC(__aeabi_lmul),
ADD_ALIAS(swiWaitForVBlank, coopWaitForVBlank),
ADD_FUNC_(irqSet),
ADD_FUNC_(irqClear),
ADD_FUNC_(irqEnable),
ADD_FUNC_(irqDisable),
ADD_FUNC_(writePowerManagement),
ADD_FUNC_(timerStart),
ADD_FUNC_(timerPause),
ADD_FUNC_(timerStop),
ADD_FUNC_(timerElapsed),
ADD_FUNC_(micSetAmp),
ADD_FUNC_(micReadData8),
ADD_FUNC_(micReadData12),
ADD_FUNC_(fifoSendAddress),
ADD_FUNC_(fifoSendValue32),
ADD_FUNC_(fifoSendDatamsg),
ADD_FUNC_(fifoSetAddressHandler),
ADD_FUNC_(fifoSetValue32Handler),
ADD_FUNC_(fifoSetDatamsgHandler),
ADD_FUNC_(fifoCheckAddress),
ADD_FUNC_(fifoCheckValue32),
ADD_FUNC_(fifoCheckDatamsg),
ADD_FUNC_(fifoCheckDatamsgLength),
ADD_FUNC_(fifoGetAddress),
ADD_FUNC_(fifoGetValue32),
ADD_FUNC_(fifoGetDatamsg),
ADD_FUNC_(swiDelay),
ADD_ALIAS(swiIntrWait, coop_swiIntrWaitCompat),
ADD_FUNC_(memcpy),
ADD_FUNC_(memcmp),
ADD_FUNC_(memset),
ADD_FUNC_(strcpy),
ADD_FUNC_(strcmp),
ADD_FUNC_(strncpy),
ADD_FUNC_(strncmp),
ADD_FUNC_(malloc),
ADD_FUNC_(free),
ADD_FUNC_(__aeabi_idiv),
ADD_FUNC_(__aeabi_idivmod),
ADD_FUNC_(__aeabi_uidiv),
ADD_FUNC_(__aeabi_uidivmod),
ADD_FUNC_(__aeabi_ldivmod),
ADD_FUNC_(__aeabi_uldivmod),
ADD_FUNC_(__aeabi_lmul),

ADD_FUNC(coopFifoSetDatamsgHandler),
ADD_FUNC(coopFifoSetValue32Handler),
ADD_FUNC(coopFifoSetAddressHandler),
ADD_FUNC(coopIrqSet),
ADD_FUNC(coopIrqCheck),
ADD_FUNC(coopIrqNext),
ADD_FUNC(coopTimerStart)
ADD_FUNC_(coopFifoSetDatamsgHandler),
ADD_FUNC_(coopFifoSetValue32Handler),
ADD_FUNC_(coopFifoSetAddressHandler),
ADD_FUNC_(coopIrqSet),
ADD_FUNC_(coopIrqCheck),
ADD_FUNC_(coopIrqNext),
ADD_FUNC_(coopTimerStart)
};

bool FeOS_ResolveImp(word_t* addr, const char* name)
bool Ke7ResolveImp(word_t* addr, const char* name)
{
register int i;
for (i = 0; i < arm7_func_count; i ++)
Expand Down
2 changes: 1 addition & 1 deletion arm7/source/main.c
Expand Up @@ -95,7 +95,7 @@ int main()
while (!exitflag)
{
coopWaitForVBlank();
FeOS_VBlankFunc();
Ke7VBlankISR();
if (!(REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R)))
break;
Wifi_Update();
Expand Down

0 comments on commit a53ba81

Please sign in to comment.