Index: branches/xZenu/src/arch/i386/libsaio/sl.h =================================================================== --- branches/xZenu/src/arch/i386/libsaio/sl.h (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/sl.h (revision 1302) @@ -1,67 +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 __LIBSAIO_SL_H -#define __LIBSAIO_SL_H - -#include -#include -#include -#include "libsaio.h" - -#define SWAP_BE16(x) OSSwapBigToHostInt16(x) -#define SWAP_LE16(x) OSSwapLittleToHostInt16(x) -#define SWAP_BE32(x) OSSwapBigToHostInt32(x) -#define SWAP_LE32(x) OSSwapLittleToHostInt32(x) -#define SWAP_BE64(x) OSSwapBigToHostInt64(x) -#define SWAP_LE64(x) OSSwapLittleToHostInt64(x) - -// File Permissions and Types -enum { - kPermOtherExecute = 1 << 0, - kPermOtherWrite = 1 << 1, - kPermOtherRead = 1 << 2, - kPermGroupExecute = 1 << 3, - kPermGroupWrite = 1 << 4, - kPermGroupRead = 1 << 5, - kPermOwnerExecute = 1 << 6, - kPermOwnerWrite = 1 << 7, - kPermOwnerRead = 1 << 8, - kPermMask = 0x1FF, - kOwnerNotRoot = 1 << 9, - kFileTypeUnknown = 0x0 << 16, - kFileTypeFlat = 0x1 << 16, - kFileTypeDirectory = 0x2 << 16, - kFileTypeLink = 0x3 << 16, - kFileTypeMask = 0x3 << 16 -}; - -#define Seek(c, p) diskSeek(c, p); -#define Read(c, a, l) diskRead(c, a, l); - -extern void * gFSLoadAddress; -extern cpu_type_t archCpuType; -cpu_type_t detectCpuType (); - -#endif /* !__LIBSAIO_SL_H */ Index: branches/xZenu/src/arch/i386/libsaio/xml.c =================================================================== --- branches/xZenu/src/arch/i386/libsaio/xml.c (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/xml.c (revision 1302) @@ -22,8 +22,10 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include +#include +#include #include "libsaio.h" -#include "sl.h" #include "xml.h" string_ref *ref_strings = NULL; Index: branches/xZenu/src/arch/i386/libsaio/console.c =================================================================== --- branches/xZenu/src/arch/i386/libsaio/console.c (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/console.c (revision 1302) @@ -46,10 +46,7 @@ #include "libsaio.h" -bool gVerboseMode; -bool gErrors; - /* * write one character to console */ Index: branches/xZenu/src/arch/i386/libsaio/xml.h =================================================================== --- branches/xZenu/src/arch/i386/libsaio/xml.h (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/xml.h (revision 1302) @@ -25,6 +25,10 @@ #ifndef __LIBSAIO_XML_H #define __LIBSAIO_XML_H +typedef char bool; +#define false 0 +#define true 1 + enum xmltype { kTagTypeNone = 0, kTagTypeDict, Index: branches/xZenu/src/arch/i386/libsaio/memory.h =================================================================== --- branches/xZenu/src/arch/i386/libsaio/memory.h (revision 0) +++ branches/xZenu/src/arch/i386/libsaio/memory.h (revision 1302) @@ -0,0 +1,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_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/libsaio/load.c =================================================================== --- branches/xZenu/src/arch/i386/libsaio/load.c (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/load.c (revision 1302) @@ -30,9 +30,7 @@ #include #include -#include -bool gHaveKernelCache; /* XXX aserebln: uninitialized? and only set to true, never to false */ cpu_type_t archCpuType=CPU_TYPE_I386; // Public Functions Index: branches/xZenu/src/arch/i386/libsaio/biosfn.c =================================================================== --- branches/xZenu/src/arch/i386/libsaio/biosfn.c (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/biosfn.c (revision 1302) @@ -39,7 +39,7 @@ 2007-12-29 dfe - Added ebiosEjectMedia */ - +#include #include "libsaio.h" @@ -246,7 +246,7 @@ #endif // Copy out data - bcopy((char *)BIOS_ADDR, rangeArray, ((char *)range - (char *)BIOS_ADDR)); + memcpy((char *)BIOS_ADDR, rangeArray, ((char *)range - (char *)BIOS_ADDR)); #if DEBUG { @@ -488,7 +488,7 @@ } __attribute__((packed)); static struct packet pkt; - bzero(&pkt, sizeof(pkt)); + memset(&pkt, 0, sizeof(pkt)); pkt.packet_size = 0x13; bb.intno = 0x13; @@ -721,7 +721,7 @@ #endif /* APM_SUPPORT */ #ifdef EISA_SUPPORT -bool eisa_present(void) +char eisa_present(void) { static bool checked = false; static bool isEISA; Index: branches/xZenu/src/arch/i386/libsaio/saio_types.h =================================================================== --- branches/xZenu/src/arch/i386/libsaio/saio_types.h (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/saio_types.h (revision 1302) @@ -62,11 +62,6 @@ }; typedef struct Tag Tag, *TagPtr; -typedef struct { - char plist[4096]; // buffer for plist - TagPtr dictionary; // buffer for xml dictionary - bool canOverride; // flag to mark a dictionary can be overriden -} config_file_t; typedef struct FinderInfo { unsigned char data[16]; @@ -112,33 +107,6 @@ #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 */ -}; - enum { kBVFlagPrimary = 0x01, kBVFlagNativeBoot = 0x02, Index: branches/xZenu/src/arch/i386/libsaio/libsaio.h =================================================================== --- branches/xZenu/src/arch/i386/libsaio/libsaio.h (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/libsaio.h (revision 1302) @@ -26,7 +26,7 @@ #ifndef __LIBSAIO_LIBSAIO_H #define __LIBSAIO_LIBSAIO_H -#include "libsa.h" +#include #include "memory.h" #include "io_inline.h" #include "saio_types.h" Index: branches/xZenu/src/arch/i386/libsaio/misc.c =================================================================== --- branches/xZenu/src/arch/i386/libsaio/misc.c (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/misc.c (revision 1302) @@ -43,7 +43,7 @@ * Copyright 1993 NeXT, Inc. * All rights reserved. */ - +#include #include "libsaio.h" /* Index: branches/xZenu/src/arch/i386/libsaio/saio_internal.h =================================================================== --- branches/xZenu/src/arch/i386/libsaio/saio_internal.h (revision 1301) +++ branches/xZenu/src/arch/i386/libsaio/saio_internal.h (revision 1302) @@ -39,7 +39,7 @@ /* biosfn.c */ #ifdef EISA_SUPPORT -extern bool eisa_present(void); +extern char eisa_present(void); #endif extern int bgetc(void); extern int biosread(int dev, int cyl, int head, int sec, int num); @@ -71,15 +71,7 @@ extern unsigned long getConventionalMemorySize(); extern void sleep(int n); -/* cache.c */ -extern void CacheReset(); -extern void CacheInit(CICell ih, long blockSize); -extern long CacheRead(CICell ih, char *buffer, long long offset, - long length, long cache); - /* console.c */ -extern bool gVerboseMode; -extern bool gErrors; extern void initBooterLog(void); extern void msglog(const char * format, ...); extern void setupBooterLog(void); @@ -92,35 +84,7 @@ //Azi: replace getc/getchar with ? console.c extern void pause(); -/* disk.c */ -extern void rescanBIOSDevice(int biosdev); -extern struct DiskBVMap* diskResetBootVolumes(int biosdev); -extern void diskFreeMap(struct DiskBVMap *map); -extern int testBiosread( int biosdev, unsigned long long secno ); -extern BVRef diskScanBootVolumes(int biosdev, int *count); -extern void diskSeek(BVRef bvr, long long position); -extern int diskRead(BVRef bvr, long addr, long length); -extern int diskIsCDROM(BVRef bvr); -extern int biosDevIsCDROM(int biosdev); -extern BVRef getBVChainForBIOSDev(int biosdev); -extern BVRef newFilteredBVChain(int minBIOSDev, int maxBIOSDev, unsigned int allowFlags, unsigned int denyFlags, int *count); -extern int freeFilteredBVChain(const BVRef chain); -extern int rawDiskRead(BVRef bvr, unsigned int secno, void *buffer, unsigned int len); -extern int rawDiskWrite(BVRef bvr, unsigned int secno, void *buffer, unsigned int len); -extern int readBootSector(int biosdev, unsigned int secno, void *buffer); -extern void turnOffFloppy(void); -extern int testFAT32EFIBootSector( int biosdev, unsigned int secno, void * buffer ); - -/* hfs_compare.c */ -extern int32_t FastUnicodeCompare(u_int16_t *uniStr1, u_int32_t len1, - u_int16_t *uniStr2, u_int32_t len2, int byte_order); -extern void utf_encodestr( const u_int16_t * ucsp, int ucslen, - u_int8_t * utf8p, u_int32_t bufsize, int byte_order ); -extern void utf_decodestr(const u_int8_t *utf8p, u_int16_t *ucsp, - u_int16_t *ucslen, u_int32_t bufsize, int byte_order ); - /* load.c */ -extern bool gHaveKernelCache; extern long ThinFatFile(void **binary, unsigned long *length); extern long DecodeMachO(void *binary, entry_t *rentry, char **raddr, int *rsize); @@ -128,34 +92,6 @@ long AllocateKernelMemory( long inSize ); long AllocateMemoryRange(char * rangeName, long start, long length, long type); -/* misc.c */ -extern void enableA20(void); -extern int checkForSupportedHardware(); -extern int isLaptop(); -extern void getPlatformName(char *nameBuf); - -/* stringTable.c */ -extern char * newStringFromList(char **list, int *size); -extern int stringLength(const char *table, int compress); -extern bool getValueForConfigTableKey(config_file_t *config, const char *key, const char **val, int *size); -extern bool removeKeyFromTable(const char *key, char *table); -extern char * newStringForStringTableKey(config_file_t *config, char *key); -extern char * newStringForKey(char *key, config_file_t *configBuff); -extern bool getValueForBootKey(const char *line, const char *match, const char **matchval, int *len); -extern bool getValueForKey(const char *key, const char **val, int *size, config_file_t *configBuff); -extern const char * getStringForKey(const char * key, config_file_t *config); -extern bool getBoolForKey(const char *key, bool *val, config_file_t *configBuff); -extern bool getIntForKey(const char *key, int *val, config_file_t *configBuff); -extern bool getColorForKey(const char *key, unsigned int *val, config_file_t *configBuff); -extern bool getDimensionForKey( const char *key, unsigned int *value, config_file_t *config, unsigned int dimension_max, unsigned int object_size ); -extern int loadConfigFile(const char *configFile, config_file_t *configBuff); -extern int loadSystemConfig(config_file_t *configBuff); -extern int loadHelperConfig(config_file_t *configBuff); -extern int loadOverrideConfig(config_file_t *configBuff); -extern char * newString(const char *oldString); -extern char * getNextArg(char ** ptr, char * val); -extern int ParseXMLFile( char * buffer, TagPtr * dict ); - /* sys.c */ extern BVRef getBootVolumeRef( const char * path, const char ** outPath ); extern long LoadVolumeFile(BVRef bvr, const char *fileSpec); @@ -191,7 +127,6 @@ extern void scanBootVolumes(int biosdev, int *count); extern void scanDisks(int biosdev, int *count); extern BVRef selectBootVolume(BVRef chain); -extern void getBootVolumeDescription(BVRef bvr, char *str, long strMaxLen, bool verbose); extern void setRootVolume(BVRef volume); extern void setBootGlobals(BVRef chain); extern int getDeviceDescription(BVRef volume, char *str);