From d1a7bf5eb558e7db4a1a27e15ebedb02e6b7f804 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Mon, 4 Feb 2013 23:45:44 -0500 Subject: Fully integrate BassAceGold's libraries, finally. The README still states that 1.2 is required to overwrite 0.13's stuff; really, 0.13 is needed only for `gcc`. So the sequence goes 0.13's `gcc` -> 1.2 -> BassAceGold's libraries -> make `libds2a.a`. DMA function names changed to match BassAceGold's. --- sdk-modifications/libsrc/.depend | 0 sdk-modifications/libsrc/Makefile | 13 +- sdk-modifications/libsrc/changes_bag.txt | 28 +++ sdk-modifications/libsrc/console/console.c | 0 sdk-modifications/libsrc/console/console.h | 0 sdk-modifications/libsrc/console/console.mk | 0 sdk-modifications/libsrc/console/font_dot.h | 0 sdk-modifications/libsrc/core/core.mk | 11 + sdk-modifications/libsrc/core/ds2_cpuclock.c | 272 +++++++++++++++++++++ sdk-modifications/libsrc/core/ds2_cpuclock.h | 22 ++ sdk-modifications/libsrc/core/ds2_dma.c | 34 +++ sdk-modifications/libsrc/core/ds2_dma.h | 142 +++++++++++ sdk-modifications/libsrc/dma/dma.mk | 9 - sdk-modifications/libsrc/dma/dmacopy.c | 167 ------------- sdk-modifications/libsrc/dma/ds2_dma.h | 54 ---- sdk-modifications/libsrc/fs/bit_ops.h | 0 sdk-modifications/libsrc/fs/cache.c | 0 sdk-modifications/libsrc/fs/directory.c | 0 sdk-modifications/libsrc/fs/directory.h | 0 sdk-modifications/libsrc/fs/disc_io/disc.c | 0 sdk-modifications/libsrc/fs/disc_io/disc.h | 0 sdk-modifications/libsrc/fs/disc_io/disc_io.h | 0 sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c | 0 sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h | 0 sdk-modifications/libsrc/fs/ds2_fcntl.c | 0 sdk-modifications/libsrc/fs/ds2_fcntl.h | 0 sdk-modifications/libsrc/fs/ds2_unistd.c | 0 sdk-modifications/libsrc/fs/ds2_unistd.h | 0 sdk-modifications/libsrc/fs/fat.h | 0 sdk-modifications/libsrc/fs/fat_misc.c | 52 ++-- sdk-modifications/libsrc/fs/fat_misc.h | 0 sdk-modifications/libsrc/fs/fatdir.h | 0 sdk-modifications/libsrc/fs/fatdir_ex.c | 0 sdk-modifications/libsrc/fs/fatdir_ex.h | 0 sdk-modifications/libsrc/fs/fatfile.c | 0 sdk-modifications/libsrc/fs/fatfile.h | 0 sdk-modifications/libsrc/fs/fatfile_ex.c | 0 sdk-modifications/libsrc/fs/fatfile_ex.h | 0 .../libsrc/fs/file_allocation_table.h | 0 sdk-modifications/libsrc/fs/filetime.c | 0 sdk-modifications/libsrc/fs/filetime.h | 0 sdk-modifications/libsrc/fs/fs.mk | 2 +- sdk-modifications/libsrc/fs/fs_api.c | 0 sdk-modifications/libsrc/fs/fs_api.h | 0 sdk-modifications/libsrc/fs/fs_cache.h | 0 sdk-modifications/libsrc/fs/fs_common.h | 0 sdk-modifications/libsrc/fs/fs_unicode.c | 0 sdk-modifications/libsrc/fs/fs_unicode.h | 0 sdk-modifications/libsrc/fs/libfat.c | 0 sdk-modifications/libsrc/fs/mem_allocate.h | 0 sdk-modifications/libsrc/fs/partition.c | 0 sdk-modifications/libsrc/fs/partition.h | 0 sdk-modifications/libsrc/key/key.c | 0 sdk-modifications/libsrc/key/key.h | 0 sdk-modifications/libsrc/key/key.mk | 0 sdk-modifications/libsrc/zlib/README | 9 +- sdk-modifications/libsrc/zlib/adler32.c | 0 sdk-modifications/libsrc/zlib/compress.c | 0 sdk-modifications/libsrc/zlib/crc32.c | 0 sdk-modifications/libsrc/zlib/crc32.h | 0 sdk-modifications/libsrc/zlib/deflate.c | 0 sdk-modifications/libsrc/zlib/deflate.h | 0 sdk-modifications/libsrc/zlib/gzclose.c | 0 sdk-modifications/libsrc/zlib/gzguts.h | 0 sdk-modifications/libsrc/zlib/gzlib.c | 0 sdk-modifications/libsrc/zlib/gzread.c | 0 sdk-modifications/libsrc/zlib/gzwrite.c | 0 sdk-modifications/libsrc/zlib/infback.c | 0 sdk-modifications/libsrc/zlib/inffast.c | 0 sdk-modifications/libsrc/zlib/inffast.h | 0 sdk-modifications/libsrc/zlib/inffixed.h | 0 sdk-modifications/libsrc/zlib/inflate.c | 0 sdk-modifications/libsrc/zlib/inflate.h | 0 sdk-modifications/libsrc/zlib/inftrees.c | 0 sdk-modifications/libsrc/zlib/inftrees.h | 0 sdk-modifications/libsrc/zlib/trees.c | 0 sdk-modifications/libsrc/zlib/trees.h | 0 sdk-modifications/libsrc/zlib/uncompr.c | 0 sdk-modifications/libsrc/zlib/zconf.h | 4 +- sdk-modifications/libsrc/zlib/zlib.h | 0 sdk-modifications/libsrc/zlib/zlib.mk | 0 sdk-modifications/libsrc/zlib/zutil.c | 0 sdk-modifications/libsrc/zlib/zutil.h | 0 83 files changed, 555 insertions(+), 264 deletions(-) delete mode 100644 sdk-modifications/libsrc/.depend create mode 100644 sdk-modifications/libsrc/changes_bag.txt mode change 100644 => 100755 sdk-modifications/libsrc/console/console.c mode change 100644 => 100755 sdk-modifications/libsrc/console/console.h mode change 100644 => 100755 sdk-modifications/libsrc/console/console.mk mode change 100644 => 100755 sdk-modifications/libsrc/console/font_dot.h create mode 100644 sdk-modifications/libsrc/core/core.mk create mode 100644 sdk-modifications/libsrc/core/ds2_cpuclock.c create mode 100644 sdk-modifications/libsrc/core/ds2_cpuclock.h create mode 100644 sdk-modifications/libsrc/core/ds2_dma.c create mode 100644 sdk-modifications/libsrc/core/ds2_dma.h delete mode 100644 sdk-modifications/libsrc/dma/dma.mk delete mode 100644 sdk-modifications/libsrc/dma/dmacopy.c delete mode 100644 sdk-modifications/libsrc/dma/ds2_dma.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/bit_ops.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/cache.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/directory.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/directory.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/disc_io/disc.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/disc_io/disc.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/disc_io/disc_io.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/ds2_fcntl.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/ds2_fcntl.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/ds2_unistd.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/ds2_unistd.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fat.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fat_misc.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fatdir.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fatdir_ex.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/fatdir_ex.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fatfile.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/fatfile.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fatfile_ex.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/fatfile_ex.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/file_allocation_table.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/filetime.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/filetime.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fs_api.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/fs_api.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fs_cache.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fs_common.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/fs_unicode.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/fs_unicode.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/libfat.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/mem_allocate.h mode change 100644 => 100755 sdk-modifications/libsrc/fs/partition.c mode change 100644 => 100755 sdk-modifications/libsrc/fs/partition.h mode change 100644 => 100755 sdk-modifications/libsrc/key/key.c mode change 100644 => 100755 sdk-modifications/libsrc/key/key.h mode change 100644 => 100755 sdk-modifications/libsrc/key/key.mk mode change 100644 => 100755 sdk-modifications/libsrc/zlib/adler32.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/compress.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/crc32.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/crc32.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/deflate.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/deflate.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/gzclose.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/gzguts.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/gzlib.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/gzread.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/gzwrite.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/infback.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/inffast.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/inffast.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/inffixed.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/inflate.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/inflate.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/inftrees.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/inftrees.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/trees.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/trees.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/uncompr.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/zlib.h mode change 100644 => 100755 sdk-modifications/libsrc/zlib/zlib.mk mode change 100644 => 100755 sdk-modifications/libsrc/zlib/zutil.c mode change 100644 => 100755 sdk-modifications/libsrc/zlib/zutil.h (limited to 'sdk-modifications/libsrc') diff --git a/sdk-modifications/libsrc/.depend b/sdk-modifications/libsrc/.depend deleted file mode 100644 index e69de29..0000000 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 old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/console/console.h b/sdk-modifications/libsrc/console/console.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/console/console.mk b/sdk-modifications/libsrc/console/console.mk old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/console/font_dot.h b/sdk-modifications/libsrc/console/font_dot.h old mode 100644 new mode 100755 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 + +#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 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 -#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 old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/cache.c b/sdk-modifications/libsrc/fs/cache.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/directory.c b/sdk-modifications/libsrc/fs/directory.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/directory.h b/sdk-modifications/libsrc/fs/directory.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/disc_io/disc.c b/sdk-modifications/libsrc/fs/disc_io/disc.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/disc_io/disc.h b/sdk-modifications/libsrc/fs/disc_io/disc.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/disc_io/disc_io.h b/sdk-modifications/libsrc/fs/disc_io/disc_io.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c b/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h b/sdk-modifications/libsrc/fs/disc_io/io_ds2_mmcf.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/ds2_fcntl.c b/sdk-modifications/libsrc/fs/ds2_fcntl.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/ds2_fcntl.h b/sdk-modifications/libsrc/fs/ds2_fcntl.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/ds2_unistd.c b/sdk-modifications/libsrc/fs/ds2_unistd.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/ds2_unistd.h b/sdk-modifications/libsrc/fs/ds2_unistd.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fat.h b/sdk-modifications/libsrc/fs/fat.h old mode 100644 new mode 100755 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 old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fatdir.h b/sdk-modifications/libsrc/fs/fatdir.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fatdir_ex.c b/sdk-modifications/libsrc/fs/fatdir_ex.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fatdir_ex.h b/sdk-modifications/libsrc/fs/fatdir_ex.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fatfile.c b/sdk-modifications/libsrc/fs/fatfile.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fatfile.h b/sdk-modifications/libsrc/fs/fatfile.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fatfile_ex.c b/sdk-modifications/libsrc/fs/fatfile_ex.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fatfile_ex.h b/sdk-modifications/libsrc/fs/fatfile_ex.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/file_allocation_table.h b/sdk-modifications/libsrc/fs/file_allocation_table.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/filetime.c b/sdk-modifications/libsrc/fs/filetime.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/filetime.h b/sdk-modifications/libsrc/fs/filetime.h old mode 100644 new mode 100755 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 old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fs_api.h b/sdk-modifications/libsrc/fs/fs_api.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fs_cache.h b/sdk-modifications/libsrc/fs/fs_cache.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fs_common.h b/sdk-modifications/libsrc/fs/fs_common.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fs_unicode.c b/sdk-modifications/libsrc/fs/fs_unicode.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/fs_unicode.h b/sdk-modifications/libsrc/fs/fs_unicode.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/libfat.c b/sdk-modifications/libsrc/fs/libfat.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/mem_allocate.h b/sdk-modifications/libsrc/fs/mem_allocate.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/partition.c b/sdk-modifications/libsrc/fs/partition.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/fs/partition.h b/sdk-modifications/libsrc/fs/partition.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/key/key.c b/sdk-modifications/libsrc/key/key.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/key/key.h b/sdk-modifications/libsrc/key/key.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/key/key.mk b/sdk-modifications/libsrc/key/key.mk old mode 100644 new mode 100755 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 . \ 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 . \ No newline at end of file diff --git a/sdk-modifications/libsrc/zlib/adler32.c b/sdk-modifications/libsrc/zlib/adler32.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/compress.c b/sdk-modifications/libsrc/zlib/compress.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/crc32.c b/sdk-modifications/libsrc/zlib/crc32.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/crc32.h b/sdk-modifications/libsrc/zlib/crc32.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/deflate.c b/sdk-modifications/libsrc/zlib/deflate.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/deflate.h b/sdk-modifications/libsrc/zlib/deflate.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/gzclose.c b/sdk-modifications/libsrc/zlib/gzclose.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/gzguts.h b/sdk-modifications/libsrc/zlib/gzguts.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/gzlib.c b/sdk-modifications/libsrc/zlib/gzlib.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/gzread.c b/sdk-modifications/libsrc/zlib/gzread.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/gzwrite.c b/sdk-modifications/libsrc/zlib/gzwrite.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/infback.c b/sdk-modifications/libsrc/zlib/infback.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/inffast.c b/sdk-modifications/libsrc/zlib/inffast.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/inffast.h b/sdk-modifications/libsrc/zlib/inffast.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/inffixed.h b/sdk-modifications/libsrc/zlib/inffixed.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/inflate.c b/sdk-modifications/libsrc/zlib/inflate.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/inflate.h b/sdk-modifications/libsrc/zlib/inflate.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/inftrees.c b/sdk-modifications/libsrc/zlib/inftrees.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/inftrees.h b/sdk-modifications/libsrc/zlib/inftrees.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/trees.c b/sdk-modifications/libsrc/zlib/trees.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/trees.h b/sdk-modifications/libsrc/zlib/trees.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/uncompr.c b/sdk-modifications/libsrc/zlib/uncompr.c old mode 100644 new mode 100755 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 /* 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 /* for off_t */ # endif #endif diff --git a/sdk-modifications/libsrc/zlib/zlib.h b/sdk-modifications/libsrc/zlib/zlib.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/zlib.mk b/sdk-modifications/libsrc/zlib/zlib.mk old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/zutil.c b/sdk-modifications/libsrc/zlib/zutil.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/zlib/zutil.h b/sdk-modifications/libsrc/zlib/zutil.h old mode 100644 new mode 100755 -- cgit v1.2.3