diff --git a/Makefile.arm11 b/Makefile.arm11 index cf15fda..699cd28 100644 --- a/Makefile.arm11 +++ b/Makefile.arm11 @@ -18,7 +18,7 @@ #--------------------------------------------------------------------------------- TARGET := code11 BUILD := build11 -SOURCES := source/arm11 source +SOURCES := source source/arm11 INCLUDES := include DATA := diff --git a/Makefile.arm9 b/Makefile.arm9 index aef99b6..5634bde 100644 --- a/Makefile.arm9 +++ b/Makefile.arm9 @@ -18,8 +18,8 @@ #--------------------------------------------------------------------------------- TARGET := code9 BUILD := build9 -SOURCES := source/arm9 source/arm9/fatfs source -INCLUDES := include include/arm9 include/arm9/fatfs +SOURCES := source source/arm9 source/arm9/fatfs +INCLUDES := include DATA := data #--------------------------------------------------------------------------------- diff --git a/build.bat b/build.bat index 8182ff5..feabff9 100644 --- a/build.bat +++ b/build.bat @@ -1,2 +1,2 @@ -make +make 2> log.txt pause \ No newline at end of file diff --git a/include/arm9/fatfs/diskio.h b/include/arm9/fatfs/diskio.h index 961a742..611c24a 100644 --- a/include/arm9/fatfs/diskio.h +++ b/include/arm9/fatfs/diskio.h @@ -13,7 +13,7 @@ extern "C" { #endif -#include "integer.h" +#include "arm9/fatfs/integer.h" /* Status of Disk Functions */ diff --git a/include/arm9/fatfs/ff.h b/include/arm9/fatfs/ff.h index 6a94693..338e009 100644 --- a/include/arm9/fatfs/ff.h +++ b/include/arm9/fatfs/ff.h @@ -23,8 +23,8 @@ extern "C" { #endif -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ +#include "arm9/fatfs/integer.h" /* Basic integer types */ +#include "arm9/fatfs/ffconf.h" /* FatFs configuration options */ #if _FATFS != _FFCONF #error Wrong configuration file (ffconf.h). #endif diff --git a/include/arm9/ndma.h b/include/arm9/ndma.h index 44e32b5..f54cb54 100644 --- a/include/arm9/ndma.h +++ b/include/arm9/ndma.h @@ -7,6 +7,8 @@ #include "types.h" + + #define REG_NDMA_GLOBAL_CNT *((vu32*)0x10002000) #define REG_NDMA0_SRC_ADDR *((vu32*)0x10002004) diff --git a/include/types.h b/include/types.h index 8d599d1..39dcd24 100644 --- a/include/types.h +++ b/include/types.h @@ -9,6 +9,7 @@ #define NORETURN __attribute__((noreturn)) #define PACKED __attribute__((packed)) +#define UNUSED __attribute__((unused)) #define ALIGN(n) __attribute__((aligned(n))) diff --git a/source/arm11/cache.s b/source/arm11/cache.s index bc38541..6354f90 100644 --- a/source/arm11/cache.s +++ b/source/arm11/cache.s @@ -1,6 +1,6 @@ .arm .cpu mpcore -.fpu vfpv2 +.fpu softvfp .global invalidateICache .global flushDCache @@ -8,6 +8,8 @@ .type invalidateICache STT_FUNC .type flushDCache STT_FUNC +.section ".text" + invalidateICache: diff --git a/source/arm11/gfx.c b/source/arm11/gfx.c index c40ace5..7eea2c8 100644 --- a/source/arm11/gfx.c +++ b/source/arm11/gfx.c @@ -1,14 +1,11 @@ -#include -#include -#include -#include #include "types.h" #include "IO.h" #include "mem_map.h" #include "util.h" #include "arm11/i2c.h" #include "gfx.h" -//#include "test2_ppm_bin.h" + + extern void gpio_set_bit(vu16 *reg, u8 bit_num); extern void gpio_clear_bit(vu16 *reg, u8 bit_num); @@ -46,11 +43,11 @@ *((vu32 *)(0x10400400+0x78)) = 0x70100; // gets set to 0x0 later on *((vu32 *)(0x10400400+0x80)) = 0x0; - for(int i=0; i<0x100; i++) + for(u32 i = 0; i < 0x100; i++) { u32 val = 0x10101; val *= i; - *((vu32 *)(0x10400400+0x84)) = val; + *((vu32*)(0x10400400+0x84)) = val; } } @@ -87,11 +84,11 @@ *((vu32 *)(0x10400500+0x78)) = 0x70100; // gets set to 0x0 later on *((vu32 *)(0x10400500+0x80)) = 0x0; - for(int i=0; i<0x100; i++) + for(u32 i = 0; i < 0x100; i++) { u32 val = 0x10101; val *= i; - *((vu32 *)(0x10400500+0x84)) = val; + *((vu32*)(0x10400500+0x84)) = val; } } diff --git a/source/arm11/gpio.s b/source/arm11/gpio.s index 3933896..405761f 100644 --- a/source/arm11/gpio.s +++ b/source/arm11/gpio.s @@ -1,6 +1,6 @@ .arm - .cpu mpcore +.fpu softvfp .global gpio_set_bit .global gpio_clear_bit @@ -8,7 +8,9 @@ .type gpio_set_bit STT_FUNC .type gpio_clear_bit STT_FUNC -.section .text +.section ".text" + + gpio_set_bit: ldrh r2, [r0] @@ -17,7 +19,8 @@ orrs r2, r1 strh r2, [r0] bx lr - + + gpio_clear_bit: ldrh r2, [r0] movs r3, #1 @@ -25,6 +28,3 @@ bics r2, r1 strh r2, [r0] bx lr - -.pool - diff --git a/source/arm11/i2c.c b/source/arm11/i2c.c index 0b3b895..cd3ee2f 100644 --- a/source/arm11/i2c.c +++ b/source/arm11/i2c.c @@ -1,12 +1,10 @@ -#include -#include -#include -#include #include "types.h" #include "IO.h" #include "mem_map.h" #include "util.h" + + struct i2c_dev_table_entry { u32 bus_id; u8 devaddr; @@ -25,6 +23,7 @@ {1, 0x44} }; + // i2c mcu defines bool i2cmcu_reg0_upper_read; u8 i2cmcu_reg0_upper_data; @@ -49,6 +48,7 @@ u32 i2c_readregdata(u32 dev_id, u32 regaddr, u8 *out, u32 size); u32 i2cmcu_readregdata(u32 regaddr, u8 *outbuf, u32 size); + void i2c_wait(u32 bus_id) { u8 result; diff --git a/source/arm11/main.c b/source/arm11/main.c index fcb609b..1dcedc5 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -1,4 +1,3 @@ -#include #include "types.h" #include "mem_map.h" #include "util.h" diff --git a/source/arm11/start.s b/source/arm11/start.s index 3bff0ea..03cf6a5 100644 --- a/source/arm11/start.s +++ b/source/arm11/start.s @@ -2,7 +2,7 @@ .arm .cpu mpcore -.fpu vfpv2 +.fpu softvfp .global _start .global _init @@ -16,13 +16,12 @@ .extern __bss_start__ .extern __bss_end__ -.section ".init" +.section ".crt0" _start: cpsid aif, #0x1F @ Disable all interrupts, system mode - ldr sp, =A11_STUB_ENTRY ldr r0, =0x54078 @ Everything disabled mcr p15, 0, r0, c1, c0, 0 @ Write control register @@ -43,6 +42,9 @@ mcr p15, 0, r1, c7, c6, 0 @ Invalidate Entire Data Cache mcr p15, 0, r1, c7, c10, 4 @ Data Synchronization Barrier + // Set sp + ldr sp, =A11_STUB_ENTRY + ldr r0, =__bss_start__ ldr r1, =__bss_end__ sub r1, r1, r0 @@ -59,10 +61,12 @@ disableCaches: mov r2, lr bl flushDCache + ldr r0, =0x54078 @ Everything disabled mcr p15, 0, r0, c1, c0, 0 @ Write control register mov r0, #0 @ Everything disabled mcr p15, 0, r0, c1, c0, 1 @ Write Auxiliary Control Register + mcr p15, 0, r0, c7, c5, 4 @ Flush Prefetch Buffer mcr p15, 0, r0, c7, c5, 0 @ Invalidate Entire Instruction Cache. Also flushes the branch target cache mcr p15, 0, r0, c7, c6, 0 @ Invalidate Entire Data Cache diff --git a/source/arm9/cache.s b/source/arm9/cache.s index ccdec39..753edb6 100644 --- a/source/arm9/cache.s +++ b/source/arm9/cache.s @@ -16,6 +16,9 @@ .type invalidateDCache STT_FUNC .type invalidateDCacheRange STT_FUNC +.section ".text" + + #define ICACHE_SIZE 0x2000 #define DCACHE_SIZE 0x1000 #define CACHE_LINE_SIZE 32 diff --git a/source/arm9/console.c b/source/arm9/console.c index 9e1a5bc..f34d7f6 100644 --- a/source/arm9/console.c +++ b/source/arm9/console.c @@ -3,7 +3,7 @@ #include #include "types.h" #include "gfx.h" -#include "console.h" +#include "arm9/console.h" #include "default_font_bin.h" @@ -120,6 +120,7 @@ currentConsole->cursorX = 0; break; } + default: ; } } //--------------------------------------------------------------------------------- @@ -172,24 +173,25 @@ break; } + default: ; } } // strchr() function with length check from WinterMute //--------------------------------------------------------------------------------- -static char *strnchr(const char *p, char c, size_t n) { +static const char *strnchr(const char *p, char c, size_t n) { //--------------------------------------------------------------------------------- if (!p) return 0; while (n-- > 0) { - if (*p == c) return ((char *)p); + if (*p == c) return p; p++; } return 0; } //--------------------------------------------------------------------------------- -ssize_t con_write(struct _reent *r,int fd,const char *ptr, size_t len) { +ssize_t con_write(UNUSED struct _reent *r,UNUSED int fd,const char *ptr, size_t len) { //--------------------------------------------------------------------------------- char chr; @@ -208,7 +210,7 @@ if ( chr == 0x1b && *tmp == '[' ) { bool escaping = true; - char *escapeseq = tmp++; + const char *escapeseq = tmp++; int escapelen = 1; i++; count++; @@ -448,6 +450,7 @@ case 49: // reset background color currentConsole->fg = 0; break; + default: ; } } while (escapelen > 0); diff --git a/source/arm9/debug.c b/source/arm9/debug.c index 9cdf9ba..32528e8 100644 --- a/source/arm9/debug.c +++ b/source/arm9/debug.c @@ -2,8 +2,8 @@ #include #include "types.h" #include "mem_map.h" -#include "console.h" -#include "mpu.h" +#include "arm9/console.h" +#include "arm9/mpu.h" @@ -26,7 +26,7 @@ void NORETURN panic() { - volatile register lr; + vu32 register lr; disableMpu(); consoleInit(0, NULL); diff --git a/source/arm9/dev.c b/source/arm9/dev.c index 8e72b21..3d0d4a0 100644 --- a/source/arm9/dev.c +++ b/source/arm9/dev.c @@ -87,6 +87,11 @@ sdmmc_dnand_is_active, NULL }, + {0}, + {0}, + {0}, + {0}, + {0} }; const dev_struct *dev_decnand = &dev_dnand.dev; @@ -325,7 +330,7 @@ return true; } -bool sdmmc_dnand_write_sector(u32 sector, u32 count, const void *buf) +bool sdmmc_dnand_write_sector(UNUSED u32 sector, UNUSED u32 count, UNUSED const void *buf) { if(!dev_dnand.dev.initialized) return false; diff --git a/source/arm9/exception.s b/source/arm9/exception.s index 1c27bc3..f0113dd 100644 --- a/source/arm9/exception.s +++ b/source/arm9/exception.s @@ -13,6 +13,8 @@ .extern guruMeditation +.section ".text" + undefHandler: diff --git a/source/arm9/fatfs/ccsbcs.c b/source/arm9/fatfs/ccsbcs.c index d99da17..6fe9f87 100644 --- a/source/arm9/fatfs/ccsbcs.c +++ b/source/arm9/fatfs/ccsbcs.c @@ -21,7 +21,7 @@ / 869 Greek 2 */ -#include "ff.h" +#include "arm9/fatfs/ff.h" #if _CODE_PAGE == 437 diff --git a/source/arm9/fatfs/diskio.c b/source/arm9/fatfs/diskio.c index 44d7ebf..e9b8416 100644 --- a/source/arm9/fatfs/diskio.c +++ b/source/arm9/fatfs/diskio.c @@ -27,7 +27,7 @@ /*-----------------------------------------------------------------------*/ DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber to identify the drive */ + UNUSED BYTE pdrv /* Physical drive nmuber to identify the drive */ ) { return 0; @@ -129,7 +129,7 @@ void *buff /* Buffer to send/receive control data */ ) { - dev_struct *dev; + const dev_struct *dev; switch(pdrv) { diff --git a/source/arm9/fatfs/ff.c b/source/arm9/fatfs/ff.c index 7d63de4..54b3079 100644 --- a/source/arm9/fatfs/ff.c +++ b/source/arm9/fatfs/ff.c @@ -16,8 +16,8 @@ /----------------------------------------------------------------------------*/ -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ +#include "arm9/fatfs/ff.h" /* Declarations of FatFs API */ +#include "arm9/fatfs/diskio.h" /* Declarations of disk I/O functions */ /*-------------------------------------------------------------------------- diff --git a/source/arm9/main.c b/source/arm9/main.c index 61f55a5..28304b0 100644 --- a/source/arm9/main.c +++ b/source/arm9/main.c @@ -4,14 +4,14 @@ #include "mem_map.h" #include "IO.h" #include "util.h" -#include "console.h" -#include "dev.h" -#include "fatfs/ff.h" -#include "fatfs/diskio.h" -#include "firm.h" +#include "arm9/console.h" +#include "arm9/dev.h" +#include "arm9/fatfs/ff.h" +#include "arm9/fatfs/diskio.h" +#include "arm9/firm.h" #include "hid.h" -#include "main.h" -#include "spiflash.h" +#include "arm9/main.h" +#include "arm9/spiflash.h" #include "pxi.h" // PrintConsole for each screen diff --git a/source/arm9/menu.c b/source/arm9/menu.c index f93c94b..d9746e5 100644 --- a/source/arm9/menu.c +++ b/source/arm9/menu.c @@ -4,14 +4,14 @@ #include "mem_map.h" #include "IO.h" #include "util.h" -#include "console.h" -#include "dev.h" -#include "fatfs/ff.h" -#include "fatfs/diskio.h" +#include "arm9/console.h" +#include "arm9/dev.h" +#include "arm9/fatfs/ff.h" +#include "arm9/fatfs/diskio.h" #include "hid.h" -#include "main.h" -#include "util_nand.h" -#include "menu.h" +#include "arm9/main.h" +#include "arm9/util_nand.h" +#include "arm9/menu.h" u8 color; enum menu_state_type menu_state; diff --git a/source/arm9/spiflash.c b/source/arm9/spiflash.c index 898b99c..c24e620 100644 --- a/source/arm9/spiflash.c +++ b/source/arm9/spiflash.c @@ -1,6 +1,8 @@ #include "types.h" #include "IO.h" -#include "spiflash.h" +#include "arm9/spiflash.h" + + void spi_busy_wait() { diff --git a/source/arm9/util_nand.c b/source/arm9/util_nand.c index b0b83f8..2ab94d3 100644 --- a/source/arm9/util_nand.c +++ b/source/arm9/util_nand.c @@ -2,12 +2,12 @@ #include #include "types.h" #include "mem_map.h" -#include "console.h" -#include "dev.h" -#include "fatfs/ff.h" +#include "arm9/console.h" +#include "arm9/dev.h" +#include "arm9/fatfs/ff.h" #include "hid.h" #include "util.h" -#include "util_nand.h" +#include "arm9/util_nand.h"