Index: branches/xZenu/src/arch/i386/libsaio/xml.c =================================================================== --- branches/xZenu/src/arch/i386/libsaio/xml.c (revision 1297) +++ branches/xZenu/src/arch/i386/libsaio/xml.c (revision 1298) @@ -67,20 +67,20 @@ } 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; @@ -88,20 +88,20 @@ #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 }; @@ -130,7 +130,7 @@ XMLGetProperty( TagPtr dict, const char * key ) { TagPtr tagList, tag; - + if (dict->type != kTagTypeDict) return 0; tag = 0; @@ -155,7 +155,7 @@ { int count = 0; TagPtr tagList, tag; - + if (dict->type != kTagTypeDict && dict->type != kTagTypeArray) return 0; tag = 0; tagList = dict->tag; @@ -169,7 +169,7 @@ ) continue; if(tag->type == kTagTypeKey) printf("Located key %s\n", tag->string); - + count++; } @@ -182,7 +182,7 @@ int element = 0; TagPtr tmp = dict->tag; - + while(element < id) { element++; @@ -203,7 +203,7 @@ } 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;", '>'), @@ -245,7 +245,7 @@ *o++ = *s++; } - + return out; } @@ -271,17 +271,17 @@ 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); @@ -384,7 +384,7 @@ } } char* str = GetRefString(id); - + TagPtr tmpTag = NewTag(); tmpTag->type = kTagTypeString; tmpTag->string = str; @@ -536,38 +536,38 @@ { 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; @@ -588,20 +588,20 @@ 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) { @@ -609,15 +609,15 @@ 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; } @@ -629,26 +629,26 @@ { 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; } @@ -688,7 +688,7 @@ if (tmpTag == 0) return -1; integer = 0; - + if(size > 1 && (val[1] == 'x' || val[1] == 'X')) // Hex value { val += 2; @@ -741,7 +741,7 @@ if (negative) integer = -integer; } - + tmpTag->type = kTagTypeInteger; tmpTag->string = (char *)integer; tmpTag->tag = 0; @@ -761,7 +761,7 @@ { long length; TagPtr tmpTag; - + length = FixDataMatchingTag(buffer, kXMLTagData); if (length == -1) return -1; @@ -844,7 +844,7 @@ GetNextTag( char * buffer, char ** tag, long * start ) { long cnt, cnt2; - + if (tag == 0) return -1; // Find the start of the tag. @@ -856,7 +856,7 @@ 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'; @@ -904,7 +904,7 @@ { long cnt; TagPtr tag; - + if (gTagsFree == 0) { tag = (TagPtr)malloc(kTagsPerBlock * sizeof(Tag)); @@ -919,10 +919,10 @@ tag[cnt].tagNext = tag + cnt + 1; } tag[kTagsPerBlock - 1].tagNext = 0; - + gTagsFree = tag; } - + tag = gTagsFree; gTagsFree = tag->tagNext; @@ -937,12 +937,12 @@ { #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; @@ -960,9 +960,9 @@ struct Symbol { - long refCount; - struct Symbol *next; - char string[]; + long refCount; + struct Symbol *next; + char string[]; }; typedef struct Symbol Symbol, *SymbolPtr; @@ -976,32 +976,39 @@ 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; } @@ -1014,7 +1021,7 @@ { SymbolPtr symbol, prev; prev = 0; - + // Look for string in the list of symbols. symbol = FindSymbol(string, &prev); if (symbol == 0) return; @@ -1040,19 +1047,19 @@ 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; } @@ -1080,7 +1087,7 @@ char* XMLCastString(TagPtr dict) { if(!dict) return NULL; - + if((dict->type == kTagTypeString) || (dict->type == kTagTypeKey)) return dict->string; @@ -1091,7 +1098,7 @@ { if(dict && ((dict->type == kTagTypeString) || - (dict->type == kTagTypeKey))) + (dict->type == kTagTypeKey))) { return dict->offset; } Index: branches/xZenu/src/arch/i386/libsaio/console.c =================================================================== --- branches/xZenu/src/arch/i386/libsaio/console.c (revision 1297) +++ branches/xZenu/src/arch/i386/libsaio/console.c (revision 1298) @@ -49,72 +49,7 @@ 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_SIZE 134 -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 */ @@ -160,58 +95,6 @@ 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() { Index: branches/xZenu/src/arch/i386/boot2/boot.c =================================================================== --- branches/xZenu/src/arch/i386/boot2/boot.c (revision 1297) +++ branches/xZenu/src/arch/i386/boot2/boot.c (revision 1298) @@ -50,13 +50,14 @@ */ +#include + #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)); @@ -78,7 +79,8 @@ 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); } //========================================================================== Index: branches/xZenu/src/arch/i386/boot2/Makefile =================================================================== --- branches/xZenu/src/arch/i386/boot2/Makefile (revision 1297) +++ branches/xZenu/src/arch/i386/boot2/Makefile (revision 1298) @@ -27,9 +27,10 @@ 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 Index: branches/xZenu/src/arch/i386/libsa/libsa.h =================================================================== --- branches/xZenu/src/arch/i386/libsa/libsa.h (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/libsa.h (revision 1298) @@ -1,154 +0,0 @@ -/* - * 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 -#include -#include -#include - -/* - * 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 */ Index: branches/xZenu/src/arch/i386/libsa/efi_tables.h =================================================================== --- branches/xZenu/src/arch/i386/libsa/efi_tables.h (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/efi_tables.h (revision 1298) @@ -1,16 +0,0 @@ -/*! @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__ Index: branches/xZenu/src/arch/i386/libsa/setjmp.s =================================================================== --- branches/xZenu/src/arch/i386/libsa/setjmp.s (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/setjmp.s (revision 1298) @@ -1,58 +0,0 @@ -/* - * 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 - -#define O_EDI 0 -#define O_ESI 4 -#define O_EBX 8 -#define O_EBP 12 -#define O_ESP 16 -#define O_EIP 20 - -LEAF(_setjmp, 0) -X_LEAF(_set_label, _setjmp) - movl 4(%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) - movl 4(%esp), %edx // address of save area - movl O_EDI(%edx), %edi - movl O_ESI(%edx), %esi - movl O_EBX(%edx), %ebx - movl O_EBP(%edx), %ebp - movl O_ESP(%edx), %esp - movl O_EIP(%edx), %eax // %eip (return address) - movl %eax, 0(%esp) - popl %eax // ret addr != 0 - jmp *%eax // indirect Index: branches/xZenu/src/arch/i386/libsa/Cconfig =================================================================== --- branches/xZenu/src/arch/i386/libsa/Cconfig (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/Cconfig (revision 1298) @@ -1 +0,0 @@ - Index: branches/xZenu/src/arch/i386/libsa/prf.c =================================================================== --- branches/xZenu/src/arch/i386/libsa/prf.c (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/prf.c (revision 1298) @@ -1,167 +0,0 @@ -/* - * 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.c 7.1 (Berkeley) 6/5/86 - */ - -#include - -#define SPACE 1 -#define ZERO 2 -#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; -} Index: branches/xZenu/src/arch/i386/libsa/error.c =================================================================== --- branches/xZenu/src/arch/i386/libsa/error.c (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/error.c (revision 1298) @@ -1,35 +0,0 @@ -/* - * 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; -} Index: branches/xZenu/src/arch/i386/libsa/Makefile =================================================================== --- branches/xZenu/src/arch/i386/libsa/Makefile (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/Makefile (revision 1298) @@ -1,48 +0,0 @@ -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 Index: branches/xZenu/src/arch/i386/libsa/efi_tables.c =================================================================== --- branches/xZenu/src/arch/i386/libsa/efi_tables.c (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/efi_tables.c (revision 1298) @@ -1,162 +0,0 @@ -/*! @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; -} Index: branches/xZenu/src/arch/i386/libsa/memory.h =================================================================== --- branches/xZenu/src/arch/i386/libsa/memory.h (revision 1297) +++ branches/xZenu/src/arch/i386/libsa/memory.h (revision 1298) @@ -1,144 +0,0 @@ -/* - * 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_SEG 0x1000 // zef: old STACK_SEG 0x5000 -#define STACK_OFS 0xFFF0 // stack pointer - -#define BOOT1U_SEG 0x1000 -#define BOOT1U_OFS 0x0200 - -#define BOOT2_SEG 0x2000 -#define BOOT2_OFS 0x0200 // 512 byte disk sector offset - -#define BOOT2_MAX_LENGTH 0x6FE00 // Maximum size for boot2 is currentl 447kb - -#define BIOS_ADDR 0x8000 // BIOS disk I/O buffer -#define BIOS_LEN 0x8000 // 32K - divisible by 512 and 2048 - -#define BOOT0_ADDR 0x7E00 // 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 */ Index: branches/xZenu/src/arch/i386/Makefile =================================================================== --- branches/xZenu/src/arch/i386/Makefile (revision 1297) +++ branches/xZenu/src/arch/i386/Makefile (revision 1298) @@ -13,7 +13,7 @@ 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 $@