Chameleon

Chameleon Commit Details

Date:2011-08-06 19:49:15 (12 years 8 months ago)
Author:Evan Lojewski
Commit:1298
Parents: 1297
Message:Remove libsa.
Changes:
D/branches/xZenu/src/arch/i386/libsa/Makefile
D/branches/xZenu/src/arch/i386/libsa/efi_tables.c
D/branches/xZenu/src/arch/i386/libsa/memory.h
D/branches/xZenu/src/arch/i386/libsa/libsa.h
D/branches/xZenu/src/arch/i386/libsa/efi_tables.h
D/branches/xZenu/src/arch/i386/libsa/setjmp.s
D/branches/xZenu/src/arch/i386/libsa/Cconfig
D/branches/xZenu/src/arch/i386/libsa/prf.c
D/branches/xZenu/src/arch/i386/libsa/error.c
M/branches/xZenu/src/arch/i386/libsaio/console.c
M/branches/xZenu/src/arch/i386/boot2/boot.c
M/branches/xZenu/src/arch/i386/Makefile
M/branches/xZenu/src/arch/i386/boot2/Makefile
M/branches/xZenu/src/arch/i386/libsaio/xml.c

File differences

branches/xZenu/src/arch/i386/libsaio/xml.c
6767
6868
6969
70
71
72
73
74
75
70
71
72
73
74
75
7676
7777
7878
7979
80
81
82
83
80
81
82
83
8484
8585
8686
......
8888
8989
9090
91
92
93
94
95
96
97
98
91
92
93
94
95
96
97
98
9999
100100
101101
102102
103
104
103
104
105105
106106
107107
......
130130
131131
132132
133
133
134134
135135
136136
......
155155
156156
157157
158
158
159159
160160
161161
......
169169
170170
171171
172
172
173173
174174
175175
......
182182
183183
184184
185
185
186186
187187
188188
......
203203
204204
205205
206
206
207207
208208
209209
......
245245
246246
247247
248
248
249249
250250
251251
......
271271
272272
273273
274
274
275275
276276
277277
278278
279
279
280280
281
281
282282
283283
284
284
285285
286286
287287
......
384384
385385
386386
387
387
388388
389389
390390
......
536536
537537
538538
539
539
540540
541541
542
542
543543
544544
545545
546546
547547
548548
549
549
550550
551
551
552552
553553
554554
555555
556
556
557557
558558
559559
560560
561561
562562
563
563
564564
565565
566566
567567
568568
569569
570
570
571571
572572
573573
......
588588
589589
590590
591
591
592592
593593
594
594
595595
596596
597
597
598598
599599
600600
601601
602602
603603
604
604
605605
606606
607607
......
609609
610610
611611
612
612
613613
614614
615615
616616
617617
618
618
619619
620
620
621621
622622
623623
......
629629
630630
631631
632
632
633633
634634
635
635
636636
637637
638
638
639639
640640
641641
642642
643643
644644
645
645
646646
647647
648648
649649
650650
651
651
652652
653653
654654
......
688688
689689
690690
691
691
692692
693693
694694
......
741741
742742
743743
744
744
745745
746746
747747
......
761761
762762
763763
764
764
765765
766766
767767
......
844844
845845
846846
847
847
848848
849849
850850
......
856856
857857
858858
859
859
860860
861861
862862
......
904904
905905
906906
907
907
908908
909909
910910
......
919919
920920
921921
922
922
923923
924924
925
925
926926
927927
928928
......
937937
938938
939939
940
940
941941
942
942
943943
944944
945
945
946946
947947
948948
......
960960
961961
962962
963
964
965
963
964
965
966966
967967
968968
......
976976
977977
978978
979
979
980980
981
981
982982
983983
984
984
985985
986986
987987
988988
989
990
991
989
990
991
992
993
994
992995
993996
994997
995
998
996999
9971000
9981001
9991002
1000
1003
10011004
10021005
1003
1004
1006
1007
1008
1009
1010
1011
10051012
10061013
10071014
......
10141021
10151022
10161023
1017
1024
10181025
10191026
10201027
......
10401047
10411048
10421049
1043
1050
10441051
10451052
1046
1053
10471054
10481055
1049
1056
10501057
10511058
10521059
1053
1060
10541061
1055
1062
10561063
10571064
10581065
......
10801087
10811088
10821089
1083
1090
10841091
10851092
10861093
......
10911098
10921099
10931100
1094
1101
10951102
10961103
10971104
}
struct Module {
struct Module *nextModule;
long willLoad;
TagPtr dict;
char *plistAddr;
long plistLength;
char *driverPath;
struct Module *nextModule;
long willLoad;
TagPtr dict;
char *plistAddr;
long plistLength;
char *driverPath;
};
typedef struct Module Module, *ModulePtr;
struct DriverInfo {
char *plistAddr;
long plistLength;
void *moduleAddr;
long moduleLength;
char *plistAddr;
long plistLength;
void *moduleAddr;
long moduleLength;
};
typedef struct DriverInfo DriverInfo, *DriverInfoPtr;
#define kDriverPackageSignature2 'MOSX'
struct DriversPackage {
unsigned long signature1;
unsigned long signature2;
unsigned long length;
unsigned long adler32;
unsigned long version;
unsigned long numDrivers;
unsigned long reserved1;
unsigned long reserved2;
unsigned long signature1;
unsigned long signature2;
unsigned long length;
unsigned long adler32;
unsigned long version;
unsigned long numDrivers;
unsigned long reserved1;
unsigned long reserved2;
};
typedef struct DriversPackage DriversPackage;
enum {
kCFBundleType2,
kCFBundleType3
kCFBundleType2,
kCFBundleType3
};
XMLGetProperty( TagPtr dict, const char * key )
{
TagPtr tagList, tag;
if (dict->type != kTagTypeDict) return 0;
tag = 0;
{
int count = 0;
TagPtr tagList, tag;
if (dict->type != kTagTypeDict && dict->type != kTagTypeArray) return 0;
tag = 0;
tagList = dict->tag;
) continue;
if(tag->type == kTagTypeKey) printf("Located key %s\n", tag->string);
count++;
}
int element = 0;
TagPtr tmp = dict->tag;
while(element < id)
{
element++;
} XMLEntity;
/* This is ugly, but better than specifying the lengths by hand */
#define _e(str,c) {str,sizeof(str)-1,c}
#define _e(str,c) {str,sizeof(str)-1,c}
const XMLEntity ents[] = {
_e("quot;",'"'), _e("apos;",'\''),
_e("lt;", '<'), _e("gt;", '>'),
*o++ = *s++;
}
return out;
}
strcpy(configBuffer, buffer);
buffer_start = configBuffer;
while (1)
{
length = XMLParseNextTag(configBuffer + pos, &tag);
if (length == -1) break;
pos += length;
if (tag == 0) continue;
if (tag->type == kTagTypeDict) break;
XMLFreeTag(tag);
}
free(configBuffer);
}
}
char* str = GetRefString(id);
TagPtr tmpTag = NewTag();
tmpTag->type = kTagTypeString;
tmpTag->string = str;
{
long length, pos;
TagPtr tagList, tmpTag;
tagList = 0;
pos = 0;
if (!empty)
{
while (1)
{
length = XMLParseNextTag(buffer + pos, &tmpTag);
if (length == -1) break;
pos += length;
if (tmpTag == 0) break;
tmpTag->tagNext = tagList;
tagList = tmpTag;
}
if (length == -1)
{
XMLFreeTag(tagList);
return -1;
}
}
tmpTag = NewTag();
if (tmpTag == 0)
{
XMLFreeTag(tagList);
return -1;
}
tmpTag->type = type;
tmpTag->string = 0;
tmpTag->offset = buffer_start ? buffer - buffer_start : 0;
long length, length2;
char *string;
TagPtr tmpTag, subTag;
length = FixDataMatchingTag(buffer, kXMLTagKey);
if (length == -1) return -1;
length2 = XMLParseNextTag(buffer + length, &subTag);
if (length2 == -1) return -1;
tmpTag = NewTag();
if (tmpTag == 0)
{
XMLFreeTag(subTag);
return -1;
}
string = NewSymbol(buffer);
if (string == 0)
{
XMLFreeTag(tmpTag);
return -1;
}
tmpTag->type = kTagTypeKey;
tmpTag->string = string;
tmpTag->tag = subTag;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
tmpTag->tagNext = 0;
*tag = tmpTag;
return length + length2;
}
{
long length;
char * string;
length = FixDataMatchingTag(buffer, kXMLTagString);
if (length == -1) return -1;
TagPtr tmpTag = NewTag();
if (tmpTag == 0) return -1;
string = NewSymbol(buffer);
if (string == 0)
{
XMLFreeTag(tmpTag);
return -1;
}
tmpTag->type = kTagTypeString;
tmpTag->string = string;
tmpTag->tag = 0;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
tmpTag->tagNext = 0;
*tag = tmpTag;
return length;
}
if (tmpTag == 0) return -1;
integer = 0;
if(size > 1 && (val[1] == 'x' || val[1] == 'X'))// Hex value
{
val += 2;
if (negative)
integer = -integer;
}
tmpTag->type = kTagTypeInteger;
tmpTag->string = (char *)integer;
tmpTag->tag = 0;
{
long length;
TagPtr tmpTag;
length = FixDataMatchingTag(buffer, kXMLTagData);
if (length == -1) return -1;
GetNextTag( char * buffer, char ** tag, long * start )
{
long cnt, cnt2;
if (tag == 0) return -1;
// Find the start of the tag.
cnt2 = cnt + 1;
while ((buffer[cnt2] != '\0') && (buffer[cnt2] != '>')) cnt2++;
if (buffer[cnt2] == '\0') return -1;
// Fix the tag data.
*tag = buffer + cnt + 1;
buffer[cnt2] = '\0';
{
long cnt;
TagPtr tag;
if (gTagsFree == 0)
{
tag = (TagPtr)malloc(kTagsPerBlock * sizeof(Tag));
tag[cnt].tagNext = tag + cnt + 1;
}
tag[kTagsPerBlock - 1].tagNext = 0;
gTagsFree = tag;
}
tag = gTagsFree;
gTagsFree = tag->tagNext;
{
#if DOFREE
if (tag == 0) return;
if (tag->string) FreeSymbol(tag->string);
XMLFreeTag(tag->tag);
XMLFreeTag(tag->tagNext);
// Clear and free the tag.
tag->type = kTagTypeNone;
tag->string = 0;
struct Symbol
{
long refCount;
struct Symbol *next;
char string[];
long refCount;
struct Symbol *next;
char string[];
};
typedef struct Symbol Symbol, *SymbolPtr;
static char *
NewSymbol( char * string )
{
static SymbolPtr lastGuy = 0;
static SymbolPtr lastGuy = 0;
SymbolPtr symbol;
// Look for string in the list of symbols.
symbol = FindSymbol(string, 0);
// Add the new symbol.
if (symbol == 0)
{
symbol = (SymbolPtr)malloc(sizeof(Symbol) + 1 + strlen(string));
if (symbol == 0) //return 0;
stop("NULL symbol!");
if (symbol == 0)
{
printf("NULL symbol!");
while(1);
}
// Set the symbol's data.
symbol->refCount = 0;
strcpy(symbol->string, string);
// Add the symbol to the list.
symbol->next = gSymbolsHead;
gSymbolsHead = symbol;
}
// Update the refCount and return the string.
symbol->refCount++;
if (lastGuy && lastGuy->next != 0) stop("last guy not last!");
if (lastGuy && lastGuy->next != 0)
{
printf("last guy not last!");
while(1);
}
return symbol->string;
}
{
SymbolPtr symbol, prev;
prev = 0;
// Look for string in the list of symbols.
symbol = FindSymbol(string, &prev);
if (symbol == 0) return;
FindSymbol( char * string, SymbolPtr * prevSymbol )
{
SymbolPtr symbol, prev;
symbol = gSymbolsHead;
prev = 0;
while (symbol != 0) {
if (!strcmp(symbol->string, string)) break;
prev = symbol;
symbol = symbol->next;
}
if ((symbol != 0) && (prevSymbol != 0)) *prevSymbol = prev;
return symbol;
}
char* XMLCastString(TagPtr dict)
{
if(!dict) return NULL;
if((dict->type == kTagTypeString) ||
(dict->type == kTagTypeKey)) return dict->string;
{
if(dict &&
((dict->type == kTagTypeString) ||
(dict->type == kTagTypeKey)))
(dict->type == kTagTypeKey)))
{
return dict->offset;
}
branches/xZenu/src/arch/i386/libsaio/console.c
4949
5050
5151
52
53
54
55
56
57
58
59
60
61
6252
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
11853
11954
12055
......
16095
16196
16297
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
21598
21699
217100
bool gVerboseMode;
bool gErrors;
/*
* Azi: Doubled available log size; this seems to fix some hangs and instant reboots caused by
* booting with -f (ignore caches). 96kb are enough to hold full log, booting with -f; even so,
* this depends on how much we "play" at the boot prompt and with what patches we're playing,
* depending on how much they print to the log.
*
* Kabyl: BooterLog
*/
#define BOOTER_LOG_SIZE(128 * 1024)
#define SAFE_LOG_SIZE134
char *msgbuf = 0;
char *cursor = 0;
struct putc_info //Azi: exists on gui.c & printf.c
{
char * str;
char * last_str;
};
static int
sputc(int c, struct putc_info * pi) //Azi: same as above
{
if (pi->last_str)
if (pi->str == pi->last_str)
{
*(pi->str) = '\0';
return 0;
}
*(pi->str)++ = c;
return c;
}
void initBooterLog(void)
{
msgbuf = malloc(BOOTER_LOG_SIZE);
bzero(msgbuf, BOOTER_LOG_SIZE);
cursor = msgbuf;
}
void msglog(const char * fmt, ...)
{
va_list ap;
struct putc_info pi;
if (!msgbuf)
return;
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
return;
va_start(ap, fmt);
pi.str = cursor;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
va_end(ap);
cursor += strlen((char *)cursor);
}
void setupBooterLog(void)
{
if (!msgbuf)
return;
}
/* Kabyl: !BooterLog */
/*
* write one character to console
*/
return (c);
}
int verbose(const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (gVerboseMode)
{
prf(fmt, ap, putchar, 0);
}
{
// Kabyl: BooterLog
struct putc_info pi;
if (!msgbuf)
return 0;
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
return 0;
pi.str = cursor;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
cursor += strlen((char *)cursor);
}
va_end(ap);
return(0);
}
int error(const char * fmt, ...)
{
va_list ap;
gErrors = true;
va_start(ap, fmt);
prf(fmt, ap, putchar, 0);
va_end(ap);
return(0);
}
void stop(const char * fmt, ...)
{
va_list ap;
printf("\n");
va_start(ap, fmt);
prf(fmt, ap, putchar, 0);
va_end(ap);
printf("\nThis is a non recoverable error! System HALTED!!!");
halt();
while (1);
}
/** Print a "Press a key to continue..." message and wait for a key press. */
void pause()
{
branches/xZenu/src/arch/i386/boot2/boot.c
5050
5151
5252
53
54
5355
5456
5557
5658
5759
5860
59
6061
6162
6263
......
7879
7980
8081
81
82
83
8284
8385
8486
*/
#include <stdio.h>
#include "boot.h"
extern void init_module_system();
extern int execute_hook(const char* name, void*, void*, void*, void*);
extern void bzero(void * dst, size_t len);
extern void stop(const char *format, ...);
extern void enableA20(void);
extern void video_mode(int mode);
extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
static void malloc_error(char *addr, size_t size, const char *file, int line)
{
stop("\nMemory allocation error! Addr=0x%x, Size=0x%x, File=%s, Line=%d\n", (unsigned)addr, (unsigned)size, file, line);
printf("\nMemory allocation error! Addr=0x%x, Size=0x%x, File=%s, Line=%d\n", (unsigned)addr, (unsigned)size, file, line);
while(1);
}
//==========================================================================
branches/xZenu/src/arch/i386/boot2/Makefile
2727
2828
2929
30
31
32
30
31
32
33
3334
3435
3536
INC = -I. -I$(SYMROOT) -I$(LIBSADIR) -I$(LIBSAIODIR) -I${SRCROOT}/include
LIBS= -L$(SYMROOT) -lsaio -lsa
LIBDEP= libsaio.a libsa.a
LIBS= -L$(SYMROOT) -lsaio
#-lsaio
LIBDEP= libsaio.a
#libsaio.a
OTHER_FILES =
# enable boot2 to find boot_modules.c
branches/xZenu/src/arch/i386/libsa/libsa.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* 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
* 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.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __BOOT_LIBSA_H
#define __BOOT_LIBSA_H
/* Exported API for standalone library */
#include <mach-o/loader.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>
/*
* ctype stuff (aserebln)
*/
static inline int isupper(int c)
{
return (c >= 'A' && c <= 'Z');
}
static inline int islower(int c)
{
return (c >= 'a' && c <= 'z');
}
static inline int isalpha(int c)
{
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
}
static inline int isascii(int c)
{
return ( (c >= 0x20) && (c < 0x7f) );
}
static inline int isspace(int c)
{
return (c == ' ' || c == '\t' || c == '\n' || c == '\12');
}
static inline int isdigit(int c)
{
return (c >= '0' && c <= '9');
}
static inline int isxdigit(int c)
{
return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
}
static inline int ispunct(int c)
{
return (c == '.' || c == '-');
}
/*
* string.c
*/
#ifndef bcopy
extern void bcopy(const void * src, void * dst, size_t len);
#endif
#ifndef bzero
extern void bzero(void * dst, size_t len);
#endif
extern void * memset(void * dst, int c, size_t n);
extern void * memcpy(void * dst, const void * src, size_t len);
extern int memcmp(const void * p1, const void * p2, size_t len);
extern int strcmp(const char * s1, const char * s2);
extern int strncmp(const char * s1, const char * s2, size_t n);
extern char * strcpy(char * s1, const char * s2);
extern char * strncpy(char * s1, const char * s2, size_t n);
extern size_t strlcpy(char * s1, const char * s2, size_t n);
extern char * strstr(const char *in, const char *str);
extern int atoi(const char * str);
extern int ptol(const char * str);
extern size_t strlen(const char * str);
extern char * strcat(char * s1, const char * s2);
extern char * strncat(char * s1, const char * s2, size_t n);
extern char * strdup(const char *s1);
#if STRNCASECMP
extern int strncasecmp(const char * s1, const char * s2, size_t n);
#endif
extern char * strchr(const char *str, int c);
extern char * strbreak(const char *str, char **next, long *len);
extern uint8_t checksum8( void * start, unsigned int length );
/*
* error.c
*/
extern int errno;
extern char * strerror(int errnum);
/*
* strtol.c
*/
extern long strtol(const char * nptr, char ** endptr, int base);
extern unsigned long strtoul(const char * nptr, char ** endptr, int base);
extern unsigned long long strtouq(const char *nptr, char ** endptr, int base);
/*
* prf.c
*/
extern void prf(const char * fmt, va_list ap, int (*putfn_p)(),
void * putfn_arg);
/*
* printf.c
*/
extern int sprintf(char *s, const char * format, ...);
extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);
/*
* zalloc.c
*/
#define malloc(size)safe_malloc(size, __FILE__, __LINE__)
extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
extern void * safe_malloc(size_t size,const char *file, int line);
extern void free(void * start);
extern void * realloc(void * ptr, size_t size);
/*
* getsegbyname.c
*/
extern struct segment_command *
getsegbynamefromheader(struct mach_header * mhp, char * segname);
#endif /* !__BOOT_LIBSA_H */
branches/xZenu/src/arch/i386/libsa/efi_tables.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*! @file efi_tables.h
@abstract Utility functions for dealing with EFI tables
Copyright 2007 David F. Elliott. All rights reserved.
*/
#ifndef _LIBSA_EFI_TABLES_H__
#define _LIBSA_EFI_TABLES_H__
#include "efi.h"
uint32_t crc32(uint32_t crc, const void *buf, size_t size);
void efi_guid_unparse_upper(EFI_GUID const *pGuid, char *out);
bool efi_guid_is_null(EFI_GUID const *pGuid);
int efi_guid_compare(EFI_GUID const *pG1, EFI_GUID const *pG2);
#endif //ndef _LIBSA_EFI_TABLES_H__
branches/xZenu/src/arch/i386/libsa/setjmp.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999 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 1.1 (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.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <architecture/i386/asm_help.h>
#defineO_EDI0
#defineO_ESI4
#defineO_EBX8
#defineO_EBP12
#defineO_ESP16
#define O_EIP20
LEAF(_setjmp, 0)
X_LEAF(_set_label, _setjmp)
movl4(%esp), %edx // address of save area
movl%edi, O_EDI(%edx)
movl%esi, O_ESI(%edx)
movl%ebx, O_EBX(%edx)
movl%ebp, O_EBP(%edx)
movl%esp, O_ESP(%edx)
movl(%esp), %ecx // %eip (return address)
movl%ecx, O_EIP(%edx)
subl%eax, %eax // retval <- 0
ret
LEAF(_longjmp, 0)
X_LEAF(_jump_label, _longjmp)
movl4(%esp), %edx // address of save area
movlO_EDI(%edx), %edi
movlO_ESI(%edx), %esi
movlO_EBX(%edx), %ebx
movlO_EBP(%edx), %ebp
movlO_ESP(%edx), %esp
movlO_EIP(%edx), %eax // %eip (return address)
movl%eax, 0(%esp)
popl%eax // ret addr != 0
jmp *%eax // indirect
branches/xZenu/src/arch/i386/libsa/Cconfig
1
branches/xZenu/src/arch/i386/libsa/prf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* 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
* 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.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Mach Operating System
* Copyright (c) 1990 Carnegie-Mellon University
* Copyright (c) 1989 Carnegie-Mellon University
* Copyright (c) 1988 Carnegie-Mellon University
* Copyright (c) 1987 Carnegie-Mellon University
* All rights reserved. The CMU software License Agreement specifies
* the terms and conditions for use and redistribution.
*/
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
*@(#)prf.c7.1 (Berkeley) 6/5/86
*/
#include <sys/param.h>
#define SPACE1
#define ZERO2
#define UCASE 16
/*
* Scaled down version of C Library printf.
* Used to print diagnostic information directly on console tty.
* Since it is not interrupt driven, all system activities are
* suspended.
*
*/
/*
* Printn prints a number n in base b.
* We don't use recursion to avoid deep kernel stacks.
*/
static void
printn(n, b, flag, minwidth, putfn_p, putfn_arg)
u_long n;
int b, flag, minwidth;
int (*putfn_p)();
void *putfn_arg;
{
char prbuf[11];
register char *cp;
int width = 0, neg = 0;
if (b == 10 && (int)n < 0) {
neg = 1;
n = (unsigned)(-(int)n);
}
cp = prbuf;
do {
*cp++ = "0123456789abcdef0123456789ABCDEF"[(flag & UCASE) + n%b];
n /= b;
width++;
} while (n);
if (neg) {
(*putfn_p)('-', putfn_arg);
width++;
}
while (width++ < minwidth)
(*putfn_p)( (flag & ZERO) ? '0' : ' ', putfn_arg);
do
(*putfn_p)(*--cp, putfn_arg);
while (cp > prbuf);
}
void prf(
char *fmt,
unsigned int *adx,
int (*putfn_p)(),
void *putfn_arg
)
{
int b, c;
char *s;
int flag = 0, width = 0;
int minwidth;
loop:
while ((c = *fmt++) != '%') {
if(c == '\0')
return;
(*putfn_p)(c, putfn_arg);
}
minwidth = 0;
again:
c = *fmt++;
switch (c) {
case 'l':
goto again;
case ' ':
flag |= SPACE;
goto again;
case '0':
if (minwidth == 0) {
/* this is a flag */
flag |= ZERO;
goto again;
} /* fall through */
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
minwidth *= 10;
minwidth += c - '0';
goto again;
case 'X':
flag |= UCASE;
/* fall through */
case 'x':
b = 16;
goto number;
case 'd':
b = 10;
goto number;
case 'o': case 'O':
b = 8;
number:
printn((u_long)*adx, b, flag, minwidth, putfn_p, putfn_arg);
break;
case 's':
s = (char *)*adx;
while (c = *s++) {
(*putfn_p)(c, putfn_arg);
width++;
}
while (width++ < minwidth)
(*putfn_p)(' ', putfn_arg);
break;
case 'c':
(*putfn_p)((char)*adx, putfn_arg);
break;
}
adx++;
goto loop;
}
branches/xZenu/src/arch/i386/libsa/error.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* 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
* 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.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* error handling */
#include "libsa.h"
int errno;
char * strerror(int errnum)
{
static char error_string[16];
sprintf(error_string,"Error %d", errnum);
return error_string;
}
branches/xZenu/src/arch/i386/libsa/Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
ROOT = $(shell pwd)/../../../../
DIR = libsa
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386/${DIR}
SYMROOT = $(ROOT)/sym/i386
DSTROOT = $(ROOT)/dst/usr/standalone/i386/
DOCROOT = $(ROOT)/doc
LIBSAIODIR = ../libsaio
CFLAGS:= $(RC_CFLAGS) $(OPTIM) $(MORECPP) -static -g -Wmost -Werror \
-fno-builtin -DSAIO_INTERNAL_USER $(OMIT_FRAME_POINTER_CFLAG) \
-fno-align-functions -fno-stack-protector \
-msoft-float -nostdinc -include $(SRCROOT)/autoconf.h
CPPFLAGS := $(CPPFLAGS) -static -nostdinc++ -Wmost -Werror \
-fno-builtin -msoft-float \
-fno-rtti -fno-exceptions \
-include $(SRCROOT)/autoconf.h
INC = -I. -I$(SYMROOT) -I$(LIBSAIODIR) -I${SRCROOT}/include
OBJECTS = prf \
error \
setjmp efi_tables
LIBS = libsa.a
LIBS := $(addprefix $(SYMROOT)/, $(LIBS))
DIRS_NEEDED =
include ${ROOT}/Make.rules
all: $(OBJROOT) $(SYMROOT) $(LIBS)
$(LIBS): ${ACTUAL_OBJECTS}
@echo "\t[RM] $@"
@rm -f $@
@echo "\t[AR] $(@F)"
@ar q $@ $^ &> /dev/null
@echo "\t[RANLIB] $(@F)"
@ranlib $@
# dependencies
-include $(OBJROOT)/Makedep
branches/xZenu/src/arch/i386/libsa/efi_tables.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*! @file efi_tables.c
Copyright 2007 David F. Elliott. All rights reserved.
*/
#include "libsa.h"
#include "efi_tables.h"
/*==========================================================================
* CRC32 implementation copied from xnu in turn copied from Gary S. Brown.
*/
/*-
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
* code or tables extracted from it, as desired without restriction.
*
* First, the polynomial itself and its table of feedback terms. The
* polynomial is
* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
*
* Note that we take it "backwards" and put the highest-order term in
* the lowest-order bit. The X^32 term is "implied"; the LSB is the
* X^31 term, etc. The X^0 term (usually shown as "+1") results in
* the MSB being 1
*
* Note that the usual hardware shift register implementation, which
* is what we're using (we're merely optimizing it by doing eight-bit
* chunks at a time) shifts bits into the lowest-order term. In our
* implementation, that means shifting towards the right. Why do we
* do it this way? Because the calculated CRC must be transmitted in
* order from highest-order term to lowest-order term. UARTs transmit
* characters in order from LSB to MSB. By storing the CRC this way
* we hand it to the UART in the order low-byte to high-byte; the UART
* sends each low-bit to hight-bit; and the result is transmission bit
* by bit from highest- to lowest-order term without requiring any bit
* shuffling on our part. Reception works similarly
*
* The feedback terms table consists of 256, 32-bit entries. Notes
*
* The table can be generated at runtime if desired; code to do so
* is shown later. It might not be obvious, but the feedback
* terms simply represent the results of eight shift/xor opera
* tions for all combinations of data and CRC register values
*
* The values must be right-shifted by eight bits by the "updcrc
* logic; the shift must be unsigned (bring in zeroes). On some
* hardware you could probably optimize the shift in assembler by
* using byte-swap instructions
* polynomial $edb88320
*
*
* CRC32 code derived from work by Gary S. Brown.
*/
static uint32_t crc32_tab[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3,0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de,0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5,0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940,0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
uint32_t crc32(uint32_t crc, const void *buf, size_t size)
{
const uint8_t *p;
p = buf;
crc = crc ^ ~0U;
while (size--)
crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
return crc ^ ~0U;
}
/*==========================================================================
* Utility function to make a device tree string from an EFI_GUID
*/
void efi_guid_unparse_upper(EFI_GUID const *pGuid, char *out)
{
sprintf(out, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
pGuid->Data1, /* - */
pGuid->Data2, /* - */
pGuid->Data3, /* - */
pGuid->Data4[0], pGuid->Data4[1], /* - */
pGuid->Data4[2], pGuid->Data4[3],
pGuid->Data4[4], pGuid->Data4[5],
pGuid->Data4[6], pGuid->Data4[7]);
}
bool efi_guid_is_null(EFI_GUID const *pGuid)
{
if(pGuid->Data1 == 0 && pGuid->Data2 == 0 && pGuid->Data3 == 0)
{
int i;
for(i=0; i<8; ++i)
{
if(pGuid->Data4[i] != 0)
return false;
}
return true;
}
return false;
}
#define COMPARE_MEMBER_AND_RETURN_IF_NE(a,b,mem) \
if( ((a)->mem) < ((b)->mem) ) \
return -1; \
else if( ((a)->mem) > ((b)->mem) ) \
return 1;
int efi_guid_compare(EFI_GUID const *pG1, EFI_GUID const *pG2)
{
COMPARE_MEMBER_AND_RETURN_IF_NE(pG1, pG2, Data1);
COMPARE_MEMBER_AND_RETURN_IF_NE(pG1, pG2, Data2);
COMPARE_MEMBER_AND_RETURN_IF_NE(pG1, pG2, Data3);
int i;
for(i=0; i<8; ++i)
{
COMPARE_MEMBER_AND_RETURN_IF_NE(pG1, pG2, Data4[i]);
}
return 0;
}
branches/xZenu/src/arch/i386/libsa/memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* 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
* 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.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __BOOT_MEMORY_H
#define __BOOT_MEMORY_H
/* Memory addresses used by booter and friends */
/* DFE 2007-12-21: Changed BASE_SEG to be conditional
This allows boot1u and other planned first-stage booters to avoid
maintaining their own copies of asm.s and bios.s and instead
simply build the files from libsaio with the right preprocessor
definitions.
This affects BASE_ADDR and OFFSET16() thus obviating the need for
separate BASE1U_ADDR and OFFSET1U16() macros.
Be careful though as changing these values with preprocessor macros
obviously requires rebuilding the source files. That means in particular
that libsaio.a is only suitable for boot2.
*/
#if defined(BASE_SEG)
/* assume user knows what he's doing */
#elif defined(BOOT1)
# define BASE_SEG BOOT1U_SEG
#else
# define BASE_SEG BOOT2_SEG
#endif
#define STACK_SEG0x1000// zef: old STACK_SEG 0x5000
#define STACK_OFS0xFFF0// stack pointer
#define BOOT1U_SEG0x1000
#define BOOT1U_OFS0x0200
#define BOOT2_SEG0x2000
#define BOOT2_OFS0x0200// 512 byte disk sector offset
#define BOOT2_MAX_LENGTH0x6FE00// Maximum size for boot2 is currentl 447kb
#define BIOS_ADDR0x8000// BIOS disk I/O buffer
#define BIOS_LEN0x8000// 32K - divisible by 512 and 2048
#define BOOT0_ADDR0x7E00// boot0 gets loaded here
/* These are all "virtual" addresses...
* which are physical addresses plus MEMBASE.
*/
#define ADDR32(seg, ofs) (((seg) << 4 ) + (ofs))
#define MEMBASE 0x0
#define BOOTSTRUCT_ADDR 0x00011000 // it's slightly smaller
#define BOOTSTRUCT_LEN 0x0000F000
#define BASE_ADDR ADDR32(BASE_SEG, 0)
#define BOOT1U_ADDR ADDR32(BOOT1U_SEG, BOOT1U_OFS)
#define BOOT2_ADDR ADDR32(BOOT2_SEG, BOOT2_OFS)
// TODO: BOOT_ADDR ?
#define HIB_ADDR 0x00040000 // special hibernation area
#define HIB_LEN 0x00060000
#define VIDEO_ADDR 0x000A0000 // unusable space
#define VIDEO_LEN 0x00060000
#define KERNEL_ADDR 0x00100000 // 128M kernel + drivers
#define KERNEL_LEN 0x08000000
#define ZALLOC_ADDR 0x08100000 // 256M zalloc area
#define ZALLOC_LEN 0x10000000
#define LOAD_ADDR 0x18100000 // 64M File load buffer
#define LOAD_LEN 0x04000000
// Location of data fed to boot2 by the prebooter
#define PREBOOT_DATA 0x1C100000 // Still have enough room for a 63M ramdisk image
// in case of 512MB system memory.
#define TFTP_ADDR LOAD_ADDR // tftp download buffer
#define TFTP_LEN LOAD_LEN
#define kLoadAddr LOAD_ADDR
#define kLoadSize LOAD_LEN
#define CONVENTIONAL_LEN 0x0A0000 // 640k
#define EXTENDED_ADDR 0x100000 // 1024k
#define ptov(paddr) ((paddr) - MEMBASE)
#define vtop(vaddr) ((vaddr) + MEMBASE)
/*
* Extract segment/offset from a linear address.
*/
#define OFFSET16(addr) ((addr) - BASE_ADDR)
#define OFFSET(addr) ((addr) & 0xFFFF)
#define SEGMENT(addr) (((addr) & 0xF0000) >> 4)
/* Extract segment/offset in normalized form so that the resulting far pointer
will point to something that is very unlikely to straddle a segment.
This is sometimes known as a "huge" pointer.
*/
#define NORMALIZED_OFFSET(addr) ((addr) & 0x000F)
#define NORMALIZED_SEGMENT(addr) (((addr) & 0xFFFF0) >> 4)
/*
* We need a minimum of 32MB of system memory.
*/
#define MIN_SYS_MEM_KB (32 * 1024)
/*
* The number of descriptor entries in the GDT.
*/
#define NGDTENT 7
/*
* The total size of the GDT in bytes.
* Each descriptor entry require 8 bytes.
*/
#define GDTLIMIT ( NGDTENT * 8 )
#endif /* !__BOOT_MEMORY_H */
branches/xZenu/src/arch/i386/Makefile
1313
1414
1515
16
16
1717
1818
1919
include ${ROOT}/Make.rules
# The order of building is important.
SUBDIRS = libsa libsaio boot0 boot1 boot2 cdboot
SUBDIRS = libsaio boot0 boot1 boot2 cdboot
all: ${OBJROOT} ${SYMROOT}
@#cd modules; ${MAKE} BUILT_IN=yes $@

Archive Download the corresponding diff file

Revision: 1298