aboutsummaryrefslogtreecommitdiff
path: root/sdk-modifications/libsrc
diff options
context:
space:
mode:
Diffstat (limited to 'sdk-modifications/libsrc')
-rw-r--r--sdk-modifications/libsrc/.depend0
-rw-r--r--sdk-modifications/libsrc/Makefile13
-rw-r--r--sdk-modifications/libsrc/changes_bag.txt28
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/console/console.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/console/console.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/console/console.mk0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/console/font_dot.h0
-rw-r--r--sdk-modifications/libsrc/core/core.mk11
-rw-r--r--sdk-modifications/libsrc/core/ds2_cpuclock.c272
-rw-r--r--sdk-modifications/libsrc/core/ds2_cpuclock.h22
-rw-r--r--sdk-modifications/libsrc/core/ds2_dma.c34
-rw-r--r--sdk-modifications/libsrc/core/ds2_dma.h142
-rw-r--r--sdk-modifications/libsrc/dma/dma.mk9
-rw-r--r--sdk-modifications/libsrc/dma/dmacopy.c167
-rw-r--r--sdk-modifications/libsrc/dma/ds2_dma.h54
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/bit_ops.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/cache.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/directory.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/directory.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/disc_io/disc.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/disc_io/disc.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/disc_io/disc_io.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/ds2_fcntl.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/ds2_fcntl.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/ds2_unistd.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/ds2_unistd.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fat.h0
-rw-r--r--sdk-modifications/libsrc/fs/fat_misc.c52
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fat_misc.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fatdir.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fatdir_ex.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fatdir_ex.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fatfile.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fatfile.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fatfile_ex.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fatfile_ex.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/file_allocation_table.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/filetime.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/filetime.h0
-rw-r--r--sdk-modifications/libsrc/fs/fs.mk2
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fs_api.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fs_api.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fs_cache.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fs_common.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fs_unicode.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/fs_unicode.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/libfat.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/mem_allocate.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/partition.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/fs/partition.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/key/key.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/key/key.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/key/key.mk0
-rw-r--r--sdk-modifications/libsrc/zlib/README9
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/adler32.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/compress.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/crc32.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/crc32.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/deflate.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/deflate.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/gzclose.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/gzguts.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/gzlib.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/gzread.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/gzwrite.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/infback.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/inffast.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/inffast.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/inffixed.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/inflate.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/inflate.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/inftrees.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/inftrees.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/trees.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/trees.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/uncompr.c0
-rw-r--r--sdk-modifications/libsrc/zlib/zconf.h4
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/zlib.h0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/zlib.mk0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/zutil.c0
-rwxr-xr-x[-rw-r--r--]sdk-modifications/libsrc/zlib/zutil.h0
83 files changed, 555 insertions, 264 deletions
diff --git a/sdk-modifications/libsrc/.depend b/sdk-modifications/libsrc/.depend
deleted file mode 100644
index e69de29..0000000
--- a/sdk-modifications/libsrc/.depend
+++ /dev/null
diff --git a/sdk-modifications/libsrc/Makefile b/sdk-modifications/libsrc/Makefile
index 6e2b4ab..3d63b76 100644
--- a/sdk-modifications/libsrc/Makefile
+++ b/sdk-modifications/libsrc/Makefile
@@ -13,7 +13,7 @@ CONSOLE_DIR = $(TOPDIR)/console
FS_DIR = $(TOPDIR)/fs
KEY_DIR = $(TOPDIR)/key
ZLIB_DIR = $(TOPDIR)/zlib
-DMA_DIR = $(TOPDIR)/dma
+CORE_DIR = $(TOPDIR)/core
SRC :=
@@ -24,14 +24,17 @@ INCLUDES := -I../include
INC := $(INCLUDES)
CFLAGS := -mips32 -O3 -mno-abicalls -fno-pic -fno-builtin \
- -fno-exceptions -ffunction-sections -mlong-calls\
- -fomit-frame-pointer -msoft-float -G 4
-
+ -fno-exceptions -ffunction-sections -mno-long-calls\
+ -fomit-frame-pointer -msoft-float -G 4 \
+ -fgcse-sm -fgcse-las -fgcse-after-reload \
+ -fweb -fpeel-loops
+
+
include $(CONSOLE_DIR)/console.mk
include $(FS_DIR)/fs.mk
include $(KEY_DIR)/key.mk
include $(ZLIB_DIR)/zlib.mk
-include $(DMA_DIR)/dma.mk
+include $(CORE_DIR)/core.mk
#OBJS := $(addsuffix .o , $(basename $(notdir $(SRC))))
#SOBJS := $(addsuffix .o , $(basename $(notdir $(SSRC))))
diff --git a/sdk-modifications/libsrc/changes_bag.txt b/sdk-modifications/libsrc/changes_bag.txt
new file mode 100644
index 0000000..63b82a9
--- /dev/null
+++ b/sdk-modifications/libsrc/changes_bag.txt
@@ -0,0 +1,28 @@
+Unofficial libds2a by BassAceGold
+ Based on 0.13 beta Supercard SDK release, contains full lib with changes
+
+
+
+release 1:
+ -inclusion of ds2_unistd.h and ds2_fcntl.h
+ -updated zlib to 1.5.2
+
+release 2:
+ -mkdir no longer freezes
+ -faster fopen times for file reading
+ (no longer searches for the next cluster to write to with read only mode)
+ -makes DS2's DMA (direct memory access hardware) features publically available
+ -adds extra cpu clock speeds (may be unstable)
+ ds2_setCPULevel(level)
+ -can now get the current CPU clock speed as an integer value
+ ds2_getCPUClock()
+
+release 2 fix 1:
+ -added ds2_udelay and ds2_mdelay variant functions.
+ must be used with ds2_setCPULevel for accurate timings,
+ old functions, udelay and mdelay, should not be used with the new
+ cpu clock functions
+ -added further optimizations to makefile
+
+release 2 fix 2:
+ -fat_getDiskSpaceInfo no longer freezes
diff --git a/sdk-modifications/libsrc/console/console.c b/sdk-modifications/libsrc/console/console.c
index f455ac5..f455ac5 100644..100755
--- a/sdk-modifications/libsrc/console/console.c
+++ b/sdk-modifications/libsrc/console/console.c
diff --git a/sdk-modifications/libsrc/console/console.h b/sdk-modifications/libsrc/console/console.h
index f6d74a4..f6d74a4 100644..100755
--- a/sdk-modifications/libsrc/console/console.h
+++ b/sdk-modifications/libsrc/console/console.h
diff --git a/sdk-modifications/libsrc/console/console.mk b/sdk-modifications/libsrc/console/console.mk
index b8a436e..b8a436e 100644..100755
--- a/sdk-modifications/libsrc/console/console.mk
+++ b/sdk-modifications/libsrc/console/console.mk
diff --git a/sdk-modifications/libsrc/console/font_dot.h b/sdk-modifications/libsrc/console/font_dot.h
index cdf6067..cdf6067 100644..100755
--- a/sdk-modifications/libsrc/console/font_dot.h
+++ b/sdk-modifications/libsrc/console/font_dot.h
diff --git a/sdk-modifications/libsrc/core/core.mk b/sdk-modifications/libsrc/core/core.mk
new file mode 100644
index 0000000..4ed3ca8
--- /dev/null
+++ b/sdk-modifications/libsrc/core/core.mk
@@ -0,0 +1,11 @@
+#fs.mk
+
+SRC += $(CORE_DIR)/ds2_dma.c \
+ $(CORE_DIR)/ds2_cpuclock.c
+
+SSRC +=
+
+INC += -I$(CORE_DIR)
+
+CFLAGS +=
+
diff --git a/sdk-modifications/libsrc/core/ds2_cpuclock.c b/sdk-modifications/libsrc/core/ds2_cpuclock.c
new file mode 100644
index 0000000..57f2143
--- /dev/null
+++ b/sdk-modifications/libsrc/core/ds2_cpuclock.c
@@ -0,0 +1,272 @@
+#include <ds2_types.h>
+
+#include "ds2_cpuclock.h"
+
+#define REG8(addr) *((volatile u8 *)(addr))
+#define REG16(addr) *((volatile u16 *)(addr))
+#define REG32(addr) *((volatile u32 *)(addr))
+
+#define SDRAM_TRAS 50 /* RAS# Active Time */
+#define SDRAM_RCD 23 /* RAS# to CAS# Delay */
+#define SDRAM_TPC 23 /* RAS# Precharge Time */
+#define SDRAM_TRWL 7 /* Write Latency Time */
+#define SDRAM_TREF 7813 /* Refresh period: 8192 refresh cycles/64ms */
+
+#define EMC_BASE 0xB3010000
+#define EMC_DMCR (EMC_BASE + 0x80) /* DRAM Control Register */
+#define REG_EMC_DMCR REG32(EMC_DMCR)
+#define EMC_RTCSR (EMC_BASE + 0x84) /* Refresh Time Control/Status Register */
+#define REG_EMC_RTCSR REG16(EMC_RTCSR)
+#define EMC_RTCOR (EMC_BASE + 0x8c) /* Refresh Time Constant Register */
+#define REG_EMC_RTCOR REG16(EMC_RTCOR)
+#define EMC_RTCNT (EMC_BASE + 0x88) /* Refresh Timer Counter */
+#define REG_EMC_RTCNT REG16(EMC_RTCNT)
+
+
+
+#define CPM_BASE 0xB0000000
+#define CPM_CPCCR (CPM_BASE+0x00)
+#define CPM_CPPCR (CPM_BASE+0x10)
+//#define CPM_RSR (CPM_BASE+0x08)
+#define REG_CPM_CPCCR REG32(CPM_CPCCR)
+#define REG_CPM_CPPCR REG32(CPM_CPPCR)
+#define CPM_CPCCR_CE (1 << 22)
+
+
+
+
+
+
+#define EMC_DMCR_TRAS_BIT 13
+#define EMC_DMCR_TRAS_MASK (0x07 << EMC_DMCR_TRAS_BIT)
+#define EMC_DMCR_RCD_BIT 11
+#define EMC_DMCR_RCD_MASK (0x03 << EMC_DMCR_RCD_BIT)
+#define EMC_DMCR_TPC_BIT 8
+#define EMC_DMCR_TPC_MASK (0x07 << EMC_DMCR_TPC_BIT)
+#define EMC_DMCR_TRWL_BIT 5
+#define EMC_DMCR_TRWL_MASK (0x03 << EMC_DMCR_TRWL_BIT)
+#define EMC_DMCR_TRC_BIT 2
+#define EMC_DMCR_TRC_MASK (0x07 << EMC_DMCR_TRC_BIT)
+
+#define EMC_RTCSR_CKS_BIT 0
+#define EMC_RTCSR_CKS_MASK (0x07 << EMC_RTCSR_CKS_BIT)
+
+
+#define CPM_CPCCR_LDIV_BIT 16
+#define CPM_CPCCR_LDIV_MASK (0x1f << CPM_CPCCR_LDIV_BIT)
+#define CPM_CPCCR_MDIV_BIT 12
+#define CPM_CPCCR_MDIV_MASK (0x0f << CPM_CPCCR_MDIV_BIT)
+#define CPM_CPCCR_PDIV_BIT 8
+#define CPM_CPCCR_PDIV_MASK (0x0f << CPM_CPCCR_PDIV_BIT)
+#define CPM_CPCCR_HDIV_BIT 4
+#define CPM_CPCCR_HDIV_MASK (0x0f << CPM_CPCCR_HDIV_BIT)
+#define CPM_CPCCR_CDIV_BIT 0
+#define CPM_CPCCR_CDIV_MASK (0x0f << CPM_CPCCR_CDIV_BIT)
+
+
+#define CPM_CPPCR_PLLM_BIT 23
+#define CPM_CPPCR_PLLM_MASK (0x1ff << CPM_CPPCR_PLLM_BIT)
+#define CPM_CPPCR_PLLN_BIT 18
+#define CPM_CPPCR_PLLN_MASK (0x1f << CPM_CPPCR_PLLN_BIT)
+#define CPM_CPPCR_PLLOD_BIT 16
+#define CPM_CPPCR_PLLOD_MASK (0x03 << CPM_CPPCR_PLLOD_BIT)
+#define CPM_CPPCR_PLLS (1 << 10)
+#define CPM_CPPCR_PLLBP (1 << 9)
+#define CPM_CPPCR_PLLEN (1 << 8)
+#define CPM_CPPCR_PLLST_BIT 0
+#define CPM_CPPCR_PLLST_MASK (0xff << CPM_CPPCR_PLLST_BIT)
+
+
+#define PLL_M 0
+#define PLL_N 1
+#define PLL_CCLK 2
+#define PLL_HCLK 3
+#define PLL_MCLK 4
+#define PLL_PCLK 5
+
+#define CFG_EXTAL 24000000
+#define EXTAL_CLK CFG_EXTAL
+
+
+#define __cpm_get_pllm() \
+ ((REG_CPM_CPPCR & CPM_CPPCR_PLLM_MASK) >> CPM_CPPCR_PLLM_BIT)
+
+#define __cpm_get_plln() \
+ ((REG_CPM_CPPCR & CPM_CPPCR_PLLN_MASK) >> CPM_CPPCR_PLLN_BIT)
+
+#define __cpm_get_cdiv() \
+ ((REG_CPM_CPCCR & CPM_CPCCR_CDIV_MASK) >> CPM_CPCCR_CDIV_BIT)
+
+
+static unsigned char pll_m_n[CPU_MAX_LEVEL_EX + 1][6] = {
+ //M, N, CCLK, HCLK, MCLK, PCLK, EXT_CLK=24MHz
+ {10-2, 2-2, 1, 1, 1, 1}, //0 60, 60, 1/1
+ {10-2, 2-2, 0, 1, 1, 1}, //1 120, 60, 1/2
+ {10-2, 2-2, 0, 0, 0, 0}, //2 120, 120, 1/1
+ {12-2, 2-2, 0, 1, 1, 1}, //3 144, 72, 1/2
+ {16-2, 2-2, 0, 1, 1, 1}, //4 192, 96, 1/2
+ {17-2, 2-2, 0, 0, 1, 1}, //5 204, 102, 1/2
+ {20-2, 2-2, 0, 1, 1, 1}, //6 240, 120, 1/2
+ {22-2, 2-2, 0, 2, 2, 2}, //7 264, 88, 1/3
+ {24-2, 2-2, 0, 2, 2, 2}, //8 288, 96, 1/3
+ {25-2, 2-2, 0, 2, 2, 2}, //9 300, 100, 1/3
+ {28-2, 2-2, 0, 2, 2, 2}, //10 336, 112, 1/3
+ {30-2, 2-2, 0, 2, 2, 2}, //11 360, 120, 1/3
+ {32-2, 2-2, 0, 2, 2, 2}, //12 384, 128, 1/3
+ {33-2, 2-2, 0, 2, 2, 2}, //13 396, 132, 1/3
+
+ {34-2, 2-2, 0, 2, 2, 2}, //14 404, 132, 1/3
+ {35-2, 2-2, 0, 2, 2, 2}, //15 420, 132, 1/3
+ {36-2, 2-2, 0, 2, 2, 2}, //16 438, 132, 1/3
+ {37-2, 2-2, 0, 2, 2, 2}, //17 444, 132, 1/3
+ {38-2, 2-2, 0, 2, 2, 2}, //18 456, 132, 1/3
+ //{39-2, 2-2, 0, 2, 2, 2}, //468, instant crash!
+ };
+
+static int _sdram_convert(unsigned int pllin,unsigned int *sdram_dmcr, unsigned int *sdram_div, unsigned int *sdram_tref)
+{
+ register unsigned int ns, dmcr,tmp;
+
+ dmcr = ~(EMC_DMCR_TRAS_MASK | EMC_DMCR_RCD_MASK | EMC_DMCR_TPC_MASK |
+ EMC_DMCR_TRWL_MASK | EMC_DMCR_TRC_MASK) & REG_EMC_DMCR;
+
+ /* Set sdram operation parameter */
+ //pllin unit is KHz
+ ns = 1000000*1024 / pllin;
+ tmp = SDRAM_TRAS*1024/ns;
+ if (tmp < 4) tmp = 4;
+ if (tmp > 11) tmp = 11;
+ dmcr |= ((tmp-4) << EMC_DMCR_TRAS_BIT);
+
+ tmp = SDRAM_RCD*1024/ns;
+ if (tmp > 3) tmp = 3;
+ dmcr |= (tmp << EMC_DMCR_RCD_BIT);
+
+ tmp = SDRAM_TPC*1024/ns;
+ if (tmp > 7) tmp = 7;
+ dmcr |= (tmp << EMC_DMCR_TPC_BIT);
+
+ tmp = SDRAM_TRWL*1024/ns;
+ if (tmp > 3) tmp = 3;
+ dmcr |= (tmp << EMC_DMCR_TRWL_BIT);
+
+ tmp = (SDRAM_TRAS + SDRAM_TPC)*1024/ns;
+ if (tmp > 14) tmp = 14;
+ dmcr |= (((tmp + 1) >> 1) << EMC_DMCR_TRC_BIT);
+
+ *sdram_dmcr = dmcr;
+
+ /* Set refresh registers */
+ unsigned int div;
+ tmp = SDRAM_TREF*1024/ns;
+ div = (tmp + 254)/255;
+ if(div <= 4) div = 1; // 1/4
+ else if(div <= 16) div = 2; // 1/16
+ else div = 3; // 1/64
+
+ *sdram_div = ~EMC_RTCSR_CKS_MASK & REG_EMC_RTCSR | div;
+
+ unsigned int divm= 4;
+ while(--div) divm *= 4;
+
+ tmp = tmp/divm + 1;
+ *sdram_tref = tmp;
+
+ return 0;
+}
+
+
+const static int FR2n[] = {
+ 1, 2, 3, 4, 6, 8, 12, 16, 24, 32
+};
+
+static unsigned int _pllout;
+static unsigned int _iclk;
+
+static void detect_clockNew(void){
+ _pllout = (__cpm_get_pllm() + 2)* EXTAL_CLK / (__cpm_get_plln() + 2);
+ _iclk = _pllout / FR2n[__cpm_get_cdiv()];
+}
+
+
+//udelay overclock
+void ds2_udelay(unsigned int usec)
+{
+ /*unsigned int i = usec * (_iclk / 2000000);
+
+ __asm__ __volatile__ (
+ "\t.set noreorder\n"
+ "1:\n\t"
+ "bne\t%0, $0, 1b\n\t"
+ "addi\t%0, %0, -1\n\t"
+ ".set reorder\n"
+ : "=r" (i)
+ : "0" (i)
+ );*/
+}
+
+//mdelay overclock
+void ds2_mdelay(unsigned int msec)
+{
+ /*int i;
+ for(i=0;i<msec;i++)
+ {
+ ds2_udelay(1000);
+ }*/
+}
+
+
+
+
+int ds2_getCPUClock(void){
+ return (_pllout/1000/1000);
+}
+
+
+
+/* convert pll while program is running */
+int ds2_setCPULevel(unsigned int level){
+ unsigned int freq_b;
+ unsigned int dmcr;
+ unsigned int rtcsr;
+ unsigned int tref;
+ unsigned int cpccr;
+ unsigned int cppcr;
+
+ if(level > CPU_MAX_LEVEL_EX) return -1;
+
+ freq_b = (pll_m_n[level][PLL_M]+2)*(EXTAL_CLK/1000)/(pll_m_n[level][PLL_N]+2);
+
+ //freq_b unit is KHz
+ _sdram_convert(freq_b/pll_m_n[level][PLL_MCLK], &dmcr, &rtcsr, &tref);
+
+ cpccr = REG_CPM_CPCCR;
+ cppcr = REG_CPM_CPPCR;
+
+ REG_CPM_CPCCR = ~CPM_CPCCR_CE & cpccr;
+
+ cppcr &= ~(CPM_CPPCR_PLLM_MASK | CPM_CPPCR_PLLN_MASK);
+ cppcr |= (pll_m_n[level][PLL_M] << CPM_CPPCR_PLLM_BIT) | (pll_m_n[level][PLL_N] << CPM_CPPCR_PLLN_BIT);
+
+ cpccr &= ~(CPM_CPCCR_CDIV_MASK | CPM_CPCCR_HDIV_MASK | CPM_CPCCR_PDIV_MASK |
+ CPM_CPCCR_MDIV_MASK | CPM_CPCCR_LDIV_MASK);
+ cpccr |= (pll_m_n[level][PLL_CCLK] << CPM_CPCCR_CDIV_BIT) | (pll_m_n[level][PLL_HCLK] << CPM_CPCCR_HDIV_BIT) |
+ (pll_m_n[level][PLL_MCLK] << CPM_CPCCR_MDIV_BIT) | (pll_m_n[level][PLL_PCLK] << CPM_CPCCR_PDIV_BIT) |
+ (31 << CPM_CPCCR_LDIV_BIT);
+
+ REG_CPM_CPCCR = cpccr;
+ REG_CPM_CPPCR = cppcr;
+
+ REG_CPM_CPCCR |= CPM_CPCCR_CE;
+ //Wait PLL stable
+ while(!(CPM_CPPCR_PLLS & REG_CPM_CPPCR));
+
+ //REG_EMC_DMCR = dmcr;
+ REG_EMC_RTCOR = tref;
+ REG_EMC_RTCNT = tref;
+
+ detect_clockNew();
+ return 0;
+}
+
+
diff --git a/sdk-modifications/libsrc/core/ds2_cpuclock.h b/sdk-modifications/libsrc/core/ds2_cpuclock.h
new file mode 100644
index 0000000..c28635b
--- /dev/null
+++ b/sdk-modifications/libsrc/core/ds2_cpuclock.h
@@ -0,0 +1,22 @@
+#ifndef _DS2_CPUCLOCK_H__
+#define _DS2_CPUCLOCK_H__
+
+
+#define CPU_MAX_LEVEL_EX 18
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int ds2_getCPUClock(void);
+extern int ds2_setCPULevel(unsigned int level);
+extern void udelayOC(unsigned int usec);
+extern void mdelayOC(unsigned int msec);
+
+//#define ds2_setCPUclocklevel ds2_setCPULevel
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__DS2_CPUCLOCK_H__
diff --git a/sdk-modifications/libsrc/core/ds2_dma.c b/sdk-modifications/libsrc/core/ds2_dma.c
new file mode 100644
index 0000000..0b0eca1
--- /dev/null
+++ b/sdk-modifications/libsrc/core/ds2_dma.c
@@ -0,0 +1,34 @@
+#include "ds2_dma.h"
+
+
+
+//register a DMA transfer request
+//ch: channel id request, there are 6 channles,
+//irq_handler: the DMA interruption handle
+//arg: argument to the handle
+//mode: DMA mode, such as port width, address increased/fixed, and so on
+//type: DMA request type
+extern int dma_request(int ch, void (*irq_handler)(unsigned int), unsigned int arg,
+ unsigned int mode, unsigned int type);
+
+//start DMA transfer, must request a DMA first
+//ch: channel id
+//srcAddr: DMA source address
+//dstAddr: DMA destination address
+//count: DMA transfer count, the total bytes due the mode in dma_request
+extern void dma_start(int ch, unsigned int srcAddr, unsigned int dstAddr,
+ unsigned int count);
+
+
+int _dmaCopy(int ch, void *dest, void *src, unsigned int size, unsigned int flags){
+ int test = 0;
+ if(!(test = dma_request(ch, 0, 0,
+ //increment dest addr
+ DMAC_DCMD_DAI | flags,
+ //auto request type
+ DMAC_DRSR_RS_AUTO)))
+ {
+ dma_start(ch, (unsigned int)src, (unsigned int)dest, size);
+ }
+ return test;
+}
diff --git a/sdk-modifications/libsrc/core/ds2_dma.h b/sdk-modifications/libsrc/core/ds2_dma.h
new file mode 100644
index 0000000..a66588a
--- /dev/null
+++ b/sdk-modifications/libsrc/core/ds2_dma.h
@@ -0,0 +1,142 @@
+#ifndef _DS2_DMA_H__
+#define _DS2_DMA_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define MAX_DMA_NUM 6 /* max 6 channels */
+
+
+// DMA request source register
+#define DMAC_DRSR_RS_BIT 0
+#define DMAC_DRSR_RS_AUTO (8 << DMAC_DRSR_RS_BIT)
+
+
+// DMA channel command register
+#define DMAC_DCMD_SAI (1 << 23) /* source address increment */
+#define DMAC_DCMD_DAI (1 << 22) /* dest address increment */
+
+#define DMAC_DCMD_SWDH_BIT 14 /* source port width */
+#define DMAC_DCMD_SWDH_32 (0 << DMAC_DCMD_SWDH_BIT)
+#define DMAC_DCMD_SWDH_8 (1 << DMAC_DCMD_SWDH_BIT)
+#define DMAC_DCMD_SWDH_16 (2 << DMAC_DCMD_SWDH_BIT)
+
+#define DMAC_DCMD_DWDH_BIT 12 /* dest port width */
+#define DMAC_DCMD_DWDH_32 (0 << DMAC_DCMD_DWDH_BIT)
+#define DMAC_DCMD_DWDH_8 (1 << DMAC_DCMD_DWDH_BIT)
+ #define DMAC_DCMD_DWDH_16 (2 << DMAC_DCMD_DWDH_BIT)
+
+#define DMAC_DCMD_DS_BIT 8 /* transfer data size of a data unit */
+#define DMAC_DCMD_DS_32BIT (0 << DMAC_DCMD_DS_BIT)
+#define DMAC_DCMD_DS_8BIT (1 << DMAC_DCMD_DS_BIT)
+#define DMAC_DCMD_DS_16BIT (2 << DMAC_DCMD_DS_BIT)
+#define DMAC_DCMD_DS_16BYTE (3 << DMAC_DCMD_DS_BIT)
+#define DMAC_DCMD_DS_32BYTE (4 << DMAC_DCMD_DS_BIT)
+
+#define DMAC_DCMD_TM (1 << 7) /* transfer mode: 0-single 1-block */
+
+
+//detect if channel has completed job
+#define DMAC_DCCSR_TT (1 << 3) /* transfer terminated */
+#define DMAC_BASE 0xB3020000
+#define REG32(addr) *((volatile u32 *)(addr))
+#define DMAC_DCCSR(n) (DMAC_BASE + (0x10 + (n) * 0x20)) /* DMA control/status */
+#define REG_DMAC_DCCSR(n) REG32(DMAC_DCCSR((n)))
+
+#define ds2_DMA_isBusy(n) \
+ !( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_TT )
+
+
+/*
+Copy modes
+
+*/
+
+#define DMA_MODE32BYTE DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 | \
+ DMAC_DCMD_DS_32BYTE | DMAC_DCMD_TM
+
+#define DMA_MODE16BYTE DMAC_DCMD_SWDH_16 | DMAC_DCMD_DWDH_16 | \
+ DMAC_DCMD_DS_16BYTE | DMAC_DCMD_TM
+
+#define DMA_MODE32BIT DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 | \
+ DMAC_DCMD_DS_32BIT
+
+#define DMA_MODE16BIT DMAC_DCMD_SWDH_16 | DMAC_DCMD_DWDH_16 | \
+ DMAC_DCMD_DS_16BIT
+
+#define DMA_MODE8BIT DMAC_DCMD_SWDH_8 | DMAC_DCMD_DWDH_8 | \
+ DMAC_DCMD_DS_8BIT | DMAC_DCMD_TM
+
+#define DMA_MODECOPY DMAC_DCMD_SAI
+
+
+
+extern int _dmaCopy(int ch, void *dest, void *src, unsigned int size, unsigned int flags);
+
+/*
+ * Copy 'size' bytes from src to dest, in blocks of 32 bytes.
+ * size is in bytes and must be a multiple of 32.
+ * Both src and dest must be aligned to 32 bytes.
+ * Returns 0 on failure, non-zero on success.
+ */
+#define ds2_DMAcopy_32Byte(ch, dest, src, size)\
+ _dmaCopy(ch, dest, src, size, DMA_MODECOPY | DMA_MODE32BYTE)
+
+/*
+ * Copy 'size' bytes from src to dest, in blocks of 16 bytes.
+ * size is in bytes and must be a multiple of 16.
+ * Both src and dest must be aligned to 16 bytes.
+ * Returns 0 on failure, non-zero on success.
+ */
+#define ds2_DMAcopy_16Byte(ch, dest, src, size)\
+ _dmaCopy(ch, dest, src, size, DMA_MODECOPY | DMA_MODE16BYTE);
+
+/*
+ * Copy 'size' bytes from src to dest, in blocks of 32 bits (4 bytes).
+ * size is in bytes and must be a multiple of 4.
+ * Both src and dest must be aligned to 32 bits (4 bytes).
+ * Returns 0 on failure, non-zero on success.
+ */
+#define ds2_DMAcopy_32Bit(ch, dest, src, size)\
+ _dmaCopy(ch, dest, src, size, DMA_MODECOPY | DMA_MODE32BIT);
+
+/*
+- * Copy 'size' bytes from src to dest, in blocks of 16 bits (2 bytes).
+- * size is in bytes and must be a multiple of 2.
+- * Both src and dest must be aligned to 16 bits (2 bytes).
+- * Returns 0 on failure, non-zero on success.
+- */
+#define ds2_DMAcopy_16Bit(ch, dest, src, size)\
+ _dmaCopy(ch, dest, src, size, DMA_MODECOPY | DMA_MODE16BIT)
+
+/*
+- * Copy 'size' individual bytes (8 bits at a time) from src to dest.
+- * Returns 0 on failure, non-zero on success.
+- */
+#define ds2_DMAcopy_8Bit(ch, dest, src, size)\
+ _dmaCopy(ch, dest, src, size, DMA_MODECOPY | DMA_MODE8BIT)
+
+
+
+//Stop DMA transfer
+extern void dma_stop(int ch);
+
+#define ds2_DMA_stop(ch)\
+ dma_stop(ch)
+
+//Wait DMA transfer over
+extern int dma_wait_finish(int ch);
+
+#define ds2_DMA_wait(ch)\
+ dma_wait_finish(ch)
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__DMA_H__
+
diff --git a/sdk-modifications/libsrc/dma/dma.mk b/sdk-modifications/libsrc/dma/dma.mk
deleted file mode 100644
index 0edf343..0000000
--- a/sdk-modifications/libsrc/dma/dma.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-#dma.mk
-
-SRC += $(DMA_DIR)/dmacopy.c
-
-SSRC +=
-
-INC += -I$(DMA_DIR)
-
-CFLAGS += \ No newline at end of file
diff --git a/sdk-modifications/libsrc/dma/dmacopy.c b/sdk-modifications/libsrc/dma/dmacopy.c
deleted file mode 100644
index 83609d3..0000000
--- a/sdk-modifications/libsrc/dma/dmacopy.c
+++ /dev/null
@@ -1,167 +0,0 @@
-#include <stdlib.h>
-#include "ds2_dma.h"
-#include "ds2_types.h"
-
-#define MAX_DMA_NUM 6 /* max 6 channels */
-
-
-// DMA request source register
-#define DMAC_DRSR_RS_BIT 0
-#define DMAC_DRSR_RS_MASK (0x2f << DMAC_DRSR_RS_BIT)
- #define DMAC_DRSR_RS_AUTO (8 << DMAC_DRSR_RS_BIT)
- #define DMAC_DRSR_RS_UART0OUT (20 << DMAC_DRSR_RS_BIT)
- #define DMAC_DRSR_RS_UART0IN (21 << DMAC_DRSR_RS_BIT)
- #define DMAC_DRSR_RS_SSIOUT (22 << DMAC_DRSR_RS_BIT)
- #define DMAC_DRSR_RS_SSIIN (23 << DMAC_DRSR_RS_BIT)
- #define DMAC_DRSR_RS_AICOUT (24 << DMAC_DRSR_RS_BIT)
- #define DMAC_DRSR_RS_AICIN (25 << DMAC_DRSR_RS_BIT)
- #define DMAC_DRSR_RS_MSCOUT (26 << DMAC_DRSR_RS_BIT) //SD0
- #define DMAC_DRSR_RS_MSCIN (27 << DMAC_DRSR_RS_BIT)
-
-
-// DMA channel command register
-#define DMAC_DCMD_SAI (1 << 23) /* source address increment */
-#define DMAC_DCMD_DAI (1 << 22) /* dest address increment */
-#define DMAC_DCMD_SWDH_BIT 14 /* source port width */
-#define DMAC_DCMD_SWDH_MASK (0x03 << DMAC_DCMD_SWDH_BIT)
- #define DMAC_DCMD_SWDH_32 (0 << DMAC_DCMD_SWDH_BIT)
- #define DMAC_DCMD_SWDH_8 (1 << DMAC_DCMD_SWDH_BIT)
- #define DMAC_DCMD_SWDH_16 (2 << DMAC_DCMD_SWDH_BIT)
-#define DMAC_DCMD_DWDH_BIT 12 /* dest port width */
-#define DMAC_DCMD_DWDH_MASK (0x03 << DMAC_DCMD_DWDH_BIT)
- #define DMAC_DCMD_DWDH_32 (0 << DMAC_DCMD_DWDH_BIT)
- #define DMAC_DCMD_DWDH_8 (1 << DMAC_DCMD_DWDH_BIT)
- #define DMAC_DCMD_DWDH_16 (2 << DMAC_DCMD_DWDH_BIT)
-#define DMAC_DCMD_DS_BIT 8 /* transfer data size of a data unit */
-#define DMAC_DCMD_DS_MASK (0x07 << DMAC_DCMD_DS_BIT)
- #define DMAC_DCMD_DS_32BIT (0 << DMAC_DCMD_DS_BIT)
- #define DMAC_DCMD_DS_8BIT (1 << DMAC_DCMD_DS_BIT)
- #define DMAC_DCMD_DS_16BIT (2 << DMAC_DCMD_DS_BIT)
- #define DMAC_DCMD_DS_16BYTE (3 << DMAC_DCMD_DS_BIT)
- #define DMAC_DCMD_DS_32BYTE (4 << DMAC_DCMD_DS_BIT)
-#define DMAC_DCMD_TM (1 << 7) /* transfer mode: 0-single 1-block */
-#define DMAC_DCCSR_TT (1 << 3) /* transfer terminated */
-
-#define DMAC_BASE 0xB3020000
-#define REG32(addr) *((volatile u32 *)(addr))
-#define DMAC_DCCSR(n) (DMAC_BASE + (0x10 + (n) * 0x20)) /* DMA control/status */
-#define REG_DMAC_DCCSR(n) REG32(DMAC_DCCSR((n)))
-
-#define __dmac_channel_transmit_end_detected(n) \
- ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_TT )
-
-/*
- * Copy 'size' bytes from src to dest, in blocks of 32 bytes.
- * size is in bytes and must be a multiple of 32.
- * Both src and dest must be aligned to 32 bytes.
- * Returns 0 on failure, non-zero on success.
- */
-int dma_copy32Byte(int ch, void *dest, void *src, unsigned int size){
- int test = 0;
- if(!(test = dma_request(ch, NULL, 0,
- //increment dest addr, increment source addr
- DMAC_DCMD_DAI | DMAC_DCMD_SAI |
- //set src width 32 bytes, set dest width 32 bytes
- DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 |
- //set copy mode to 32 bytes, copy in blocks
- DMAC_DCMD_DS_32BYTE | DMAC_DCMD_TM,
- //auto request type
- DMAC_DRSR_RS_AUTO)))
- {
- dma_start(ch, (unsigned int)src, (unsigned int)dest, size);
- }
- return test;
-}
-
-/*
-
-int sampleUsage(in ch, void *dest, void *src, unsigned int size){
- //channel 0 is used for mmc stuff, so its best to avoid using it
-
- //initialize and start copy
- if(dma_copy32Byte(ch, dest, src, size)){
- dma_wait_finish(ch);//wait for copy to finish
- dma_stop(ch);//must stop after transfer is done to reset channel
- return 0;
- }
- return -1;
-}
-
-*/
-
-/*
- * Copy 'size' bytes from src to dest, in blocks of 16 bytes.
- * size is in bytes and must be a multiple of 16.
- * Both src and dest must be aligned to 16 bytes.
- * Returns 0 on failure, non-zero on success.
- */
-int dma_copy16Byte(int ch, void *dest, void *src, unsigned int size){
- int test = 0;
- if(!(test = dma_request(ch, NULL, 0,
- DMAC_DCMD_DAI | DMAC_DCMD_SAI | DMAC_DCMD_SWDH_16 |
- DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BYTE | DMAC_DCMD_TM,
- DMAC_DRSR_RS_AUTO)))
- {
- dma_start(ch, (unsigned int)src, (unsigned int)dest, size);
- }
-
- return test;
-}
-
-/*
- * Copy 'size' bytes from src to dest, in blocks of 32 bits (4 bytes).
- * size is in bytes and must be a multiple of 4.
- * Both src and dest must be aligned to 32 bits (4 bytes).
- * Returns 0 on failure, non-zero on success.
- */
-int dma_copy32Bit(int ch, void *dest, void *src, unsigned int size){
- int test = 0;
- if(!(test = dma_request(ch, NULL, 0,
- DMAC_DCMD_DAI | DMAC_DCMD_SAI | DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 |
- DMAC_DCMD_DS_32BIT | DMAC_DCMD_TM,
- DMAC_DRSR_RS_AUTO)))
- {
- dma_start(ch, (unsigned int)src, (unsigned int)dest, size);
- }
-
- return test;
-}
-
-/*
- * Copy 'size' bytes from src to dest, in blocks of 16 bits (2 bytes).
- * size is in bytes and must be a multiple of 2.
- * Both src and dest must be aligned to 16 bits (2 bytes).
- * Returns 0 on failure, non-zero on success.
- */
-int dma_copy16Bit(int ch, void *dest, void *src, unsigned int size){
- int test = 0;
-
- if(!(test = dma_request(ch, NULL, 0,
- DMAC_DCMD_DAI | DMAC_DCMD_SAI | DMAC_DCMD_SWDH_16 | DMAC_DCMD_DWDH_16 |
- DMAC_DCMD_DS_16BIT,
- DMAC_DRSR_RS_AUTO)))
- {
- dma_start(ch, (unsigned int)src, (unsigned int)dest, size);
- }
-
- return test;
-}
-
-
-//returns if a channel is still copying
-int dma_isBusy(int ch){
- if(ch < 1 || ch >= MAX_DMA_NUM)
- return 0;
-
- return !__dmac_channel_transmit_end_detected(ch);
-}
-
-//returns the first non busy channel
-int dma_getFree(void){
- int i;
- for(i = 1; i < MAX_DMA_NUM; i++){
- if(!dma_isBusy(i))
- return i;
- }
- return -1;
-}
diff --git a/sdk-modifications/libsrc/dma/ds2_dma.h b/sdk-modifications/libsrc/dma/ds2_dma.h
deleted file mode 100644
index 491df0e..0000000
--- a/sdk-modifications/libsrc/dma/ds2_dma.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef __DMA_H__
-#define __DMA_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//register a DMA transfer request
-//ch: channel id request, there are 6 channles,
-//irq_handler: the DMA interruption handle
-//arg: argument to the handle
-//mode: DMA mode, such as port width, address increased/fixed, and so on
-//type: DMA request type
-extern int dma_request(int ch, void (*irq_handler)(unsigned int), unsigned int arg,
- unsigned int mode, unsigned int type);
-
-//start DMA transfer, must request a DMA first
-//ch: channel id
-//srcAddr: DMA source address
-//dstAddr: DMA destination address
-//count: DMA transfer count, the total bytes due the mode in dma_request
-extern void dma_start(int ch, unsigned int srcAddr, unsigned int dstAddr,
- unsigned int count);
-
-//Stop DMA transfer
-extern void dma_stop(int ch);
-
-//Wait DMA transfer over
-extern int dma_wait_finish(int ch);
-
-
-/*
- * Copy 'size' bytes from src to dest, in blocks of 32 bytes.
- * size is in bytes and must be a multiple of 32.
- * Both src and dest must be aligned to 32 bytes.
- * Returns 0 on failure, non-zero on success.
- */
-extern int dma_copy32Byte(int ch, void *dest, void *src, unsigned int size);
-// Blocks of 16 bytes, aligned to 16 bytes
-extern int dma_copy16Byte(int ch, void *dest, void *src, unsigned int size);
-// Blocks of 4 bytes, aligned to 4 bytes
-extern int dma_copy32Bit(int ch, void *dest, void *src, unsigned int size);
-// Blocks of 2 bytes, aligned to 2 bytes
-extern int dma_copy16Bit(int ch, void *dest, void *src, unsigned int size);
-extern int dma_isBusy(int ch);
-extern int dma_isFree(int ch);
-extern int dma_getFree(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__DMA_H__
-
diff --git a/sdk-modifications/libsrc/fs/bit_ops.h b/sdk-modifications/libsrc/fs/bit_ops.h
index f823db7..f823db7 100644..100755
--- a/sdk-modifications/libsrc/fs/bit_ops.h
+++ b/sdk-modifications/libsrc/fs/bit_ops.h
diff --git a/sdk-modifications/libsrc/fs/cache.c b/sdk-modifications/libsrc/fs/cache.c
index 2c66e1f..2c66e1f 100644..100755
--- a/sdk-modifications/libsrc/fs/cache.c
+++ b/sdk-modifications/libsrc/fs/cache.c
diff --git a/sdk-modifications/libsrc/fs/directory.c b/sdk-modifications/libsrc/fs/directory.c
index b30cccc..b30cccc 100644..100755
--- a/sdk-modifications/libsrc/fs/directory.c
+++ b/sdk-modifications/libsrc/fs/directory.c
diff --git a/sdk-modifications/libsrc/fs/directory.h b/sdk-modifications/libsrc/fs/directory.h
index 654c5d2..654c5d2 100644..100755
--- a/sdk-modifications/libsrc/fs/directory.h
+++ b/sdk-modifications/libsrc/fs/directory.h
diff --git a/sdk-modifications/libsrc/fs/disc_io/disc.c b/sdk-modifications/libsrc/fs/disc_io/disc.c
index 8b50953..8b50953 100644..100755
--- a/sdk-modifications/libsrc/fs/disc_io/disc.c
+++ b/sdk-modifications/libsrc/fs/disc_io/disc.c
diff --git a/sdk-modifications/libsrc/fs/disc_io/disc.h b/sdk-modifications/libsrc/fs/disc_io/disc.h
index 2129359..2129359 100644..100755
--- a/sdk-modifications/libsrc/fs/disc_io/disc.h
+++ b/sdk-modifications/libsrc/fs/disc_io/disc.h
diff --git a/sdk-modifications/libsrc/fs/disc_io/disc_io.h b/sdk-modifications/libsrc/fs/disc_io/disc_io.h
index 6ac0c31..6ac0c31 100644..100755
--- a/sdk-modifications/libsrc/fs/disc_io/disc_io.h
+++ b/sdk-modifications/libsrc/fs/disc_io/disc_io.h
diff --git a/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c b/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c
index c432d84..c432d84 100644..100755
--- a/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c
+++ b/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c
diff --git a/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h b/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h
index 334a9bc..334a9bc 100644..100755
--- a/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h
+++ b/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h
diff --git a/sdk-modifications/libsrc/fs/ds2_fcntl.c b/sdk-modifications/libsrc/fs/ds2_fcntl.c
index 0fc00d7..0fc00d7 100644..100755
--- a/sdk-modifications/libsrc/fs/ds2_fcntl.c
+++ b/sdk-modifications/libsrc/fs/ds2_fcntl.c
diff --git a/sdk-modifications/libsrc/fs/ds2_fcntl.h b/sdk-modifications/libsrc/fs/ds2_fcntl.h
index 2c69221..2c69221 100644..100755
--- a/sdk-modifications/libsrc/fs/ds2_fcntl.h
+++ b/sdk-modifications/libsrc/fs/ds2_fcntl.h
diff --git a/sdk-modifications/libsrc/fs/ds2_unistd.c b/sdk-modifications/libsrc/fs/ds2_unistd.c
index 8625eba..8625eba 100644..100755
--- a/sdk-modifications/libsrc/fs/ds2_unistd.c
+++ b/sdk-modifications/libsrc/fs/ds2_unistd.c
diff --git a/sdk-modifications/libsrc/fs/ds2_unistd.h b/sdk-modifications/libsrc/fs/ds2_unistd.h
index f5efdb1..f5efdb1 100644..100755
--- a/sdk-modifications/libsrc/fs/ds2_unistd.h
+++ b/sdk-modifications/libsrc/fs/ds2_unistd.h
diff --git a/sdk-modifications/libsrc/fs/fat.h b/sdk-modifications/libsrc/fs/fat.h
index 3ddbac3..3ddbac3 100644..100755
--- a/sdk-modifications/libsrc/fs/fat.h
+++ b/sdk-modifications/libsrc/fs/fat.h
diff --git a/sdk-modifications/libsrc/fs/fat_misc.c b/sdk-modifications/libsrc/fs/fat_misc.c
index c0f62ac..335ab59 100644
--- a/sdk-modifications/libsrc/fs/fat_misc.c
+++ b/sdk-modifications/libsrc/fs/fat_misc.c
@@ -1,9 +1,9 @@
-//fat_misc.c
-//v1.0
-
+//fat_misc.c
+//v1.0
+
#include "fat_misc.h"
-#include "fs_api.h"
-
+#include "fs_api.h"
+
static unsigned int _usedSecNums;
static int strFindFromEnd( char *str,char strValue )
@@ -40,11 +40,11 @@ static int strFindFromEnd( char *str,char strValue )
int getDirSize( const char * path, int includeSubdirs, unsigned int * dirSize )
{
- char dirPath[MAX_FILENAME_LENGTH];
+ char dirPath[MAX_FILENAME_LENGTH];
unsigned int size = 0;
if( "" == path ){
return false;
- }
+ }
memset( dirPath,0,MAX_FILENAME_LENGTH );
strcpy( dirPath,path );
@@ -54,29 +54,31 @@ int getDirSize( const char * path, int includeSubdirs, unsigned int * dirSize )
if( strlen(dirPath) > MAX_FILENAME_LENGTH )
return false;
- DIR_STATE_STRUCT *dir; dir = fat_opendir((const char*)dirPath);
+ DIR_STATE_STRUCT *dir;
+ dir = fat_opendir((const char*)dirPath);
if (dir == NULL)
- return false;
- struct stat stat_buf;
- DIR_ENTRY *currentEntry;
- char* filename;
-
- while(fat_readdir_ex(dir, &stat_buf) != NULL)
+ return false;
+
+ struct stat stat_buf;
+ DIR_ENTRY *currentEntry;
+ char* filename;
+
+ while((currentEntry = fat_readdir_ex(dir, &stat_buf)) != NULL)
{
- filename = currentEntry->d_name;
-
+ filename = currentEntry->d_name;
+
if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0)
continue;
if (!(stat_buf.st_mode & S_IFDIR)) {
size += (stat_buf.st_size+511)/512;
_usedSecNums +=(stat_buf.st_size+511)/512;
- }
- else if (includeSubdirs)
+ }
+ else if (includeSubdirs)
{
// calculate the size recursively
- unsigned int subDirSize = 0;
- char dirPathBuffer[MAX_FILENAME_LENGTH];
+ unsigned int subDirSize = 0;
+ char dirPathBuffer[MAX_FILENAME_LENGTH];
memset( dirPathBuffer,0,MAX_FILENAME_LENGTH );
strcpy( dirPathBuffer,dirPath );
@@ -90,8 +92,8 @@ int getDirSize( const char * path, int includeSubdirs, unsigned int * dirSize )
memset( dirPath,0,MAX_FILENAME_LENGTH );
strcpy( dirPath,dirPathBuffer );
}
- }
-
+ }
+
fat_closedir(dir);
*dirSize = size;
@@ -102,7 +104,7 @@ int fat_getDiskTotalSpace( char * diskName, unsigned int * diskSpace )
{
if( !strcmp("",diskName) )
return false;
-
+
unsigned int len = strlen(diskName);
if( *(diskName+len-1) != '/' ){
*(diskName+len) = '/';
@@ -116,10 +118,10 @@ int fat_getDiskTotalSpace( char * diskName, unsigned int * diskSpace )
return true;
}
-int fat_getDiskSpaceInfo( char * diskName, unsigned int * total, unsigned int * used, unsigned int * freeSpace )
+int fat_getDiskSpaceInfo( char * diskName, unsigned int * total, unsigned int * used, unsigned int * freeSpace )
{
_usedSecNums = 0;
-
+
if( !strcmp("",diskName) )
return -1;
if( !fat_getDiskTotalSpace(diskName, total) )
diff --git a/sdk-modifications/libsrc/fs/fat_misc.h b/sdk-modifications/libsrc/fs/fat_misc.h
index 05db0bb..05db0bb 100644..100755
--- a/sdk-modifications/libsrc/fs/fat_misc.h
+++ b/sdk-modifications/libsrc/fs/fat_misc.h
diff --git a/sdk-modifications/libsrc/fs/fatdir.h b/sdk-modifications/libsrc/fs/fatdir.h
index 7c419ee..7c419ee 100644..100755
--- a/sdk-modifications/libsrc/fs/fatdir.h
+++ b/sdk-modifications/libsrc/fs/fatdir.h
diff --git a/sdk-modifications/libsrc/fs/fatdir_ex.c b/sdk-modifications/libsrc/fs/fatdir_ex.c
index b773255..b773255 100644..100755
--- a/sdk-modifications/libsrc/fs/fatdir_ex.c
+++ b/sdk-modifications/libsrc/fs/fatdir_ex.c
diff --git a/sdk-modifications/libsrc/fs/fatdir_ex.h b/sdk-modifications/libsrc/fs/fatdir_ex.h
index fbac46f..fbac46f 100644..100755
--- a/sdk-modifications/libsrc/fs/fatdir_ex.h
+++ b/sdk-modifications/libsrc/fs/fatdir_ex.h
diff --git a/sdk-modifications/libsrc/fs/fatfile.c b/sdk-modifications/libsrc/fs/fatfile.c
index 304da34..304da34 100644..100755
--- a/sdk-modifications/libsrc/fs/fatfile.c
+++ b/sdk-modifications/libsrc/fs/fatfile.c
diff --git a/sdk-modifications/libsrc/fs/fatfile.h b/sdk-modifications/libsrc/fs/fatfile.h
index 4869562..4869562 100644..100755
--- a/sdk-modifications/libsrc/fs/fatfile.h
+++ b/sdk-modifications/libsrc/fs/fatfile.h
diff --git a/sdk-modifications/libsrc/fs/fatfile_ex.c b/sdk-modifications/libsrc/fs/fatfile_ex.c
index aa23fb3..aa23fb3 100644..100755
--- a/sdk-modifications/libsrc/fs/fatfile_ex.c
+++ b/sdk-modifications/libsrc/fs/fatfile_ex.c
diff --git a/sdk-modifications/libsrc/fs/fatfile_ex.h b/sdk-modifications/libsrc/fs/fatfile_ex.h
index c434b63..c434b63 100644..100755
--- a/sdk-modifications/libsrc/fs/fatfile_ex.h
+++ b/sdk-modifications/libsrc/fs/fatfile_ex.h
diff --git a/sdk-modifications/libsrc/fs/file_allocation_table.h b/sdk-modifications/libsrc/fs/file_allocation_table.h
index 4fb4149..4fb4149 100644..100755
--- a/sdk-modifications/libsrc/fs/file_allocation_table.h
+++ b/sdk-modifications/libsrc/fs/file_allocation_table.h
diff --git a/sdk-modifications/libsrc/fs/filetime.c b/sdk-modifications/libsrc/fs/filetime.c
index f2de6ef..f2de6ef 100644..100755
--- a/sdk-modifications/libsrc/fs/filetime.c
+++ b/sdk-modifications/libsrc/fs/filetime.c
diff --git a/sdk-modifications/libsrc/fs/filetime.h b/sdk-modifications/libsrc/fs/filetime.h
index fa651a7..fa651a7 100644..100755
--- a/sdk-modifications/libsrc/fs/filetime.h
+++ b/sdk-modifications/libsrc/fs/filetime.h
diff --git a/sdk-modifications/libsrc/fs/fs.mk b/sdk-modifications/libsrc/fs/fs.mk
index 9b17c48..3fee249 100644
--- a/sdk-modifications/libsrc/fs/fs.mk
+++ b/sdk-modifications/libsrc/fs/fs.mk
@@ -14,7 +14,7 @@ SRC += $(FS_DIR)/cache.c \
$(FS_DIR)/disc_io/disc.c \
$(FS_DIR)/disc_io/io_ds2_mmcf.c \
$(FS_DIR)/ds2_fcntl.c \
- $(FS_DIR)/ds2_unistd.c \
+ $(FS_DIR)/ds2_unistd.c
SSRC +=
diff --git a/sdk-modifications/libsrc/fs/fs_api.c b/sdk-modifications/libsrc/fs/fs_api.c
index b23a450..b23a450 100644..100755
--- a/sdk-modifications/libsrc/fs/fs_api.c
+++ b/sdk-modifications/libsrc/fs/fs_api.c
diff --git a/sdk-modifications/libsrc/fs/fs_api.h b/sdk-modifications/libsrc/fs/fs_api.h
index fa4ae07..fa4ae07 100644..100755
--- a/sdk-modifications/libsrc/fs/fs_api.h
+++ b/sdk-modifications/libsrc/fs/fs_api.h
diff --git a/sdk-modifications/libsrc/fs/fs_cache.h b/sdk-modifications/libsrc/fs/fs_cache.h
index 1abae66..1abae66 100644..100755
--- a/sdk-modifications/libsrc/fs/fs_cache.h
+++ b/sdk-modifications/libsrc/fs/fs_cache.h
diff --git a/sdk-modifications/libsrc/fs/fs_common.h b/sdk-modifications/libsrc/fs/fs_common.h
index ce1cfff..ce1cfff 100644..100755
--- a/sdk-modifications/libsrc/fs/fs_common.h
+++ b/sdk-modifications/libsrc/fs/fs_common.h
diff --git a/sdk-modifications/libsrc/fs/fs_unicode.c b/sdk-modifications/libsrc/fs/fs_unicode.c
index 2f1c1ed..2f1c1ed 100644..100755
--- a/sdk-modifications/libsrc/fs/fs_unicode.c
+++ b/sdk-modifications/libsrc/fs/fs_unicode.c
diff --git a/sdk-modifications/libsrc/fs/fs_unicode.h b/sdk-modifications/libsrc/fs/fs_unicode.h
index 45e9d0a..45e9d0a 100644..100755
--- a/sdk-modifications/libsrc/fs/fs_unicode.h
+++ b/sdk-modifications/libsrc/fs/fs_unicode.h
diff --git a/sdk-modifications/libsrc/fs/libfat.c b/sdk-modifications/libsrc/fs/libfat.c
index 1956d13..1956d13 100644..100755
--- a/sdk-modifications/libsrc/fs/libfat.c
+++ b/sdk-modifications/libsrc/fs/libfat.c
diff --git a/sdk-modifications/libsrc/fs/mem_allocate.h b/sdk-modifications/libsrc/fs/mem_allocate.h
index 7bbe8de..7bbe8de 100644..100755
--- a/sdk-modifications/libsrc/fs/mem_allocate.h
+++ b/sdk-modifications/libsrc/fs/mem_allocate.h
diff --git a/sdk-modifications/libsrc/fs/partition.c b/sdk-modifications/libsrc/fs/partition.c
index 1791b40..1791b40 100644..100755
--- a/sdk-modifications/libsrc/fs/partition.c
+++ b/sdk-modifications/libsrc/fs/partition.c
diff --git a/sdk-modifications/libsrc/fs/partition.h b/sdk-modifications/libsrc/fs/partition.h
index 0777b54..0777b54 100644..100755
--- a/sdk-modifications/libsrc/fs/partition.h
+++ b/sdk-modifications/libsrc/fs/partition.h
diff --git a/sdk-modifications/libsrc/key/key.c b/sdk-modifications/libsrc/key/key.c
index 8a6ad5f..8a6ad5f 100644..100755
--- a/sdk-modifications/libsrc/key/key.c
+++ b/sdk-modifications/libsrc/key/key.c
diff --git a/sdk-modifications/libsrc/key/key.h b/sdk-modifications/libsrc/key/key.h
index 21674ec..21674ec 100644..100755
--- a/sdk-modifications/libsrc/key/key.h
+++ b/sdk-modifications/libsrc/key/key.h
diff --git a/sdk-modifications/libsrc/key/key.mk b/sdk-modifications/libsrc/key/key.mk
index fa08d7c..fa08d7c 100644..100755
--- a/sdk-modifications/libsrc/key/key.mk
+++ b/sdk-modifications/libsrc/key/key.mk
diff --git a/sdk-modifications/libsrc/zlib/README b/sdk-modifications/libsrc/zlib/README
index ee06114..90f3327 100644
--- a/sdk-modifications/libsrc/zlib/README
+++ b/sdk-modifications/libsrc/zlib/README
@@ -1 +1,8 @@
-This is a modified source release of zlib. zconf.h removes a reference to sys/types.h, which creates type conflicts on the DS2 SDK. For a pristine source release of zlib, please visit <http://zlib.net/>. \ No newline at end of file
+This is a modified source release of zlib.
+
+Changes:
+ zconf.h removes a reference to sys/types.h, which creates type conflicts on the DS2 SDK.
+ gzguts.h removes standard c library includes for DS2 SDK equivalents
+
+
+For a pristine source release of zlib, please visit <http://zlib.net>. \ No newline at end of file
diff --git a/sdk-modifications/libsrc/zlib/adler32.c b/sdk-modifications/libsrc/zlib/adler32.c
index a868f07..a868f07 100644..100755
--- a/sdk-modifications/libsrc/zlib/adler32.c
+++ b/sdk-modifications/libsrc/zlib/adler32.c
diff --git a/sdk-modifications/libsrc/zlib/compress.c b/sdk-modifications/libsrc/zlib/compress.c
index ea4dfbe..ea4dfbe 100644..100755
--- a/sdk-modifications/libsrc/zlib/compress.c
+++ b/sdk-modifications/libsrc/zlib/compress.c
diff --git a/sdk-modifications/libsrc/zlib/crc32.c b/sdk-modifications/libsrc/zlib/crc32.c
index c12471e..c12471e 100644..100755
--- a/sdk-modifications/libsrc/zlib/crc32.c
+++ b/sdk-modifications/libsrc/zlib/crc32.c
diff --git a/sdk-modifications/libsrc/zlib/crc32.h b/sdk-modifications/libsrc/zlib/crc32.h
index c3e7171..c3e7171 100644..100755
--- a/sdk-modifications/libsrc/zlib/crc32.h
+++ b/sdk-modifications/libsrc/zlib/crc32.h
diff --git a/sdk-modifications/libsrc/zlib/deflate.c b/sdk-modifications/libsrc/zlib/deflate.c
index 8bd480e..8bd480e 100644..100755
--- a/sdk-modifications/libsrc/zlib/deflate.c
+++ b/sdk-modifications/libsrc/zlib/deflate.c
diff --git a/sdk-modifications/libsrc/zlib/deflate.h b/sdk-modifications/libsrc/zlib/deflate.h
index fbac44d..fbac44d 100644..100755
--- a/sdk-modifications/libsrc/zlib/deflate.h
+++ b/sdk-modifications/libsrc/zlib/deflate.h
diff --git a/sdk-modifications/libsrc/zlib/gzclose.c b/sdk-modifications/libsrc/zlib/gzclose.c
index caeb99a..caeb99a 100644..100755
--- a/sdk-modifications/libsrc/zlib/gzclose.c
+++ b/sdk-modifications/libsrc/zlib/gzclose.c
diff --git a/sdk-modifications/libsrc/zlib/gzguts.h b/sdk-modifications/libsrc/zlib/gzguts.h
index 5405749..5405749 100644..100755
--- a/sdk-modifications/libsrc/zlib/gzguts.h
+++ b/sdk-modifications/libsrc/zlib/gzguts.h
diff --git a/sdk-modifications/libsrc/zlib/gzlib.c b/sdk-modifications/libsrc/zlib/gzlib.c
index 7aedab8..7aedab8 100644..100755
--- a/sdk-modifications/libsrc/zlib/gzlib.c
+++ b/sdk-modifications/libsrc/zlib/gzlib.c
diff --git a/sdk-modifications/libsrc/zlib/gzread.c b/sdk-modifications/libsrc/zlib/gzread.c
index 4632e8f..4632e8f 100644..100755
--- a/sdk-modifications/libsrc/zlib/gzread.c
+++ b/sdk-modifications/libsrc/zlib/gzread.c
diff --git a/sdk-modifications/libsrc/zlib/gzwrite.c b/sdk-modifications/libsrc/zlib/gzwrite.c
index c346a64..c346a64 100644..100755
--- a/sdk-modifications/libsrc/zlib/gzwrite.c
+++ b/sdk-modifications/libsrc/zlib/gzwrite.c
diff --git a/sdk-modifications/libsrc/zlib/infback.c b/sdk-modifications/libsrc/zlib/infback.c
index 981aff1..981aff1 100644..100755
--- a/sdk-modifications/libsrc/zlib/infback.c
+++ b/sdk-modifications/libsrc/zlib/infback.c
diff --git a/sdk-modifications/libsrc/zlib/inffast.c b/sdk-modifications/libsrc/zlib/inffast.c
index 2f1d60b..2f1d60b 100644..100755
--- a/sdk-modifications/libsrc/zlib/inffast.c
+++ b/sdk-modifications/libsrc/zlib/inffast.c
diff --git a/sdk-modifications/libsrc/zlib/inffast.h b/sdk-modifications/libsrc/zlib/inffast.h
index e5c1aa4..e5c1aa4 100644..100755
--- a/sdk-modifications/libsrc/zlib/inffast.h
+++ b/sdk-modifications/libsrc/zlib/inffast.h
diff --git a/sdk-modifications/libsrc/zlib/inffixed.h b/sdk-modifications/libsrc/zlib/inffixed.h
index d628327..d628327 100644..100755
--- a/sdk-modifications/libsrc/zlib/inffixed.h
+++ b/sdk-modifications/libsrc/zlib/inffixed.h
diff --git a/sdk-modifications/libsrc/zlib/inflate.c b/sdk-modifications/libsrc/zlib/inflate.c
index cc89517..cc89517 100644..100755
--- a/sdk-modifications/libsrc/zlib/inflate.c
+++ b/sdk-modifications/libsrc/zlib/inflate.c
diff --git a/sdk-modifications/libsrc/zlib/inflate.h b/sdk-modifications/libsrc/zlib/inflate.h
index 95f4986..95f4986 100644..100755
--- a/sdk-modifications/libsrc/zlib/inflate.h
+++ b/sdk-modifications/libsrc/zlib/inflate.h
diff --git a/sdk-modifications/libsrc/zlib/inftrees.c b/sdk-modifications/libsrc/zlib/inftrees.c
index 60bbd58..60bbd58 100644..100755
--- a/sdk-modifications/libsrc/zlib/inftrees.c
+++ b/sdk-modifications/libsrc/zlib/inftrees.c
diff --git a/sdk-modifications/libsrc/zlib/inftrees.h b/sdk-modifications/libsrc/zlib/inftrees.h
index baa53a0..baa53a0 100644..100755
--- a/sdk-modifications/libsrc/zlib/inftrees.h
+++ b/sdk-modifications/libsrc/zlib/inftrees.h
diff --git a/sdk-modifications/libsrc/zlib/trees.c b/sdk-modifications/libsrc/zlib/trees.c
index 8c32b21..8c32b21 100644..100755
--- a/sdk-modifications/libsrc/zlib/trees.c
+++ b/sdk-modifications/libsrc/zlib/trees.c
diff --git a/sdk-modifications/libsrc/zlib/trees.h b/sdk-modifications/libsrc/zlib/trees.h
index d35639d..d35639d 100644..100755
--- a/sdk-modifications/libsrc/zlib/trees.h
+++ b/sdk-modifications/libsrc/zlib/trees.h
diff --git a/sdk-modifications/libsrc/zlib/uncompr.c b/sdk-modifications/libsrc/zlib/uncompr.c
index ad98be3..ad98be3 100644..100755
--- a/sdk-modifications/libsrc/zlib/uncompr.c
+++ b/sdk-modifications/libsrc/zlib/uncompr.c
diff --git a/sdk-modifications/libsrc/zlib/zconf.h b/sdk-modifications/libsrc/zlib/zconf.h
index 96810e7..587a87c 100644
--- a/sdk-modifications/libsrc/zlib/zconf.h
+++ b/sdk-modifications/libsrc/zlib/zconf.h
@@ -399,8 +399,8 @@ typedef uLong FAR uLongf;
#ifdef STDC
# ifndef Z_SOLO
// # include <sys/types.h> /* for off_t */
-// Does not work with the DS2 SDK. There is a type conflict between sys/types.h
-// and fs_api.h.
+// Doesn't work on the DS2 SDK, because there are type conflicts between
+// sys/types.h and the filesystem API.//# include <sys/types.h> /* for off_t */
# endif
#endif
diff --git a/sdk-modifications/libsrc/zlib/zlib.h b/sdk-modifications/libsrc/zlib/zlib.h
index 79142d1..79142d1 100644..100755
--- a/sdk-modifications/libsrc/zlib/zlib.h
+++ b/sdk-modifications/libsrc/zlib/zlib.h
diff --git a/sdk-modifications/libsrc/zlib/zlib.mk b/sdk-modifications/libsrc/zlib/zlib.mk
index 94ea103..94ea103 100644..100755
--- a/sdk-modifications/libsrc/zlib/zlib.mk
+++ b/sdk-modifications/libsrc/zlib/zlib.mk
diff --git a/sdk-modifications/libsrc/zlib/zutil.c b/sdk-modifications/libsrc/zlib/zutil.c
index 8a1d242..8a1d242 100644..100755
--- a/sdk-modifications/libsrc/zlib/zutil.c
+++ b/sdk-modifications/libsrc/zlib/zutil.c
diff --git a/sdk-modifications/libsrc/zlib/zutil.h b/sdk-modifications/libsrc/zlib/zutil.h
index d8575e0..d8575e0 100644..100755
--- a/sdk-modifications/libsrc/zlib/zutil.h
+++ b/sdk-modifications/libsrc/zlib/zutil.h