Chameleon

Chameleon Commit Details

Date:2011-06-25 09:51:01 (12 years 9 months ago)
Author:Azimutz
Commit:1058
Parents: 1057
Message:Keep up with trunk...
Changes:
M/branches/azimutz/Chazi/i386/util/fdisk/cmd.c
M/branches/azimutz/Chazi/i386/libsa/qsort.c
M/branches/azimutz/Chazi/i386/modules/klibc/vsnprintf.c
M/branches/azimutz/Chazi/i386/libsaio/saio_types.h
M/branches/azimutz/Chazi/i386/libsaio/disk.c
M/branches/azimutz/Chazi/i386/modules/klibc/vsscanf.c

File differences

branches/azimutz/Chazi/i386/libsaio/disk.c
5050
5151
5252
53
53
5454
55
56
57
58
5955
6056
6157
6258
6359
6460
61
62
63
64
65
66
6567
66
6768
69
6870
6971
70
71
72
73
74
7572
7673
7774
......
636633
637634
638635
639
636
637
640638
641639
642
640
643641
644642
645
643
646644
647645
648
646
649647
650648
651
649
652650
653651
652
654653
655654
656655
......
16421641
16431642
16441643
1645
1646
1644
16471645
16481646
16491647
......
17401738
17411739
17421740
1743
1741
17441742
17451743
17461744
* GPT support added by David Elliott. Based on IOGUIDPartitionScheme.cpp.
*/
//#define UFS_SUPPORT 1 //Azi: error: duplicate case value
//Azi: style the rest later...
#include <limits.h>
#include <IOKit/storage/IOApplePartitionScheme.h>
#include <IOKit/storage/IOGUIDPartitionScheme.h>
// Allow UFS_SUPPORT to be overridden with preprocessor option.
#ifndef UFS_SUPPORT
// zef: Disabled UFS support
#define UFS_SUPPORT 0
#endif
#if UFS_SUPPORT
#include "ufs.h"
#endif
#include <limits.h>
#include <IOKit/storage/IOApplePartitionScheme.h>
#include <IOKit/storage/IOGUIDPartitionScheme.h>
//#include "libsaio.h"
//#include "bootstruct.h"
#include "boot.h"
//#include "bootstruct.h"
#include "memory.h"
#include "fdisk.h"
#if UFS_SUPPORT
#include "ufs.h"
#endif
#include "hfs.h"
#include "ntfs.h"
#include "msdos.h"
//==========================================================================
// HFS+ GUID in LE form - Hierarchical File System (HFS+) partition - 48465300-0000-11AA-AA11-00306543ECAC
// GUID's in LE form:
// HFS+ partition - 48465300-0000-11AA-AA11-00306543ECAC
EFI_GUID const GPT_HFS_GUID = { 0x48465300, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } };
// turbo - Apple Boot partition - 426F6F74-0000-11AA-AA11-00306543ECAC
// turbo - Apple Boot Partition - 426F6F74-0000-11AA-AA11-00306543ECAC
EFI_GUID const GPT_BOOT_GUID = { 0x426F6F74, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } };
// turbo - or an EFI System partition - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
// turbo - or an EFI System Partition - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
EFI_GUID const GPT_EFISYS_GUID = { 0xC12A7328, 0xF81F, 0x11D2, { 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } };
// zef - Basic Data partition - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 for foreign OS support
// zef - Basic Data Partition - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 for foreign OS support
EFI_GUID const GPT_BASICDATA_GUID = { 0xEBD0A0A2, 0xB9E5, 0x4433, { 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7 } };
// Microsoft Reserved Partition E3C9E316-0B5C-4DB8-817DF92DF00215AE
// Microsoft Reserved Partition - E3C9E316-0B5C-4DB8-817DF92DF00215AE
EFI_GUID const GPT_BASICDATA2_GUID = { 0xE3C9E316, 0x0B5C, 0x4DB8, { 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } };
BVRef newGPTBVRef( int biosdev, int partno, unsigned int blkoff,
const gpt_ent * part,
FSInit initFunc, FSLoadFile loadFunc,
}
}
#if DEBUG //Azi: check other changed if's; (define debug "1")
//Azi: warning - too big for boot-log.. far too big.. i mean HUGE!! :P
#if DEBUG //Azi: warning - too big for boot-log.. far too big.. i mean HUGE!! :P
for (bvr = chain; bvr; bvr = bvr->next)
{
printf(" bvr: %d, dev: %d, part: %d, flags: %d, vis: %d\n", bvr, bvr->biosdev, bvr->part_no, bvr->flags, bvr->visible);
/* If Rename Partition has defined an alias, then extract it for description purpose.
* The format for the rename string is the following:
* hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" "alias";etc...
* hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" "alias"; etc...
*/
bool getVolumeLabelAlias(BVRef bvr, char* str, long strMaxLen)
branches/azimutz/Chazi/i386/libsaio/saio_types.h
66
77
88
9
9
1010
1111
1212
......
2828
2929
3030
31
3132
3233
3334
3435
35
36
36
3737
3838
3939
......
4242
4343
4444
45
46
47
45
46
47
4848
4949
5050
51
52
53
54
51
52
53
54
5555
5656
5757
58
59
60
58
59
60
6161
6262
6363
......
7373
7474
7575
76
76
7777
7878
7979
......
9393
9494
9595
96
97
96
97
9898
9999
100100
101101
102
102
103103
104104
105105
106
107
106
107
108108
109109
110110
111111
112112
113
113
114114
115115
116116
117117
118
119
120
121
122
118
119
120
121
122
123123
124124
125125
126
126
127127
128128
129
129
130130
131131
132132
......
135135
136136
137137
138
139
138
139
140140
141141
142142
143143
144144
145145
146
147
148
149
146
147
148
149
150150
151151
152
153
154
155
156
157
158
159
160
161
162
152
153
154
155
156
157
158
159
163160
164161
165
166
167
162
163
164
168165
169166
170167
171168
172169
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
197194
198195
199196
200
201
202
203
204
205
206
197
198
199
200
201
202
203
207204
208205
209206
210
211
212
213
214
215
207
208
209
210
211
212
216213
217214
218215
219
220
221
222
223
216
217
218
219
220
224221
225222
226
227
223
224
228225
229226
230227
231228
232229
233
234
235
236
230
231
232
233
237234
238235
239236
240
237
238
241239
242
243
240
241
242
244243
245
244
246245
247246
248
247
249248
250249
251
252
253
250
251
254252
255
256
257253
258
259
260
254
255
256
261257
262258
263
264
259
260
265261
266262
267263
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the "License"). You may not use this file
* Source License Version 2.0 (the "License").You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
#include <sys/reboot.h>
#include <sys/types.h>
#include <sys/param.h>
#include "bios.h"
#include "nbp_cmd.h"
#include "bootargs.h"
//Azi: shouldn't this be on disk.c ??
#if DEBUG
#if DEBUG //Azi: deal with this later - check with Mek!
#define DEBUG_DISK(x) printf x
#else
#define DEBUG_DISK(x)
typedef unsigned long entry_t;
typedef struct {
unsigned int sectors:8;
unsigned int heads:8;
unsigned int cylinders:16;
unsigned int sectors:8;
unsigned int heads:8;
unsigned int cylinders:16;
} compact_diskinfo_t;
struct driveParameters {
int cylinders;
int sectors;
int heads;
int totalDrives;
int cylinders;
int sectors;
int heads;
int totalDrives;
};
struct Tag {
long type;
char *string;
long offset;
longtype;
char *string;
longoffset;
struct Tag *tag;
struct Tag *tagNext;
};
* BIOS drive information.
*/
struct boot_drive_info {
struct drive_params {
struct drive_params {
unsigned short buf_size;
unsigned short info_flags;
unsigned long phys_cyls;
unsigned char dev_path[8];
unsigned char reserved3;
unsigned char checksum;
} params;
struct drive_dpte {
} params;
struct drive_dpte {
unsigned short io_port_base;
unsigned short control_port_base;
unsigned char head_flags;
unsigned char vendor_info;
unsigned char irq : 4;
unsigned char irq : 4;
unsigned char irq_unused : 4;
unsigned char block_count;
unsigned char dma_channel : 4;
unsigned char dma_type : 4;
unsigned char pio_type : 4;
unsigned char dma_type : 4;
unsigned char pio_type : 4;
unsigned char pio_unused : 4;
unsigned short option_flags;
unsigned short reserved;
unsigned char revision;
unsigned char checksum;
} dpte;
} dpte;
} __attribute__((packed));
typedef struct boot_drive_info boot_drive_info_t;
struct driveInfo {
boot_drive_info_t di;
int uses_ebios;
int no_emulation;
int biosdev;
int valid;
boot_drive_info_t di;
int uses_ebios;
int no_emulation;
int biosdev;
int valid;
};
typedef struct FinderInfo {
unsigned char data[16];
unsigned char data[16];
} FinderInfo;
struct BootVolume;
struct BootVolume;
typedef struct BootVolume * BVRef;
typedef struct BootVolume * CICell;
typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
char ** name, long * flags, long * time,
FinderInfo * finderInfo, long * infoValid);
char ** name, long * flags, long * time,
FinderInfo * finderInfo, long * infoValid);
typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
// Can be just pointed to free or a special free function
typedef void (*BVFree)(CICell ih);
struct iob {
unsigned int i_flgs; /* see F_* below */
unsigned int i_offset; /* seek byte offset in file */
int i_filesize; /* size of file */
char * i_buf; /* file load address */
unsigned int i_flgs;/* see F_* below */
unsigned int i_offset;/* seek byte offset in file */
int i_filesize;/* size of file */
char * i_buf;/* file load address */
};
//Azi: 4K drive fails everytime I try...??
// http://forum.voodooprojects.org/index.php/topic,568.msg9763.html#msg9763
// MSDOS_CACHE_BLOCKSIZE ??????
#define BPS 512 /* sector size of the device */
#define F_READ 0x1 /* file opened for reading */
#define F_WRITE 0x2 /* file opened for writing */
#define F_ALLOC 0x4 /* buffer allocated */
#define F_FILE 0x8 /* file instead of device */
#define F_NBSF 0x10 /* no bad sector forwarding */
#define F_SSI 0x40 /* set skip sector inhibit */
#define F_MEM 0x80 /* memory instead of file or device */
#define BPS 512/* sector size of the device */
#define F_READ 0x1/* file opened for reading */
#define F_WRITE 0x2/* file opened for writing */
#define F_ALLOC 0x4/* buffer allocated */
#define F_FILE 0x8/* file instead of device */
#define F_NBSF 0x10/* no bad sector forwarding */
#define F_SSI 0x40/* set skip sector inhibit */
#define F_MEM 0x80/* memory instead of file or device */
struct dirstuff {
char * dir_path; /* directory path */
long long dir_index; /* directory entry index */
BVRef dir_bvr; /* volume reference */
char * dir_path;/* directory path */
long long dir_index;/* directory entry index */
BVRef dir_bvr;/* volume reference */
};
#define BVSTRLEN 32
struct BootVolume {
BVRef next; /* list linkage pointer */
int biosdev; /* BIOS device number */
int type; /* device type (floppy, hd, network) */
unsigned int flags; /* attribute flags */
BVGetDescription description; /* BVGetDescription function */
int part_no; /* partition number (1 based) */
unsigned int part_boff; /* partition block offset */
unsigned int part_type; /* partition type */
unsigned int fs_boff; /* 1st block # of next read */
unsigned int fs_byteoff; /* Byte offset for read within block */
FSLoadFile fs_loadfile; /* FSLoadFile function */
FSReadFile fs_readfile; /* FSReadFile function */
FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
FSGetUUID fs_getuuid; /* FSGetUUID function */
unsigned int bps; /* bytes per sector for this device */
char name[BVSTRLEN]; /* (name of partition) */
char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
BVFree bv_free; /* BVFree function */
uint32_t modTime;
char label[BVSTRLEN]; /* partition volume label */
char altlabel[BVSTRLEN]; /* partition volume label */
bool filtered; /* newFilteredBVChain() will set to TRUE */
bool visible; /* will shown in the device list */
BVRef next; /* list linkage pointer */
int biosdev; /* BIOS device number */
int type; /* device type (floppy, hd, network) */
unsigned int flags; /* attribute flags */
BVGetDescription description; /* BVGetDescription function */
int part_no; /* partition number (1 based) */
unsigned int part_boff; /* partition block offset */
unsigned int part_type; /* partition type */
unsigned int fs_boff; /* 1st block # of next read */
unsigned int fs_byteoff; /* Byte offset for read within block */
FSLoadFile fs_loadfile; /* FSLoadFile function */
FSReadFile fs_readfile; /* FSReadFile function */
FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
FSGetUUID fs_getuuid; /* FSGetUUID function */
unsigned int bps; /* bytes per sector for this device */
char name[BVSTRLEN]; /* (name of partition) */
char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
BVFree bv_free; /* BVFree function */
uint32_t modTime;
char label[BVSTRLEN]; /* partition volume label */
char altlabel[BVSTRLEN]; /* partition volume label */
bool filtered; /* newFilteredBVChain() will set to TRUE */
bool visible; /* will shown in the device list */
};
enum {
kBVFlagPrimary = 0x01,
kBVFlagNativeBoot = 0x02,
kBVFlagForeignBoot = 0x04,
kBVFlagBootable = 0x08,
kBVFlagEFISystem = 0x10,
kBVFlagBooter = 0x20,
kBVFlagSystemVolume = 0x40
kBVFlagPrimary= 0x01,
kBVFlagNativeBoot= 0x02,
kBVFlagForeignBoot= 0x04,
kBVFlagBootable= 0x08,
kBVFlagEFISystem= 0x10,
kBVFlagBooter= 0x20,
kBVFlagSystemVolume= 0x40
};
enum {
kBIOSDevTypeFloppy = 0x00,
kBIOSDevTypeHardDrive = 0x80,
kBIOSDevTypeNetwork = 0xE0,
kBIOSDevUnitMask = 0x0F,
kBIOSDevTypeMask = 0xF0,
kBIOSDevMask = 0xFF
kBIOSDevTypeFloppy= 0x00,
kBIOSDevTypeHardDrive= 0x80,
kBIOSDevTypeNetwork= 0xE0,
kBIOSDevUnitMask= 0x0F,
kBIOSDevTypeMask= 0xF0,
kBIOSDevMask= 0xFF
};
enum {
kPartitionTypeHFS = 0xAF,
kPartitionTypeHPFS = 0x07,
kPartitionTypeFAT16 = 0x06,
kPartitionTypeFAT32 = 0x0c,
kPartitionTypeEXT3 = 0x83
kPartitionTypeHFS= 0xAF,
kPartitionTypeHPFS= 0x07,
kPartitionTypeFAT16= 0x06,
kPartitionTypeFAT32= 0x0c,
kPartitionTypeEXT3= 0x83
};
//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
#define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
/*
* KernBootStruct device types.
*/
enum {
DEV_SD = 0,
DEV_HD = 1,
DEV_FD = 2,
DEV_EN = 3
DEV_SD = 0,
DEV_HD = 1,
DEV_FD = 2,
DEV_EN = 3
};
/*
* Macros for min/max.
* min/max Macros.
* counting and rounding Macros.
*
* Azi: defined on <sys/param.h>; includes, check later...
*/
* Azi: defined on <sys/param.h>,
*i386/include/IOKit/IOLib.h (min/max), and others...
*
#ifndef MIN
#defineMIN(a,b) ( ((a) < (b)) ? (a) : (b) )
#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
#endif
#ifndef MAX
#defineMAX(a,b) ( ((a) > (b)) ? (a) : (b) )
#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
#endif
//Azi: not in use
/*#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))
#define round2(x, m)(((x) + (m / 2)) & ~(m - 1))
#define roundup2(x, m)(((x) + m - 1) & ~(m - 1))*/
#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)*/
enum {
kNetworkDeviceType = kBIOSDevTypeNetwork,
kBlockDeviceType = kBIOSDevTypeHardDrive
};// gBootFileType_t; - Kpatcher; still needed???
kNetworkDeviceType = kBIOSDevTypeNetwork,
kBlockDeviceType = kBIOSDevTypeHardDrive
}; //gBootFileType_t; - modules/kernelpatcher
enum {
kCursorTypeHidden = 0x0100,
kCursorTypeUnderline = 0x0607
kCursorTypeHidden = 0x0100,
kCursorTypeUnderline = 0x0607
};
#endif /* !__LIBSAIO_SAIO_TYPES_H */
branches/azimutz/Chazi/i386/modules/klibc/vsnprintf.c
55
66
77
8
8
9
10
911
12
1013
1114
1215
* family is built
*/
#include "libsaio.h"
//#include "libsaio.h"
//Azi: "UCHAR_MAX" & "UINT_MAX" redefined error - limits.h is also present in i386/include.
#include "libsa.h"
#include "limits.h"
enum flags {
FL_ZERO= 0x01,/* Zero modifier */
FL_MINUS= 0x02,/* Minus modifier */
branches/azimutz/Chazi/i386/modules/klibc/vsscanf.c
55
66
77
8
8
9
10
911
12
1013
1114
1215
* family is built
*/
#include "libsaio.h"
//#include "libsaio.h"
//Azi: "UCHAR_MAX" & "UINT_MAX" redefined error - limits.h is also present in i386/include.
#include "libsa.h"
#include "limits.h"
extern uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n);
#ifndef LONG_BIT
branches/azimutz/Chazi/i386/libsa/qsort.c
5757
5858
5959
60
6061
61
62
6362
6463
6564
#include <sys/types.h>
#include <stdlib.h>
#include <sys/param.h>
#include "saio_types.h" //Azi: min/max
static inline char*med3 __P((char *, char *, char *, int (*)()));
static inline void swapfunc __P((char *, char *, int, int));
branches/azimutz/Chazi/i386/util/fdisk/cmd.c
6565
6666
6767
68
6869
6970
7071
#include "part.h"
#include "cmd.h"
#include "auto.h"
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
int

Archive Download the corresponding diff file

Revision: 1058