summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-27 20:32:12 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-27 20:32:12 +0000
commit944c33403ca92d34d38e82a5778a456a2b5c3e01 (patch)
tree5cf616ab91ccaecfabdced39af9966965ab6210e /firmware/target/arm
parent109a8677425eefd10e4a4df759e3c1c9c857ff45 (diff)
downloadrockbox-944c33403ca92d34d38e82a5778a456a2b5c3e01.tar.gz
rockbox-944c33403ca92d34d38e82a5778a456a2b5c3e01.zip
* Commit dual-boot support for Creative ZVx family
* Add mkzenboot: makes it possible to integrate Rockbox bootloader with Creative firmwares without the need of distributing binaries * Add Tadeusz Pyś to credits, who figured out the minifs file system * Fix bootloader git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18352 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/tms320dm320/boot.lds4
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c105
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-target.h1
3 files changed, 108 insertions, 2 deletions
diff --git a/firmware/target/arm/tms320dm320/boot.lds b/firmware/target/arm/tms320dm320/boot.lds
index 5a4182fe29..97274a2c04 100644
--- a/firmware/target/arm/tms320dm320/boot.lds
+++ b/firmware/target/arm/tms320dm320/boot.lds
@@ -7,7 +7,7 @@ STARTUP(target/arm/tms320dm320/crt0.o)
#define DRAMSIZE (MEMORYSIZE * 0x100000)
-#define DRAMORIG 0x00900000
+#define DRAMORIG 0x01900000 /* actually it's 0x00900000 */
#define IRAMORIG 0x00000000
#define IRAMSIZE 16K
#define FLASHORIG 0x00100000
@@ -22,7 +22,7 @@ MEMORY
SECTIONS
{
- . = DRAMORIG + 0x1000000;
+ . = DRAMORIG;
.text : {
loadaddress = .;
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
index 0c4dd4bfbe..1732c5d2c4 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
@@ -28,6 +28,8 @@
#include "panic.h"
#include "ata-target.h"
#include "dm320.h"
+#include "ata.h"
+#include "string.h"
void sleep_ms(int ms)
{
@@ -109,3 +111,106 @@ void GIO2(void)
IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */
return;
}
+
+/*
+ ---------------------------------------------------------------------------
+ Creative File Systems parsing code
+ ---------------------------------------------------------------------------
+ */
+
+struct main_header
+{
+ char mblk[4];
+ unsigned char sector_size[4];
+ unsigned char disk_size[8];
+ struct partition_header
+ {
+ unsigned char end[4];
+ unsigned char start[4];
+ char name[8];
+ } partitions[31];
+};
+
+struct minifs_file
+{
+ char name[0x10];
+ unsigned char unk[4];
+ unsigned char size[4];
+ unsigned char chain1[4];
+ unsigned char chain2[4];
+};
+
+struct minifs_chain
+{
+ unsigned char unknown[4];
+ unsigned char chain[2*0x27FE];
+ unsigned char unknown2[4];
+ unsigned char length[4];
+};
+
+
+#define DIR_BITMAP_START 0x0143
+#define DIR_START 0x0144
+#define DATASPACE_BITMAP_START 0x0145
+#define DATASPACE_START 0x0146
+
+#define CLUSTER_CHAIN_SIZE 0x5008
+#define CLUSTER_CHAIN_HEAD 0x0000
+#define CLUSTER_CHAIN_BITMAP 0x0001
+#define CLUSTER_CHAIN_CHAIN 0x0002
+
+
+static unsigned short le2int16(unsigned char* buf)
+{
+ return (buf[1] << 8) | buf[0];
+}
+
+static unsigned int le2int32(unsigned char* buf)
+{
+ return (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+}
+
+int load_minifs_file(char* filename, unsigned char* location)
+{
+ struct main_header *hdr;
+ static struct minifs_file files[128];
+ struct minifs_chain *chain;
+ unsigned int i;
+ int found = -1;
+ unsigned char sector[512];
+ static unsigned char chain_data[42*512]; /* stack overflow if not static */
+
+ /* Reading MBLK */
+ ata_read_sectors(0, 1, &sector);
+ hdr = (struct main_header*)&sector;
+
+ /* Reading directory listing */
+#define CLUSTER2SECTOR(x) ( (le2int32(hdr->partitions[0].start) + (x)*8) )
+ ata_read_sectors(CLUSTER2SECTOR(DIR_START), 8, &files);
+
+ for(i=0; i<127; i++)
+ {
+ if(strcmp(files[i].name, filename) == 0)
+ found = i;
+ }
+
+ if(found == -1)
+ return -1;
+
+#define GET_CHAIN(x) ( CLUSTER2SECTOR(CLUSTER_CHAIN_CHAIN)*512 + (x)*CLUSTER_CHAIN_SIZE )
+#define FILE2SECTOR(x) ( CLUSTER2SECTOR(DATASPACE_START + (x)) )
+
+ /* Reading chain list */
+ ata_read_sectors(GET_CHAIN(le2int32(files[found].chain1))/512, 41, &chain_data[0]);
+
+ chain = (struct minifs_chain*)&chain_data[GET_CHAIN(le2int32(files[found].chain1))%512];
+
+ /* Copying data */
+ for(i=0; i<le2int32(chain->length); i++)
+ {
+ ata_read_sectors(FILE2SECTOR(le2int16(&chain->chain[i*2])), 8, location);
+ location += 0x1000;
+ }
+
+ return le2int32(files[found].size);
+}
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
index 63417d1219..6e5699e887 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
+++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
@@ -74,5 +74,6 @@ void ata_reset(void);
void ata_device_init(void);
bool ata_is_coldstart(void);
void ide_power_enable(bool on);
+int load_minifs_file(char* filename, unsigned char* location);
#endif