summaryrefslogtreecommitdiff
path: root/firmware/common/disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/disk.c')
-rw-r--r--firmware/common/disk.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index d4cfbc1a05..a81d57dd01 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -26,6 +26,7 @@
26#include "file.h" /* for release_files() */ 26#include "file.h" /* for release_files() */
27#endif 27#endif
28#include "disk.h" 28#include "disk.h"
29#include <string.h>
29 30
30/* Partition table entry layout: 31/* Partition table entry layout:
31 ----------------------- 32 -----------------------
@@ -66,8 +67,8 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive))
66 struct partinfo* pinfo = part; 67 struct partinfo* pinfo = part;
67#endif 68#endif
68 69
69 ata_read_sectors(IF_MV2(drive,) 0,1,&sector); 70 ata_read_sectors(IF_MV2(drive,) 0,1, &sector);
70 71#ifndef CREATIVE_ZVM
71 /* check that the boot sector is initialized */ 72 /* check that the boot sector is initialized */
72 if ( (sector[510] != 0x55) || 73 if ( (sector[510] != 0x55) ||
73 (sector[511] != 0xaa)) { 74 (sector[511] != 0xaa)) {
@@ -90,7 +91,46 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive))
90 /* not handled yet */ 91 /* not handled yet */
91 } 92 }
92 } 93 }
93 94#else
95 struct partition_struct
96 {
97 unsigned int end;
98 unsigned int start;
99 char name[8];
100 };
101 struct hdd_struct
102 {
103 unsigned char MBLK[4];
104 int sector_size;
105 long long total_disk_size;
106 struct partition_struct partitions[4];
107 };
108 struct hdd_struct* hdd_struct = (struct hdd_struct*)sector;
109
110 if(hdd_struct->MBLK[0] != 0x4B ||
111 hdd_struct->MBLK[1] != 0x4C ||
112 hdd_struct->MBLK[2] != 0x42 ||
113 hdd_struct->MBLK[3] != 0x4D) /* 0x4B4C424D = KLBM */
114 {
115 DEBUGF("Bad boot sector signature\n");
116 return NULL;
117 }
118 else
119 {
120 /* parse partitions */
121 for ( i=0; i<4; i++ ) {
122 if(hdd_struct->partitions[i].name[0] != 0)
123 {
124 pinfo[i].type = ( strcmp(hdd_struct->partitions[i].name, "cfs") == 0 ? PARTITION_TYPE_FAT32_LBA : 0);
125 pinfo[i].start = hdd_struct->partitions[i].start;
126 pinfo[i].size = (hdd_struct->partitions[i].end - hdd_struct->partitions[i].start);
127
128 DEBUGF("Part%d: Type %02x, start: %08lx size: %08lx\n",
129 i,pinfo[i].type,pinfo[i].start,pinfo[i].size);
130 }
131 }
132 }
133#endif
94 return pinfo; 134 return pinfo;
95} 135}
96 136
@@ -147,7 +187,7 @@ int disk_mount(int drive)
147 { 187 {
148 return 0; 188 return 0;
149 } 189 }
150#ifdef TOSHIBA_GIGABEAT_S 190#if defined(TOSHIBA_GIGABEAT_S) ||defined(CREATIVE_ZVM)
151 int i = 1; /* For the Gigabeat S, we mount the second partition */ 191 int i = 1; /* For the Gigabeat S, we mount the second partition */
152#else 192#else
153 int i = 0; 193 int i = 0;