( OBJROOT=$(OBJROOT)/$${i}; \
SYMROOT=$(SYMROOT)/$${i}; \
DSTROOT=$(DSTROOT); \
+ XCFLAGS=$(ARCHLESS_RC_CFLAGS); \
+ GENSUBDIRS="$(GENERIC_SUBDIRS)"; \
+ for x in $$GENSUBDIRS; \
+ do \
+ if [ "$$x" == "$$i" ]; then \
+ XCFLAGS="$(RC_CFLAGS)"; \
+ break; \
+ fi \
+ done; \
echo "$$OBJROOT $$SYMROOT $$DSTROOT"; \
cd $$i; ${MAKE} \
"OBJROOT=$$OBJROOT" \
"TARGET=$$i" \
"RC_KANJI=$(RC_KANJI)" \
"JAPANESE=$(JAPANESE)" \
- "RC_CFLAGS=$(ARCHLESS_RC_CFLAGS)" $@ \
+ "RC_CFLAGS=$$XCFLAGS" $@ \
) || exit $?; \
else \
echo "========= nothing to build for $$i ========="; \
*/
-#import "rcz_common.h"
-
+#include "rcz_common.h"
+#include <stdlib.h>
+#include <unistd.h>
static unsigned short que[QLEN];
#define REWIND -1
-extern int read(int fd, char *buf, int len);
+// extern int read(int fd, char *buf, int len);
+extern int b_lseek(int fdesc, unsigned int addr, int ptr);
static unsigned char *buf;
static int buf_count;
{
unsigned int c, j, k, jmatch, jabove;
int length;
- unsigned int even_length, word, token, version;
+ unsigned int even_length, word, token;
unsigned char *outorigin = out;
length = rcz_file_size(in_fd);
INSTALLDIR = $(DSTROOT)/usr/standalone/i386
DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
-FOREIGNNEXT = boot1f
-
NASM = $(SYMROOT)/nasm
-VERSIONED_FILES = boot1f
+VERSIONED_FILES = boot1 boot1f
VERS = `vers_string -f 5.0 | tr - .`
NEW_VERS = Rhapsody boot1 v$(VERS)
all: $(DIRS_NEEDED) $(VERSIONED_FILES)
+boot1: boot1.s Makefile
+ $(NASM) -dBOOTDEV=HDISK -dVERS="'$(NEW_VERS)'" boot1.s -o $(SYMROOT)/$@
+
boot1f: boot1.s Makefile
$(NASM) -dBOOTDEV=FLOPPY -dVERS="'$(NEW_VERS)'" boot1.s -o $(SYMROOT)/$@
install_i386:: all $(INSTALLDIR)
+ cp $(SYMROOT)/boot1 $(INSTALLDIR)/
cp $(SYMROOT)/boot1f $(INSTALLDIR)/
- cd $(INSTALLDIR); chmod u+w $(FOREIGNNEXT)
+ cd $(INSTALLDIR); chmod u+w $(VERSIONED_FILES)
include ../MakeInc.dir
# The ordering is important;
# boot2.o must be first.
-OBJS = boot2.o boot.o graphics.o prompt.o
+OBJS = boot2.o boot.o graphics.o drivers.o prompt.o
# button.o browser.o scrollbar.o == NOTYET
UTILDIR = ../util
SFILES = boot2.s
-CFILES = boot.c graphics.c prompt.c
+CFILES = boot.c graphics.c drivers.c prompt.c
HFILES = boot.h
OTHERFILES = Makefile
ALLSRC = $(FOREIGNSRC) $(FOREIGNBIN) $(SFILES) $(CFILES) \
#include "libsaio.h"
#include "kernBootStruct.h"
#include "boot.h"
-#include "drivers.h"
#include "nbp.h"
-/*
- * True if using default.table
- */
-static BOOL useDefaultConfig;
-
-/*
- * Name of the kernel image file to load.
- * This is specified in the config file, or may be
- * overridden by the user at the boot prompt.
- */
-static char gKernelName[BOOT_STRING_LEN];
-
/*
* The user asked for boot graphics.
*/
/*
* The device that the booter was loaded from.
*/
-int gBootDev;
+int gBootDev;
extern char * gFilename;
extern BOOL sysConfigValid;
-extern char bootPrompt[]; // In prompt.c
+extern char bootPrompt[];
extern BOOL errors;
-extern BOOL verbose_mode;
+extern BOOL gVerboseMode;
extern BOOL gSilentBoot;
-#if MULTIPLE_DEFAULTS
-char * default_names[] = {
- "$LBL",
-};
-#define NUM_DEFAULT_NAMES (sizeof(default_names)/sizeof(char *))
-int current_default = 0;
-#else
-#define DEFAULT_NAME "$LBL"
-#endif
-
/*
* Prototypes.
*/
static void getBootString();
/*
- * Message/Error logging macros.
+ * How long to wait (in seconds) to load the
+ * kernel after displaying the "boot:" prompt.
*/
-#define PRINT(x) { printf x }
-
-#ifdef DEBUG
-#define DPRINT(x) { printf x; }
-#define DSPRINT(x) { printf x; sleep(2); }
-#else
-#define DPRINT(x)
-#define DSPRINT(x)
-#endif
+#define kBootTimeout 10
//==========================================================================
// Zero the BSS.
bzero( &_DATA__bss__begin,
(&_DATA__bss__end - &_DATA__bss__begin) );
-
+
bzero( &_DATA__common__begin,
(&_DATA__common__end - &_DATA__common__begin) );
}
//==========================================================================
-// execKernel - Load the kernel image file and jump to its entry point.
+// execKernel - Load the kernel image (mach-o) and jump to its entry point.
static int
-execKernel(int fd, int installMode)
+execKernel(int fd)
{
register KERNBOOTSTRUCT * kbp = kernBootStruct;
- register char * src = gFilename;
- register char * dst = kbp->boot_file;
- char * val;
static struct mach_header head;
entry_t kernelEntry;
- int ret, size;
-#ifdef DISABLED
- char * linkerPath;
- int loadDrivers;
-#endif
-
- /* Copy the space/tab delimited word pointed by src (gFilename) to
- * kbp->boot_file.
- */
- while (*src && (*src != ' ' && *src != '\t'))
- *dst++ = *src++;
- *dst = 0;
-
- verbose("Loading %s\n", kbp->boot_file);
-
- /* perform the actual load */
+ int ret;
+
+ verbose("Loading kernel %s\n", kbp->bootFile);
+
+ // Perform the actual load.
+
kbp->kaddr = kbp->ksize = 0;
- ret = loadprog(kbp->kernDev,
- fd,
- &head,
- &kernelEntry,
- (char **) &kbp->kaddr,
- &kbp->ksize);
+
+ ret = loadprog( kbp->kernDev,
+ fd,
+ &head,
+ &kernelEntry,
+ (char **) &kbp->kaddr,
+ &kbp->ksize );
close(fd);
+ clearActivityIndicator();
if ( ret != 0 )
return ret;
- /* Clear memory that might be used for loaded drivers
- * because the standalone linker doesn't zero
- * memory that is used later for BSS in the drivers.
- */
- {
- long addr = kbp->kaddr + kbp->ksize;
- bzero((char *)addr, RLD_MEM_ADDR - addr);
- }
+ // Load boot drivers from the specifed root.
+ LoadDrivers("/");
clearActivityIndicator();
- printf("\n");
-
- if ((getValueForKey("Kernel Flags", &val, &size)) && size) {
- int oldlen, len1;
- char * cp = kbp->bootString;
- oldlen = len1 = strlen(cp);
-
- // move out the user string
- for(; len1 >= 0; len1--)
- cp[size + len1] = cp[len1 - 1];
- strncpy(cp,val,size);
- if (oldlen) cp[strlen(cp)] = ' ';
- }
if (errors) {
printf("Errors encountered while starting up the computer.\n");
- printf("Pausing %d seconds...\n", BOOT_TIMEOUT);
- sleep(BOOT_TIMEOUT);
+ printf("Pausing %d seconds...\n", kBootTimeout);
+ sleep(kBootTimeout);
}
- message("Starting Darwin Intel", 0);
-
- if (kbp->eisaConfigFunctions)
- kbp->first_addr0 = EISA_CONFIG_ADDR +
- (kbp->eisaConfigFunctions * sizeof(EISA_func_info_t));
-
- clearActivityIndicator();
+ message("Starting Darwin/x86", 0);
turnOffFloppy();
+ // Connect to APM BIOS.
+
if ( getBoolForKey("APM") )
{
if ( APMPresent() ) APMConnect32();
//==========================================================================
// Scan and record the system's PCI bus information.
-//
static void scanHardware()
{
-extern int ReadPCIBusInfo(PCI_bus_info_t *pp);
+extern int ReadPCIBusInfo(PCI_bus_info_t *);
extern void PCI_Bus_Init(PCI_bus_info_t *);
-
- KERNBOOTSTRUCT * kbp = KERNSTRUCT_ADDR;
- ReadPCIBusInfo( &kbp->pciInfo );
- PCI_Bus_Init( &kbp->pciInfo );
+ ReadPCIBusInfo( &kernBootStruct->pciInfo );
+ PCI_Bus_Init( &kernBootStruct->pciInfo );
}
//==========================================================================
boot(int bootdev)
{
register KERNBOOTSTRUCT * kbp = kernBootStruct;
- int fd, size;
- char * val;
- int installMode = 0;
+ int fd;
zeroBSS();
- // Enable A20 gate to be able to access memory above 1 MB.
+ // Enable A20 gate before accessing memory above 1Mb.
enableA20();
setMode(TEXT_MODE);
- // Initialize the malloc area to the top of conventional memory.
-
- malloc_init( (char *) ZALLOC_ADDR,
- (kbp->convmem * 1024) - ZALLOC_ADDR,
- ZALLOC_NODES );
-
// Scan hardware configuration.
scanHardware();
- // Display initial banner.
+ // Display boot prompt.
- printf( bootPrompt, kbp->convmem, kbp->extmem );
- printf( "Darwin Intel will start up in %d seconds, or you can:\n"
- " Type -v and press Return to start up Darwin Intel with "
- "diagnostic messages\n"
- " Type ? and press Return to learn about advanced startup "
- "options\n"
- " Type any other character to stop Darwin Intel from "
- "starting up automatically\n",
- BOOT_TIMEOUT );
+ printf( bootPrompt, kbp->convmem, kbp->extmem, kBootTimeout );
// Parse args, load and start kernel.
{
// Initialize globals.
- sysConfigValid = 0;
- useDefaultConfig = 0;
- errors = 0;
+ sysConfigValid = 0;
+ errors = 0;
// Make sure we are in VGA text mode.
}
flushdev();
-#if 0 // XXX - $LBL
-#if MULTIPLE_DEFAULTS
- strcpy(gKernelName, default_names[current_default]);
- if (++current_default == NUM_DEFAULT_NAMES)
- current_default = 0;
-#else
- strcpy(gKernelName, DEFAULT_NAME);
-#endif
-#endif
-
// Display boot prompt and get user supplied boot string.
getBootString();
// To force loading config file off same device as kernel,
// open kernel file to force device change if necessary.
- fd = open(gKernelName, 0);
- if (fd >= 0)
- close(fd);
+ fd = open(kbp->bootFile, 0);
+ if (fd >= 0) close(fd);
}
if ( sysConfigValid == 0 )
{
- val = 0;
- getValueForBootKey(kbp->bootString,
- "config", &val, &size);
-
- DSPRINT(("sys config was not valid trying alt\n"));
- useDefaultConfig = loadSystemConfig(val, size);
-
- if ( sysConfigValid == 0 )
- {
- DSPRINT(("sys config is not valid\n"));
- if (kbp->kernDev == DEV_EN)
- break; // return control back to PXE
- else
- continue; // keep looping
- }
+ if (kbp->kernDev == DEV_EN)
+ break; // return control back to PXE
+ else
+ continue; // keep looping
}
// Found and loaded a config file. Proceed with boot.
- gWantBootGraphics = getBoolForKey("Boot Graphics");
- gSilentBoot = getBoolForKey("Silent Boot");
+ gWantBootGraphics = getBoolForKey( kBootGraphicsKey );
+ gSilentBoot = getBoolForKey( kQuietBootKey );
- message("Loading Darwin Intel", 0);
+ message("Loading Darwin/x86", 0);
- if ( (fd = openfile(gKernelName, 0)) >= 0 )
+ if ( (fd = openfile(kbp->bootFile, 0)) >= 0 )
{
- DSPRINT(("calling exec kernel\n"));
- execKernel(fd, installMode);
-
- // If execKernel() returns, kernel load failed.
+ execKernel(fd); // will not return on success
}
else
{
- error("Can't find %s\n", gKernelName);
+ error("Can't find %s\n", kbp->bootFile);
if ( bootdev == kBootDevFloppyDisk )
{
static void showHelp()
{
+#define BOOT_DIR_DISK "/usr/standalone/i386/"
+#define BOOT_DIR_NET ""
+#define makeFilePath(x) \
+ (gBootDev == kBootDevNetwork) ? BOOT_DIR_NET x : BOOT_DIR_DISK x
+
int fd;
char * help = makeFilePath("BootHelp.txt");
// Returns 1 if the string pointed by 'cp' contains an user-specified
// kernel image file name. Used by getBootString() function.
-static inline int
-containsKernelName(char * cp)
+static int
+containsKernelName(const char * cp)
{
register char c;
-
+
skipblanks(&cp);
- // Convert everything to lower case.
+ // Convert char to lower case.
c = *cp | 0x20;
//==========================================================================
// Display the "boot:" prompt and copies the user supplied string to
// kernBootStruct->bootString. The kernel image file name is written
-// to the gKernelName buffer.
+// to kernBootStruct->bootFile.
static void
getBootString()
char * cp;
char * val;
int count;
- static int timeout = BOOT_TIMEOUT;
+ static int timeout = kBootTimeout;
-top:
- line[0] = '\0';
- cp = &line[0];
+ do {
+ line[0] = '\0';
+ cp = &line[0];
- /* If there have been problems, don't go on. */
- if ( errors ) timeout = 0;
- errors = 0;
+ // If there were errors, don't timeout on boot prompt since
+ // the same error is likely to occur again.
- // Print the boot prompt and wait a few seconds for user input.
+ if ( errors ) timeout = 0;
+ errors = 0;
- printf("\n");
- count = Gets(line, sizeof(line), timeout, "boot: ", "");
- flushdev();
+ // Print the boot prompt and wait a few seconds for user input.
- // If something was typed, don't use automatic boot again.
- // The boot: prompt will not timeout and go away until
- // the user hits the return key.
+ printf("\n");
+ count = Gets(line, sizeof(line), timeout, "boot: ", "");
+ flushdev();
- if ( count ) timeout = 0;
+ // If something was typed, don't use automatic boot again.
+ // The boot: prompt will not timeout and go away until
+ // the user hits the return key.
- skipblanks(&cp);
+ if ( count ) timeout = 0;
- // If user typed '?', then display the usage message.
+ skipblanks(&cp);
- if ( *cp == '?' )
- {
- showHelp();
- goto top;
+ // If user typed '?', then display the usage message.
+
+ if ( *cp == '?' )
+ {
+ showHelp();
+ continue;
+ }
+
+ // Load config table file specified by the user, or fallback
+ // to the default one.
+
+ val = 0;
+ getValueForBootKey(cp, "config", &val, &count);
+ loadSystemConfig(val, count);
+ if ( !sysConfigValid )
+ continue;
}
+ while ( 0 );
// Did the user specify a kernel file name at the boot prompt?
// This is fine, read the default kernel file name from the
// config table.
- printf("\n");
-
- val = 0;
- getValueForBootKey(cp, "config", &val, &count);
-
- useDefaultConfig = loadSystemConfig(val, count);
-
- if ( !sysConfigValid )
- goto top;
-
- // Get the kernel name from the config table file.
-
- if ( getValueForKey( "Kernel", &val, &count) )
+ if ( getValueForKey(kKernelNameKey, &val, &count) )
{
- strncpy(gKernelName, val, count);
+ strncpy(kernBootStruct->bootFile, val, count);
}
}
else
// Get the kernel name from the user-supplied boot string,
// and copy the name to the buffer provided.
- char * namep = gKernelName;
+ char * namep = kernBootStruct->bootFile;
while ( *cp && !(*cp == ' ' || *cp == '\t') )
*namep++ = *cp++;
// Verbose flag specified.
- verbose_mode = getValueForBootKey(cp, "-v", &val, &count);
+ gVerboseMode = getValueForBootKey(cp, "-v", &val, &count);
- // Save the boot string in kernBootStruct.
+ // Save the boot string in kernBootStruct->bootString.
- strcpy(kernBootStruct->bootString, cp);
+ if ( getValueForKey(kKernelFlagsKey, &val, &count) && count )
+ {
+ strncpy( kernBootStruct->bootString, val, count );
+ }
+ if ( strlen(cp) )
+ {
+ strcat(kernBootStruct->bootString, " ");
+ strcat(kernBootStruct->bootString, cp);
+ }
}
#ifndef __BOOT2_BOOT_H
#define __BOOT2_BOOT_H
-/*
- * How long to wait (in seconds) to load the
- * kernel after displaying the "boot:" prompt.
- */
-#define BOOT_TIMEOUT 10 /* 10 second timeout */
-
/*
* Keys used in system Default.table / Instance0.table
*/
-#define PROMPT_KEY "Prompt For Driver Disk"
-#define NUM_PROMPTS_KEY "Driver Disk Prompts"
-#define ASK_KEY "Ask For Drivers"
-#define INSTALL_KEY "Install Mode"
-#define G_MODE_KEY "Graphics Mode"
+#define kGraphicsModeKey "Graphics Mode"
+#define kBootGraphicsKey "Boot Graphics"
+#define kQuietBootKey "Quiet Boot"
+#define kKernelFlagsKey "Kernel Flags"
+#define kKernelNameKey "Kernel"
/*
* Possible values for the bootdev argument passed to boot().
*/
enum {
- kBootDevHardDisk = 0,
- kBootDevFloppyDisk = 1,
- kBootDevNetwork = 2,
+ kBootDevHardDisk = 0,
+ kBootDevFloppyDisk,
+ kBootDevNetwork
};
-/*
- * The directory that contains the booter support files.
- */
-#define BOOT_DIR_DISK "/usr/standalone/i386/"
-#define BOOT_DIR_NET ""
-
/*
* A global set by boot() to record the device that the booter
* was loaded from.
extern int gBootDev;
/*
- * Create the complete path to a booter support file.
- */
-#define makeFilePath(x) \
- (gBootDev == kBootDevNetwork) ? BOOT_DIR_NET x : BOOT_DIR_DISK x
-
-/*
- * Functions defined in graphics.c.
+ * graphics.c
*/
extern void message(char * str, int centered);
extern void setMode(int mode);
extern void spinActivityIndicator();
extern void clearActivityIndicator();
+/*
+ * drivers.c
+ */
+extern long LoadDrivers(char * dirSpec);
+
#endif /* !__BOOT2_BOOT_H */
--- /dev/null
+/*
+ * 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.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@
+ */
+/*
+ * drivers.c - Driver Loading Functions.
+ *
+ * Copyright (c) 2000 Apple Computer, Inc.
+ *
+ * DRI: Josh de Cesare
+ */
+
+#include "libsaio.h"
+#include "memory.h"
+#include "kernBootStruct.h"
+#include "nbp.h"
+#include "boot.h"
+
+enum {
+ kTagTypeNone = 0,
+ kTagTypeDict,
+ kTagTypeKey,
+ kTagTypeString,
+ kTagTypeInteger,
+ kTagTypeData,
+ kTagTypeDate,
+ kTagTypeFalse,
+ kTagTypeTrue,
+ kTagTypeArray
+};
+
+#define kXMLTagPList "plist "
+#define kXMLTagDict "dict"
+#define kXMLTagKey "key"
+#define kXMLTagString "string"
+#define kXMLTagInteger "integer"
+#define kXMLTagData "data"
+#define kXMLTagDate "date"
+#define kXMLTagFalse "false/"
+#define kXMLTagTrue "true/"
+#define kXMLTagArray "array"
+
+#define kPropCFBundleIdentifier ("CFBundleIdentifier")
+#define kPropCFBundleExecutable ("CFBundleExecutable")
+#define kPropOSBundleRequired ("OSBundleRequired")
+#define kPropOSBundleLibraries ("OSBundleLibraries")
+#define kPropIOKitPersonalities ("IOKitPersonalities")
+#define kPropIONameMatch ("IONameMatch")
+
+struct Tag {
+ long type;
+ char *string;
+ struct Tag *tag;
+ struct Tag *tagNext;
+};
+typedef struct Tag Tag, *TagPtr;
+
+struct Module {
+ 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;
+};
+typedef struct DriverInfo DriverInfo, *DriverInfoPtr;
+
+#define kDriverPackageSignature1 'MKXT'
+#define kDriverPackageSignature2 'MOSX'
+
+struct DriversPackage {
+ unsigned long signature1;
+ unsigned long signature2;
+ unsigned long length;
+ unsigned long alder32;
+ unsigned long version;
+ unsigned long numDrivers;
+ unsigned long reserved1;
+ unsigned long reserved2;
+};
+typedef struct DriversPackage DriversPackage;
+
+static long FileLoadDrivers(char *dirSpec, long plugin);
+static long NetLoadDrivers(char *dirSpec);
+static long LoadDriverMKext(char *fileSpec);
+static long LoadDriverPList(char *dirSpec, char *name);
+static long LoadMatchedModules(void);
+static long MatchPersonalities(void);
+static long MatchLibraries(void);
+static TagPtr GetProperty(TagPtr dict, char *key);
+// static ModulePtr FindModule(char *name);
+static long ParseXML(char *buffer, ModulePtr *module, TagPtr *personalities);
+static long ParseNextTag(char *buffer, TagPtr *tag);
+static long ParseTagList(char *buffer, TagPtr *tag, long type, long empty);
+static long ParseTagKey(char *buffer, TagPtr *tag);
+static long ParseTagString(char *buffer, TagPtr *tag);
+static long ParseTagInteger(char *buffer, TagPtr *tag);
+static long ParseTagData(char *buffer, TagPtr *tag);
+static long ParseTagDate(char *buffer, TagPtr *tag);
+static long ParseTagBoolean(char *buffer, TagPtr *tag, long type);
+static long GetNextTag(char *buffer, char **tag, long *start);
+static long FixDataMatchingTag(char *buffer, char *tag);
+static TagPtr NewTag(void);
+static void FreeTag(TagPtr tag);
+static char *NewSymbol(char *string);
+static void FreeSymbol(char *string);
+// static void DumpTag(TagPtr tag, long depth);
+
+static ModulePtr gModuleHead, gModuleTail;
+static TagPtr gPersonalityHead, gPersonalityTail;
+static char * gExtensionsSpec;
+static char * gDriverSpec;
+static char * gFileSpec;
+
+//==========================================================================
+// BootX shim functions.
+
+#include <ufs/ufs/dir.h>
+
+#define kLoadAddr TFTP_ADDR
+#define kLoadSize TFTP_LEN
+
+#define kPageSize 4096
+#define RoundPage(x) ((((unsigned)(x)) + kPageSize - 1) & ~(kPageSize - 1))
+
+static long
+LoadFile( char * fileSpec )
+{
+ unsigned long count = TFTP_LEN;
+ unsigned long addr = TFTP_ADDR;
+
+ if ( gBootDev == kBootDevNetwork )
+ {
+ if ( nbpTFTPReadFile(fileSpec, &count, addr) != nbpStatusSuccess )
+ return -1;
+ }
+ else
+ {
+ int fd = open( fileSpec, 0 );
+ if ( fd < 0 )
+ return -1;
+
+ count = read( fd, (char *) addr, count );
+ close(fd);
+ }
+ return count;
+}
+
+static long gImageFirstBootXAddr;
+static long gImageLastKernelAddr;
+
+static void *
+AllocateBootXMemory( long size )
+{
+ long addr = gImageFirstBootXAddr - size;
+
+ if ( addr < gImageLastKernelAddr ) return 0;
+
+ bzero(addr, size);
+
+ gImageFirstBootXAddr = addr;
+
+ return (void *)addr;
+}
+
+static long
+AllocateKernelMemory( long inSize )
+{
+ long addr = gImageLastKernelAddr;
+
+ gImageLastKernelAddr += RoundPage(inSize);
+
+ if ( gImageLastKernelAddr > gImageFirstBootXAddr )
+ stop( "AllocateKernelMemory error" );
+
+ kernBootStruct->ksize = gImageLastKernelAddr - kernBootStruct->kaddr;
+
+ return addr;
+}
+
+static long
+AllocateMemoryRange(char * rangeName, long start, long length, long type)
+{
+ if ( kernBootStruct->numBootDrivers < NDRIVERS )
+ {
+ int num = kernBootStruct->numBootDrivers;
+
+ kernBootStruct->driverConfig[num].address = start;
+ kernBootStruct->driverConfig[num].size = length;
+ kernBootStruct->driverConfig[num].type = type;
+ kernBootStruct->numBootDrivers++;
+ }
+ else
+ {
+ stop( "AllocateMemoryRange error" );
+ }
+ return 0;
+}
+
+// Map BootX file types to UFS file types defined in ufs/ufs/dir.h.
+
+enum {
+ kUnknownFileType = DT_UNKNOWN,
+ kFlatFileType = DT_REG,
+ kDirectoryFileType = DT_DIR,
+ kLinkFileType = DT_LNK
+};
+
+static long
+GetFileInfo( char * dirSpec, char * name, long * flags, long * time )
+{
+ struct dirstuff * dir;
+ struct direct * entry = 0;
+
+ dir = opendir(dirSpec);
+ if ( dir )
+ {
+ while (( entry = readdir(dir) ))
+ {
+ if ( strcmp( entry->d_name, name ) == 0 )
+ {
+ *flags = entry->d_type;
+ *time = 0;
+ break;
+ }
+ }
+ closedir(dir);
+ }
+ return ( entry ) ? 0 : -1;
+}
+
+// Map BootX types to boot counterparts.
+
+#define gBootFileType gBootDev
+enum {
+ kNetworkDeviceType = kBootDevNetwork,
+ kBlockDeviceType = kBootDevHardDisk
+};
+
+static struct dirstuff *
+OpenDir( char * dirSpec )
+{
+ return opendir(dirSpec);
+}
+
+static void
+CloseDir( struct dirstuff * dirStuff )
+{
+ closedir(dirStuff);
+}
+
+static long
+GetDirEntry( struct dirstuff * dir, long * dirIndex, char ** name,
+ long * flags, long * time)
+{
+ if ( dir )
+ {
+ struct direct * entry = readdir(dir);
+
+ if ( entry )
+ {
+ *name = entry->d_name;
+ *flags = entry->d_type;
+ *time = 0;
+ return 0;
+ }
+ }
+ return (-1);
+}
+
+static long
+InitDriverSupport()
+{
+ gExtensionsSpec = (char *) malloc( 4096 );
+ gDriverSpec = (char *) malloc( 4096 );
+ gFileSpec = (char *) malloc( 4096 );
+
+ if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec )
+ stop( "InitDriverSupport error" );
+
+ gImageLastKernelAddr = RoundPage( kernBootStruct->kaddr +
+ kernBootStruct->ksize );
+
+ gImageFirstBootXAddr = ( KERNEL_ADDR + KERNEL_LEN );
+
+ return 0;
+}
+
+static unsigned long
+Alder32( unsigned char * buffer, long length )
+{
+ long cnt;
+ unsigned long result, lowHalf, highHalf;
+
+ lowHalf = 1;
+ highHalf = 0;
+
+ for ( cnt = 0; cnt < length; cnt++ )
+ {
+ if ((cnt % 5000) == 0)
+ {
+ lowHalf %= 65521L;
+ highHalf %= 65521L;
+ }
+
+ lowHalf += buffer[cnt];
+ highHalf += lowHalf;
+ }
+
+ lowHalf %= 65521L;
+ highHalf %= 65521L;
+
+ result = (highHalf << 16) | lowHalf;
+
+ return result;
+}
+
+//==========================================================================
+// LoadDrivers
+
+long LoadDrivers( char * dirSpec )
+{
+ if ( InitDriverSupport() != 0 )
+ return 0;
+
+ if ( gBootFileType == kNetworkDeviceType )
+ {
+ NetLoadDrivers(dirSpec);
+ }
+ else /* if ( gBootFileType == kBlockDeviceType ) */
+ {
+ strcpy(gExtensionsSpec, dirSpec);
+ strcat(gExtensionsSpec, "System/Library/");
+ FileLoadDrivers(gExtensionsSpec, 0);
+ }
+#if 0
+ else
+ {
+ return 0;
+ }
+#endif
+
+ MatchPersonalities();
+
+ MatchLibraries();
+
+ LoadMatchedModules();
+
+ return 0;
+}
+
+//==========================================================================
+// FileLoadDrivers
+
+static long
+FileLoadDrivers( char * dirSpec, long plugin )
+{
+ long ret, length, index, flags, time;
+ char * name;
+ struct dirstuff * dir;
+
+ if ( !plugin )
+ {
+ long time2;
+
+ ret = GetFileInfo(dirSpec, "Extensions.mkext", &flags, &time);
+ if ((ret == 0) && (flags == kFlatFileType))
+ {
+ ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2);
+ if ((ret != 0) || (flags == kDirectoryFileType) || (time > time2))
+ {
+ sprintf(gDriverSpec, "%sExtensions.mkext", dirSpec);
+ verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec);
+ if (LoadDriverMKext(gDriverSpec) == 0) return 0;
+ }
+ }
+
+ strcat(dirSpec, "Extensions");
+ }
+
+ verbose("LoadDrivers: Loading from [%s]\n", dirSpec);
+
+ // INTEL addition
+ dir = OpenDir( dirSpec );
+
+ index = 0;
+ while (1) {
+ // INTEL modification
+ ret = GetDirEntry(dir, &index, &name, &flags, &time);
+ if (ret == -1) break;
+
+ // Make sure this is a directory.
+ if (flags != kDirectoryFileType) continue;
+
+ // Make sure this is a kext.
+ length = strlen(name);
+ if (strcmp(name + length - 5, ".kext")) continue;
+
+ if (!plugin)
+ sprintf(gDriverSpec, "%s/%s/Contents/PlugIns", dirSpec, name);
+
+ ret = LoadDriverPList(dirSpec, name);
+ if (ret != 0)
+ {
+ // printf("LoadDrivers: failed\n");
+ }
+
+ if (!plugin)
+ ret = FileLoadDrivers(gDriverSpec, 1);
+ }
+
+ // INTEL addition
+ if ( dir ) CloseDir( dir );
+
+ return 0;
+}
+
+//==========================================================================
+//
+
+static long
+NetLoadDrivers( char * dirSpec )
+{
+ long tries;
+
+#if 0
+ long cnt;
+
+ // Get the name of the kernel
+ cnt = strlen(gBootFile);
+ while (cnt--) {
+ if ((gBootFile[cnt] == '\\') || (gBootFile[cnt] == ',')) {
+ cnt++;
+ break;
+ }
+ }
+#endif
+
+ // INTEL modification
+ sprintf(gDriverSpec, "%s%s.mkext", dirSpec, kernBootStruct->bootFile);
+
+ verbose("NetLoadDrivers: Loading from [%s]\n", gDriverSpec);
+
+ tries = 3;
+ while (tries--)
+ {
+ if (LoadDriverMKext(gDriverSpec) == 0) break;
+ }
+ if (tries == -1) return -1;
+
+ return 0;
+}
+
+//==========================================================================
+// loadDriverMKext
+
+static long
+LoadDriverMKext( char * fileSpec )
+{
+ long driversAddr, driversLength;
+ char segName[32];
+ DriversPackage * package = (DriversPackage *)kLoadAddr;
+
+#define GetPackageElement(e) bswap32(package-> ## e)
+
+ // Load the MKext.
+ if (LoadFile(fileSpec) == -1) return -1;
+
+ // Verify the MKext.
+ if (( GetPackageElement(signature1) != kDriverPackageSignature1) ||
+ ( GetPackageElement(signature2) != kDriverPackageSignature2) ||
+ ( GetPackageElement(length) > kLoadSize ) ||
+ ( GetPackageElement(alder32) !=
+ Alder32((char *)&package->version, GetPackageElement(length) - 0x10) ) )
+ {
+ return -1;
+ }
+
+ // Make space for the MKext.
+ driversLength = GetPackageElement(length);
+ driversAddr = AllocateKernelMemory(driversLength);
+
+ // Copy the MKext.
+ memcpy((void *)driversAddr, (void *)kLoadAddr, driversLength);
+
+ // Add the MKext to the memory map.
+ sprintf(segName, "DriversPackage-%lx", driversAddr);
+ AllocateMemoryRange(segName, driversAddr, driversLength,
+ kBootDriverTypeMKEXT);
+
+ return 0;
+}
+
+//==========================================================================
+// LoadDriverPList
+
+static long
+LoadDriverPList( char * dirSpec, char * name )
+{
+ long length, driverPathLength;
+ ModulePtr module;
+ TagPtr personalities;
+ char * buffer = 0;
+ char * tmpDriverPath = 0;
+ long ret = -1;
+
+ do {
+ // Save the driver path.
+
+ sprintf(gFileSpec, "%s/%s/Contents/MacOS/", dirSpec, name);
+ driverPathLength = strlen(gFileSpec);
+
+ tmpDriverPath = malloc(driverPathLength + 1);
+ if (tmpDriverPath == 0) break;
+
+ strcpy(tmpDriverPath, gFileSpec);
+
+ // Construct the file spec to the plist, then load it.
+
+ sprintf(gFileSpec, "%s/%s/Contents/Info.plist", dirSpec, name);
+
+ length = LoadFile(gFileSpec);
+ if (length == -1) break;
+
+ buffer = malloc(length + 1);
+ if (buffer == 0) break;
+
+ strncpy(buffer, (char *)kLoadAddr, length);
+
+ // Parse the plist.
+
+ ret = ParseXML(buffer, &module, &personalities);
+ if (ret != 0) break;
+
+ // Allocate memory for the driver path and the plist.
+
+ module->driverPath = AllocateBootXMemory(driverPathLength + 1);
+ module->plistAddr = AllocateBootXMemory(length + 1);
+
+ if ((module->driverPath == 0) || (module->plistAddr == 0))
+ break;
+
+ // Save the driver path in the module.
+
+ strcpy(module->driverPath, tmpDriverPath);
+
+ // Add the plist to the module.
+
+ strncpy(module->plistAddr, (char *)kLoadAddr, length);
+ module->plistLength = length + 1;
+
+ // Add the module to the end of the module list.
+
+ if (gModuleHead == 0)
+ gModuleHead = module;
+ else
+ gModuleTail->nextModule = module;
+ gModuleTail = module;
+
+ // Add the persionalities to the personality list.
+
+ if (personalities) personalities = personalities->tag;
+ while (personalities != 0)
+ {
+ if (gPersonalityHead == 0)
+ gPersonalityHead = personalities->tag;
+ else
+ gPersonalityTail->tagNext = personalities->tag;
+
+ gPersonalityTail = personalities->tag;
+ personalities = personalities->tagNext;
+ }
+
+ ret = 0;
+ }
+ while (0);
+
+ if ( buffer ) free( buffer );
+ if ( tmpDriverPath ) free( tmpDriverPath );
+
+ return ret;
+}
+
+//==========================================================================
+// LoadMatchedModules
+
+static long
+LoadMatchedModules( void )
+{
+ TagPtr prop;
+ ModulePtr module;
+ char *fileName, segName[32];
+ DriverInfoPtr driver;
+ long length, driverAddr, driverLength;
+
+ module = gModuleHead;
+
+ while (module != 0)
+ {
+ if (module->willLoad)
+ {
+ prop = GetProperty(module->dict, kPropCFBundleExecutable);
+ if (prop != 0)
+ {
+ fileName = prop->string;
+ sprintf(gFileSpec, "%s%s", module->driverPath, fileName);
+ length = LoadFile(gFileSpec);
+ }
+ else
+ length = 0;
+
+ if (length != -1)
+ {
+ // Make make in the image area.
+ driverLength = sizeof(DriverInfo) + module->plistLength + length;
+ driverAddr = AllocateKernelMemory(driverLength);
+
+ // Set up the DriverInfo.
+ driver = (DriverInfoPtr)driverAddr;
+ driver->plistAddr = (char *)(driverAddr + sizeof(DriverInfo));
+ driver->plistLength = module->plistLength;
+ if (length != 0)
+ {
+ driver->moduleAddr = (void *)(driverAddr + sizeof(DriverInfo) +
+ module->plistLength);
+ driver->moduleLength = length;
+ }
+ else
+ {
+ driver->moduleAddr = 0;
+ driver->moduleLength = 0;
+ }
+
+ // Save the plist and module.
+ strcpy(driver->plistAddr, module->plistAddr);
+ if (length != 0)
+ {
+ memcpy(driver->moduleAddr, (void *)kLoadAddr, driver->moduleLength);
+ }
+
+ // Add an entry to the memory map.
+ sprintf(segName, "Driver-%lx", (unsigned long)driver);
+ AllocateMemoryRange(segName, driverAddr, driverLength,
+ kBootDriverTypeKEXT);
+ }
+ }
+ module = module->nextModule;
+ }
+
+ return 0;
+}
+
+//==========================================================================
+// MatchPersonalities
+
+static long
+MatchPersonalities( void )
+{
+#warning IONameMatch support not implemented
+ return 0;
+}
+
+//==========================================================================
+// MatchLibraries
+
+static long
+MatchLibraries( void )
+{
+ TagPtr prop, prop2;
+ ModulePtr module, module2;
+ long done;
+
+ do {
+ done = 1;
+ module = gModuleHead;
+
+ while (module != 0)
+ {
+ if (module->willLoad == 1)
+ {
+ prop = GetProperty(module->dict, kPropOSBundleLibraries);
+ if (prop != 0)
+ {
+ prop = prop->tag;
+ while (prop != 0)
+ {
+ module2 = gModuleHead;
+ while (module2 != 0)
+ {
+ prop2 = GetProperty(module2->dict, kPropCFBundleIdentifier);
+ if ((prop2 != 0) && (!strcmp(prop->string, prop2->string)))
+ {
+ if (module2->willLoad == 0) module2->willLoad = 1;
+ break;
+ }
+ module2 = module2->nextModule;
+ }
+ prop = prop->tagNext;
+ }
+ }
+ module->willLoad = 2;
+ done = 0;
+ }
+ module = module->nextModule;
+ }
+ }
+ while (!done);
+
+ return 0;
+}
+
+//==========================================================================
+// GetProperty
+
+static TagPtr
+GetProperty( TagPtr dict, char * key )
+{
+ TagPtr tagList, tag;
+
+ if (dict->type != kTagTypeDict) return 0;
+
+ tag = 0;
+ tagList = dict->tag;
+ while (tagList)
+ {
+ tag = tagList;
+ tagList = tag->tagNext;
+
+ if ((tag->type != kTagTypeKey) || (tag->string == 0)) continue;
+
+ if (!strcmp(tag->string, key)) return tag->tag;
+ }
+
+ return 0;
+}
+
+//==========================================================================
+// FindModule
+
+#if NOTDEF
+static ModulePtr
+FindModule( char * name )
+{
+ ModulePtr module;
+ TagPtr prop;
+
+ module = gModuleHead;
+
+ while (module != 0)
+ {
+ prop = GetProperty(module->dict, kPropCFBundleIdentifier);
+ if ((prop != 0) && !strcmp(name, prop->string)) break;
+ module = module->nextModule;
+ }
+
+ return module;
+}
+#endif /* NOTDEF */
+
+//==========================================================================
+// ParseXML
+
+static long
+ParseXML( char * buffer, ModulePtr * module, TagPtr * personalities )
+{
+ long length, pos;
+ TagPtr moduleDict, required;
+ ModulePtr tmpModule;
+
+ pos = 0;
+
+ while (1)
+ {
+ length = ParseNextTag(buffer + pos, &moduleDict);
+ if (length == -1) break;
+
+ pos += length;
+
+ if (moduleDict == 0) continue;
+ if (moduleDict->type == kTagTypeDict) break;
+
+ FreeTag(moduleDict);
+ }
+
+ if (length == -1) return -1;
+
+ required = GetProperty(moduleDict, kPropOSBundleRequired);
+ if ( (required == 0) ||
+ (required->type != kTagTypeString) ||
+ !strcmp(required->string, "Safe Boot"))
+ {
+ FreeTag(moduleDict);
+ return -2;
+ }
+
+ tmpModule = AllocateBootXMemory(sizeof(Module));
+ if (tmpModule == 0)
+ {
+ FreeTag(moduleDict);
+ return -1;
+ }
+ tmpModule->dict = moduleDict;
+
+ // For now, load any module that has OSBundleRequired != "Safe Boot".
+
+ tmpModule->willLoad = 1;
+
+ *module = tmpModule;
+
+ // Get the personalities.
+
+ *personalities = GetProperty(moduleDict, kPropIOKitPersonalities);
+
+ return 0;
+}
+
+//==========================================================================
+// ParseNextTag
+
+static long
+ParseNextTag( char * buffer, TagPtr * tag )
+{
+ long length, pos;
+ char * tagName;
+
+ length = GetNextTag(buffer, &tagName, 0);
+ if (length == -1) return -1;
+
+ pos = length;
+ if (!strncmp(tagName, kXMLTagPList, 6))
+ {
+ length = 0;
+ }
+ else if (!strcmp(tagName, kXMLTagDict))
+ {
+ length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0);
+ }
+ else if (!strcmp(tagName, kXMLTagDict "/"))
+ {
+ length = ParseTagList(buffer + pos, tag, kTagTypeDict, 1);
+ }
+ else if (!strcmp(tagName, kXMLTagKey))
+ {
+ length = ParseTagKey(buffer + pos, tag);
+ }
+ else if (!strcmp(tagName, kXMLTagString))
+ {
+ length = ParseTagString(buffer + pos, tag);
+ }
+ else if (!strcmp(tagName, kXMLTagInteger))
+ {
+ length = ParseTagInteger(buffer + pos, tag);
+ }
+ else if (!strcmp(tagName, kXMLTagData))
+ {
+ length = ParseTagData(buffer + pos, tag);
+ }
+ else if (!strcmp(tagName, kXMLTagDate))
+ {
+ length = ParseTagDate(buffer + pos, tag);
+ }
+ else if (!strcmp(tagName, kXMLTagFalse))
+ {
+ length = ParseTagBoolean(buffer + pos, tag, kTagTypeFalse);
+ }
+ else if (!strcmp(tagName, kXMLTagTrue))
+ {
+ length = ParseTagBoolean(buffer + pos, tag, kTagTypeTrue);
+ }
+ else if (!strcmp(tagName, kXMLTagArray))
+ {
+ length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0);
+ }
+ else if (!strcmp(tagName, kXMLTagArray "/"))
+ {
+ length = ParseTagList(buffer + pos, tag, kTagTypeArray, 1);
+ }
+ else
+ {
+ *tag = 0;
+ length = 0;
+ }
+
+ if (length == -1) return -1;
+
+ return pos + length;
+}
+
+//==========================================================================
+// ParseTagList
+
+static long
+ParseTagList( char * buffer, TagPtr * tag, long type, long empty )
+{
+ long length, pos;
+ TagPtr tagList, tmpTag;
+
+ tagList = 0;
+ pos = 0;
+
+ if (!empty)
+ {
+ while (1)
+ {
+ length = ParseNextTag(buffer + pos, &tmpTag);
+ if (length == -1) break;
+
+ pos += length;
+
+ if (tmpTag == 0) break;
+ tmpTag->tagNext = tagList;
+ tagList = tmpTag;
+ }
+
+ if (length == -1)
+ {
+ FreeTag(tagList);
+ return -1;
+ }
+ }
+
+ tmpTag = NewTag();
+ if (tmpTag == 0)
+ {
+ FreeTag(tagList);
+ return -1;
+ }
+
+ tmpTag->type = type;
+ tmpTag->string = 0;
+ tmpTag->tag = tagList;
+ tmpTag->tagNext = 0;
+
+ *tag = tmpTag;
+
+ return pos;
+}
+
+//==========================================================================
+// ParseTagKey
+
+static long
+ParseTagKey( char * buffer, TagPtr * tag )
+{
+ long length, length2;
+ char *string;
+ TagPtr tmpTag, subTag;
+
+ length = FixDataMatchingTag(buffer, kXMLTagKey);
+ if (length == -1) return -1;
+
+ length2 = ParseNextTag(buffer + length, &subTag);
+ if (length2 == -1) return -1;
+
+ tmpTag = NewTag();
+ if (tmpTag == 0)
+ {
+ FreeTag(subTag);
+ return -1;
+ }
+
+ string = NewSymbol(buffer);
+ if (string == 0)
+ {
+ FreeTag(subTag);
+ FreeTag(tmpTag);
+ return -1;
+ }
+
+ tmpTag->type = kTagTypeKey;
+ tmpTag->string = string;
+ tmpTag->tag = subTag;
+ tmpTag->tagNext = 0;
+
+ *tag = tmpTag;
+
+ return length + length2;
+}
+
+//==========================================================================
+// ParseTagString
+
+static long
+ParseTagString( char * buffer, TagPtr * tag )
+{
+ long length;
+ char * string;
+ TagPtr tmpTag;
+
+ length = FixDataMatchingTag(buffer, kXMLTagString);
+ if (length == -1) return -1;
+
+ tmpTag = NewTag();
+ if (tmpTag == 0) return -1;
+
+ string = NewSymbol(buffer);
+ if (string == 0)
+ {
+ FreeTag(tmpTag);
+ return -1;
+ }
+
+ tmpTag->type = kTagTypeString;
+ tmpTag->string = string;
+ tmpTag->tag = 0;
+ tmpTag->tagNext = 0;
+
+ *tag = tmpTag;
+
+ return length;
+}
+
+//==========================================================================
+// ParseTagInteger
+
+static long
+ParseTagInteger( char * buffer, TagPtr * tag )
+{
+ long length, integer;
+ TagPtr tmpTag;
+
+ length = FixDataMatchingTag(buffer, kXMLTagInteger);
+ if (length == -1) return -1;
+
+ tmpTag = NewTag();
+ if (tmpTag == 0) return -1;
+
+ integer = 0;
+
+ tmpTag->type = kTagTypeInteger;
+ tmpTag->string = (char *)integer;
+ tmpTag->tag = 0;
+ tmpTag->tagNext = 0;
+
+ *tag = tmpTag;
+
+ return length;
+}
+
+//==========================================================================
+// ParseTagData
+
+static long
+ParseTagData( char * buffer, TagPtr * tag )
+{
+ long length;
+ TagPtr tmpTag;
+
+ length = FixDataMatchingTag(buffer, kXMLTagData);
+ if (length == -1) return -1;
+
+ tmpTag = NewTag();
+ if (tmpTag == 0) return -1;
+
+ tmpTag->type = kTagTypeData;
+ tmpTag->string = 0;
+ tmpTag->tag = 0;
+ tmpTag->tagNext = 0;
+
+ *tag = tmpTag;
+
+ return length;
+}
+
+//==========================================================================
+// ParseTagDate
+
+static long
+ParseTagDate( char * buffer, TagPtr * tag )
+{
+ long length;
+ TagPtr tmpTag;
+
+ length = FixDataMatchingTag(buffer, kXMLTagDate);
+ if (length == -1) return -1;
+
+ tmpTag = NewTag();
+ if (tmpTag == 0) return -1;
+
+ tmpTag->type = kTagTypeDate;
+ tmpTag->string = 0;
+ tmpTag->tag = 0;
+ tmpTag->tagNext = 0;
+
+ *tag = tmpTag;
+
+ return length;
+}
+
+//==========================================================================
+// ParseTagBoolean
+
+static long
+ParseTagBoolean( char * buffer, TagPtr * tag, long type )
+{
+ TagPtr tmpTag;
+
+ tmpTag = NewTag();
+ if (tmpTag == 0) return -1;
+
+ tmpTag->type = type;
+ tmpTag->string = 0;
+ tmpTag->tag = 0;
+ tmpTag->tagNext = 0;
+
+ *tag = tmpTag;
+
+ return 0;
+}
+
+//==========================================================================
+// GetNextTag
+
+static long
+GetNextTag( char * buffer, char ** tag, long * start )
+{
+ long cnt, cnt2;
+
+ if (tag == 0) return -1;
+
+ // Find the start of the tag.
+ cnt = 0;
+ while ((buffer[cnt] != '\0') && (buffer[cnt] != '<')) cnt++;
+ if (buffer[cnt] == '\0') return -1;
+
+ // Find the end 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';
+ if (start) *start = cnt;
+
+ return cnt2 + 1;
+}
+
+//==========================================================================
+// FixDataMatchingTag
+
+static long
+FixDataMatchingTag( char * buffer, char * tag )
+{
+ long length, start, stop;
+ char * endTag;
+
+ start = 0;
+ while (1)
+ {
+ length = GetNextTag(buffer + start, &endTag, &stop);
+ if (length == -1) return -1;
+
+ if ((*endTag == '/') && !strcmp(endTag + 1, tag)) break;
+ start += length;
+ }
+
+ buffer[start + stop] = '\0';
+
+ return start + length;
+}
+
+//==========================================================================
+// NewTag
+
+#define kTagsPerBlock (0x1000)
+
+static TagPtr gTagsFree;
+
+static TagPtr
+NewTag( void )
+{
+ long cnt;
+ TagPtr tag;
+
+ if (gTagsFree == 0)
+ {
+ tag = (TagPtr)AllocateBootXMemory(kTagsPerBlock * sizeof(Tag));
+ if (tag == 0) return 0;
+
+ // Initalize the new tags.
+ for (cnt = 0; cnt < kTagsPerBlock; cnt++)
+ {
+ tag[cnt].type = kTagTypeNone;
+ tag[cnt].string = 0;
+ tag[cnt].tag = 0;
+ tag[cnt].tagNext = tag + cnt + 1;
+ }
+ tag[kTagsPerBlock - 1].tagNext = 0;
+
+ gTagsFree = tag;
+ }
+
+ tag = gTagsFree;
+ gTagsFree = tag->tagNext;
+
+ return tag;
+}
+
+//==========================================================================
+// FreeTag
+
+static void
+FreeTag( TagPtr tag )
+{
+ return;
+ if (tag == 0) return;
+
+ if (tag->string) FreeSymbol(tag->string);
+
+ FreeTag(tag->tag);
+ FreeTag(tag->tagNext);
+
+ // Clear and free the tag.
+ tag->type = kTagTypeNone;
+ tag->string = 0;
+ tag->tag = 0;
+ tag->tagNext = gTagsFree;
+ gTagsFree = tag;
+}
+
+//==========================================================================
+// Symbol object.
+
+struct Symbol
+{
+ long refCount;
+ struct Symbol *next;
+ char string[1];
+};
+typedef struct Symbol Symbol, *SymbolPtr;
+
+static SymbolPtr FindSymbol(char * string, SymbolPtr * prevSymbol);
+
+static SymbolPtr gSymbolsHead;
+
+//==========================================================================
+// NewSymbol
+
+static char *
+NewSymbol( char * string )
+{
+ SymbolPtr symbol;
+
+ // Look for string in the list of symbols.
+ symbol = FindSymbol(string, 0);
+
+ // Add the new symbol.
+ if (symbol == 0)
+ {
+ symbol = AllocateBootXMemory(sizeof(Symbol) + strlen(string));
+ if (symbol == 0) return 0;
+
+ // 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++;
+ return symbol->string;
+}
+
+//==========================================================================
+// FreeSymbol
+
+static void
+FreeSymbol( char * string )
+{
+#if 0
+ SymbolPtr symbol, prev;
+
+ // Look for string in the list of symbols.
+ symbol = FindSymbol(string, &prev);
+ if (symbol == 0) return;
+
+ // Update the refCount.
+ symbol->refCount--;
+
+ if (symbol->refCount != 0) return;
+
+ // Remove the symbol from the list.
+ if (prev != 0) prev->next = symbol->next;
+ else gSymbolsHead = symbol->next;
+
+ // Free the symbol's memory.
+ free(symbol);
+#endif
+}
+
+//==========================================================================
+// FindSymbol
+
+static SymbolPtr
+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;
+}
if ( currentMode() == mode ) return;
if ( mode == GRAPHICS_MODE &&
- (vmode_name = newStringForKey(G_MODE_KEY)) != 0)
+ (vmode_name = newStringForKey(kGraphicsModeKey)) != 0)
{
// Set to the graphics mode specified in the config table file,
// enable linear frame buffer mode, and update kernBootStruct.
+++ /dev/null
-"Languages" = "English French German Italian Spanish Swedish";
-"English" = "Type 1 to use the English language and USA keyboard while installing Rhapsody.";
-"French" = "Tapez 2 pour installer Rhapsody avec un clavier et des messages francais.";
-"German" = "Eingabe 3 fur Rhapsody-Installation mit deutscher Sprache und Tastatur.";
-"Italian" = "Premi 4 per installare Rhapsody usando lingua italiana e tastiera italiana.";
-"Spanish" = "Pulse 5 para usar el idioma y el teclado espanol en la instalacion de Rhapsody.";
-"Swedish" = "Skriv 6 for att anvanda svenska/svenskt tangentbord vid installation av Rhapsody";
-
+++ /dev/null
-/*
- * 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@
- */
-/*
- * Copyright 1993 NeXT, Inc.
- * All rights reserved.
- */
-
-#import "libsa.h"
-#import "console.h"
-#import "fontio.h"
-#import "graphics.h"
-#import "button.h"
-#import "browser.h"
-#import "scrollbar.h"
-#import "ns_logo.h"
-#import "dot.h"
-#import "hdot.h"
-#import "keys.h"
-
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
-browser_t *
-createBrowser(
- char **items,
- int nitems,
- char *top_message,
- char *bottom_message,
- char *button_string,
- int type
-)
-{
- browser_t *bp;
- register int i;
-
- bp = (browser_t *)zalloc(sizeof(browser_t));
- bp->items = items;
- bp->nitems = nitems;
- bp->bot_visible = min( MAX_ITEMS_VISIBLE - 1, nitems - 1 );
- /* bp->top_visible = 0; */
-
- bp->top_message = top_message;
- bp->top_h = max (strheight(bp->top_message), ns_logo_bitmap_HEIGHT);
- bp->top_w = strwidth(bp->top_message) + ns_logo_bitmap_WIDTH +
- BROWSER_XMARGIN;
- bp->bottom_message = bottom_message;
- bp->bottom_h = bottom_message ?
- strheight(bottom_message) :
- -BROWSER_YMARGIN;
- bp->bottom_w = strwidth(bottom_message);
- if (nitems) {
- bp->selected = (char *)zalloc(nitems);
- if (type == BROWSER_CURRENT_IS_SELECTED)
- bp->selected[0] = 1;
- bp->item_h = strheight(items[0]);
- for(i=0; i < nitems; i++)
- bp->item_w = max(bp->item_w, strwidth(items[i]));
- bp->item_w += 2 * BROWSER_XMARGIN + dot_bitmap_WIDTH;
- bp->item_box_w = bp->item_w + 2 * BROWSER_XMARGIN;
- bp->item_box_h = bp->item_h * (bp->bot_visible - bp->top_visible + 1)
- + 2 * BROWSER_YMARGIN;
- initScrollbar(&bp->scrollbar, 0, 0, SB_WIDTH,
- bp->item_box_h - 2 * POPUP_FRAME_MARGIN,
- 0, (bp->bot_visible - bp->top_visible + 1) * 100 / bp->nitems);
- bp->item_box_w += SB_WIDTH + POPUP_FRAME_MARGIN;
- } else {
- bp->item_box_h = -BROWSER_YMARGIN;
- }
- initButton(&bp->button, 0, 0, button_string, BUTTON_DRAW_RETURN);
- bp->h = bp->top_h + bp->item_box_h + bp->bottom_h +
- bp->button.loc.h + 5 * BROWSER_YMARGIN;
- bp->w = max(bp->top_w, bp->bottom_w);
- bp->w = max(bp->w, bp->item_box_w) + 2 * BROWSER_XMARGIN;
- bp->x = (SCREEN_W - bp->w) / 2;
- bp->y = (SCREEN_H - bp->h) / 2;
- if (nitems) {
- bp->item_box_x = bp->x + (bp->w - bp->item_box_w) / 2;
- bp->scrollbar.loc.x = bp->item_box_x + POPUP_FRAME_MARGIN;
- bp->item_box_y = bp->y + 2 * BROWSER_YMARGIN + bp->top_h;
- bp->scrollbar.loc.y = bp->item_box_y + POPUP_FRAME_MARGIN;
- }
- bp->bottom_y = bp->y + 3 * BROWSER_YMARGIN + bp->top_h + bp->item_box_h;
- bp->button.loc.x = bp->x + bp->w - bp->button.loc.w - BROWSER_XMARGIN;
- bp->button.loc.y = bp->y + bp->h - bp->button.loc.h - BROWSER_YMARGIN;
-
- bp->type = type;
-
- return bp;
-}
-
-inline void
-destroyBrowser(
- browser_t *bp
-)
-{
-/* destroyButton(bp->button); */
-/* destroyScrollbar(bp->scrollbar); */
- zfree((char *)bp);
-}
-
-static int item_y(
- browser_t *bp,
- int item_num
-)
-{
- return ((bp)->item_box_y + BROWSER_YMARGIN +
- (item_num - bp->top_visible) * (bp)->item_h + (bp)->item_h / 2);
-}
-
-setItemHighlight(browser_t *bp, int item, int highlight)
-{
- register int xpos = bp->item_box_x + POPUP_FRAME_MARGIN +
- SB_WIDTH + BROWSER_XMARGIN;
- if (currentMode() != GRAPHICS_MODE ||
- item < bp->top_visible ||
- item > bp->bot_visible)
- return;
- blit_clear(bp->item_w, xpos, item_y(bp, item),
- CENTER_V, highlight ? COLOR_WHITE : TEXT_BG);
- if (bp->selected[item])
- copyImage( highlight ? &hdot_bitmap : &dot_bitmap,
- xpos,
- item_y(bp, item) - dot_bitmap_HEIGHT/2);
- xpos += BROWSER_XMARGIN + dot_bitmap_WIDTH;
- blit_string(bp->items[item], xpos, item_y(bp, item),
- TEXT_FG, CENTER_V);
-}
-
-static void drawItembox(browser_t *bp)
-{
- register int i;
- bp->scrollbar.position = bp->top_visible * 100 / bp->nitems;
- drawScrollbar(&bp->scrollbar);
- for(i = bp->top_visible; i <= bp->bot_visible; i++)
- setItemHighlight(bp, i, i == bp->current);
-}
-
-static char *Separator = "----------------------------------------\n";
-
-void drawBrowser(browser_t *bp)
-{
- short item_y;
- register int i;
-
- clearActivityIndicator();
- if (currentMode() == TEXT_MODE) {
- printf("%s", Separator);
- if (bp->top_message) {
- printf("%s\n%s",bp->top_message, Separator);
- }
- if (bp->nitems) {
- for (i = bp->top_visible; i <= bp->bot_visible; i++) {
- printf("% 2d. %c %s\n",i+1,
- bp->selected[i] ? '*' : ' ',
- bp->items[i]);
- }
- if (bp->bot_visible != bp->nitems - 1)
- printf("......<More>\n");
- printf(Separator);
- }
- if (bp->bottom_message) {
- printf("%s\n",bp->bottom_message);
- }
- printf(">> ");
- } else { /* GRAPHICS_MODE */
- popupBox(bp->x, bp->y, bp->w, bp->h, TEXT_BG, POPUP_OUT);
- copyImage(&ns_logo_bitmap, bp->x + BROWSER_XMARGIN,
- bp->y + BROWSER_YMARGIN + (bp->top_h - ns_logo_bitmap_HEIGHT)/2 );
- blit_string(bp->top_message,
- bp->x + ns_logo_bitmap_WIDTH + 2 * BROWSER_XMARGIN,
- bp->y + (bp->top_h / 2) + BROWSER_YMARGIN,
- TEXT_FG, CENTER_V);
- if (bp->bottom_message)
- blit_string(bp->bottom_message,
- bp->x + bp->w / 2, bp->bottom_y + bp->bottom_h / 2,
- TEXT_FG, CENTER_H | CENTER_V);
- drawButton(&bp->button);
- /* draw all items and highlight item 0 */
- if (bp->nitems) {
- popupBox(bp->item_box_x, bp->item_box_y,
- bp->item_box_w, bp->item_box_h,
- TEXT_BG, POPUP_IN);
- drawItembox(bp);
- }
- }
-}
-
-clearBrowser(browser_t *bp)
-{
- if (currentMode() == GRAPHICS_MODE)
- clearBox(bp->x, bp->y, bp->w, bp->h);
-}
-
-
-selectItem(browser_t *bp, int item)
-{
- int i;
- if (bp->selected[item] == 0 &&
- (bp->type == BROWSER_CURRENT_IS_SELECTED)) {
- for (i=0; i < bp->nitems; i++)
- if (bp->selected[i]) {
- bp->selected[i] = 0;
- setItemHighlight(bp, i, i == bp->current);
- }
- }
- bp->selected[item] = !bp->selected[item];
- setItemHighlight(bp, item, item == bp->current);
-}
-
-runBrowser(browser_t *bp)
-{
- int c, i;
- char *s;
-
- if (bp->nitems == 0) {
- while ((c = getc() != '\r'));
- putc('\n');
- return;
- }
-
- if (currentMode() == TEXT_MODE) {
- s = zalloc(128);
- for(;;) {
- gets(s, 128);
- if ((*s == 'f') || (*s == 'F')) {
- if (currentMode() == TEXT_MODE)
- if (bp->bot_visible != bp->nitems - 1) {
- bp->top_visible += MAX_ITEMS_VISIBLE;
- bp->bot_visible += MAX_ITEMS_VISIBLE;
- bp->bot_visible = min(bp->nitems - 1, bp->bot_visible);
- drawBrowser(bp);
- continue;
- }
- } else if ((*s == 'b') || (*s == 'B')) {
- if (currentMode() == TEXT_MODE)
- if (bp->top_visible >= MAX_ITEMS_VISIBLE) {
- bp->top_visible -= MAX_ITEMS_VISIBLE;
- bp->bot_visible = bp->top_visible +
- MAX_ITEMS_VISIBLE - 1;
- drawBrowser(bp);
- continue;
- }
- }
- if (*s == '\0')
- return;
- i = atoi(s);
- if (i < 1 || i > bp->nitems) {
- printf("Please enter a number between 1 and %d.\n"
- "Press <Return>:",
- bp->nitems);
- while ((c = getc()) != '\r');
- } else {
- selectItem(bp, i-1);
- }
- drawBrowser(bp);
- }
- zfree(s);
- return;
- }
-
- for(;;) {
- switch((c = getc())) {
- case 'j':
- case K_DOWN:
- if (bp->current == bp->bot_visible &&
- bp->bot_visible != bp->nitems - 1) {
- bp->top_visible++;
- bp->bot_visible++;
- bp->current++;
- if (bp->type == BROWSER_CURRENT_IS_SELECTED)
- selectItem(bp, bp->current);
- drawItembox(bp);
- } else if (bp->current < bp->nitems - 1) {
- setItemHighlight(bp, bp->current, 0);
- bp->current++;
- if (bp->type == BROWSER_CURRENT_IS_SELECTED)
- selectItem(bp, bp->current);
- else
- setItemHighlight(bp, bp->current, 1);
- }
- break;
- case 'k':
- case K_UP:
- if (bp->current == bp->top_visible &&
- bp->top_visible != 0) {
- bp->top_visible--;
- bp->bot_visible--;
- bp->current--;
- if (bp->type == BROWSER_CURRENT_IS_SELECTED)
- selectItem(bp, bp->current);
- drawItembox(bp);
- } else if (bp->current > 0) {
- setItemHighlight(bp, bp->current, 0);
- bp->current--;
- if (bp->type == BROWSER_CURRENT_IS_SELECTED)
- selectItem(bp, bp->current);
- else
- setItemHighlight(bp, bp->current, 1);
- }
- break;
- case ' ':
- if (!(bp->type == BROWSER_CURRENT_IS_SELECTED))
- selectItem(bp, bp->current);
- break;
- case '\r':
- case '\n':
- return;
- }
- }
-}
-
-static browser_t *_doBrowser(
- char **items,
- int nitems,
- char *top_message,
- char *bottom_message,
- char *button_string,
- int type
-)
-{
- browser_t *bp;
-
- bp = createBrowser(items, nitems,
- top_message, bottom_message, button_string, type);
- drawBrowser(bp);
- runBrowser(bp);
- clearBrowser(bp);
- return bp;
-}
-
-/*
- * returns an array of characters, one per item,
- * that are set to 0 if the item was not selected,
- * 1 if the item was selected.
- */
-char * popupBrowser(
- char **items,
- int nitems,
- char *top_message,
- char *bottom_message,
- char *button_string,
- int type
-)
-{
- browser_t *bp;
- register char *selected;
-
- bp = _doBrowser(items, nitems,
- top_message, bottom_message, button_string, type);
- selected = bp->selected;
- destroyBrowser(bp);
- return selected;
-}
-
-void popupPanel(
- char *message
-)
-{
- browser_t *bp;
-
- bp = _doBrowser(0, 0,
- message, 0, "Continue", 0);
- zfree(bp->selected);
- destroyBrowser(bp);
-}
-
-
+++ /dev/null
-/*
- * 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@
- */
-#import "graphics.h"
-#import "button.h"
-#import "scrollbar.h"
-
-typedef struct browser {
- rect_t loc;
- short x,y,w,h;
- char **items;
- char *selected;
- char *top_message;
- char *bottom_message;
- short nitems;
- short current;
- short top_visible;
- short bot_visible;
- short type;
- short item_box_x, item_box_y; /* item box location */
- short item_box_w, item_box_h;
- short item_h, item_w; /* individual item metrics */
- short top_h, top_w; /* size of top text area */
- button_t button;
- scroll_t scrollbar;
- short bottom_y;
- short bottom_h, bottom_w; /* size of bottom text area */
-} browser_t;
-
-#define BROWSER_XMARGIN 8
-#define BROWSER_YMARGIN 8
-
-#define MAX_ITEMS_VISIBLE 8
-
-#define BROWSER_SELECT_MULTIPLE 0
-#define BROWSER_CURRENT_IS_SELECTED 1
-
-#define BROWSER_NO_MESSAGE ((char *)0)
-#define BROWSER_INSTRUCTIONS ((char *)1)
-
-extern char * popupBrowser(
- char **items,
- int nitems,
- char *top_message,
- char *bottom_message,
- char *button_string,
- int type
-);
+++ /dev/null
-/*
- * 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@
- */
-/*
- * Copyright 1993 NeXT, Inc.
- * All rights reserved.
- */
-
-#import "libsa.h"
-#import "console.h"
-#import "fontio.h"
-#import "graphics.h"
-#import "button.h"
-#import "return.h"
-
-button_t *initButton(
- button_t *bp,
- int x,
- int y,
- char *message,
- int drawReturnSign
-)
-{
- bp->loc.x = x;
- bp->loc.y = y;
- bp->loc.h = strheight(message) + 2 * BUTTON_YMARGIN;
- bp->loc.w = strwidth(message) + 2 * BUTTON_XMARGIN;
- if (drawReturnSign)
- bp->loc.w += return_bitmap_WIDTH + BUTTON_XMARGIN;
- bp->message = message;
- bp->flags = drawReturnSign ? BUTTON_DRAW_RETURN : 0;
- return bp;
-}
-
-#if 0
-void destroyButton(
- button_t *bp
-)
-{
- zfree((char *)bp);
-}
-#endif
-
-void drawButton(
- button_t *bp
-)
-{
- popupBox(bp->loc.x, bp->loc.y, bp->loc.w, bp->loc.h, TEXT_BG, POPUP_OUT);
- blit_string(bp->message,
- bp->loc.x + BUTTON_XMARGIN, bp->loc.y + bp->loc.h / 2,
- TEXT_FG, CENTER_V);
- if (bp->flags & BUTTON_DRAW_RETURN) {
- copyImage(&return_bitmap,
- bp->loc.x + bp->loc.w - BUTTON_XMARGIN - return_bitmap_WIDTH,
- bp->loc.y + (bp->loc.h - return_bitmap_HEIGHT) / 2);
- }
-}
-
-#if 0
-void
-clearButton(
- button_t *bp,
- int color
-)
-{
- clearRect(bp->loc.x,bp->loc.y, bp->loc.w, bp->loc.h, color);
-}
-#endif
+++ /dev/null
-/*
- * 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@
- */
-#import "graphics.h"
-
-typedef struct button {
- rect_t loc;
- int flags;
- char *message;
-} button_t;
-
-#define BUTTON_DRAW_RETURN 1
-#define BUTTON_XMARGIN 6
-#define BUTTON_YMARGIN 6
-
-extern button_t *initButton(
- button_t *bp,
- int x,
- int y,
- char *message,
- int drawReturnSign
-);
-
-extern void destroyButton(
- button_t *bp
-);
-
-extern void drawButton(
- button_t *bp
-);
\ No newline at end of file
+++ /dev/null
-/*
- * 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@
- */
-/*
- * Copyright 1993 NeXT, Inc.
- * All rights reserved.
- */
-
-#import "libsaio.h"
-#import "io_inline.h"
-#import "kernBootStruct.h"
-#import "font.h"
-#import "bitmap.h"
-#import "console.h"
-#import "graphics.h"
-#import "ns_box.h"
-#import "ns_logo.h"
-
-int
-popupQuestionBox(char *string)
-{
- int ch, answer=0;
- int popup_x, popup_y, popup_w, popup_top_h, popup_h;
- int popup_t_x, popup_t_y, popup_t_w;
- int xpos;
- int blink = 0;
- int time, endtime;
- char buf[64];
-
- clearActivityIndicator();
- if (kernBootStruct->graphicsMode == GRAPHICS_MODE) {
- popup_w = strwidth(string) + ns_logo_bitmap_WIDTH +
- 3 * POPUP_XMARGIN;
- popup_x = (SCREEN_W - popup_w) / 2;
- popup_t_x = (popup_x + (popup_w - POPUP_T_W) / 2);
- popup_top_h = max(strheight(string), ns_logo_bitmap.height)
- + 2 * POPUP_YMARGIN;
- popup_h = popup_top_h + POPUP_YMARGIN + POPUP_T_H;
- popup_y = (SCREEN_H - popup_h) / 2;
- popup_t_y = popup_y + popup_h - (POPUP_T_H + POPUP_YMARGIN);
- popupBox(popup_x, popup_y, popup_w, popup_h, TEXT_BG, POPUP_OUT);
-
- copyImage(&ns_logo_bitmap, popup_x + POPUP_XMARGIN,
- popup_y + (popup_top_h - ns_logo_bitmap_HEIGHT) / 2);
- popupBox(popup_t_x, popup_t_y,
- POPUP_T_W, POPUP_T_H, COLOR_WHITE, POPUP_IN);
- blit_string(string, popup_x + ns_logo_bitmap_WIDTH + 2 * POPUP_XMARGIN,
- popup_y + (popup_top_h - strheight(string)) / 2
- + fontp->bbx.height + fontp->bbx.yoff,
- TEXT_FG, 0);
- xpos = popup_t_x + POPUP_T_XMARGIN - fontp->bbx.xoff;
-
- for (;;) {
- time = time18();
- endtime = time + 12;
-
- blink = ! blink;
- clearRect(xpos, popup_t_y + POPUP_T_YMARGIN, 1,
- POPUP_T_H - 2 * POPUP_T_YMARGIN,
- blink ? COLOR_BLACK : COLOR_WHITE);
- while (time18() < endtime)
- if (ch = readKeyboardStatus())
- break;
- if (ch) {
- ch = getc();
- switch (ch) {
- case '\n':
- case '\r':
- /* erase popup box */
- clearBox(popup_x, popup_y, popup_w, popup_h);
- return answer;
- case '\b':
- clearRect(popup_t_x+3, popup_t_y+3,
- POPUP_T_W-6, POPUP_T_H-6, COLOR_WHITE);
- blink = answer = 0;
- xpos = popup_t_x + POPUP_T_XMARGIN - fontp->bbx.xoff;
- break;
- default:
- if (answer)
- break;
- buf[0] = answer = ch;
- buf[1] = '\0';
- clearRect(xpos, popup_t_y + POPUP_T_YMARGIN, 1,
- POPUP_T_H - 2 * POPUP_T_YMARGIN, COLOR_WHITE);
- blink = 0;
- xpos += blit_string(buf, xpos,
- popup_t_y + POPUP_T_YMARGIN + fontp->bbx.height
- + fontp->bbx.yoff,
- COLOR_BLACK, 0);
- break;
- }
- }
- }
- } else {
- printf(string);
- printf("\n>> ");
- gets(buf,sizeof(buf));
- return buf[0];
- }
-}
+++ /dev/null
-/*
- * 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@
- */
-#import <mach/boolean.h>
-
-#import <mach/i386/vm_types.h>
-#import <architecture/i386/cpu.h>
-
-/*
- * Primatives for manipulating the
- * cpu cache(s).
- */
-
-static __inline__
-void
-enable_cache(void)
-{
- cr0_t cr0;
-
- asm volatile(
- "mov %%cr0,%0"
- : "=r" (cr0));
-
- cr0.cd = cr0.nw = 0;
-
- asm volatile(
- "wbinvd; mov %0,%%cr0"
- :
- : "r" (cr0));
-}
-
-static __inline__
-void
-flush_cache(void)
-{
- asm volatile("wbinvd");
-}
-
-/*
- * Memory sizing code.
- *
- * Tunable Parameters:
- * SCAN_INCR Size of memory scanning segment.
- * SCAN_LEN Length to actually test, per segment,
- * starting at the front of the segment.
- * SCAN_LIM Highest address to test for existence of memory.
- *
- * Assumptions:
- * Primary assumption is that SCAN_INCR and SCAN_LEN are chosen
- * and the stack is positioned in its segment such that the tested
- * portion of the segment does not overlap with any portion of the
- * stack's location in that segment. The best way to acomplish this
- * is to position the stack at the high end of a segment, and to make
- * the segment size large enough to prevent it from overlapping the
- * test area. The stack needs to be large enough to contain the low
- * memory save area as well as the code for the scan function.
- */
-#define KB(x) (1024*(x))
-#define MB(x) (1024*KB(x))
-
-#define SCAN_PAT0 0x76543210
-#define SCAN_PAT1 0x89abcdef
-
-struct test_datum {
- unsigned int word0;
- unsigned int word1;
-};
-
-vm_offset_t
-scan_memory(
- vm_offset_t end_of_memory,
- vm_offset_t end_of_cnvmem,
- unsigned int SCAN_INCR,
- unsigned int SCAN_LEN,
- unsigned int SCAN_LIM
-)
-{
- struct test_datum zero_pat = { 0, 0 };
- vm_offset_t memory;
-
- /*
- * Make sure that the cache(s) are flushed
- * and enabled.
- */
- enable_cache();
-
- /*
- * Round the starting address to the next
- * segment boundary. This is where we will
- * begin testing.
- */
- end_of_memory = (end_of_memory + (SCAN_INCR - 1) & ~(SCAN_INCR - 1));
-
- /*
- * Zero out the test area of each segent
- * which is located in extended memory.
- */
- memory = KB(1024);
-
- while (memory < end_of_memory) {
- struct test_datum *memory_ptr;
-
- (vm_offset_t)memory_ptr = memory;
-
- while ((vm_offset_t)memory_ptr < memory + SCAN_LEN)
- *memory_ptr++ = zero_pat;
-
- memory += SCAN_INCR;
- }
-
- {
- /*
- * Code for segment scanning function.
- */
- extern unsigned int Scan_segment_code[],
- Scan_segment_code_end[];
- /*
- * Location on the stack to where this
- * function is copied and then executed
- * from!! N.B. This code must be position
- * independent. (duh)
- */
- unsigned int scan_func[
- Scan_segment_code_end -
- Scan_segment_code];
-
- /*
- * Copy the scan function onto the stack.
- */
- memcpy(scan_func, Scan_segment_code, sizeof (scan_func));
-
- while (end_of_memory < SCAN_LIM) {
- display_kbytes(end_of_memory);
- if (!((vm_offset_t (*)())scan_func)(
- end_of_memory,
- end_of_cnvmem,
- SCAN_INCR,
- SCAN_LEN))
- break;
-
- end_of_memory += SCAN_INCR;
- }
- }
-
- display_kbytes(end_of_memory);
-
- return (end_of_memory);
-}
-
-static
-void
-display_kbytes(
- vm_offset_t address
-)
-{
- unsigned int quant, dig, done = 0, mag = 1000000000;
- int places = 1;
-
- quant = address / 1024;
-
- while (mag > 0) {
- done *= 10;
- dig = (quant / mag) - done;
- done += dig;
- if (done > 0 || mag == 1) {
- putc(dig + '0');
- places++;
- }
- mag /= 10;
- }
-
- putc('K');
-
- while (places-- > 0)
- putc('\b');
-}
-
-/*
- * Memory scan function, which tests one segment of memory.
- * This code is copied onto the stack and executed there to
- * avoid problems when memory aliasing occurs. If it detects
- * problems due to aliasing to low memory, it restores the
- * low memory segments before returning.
- *
- * Parameters:
- * end_of_memory Address to start testing at,
- * this is rounded to the start of
- * the next segment internally.
- * end_of_cnvmem Address where conventional
- * memory ends.
- * SCAN_INCR Size of each segment.
- * SCAN_LEN Size of per segment test area,
- * located at the front of the segment.
- * SCAN_LIM Address next segment after highest
- * to test.
- */
-static
-boolean_t
-scan_segment(
- vm_offset_t start_of_segment,
- vm_offset_t end_of_cnvmem,
- unsigned int SCAN_INCR,
- unsigned int SCAN_LEN
-)
-{
- /*
- * Location on the stack where the test
- * area of each segment of low memory is
- * saved, appended together. The copy is
- * used to detect memory aliasing and to
- * restore memory on that occasion.
- */
- unsigned int copy_area[
- ((KB(640) / SCAN_INCR) * SCAN_LEN)
- / sizeof (unsigned int)];
- struct test_datum *test_ptr,
- test_pat = { SCAN_PAT0, SCAN_PAT1 },
- zero_pat = { 0, 0 };
- vm_offset_t memory, copy;
-
- /*
- * Copy the test area of each low memory
- * segment to the save area. Low memory
- * begins at zero, and runs to the end of
- * conventional memory.
- */
- copy = (vm_offset_t)copy_area;
- memory = 0;
-
- while (memory < KB(640)) {
- unsigned int *memory_ptr, *copy_ptr;
-
- if (memory <= (end_of_cnvmem - SCAN_LEN)) {
- (vm_offset_t)memory_ptr = memory;
- (vm_offset_t)copy_ptr = copy;
-
- while ((vm_offset_t)memory_ptr < memory + SCAN_LEN)
- *copy_ptr++ = *memory_ptr++;
- }
-
- memory += SCAN_INCR; copy += SCAN_LEN;
- }
-
- /*
- * Write the test pattern in the test
- * area of the current segment.
- */
- (vm_offset_t)test_ptr = start_of_segment;
-
- while ((vm_offset_t)test_ptr < start_of_segment + SCAN_LEN)
- *test_ptr++ = test_pat;
-
- /*
- * Flush the data cache to insure that the
- * data actually gets written to main memory.
- * This will provoke aliasing to occur if
- * it is in fact present.
- */
- flush_cache();
-
- /*
- * Compare low memory against the save
- * area, breaking out immediately if
- * an inconsistency is observed.
- */
- copy = (vm_offset_t)copy_area;
- memory = 0;
-
- while (memory < KB(640)) {
- struct test_datum *memory_ptr, *copy_ptr;
-
- if (memory <= (end_of_cnvmem - SCAN_LEN)) {
- (vm_offset_t)memory_ptr = memory;
- (vm_offset_t)copy_ptr = copy;
-
- while ((vm_offset_t)memory_ptr < memory + SCAN_LEN) {
- if ( memory_ptr->word0 != copy_ptr->word0 ||
- memory_ptr->word1 != copy_ptr->word1 )
- break;
-
- memory_ptr++; copy_ptr++;
- }
-
- if ((vm_offset_t)memory_ptr < memory + SCAN_LEN)
- break;
- }
-
- memory += SCAN_INCR; copy += SCAN_LEN;
- }
-
- /*
- * If an inconsistency was found in low
- * memory, restore the entire region from
- * the save area and return a failure.
- */
- if (memory < KB(640)) {
- copy = (vm_offset_t)copy_area;
- memory = 0;
-
- while (memory < KB(640)) {
- unsigned int *memory_ptr, *copy_ptr;
-
- if (memory <= (end_of_cnvmem - SCAN_LEN)) {
- (vm_offset_t)memory_ptr = memory;
- (vm_offset_t)copy_ptr = copy;
-
- while ((vm_offset_t)memory_ptr < memory + SCAN_LEN)
- *memory_ptr++ = *copy_ptr++;
- }
-
- memory += SCAN_INCR; copy += SCAN_LEN;
- }
-
- return (FALSE);
- }
-
- /*
- * Check the memory we have already scanned
- * to see whether aliasing occurred there.
- * The test area of each segment should contain
- * zeros.
- */
- memory = KB(1024);
-
- while (memory < start_of_segment) {
- struct test_datum *memory_ptr;
-
- (vm_offset_t)memory_ptr = memory;
-
- while ((vm_offset_t)memory_ptr < memory + SCAN_LEN) {
- if ( memory_ptr->word0 != zero_pat.word0 ||
- memory_ptr->word1 != zero_pat.word1 )
- break;
-
- memory_ptr++;
- }
-
- if ((vm_offset_t)memory_ptr < memory + SCAN_LEN)
- break;
-
- memory += SCAN_INCR;
- }
-
- if (memory < start_of_segment)
- return (FALSE);
-
- /*
- * Now check the current segment to see
- * whether the test patten was correctly
- * written out.
- */
- (vm_offset_t)test_ptr = start_of_segment;
-
- while ((vm_offset_t)test_ptr < start_of_segment + SCAN_LEN) {
- if ( test_ptr->word0 != test_pat.word0 ||
- test_ptr->word1 != test_pat.word1 )
- break;
-
- test_ptr++;
- }
-
- if ((vm_offset_t)test_ptr < start_of_segment + SCAN_LEN)
- return (FALSE);
-
- /*
- * Zero the current segment, which has now
- * passed the test!!
- */
- (vm_offset_t)test_ptr = start_of_segment;
-
- while ((vm_offset_t)test_ptr < start_of_segment + SCAN_LEN)
- *test_ptr++ = zero_pat;
-
- return (TRUE);
-}
+++ /dev/null
-s/_scan_segment/.globl _Scan_segment_code\
-_Scan_segment_code/
-$a\
-.align 2,0x90\
-.globl _Scan_segment_code_end\
-_Scan_segment_code_end:
+++ /dev/null
-/*
- * 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@
- */
-/*
- * Copyright 1993 NeXT, Inc.
- * All rights reserved.
- */
-
-#import "libsa.h"
-#import "console.h"
-#import "fontio.h"
-#import "graphics.h"
-#import "scrollbar.h"
-
-
-scroll_t *initScrollbar(
- scroll_t *sp,
- int x,
- int y,
- int w,
- int h,
- int position, /* 0 - 100 */
- int percent /* 0 - 100 */
-)
-{
- sp->loc.x = x;
- sp->loc.y = y;
- sp->loc.w = w;
- sp->loc.h = h;
- sp->position = position;
- sp->percent = percent;
- return sp;
-}
-
-#if 0
-void destroyScrollbar(
- scroll_t *sp
-)
-{
- (void)zfree((char *)sp);
-}
-#endif
-
-void drawScrollbar(
- scroll_t *sp
-)
-{
- clearRect(sp->loc.x, sp->loc.y, sp->loc.w, sp->loc.h, SB_BG);
-// clearRect(sp->loc.x, sp->loc.y, sp->loc.w, 1, COLOR_BLACK);
-// clearRect(sp->loc.x, sp->loc.y + sp->loc.h - 1, sp->loc.w, 1, COLOR_BLACK);
-// clearRect(sp->loc.x, sp->loc.y, 1, sp->loc.h, COLOR_BLACK);
- clearRect(sp->loc.x + sp->loc.w - 1, sp->loc.y, 1, sp->loc.h, COLOR_BLACK);
- if (sp->percent < 100)
- popupBox(sp->loc.x + SB_MARGIN,
- sp->loc.y + (sp->position * (sp->loc.h - 2 * SB_MARGIN)) / 100,
- sp->loc.w - 3 * SB_MARGIN,
- (sp->loc.h - 2 * SB_MARGIN) * sp->percent / 100,
- TEXT_BG, POPUP_OUT);
-}
-
-#if 0
-void clearScrollbar(
- scroll_t *sp,
- int color
-)
-{
- clearRect(sp->loc.x, sp->loc.y, sp->loc.w, sp->loc.h, color);
-}
-#endif
+++ /dev/null
-/*
- * 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@
- */
-/* scroll bar */
-#import <graphics.h>
-
-typedef struct scrollbar {
- rect_t loc;
- unsigned char position; /* 0 - 100 */
- unsigned char percent; /* 0 - 100 */
-} scroll_t;
-
-#define SB_MARGIN 1
-#define SB_BG COLOR_DK_GREY
-
-#define SB_WIDTH 16
\ No newline at end of file
+++ /dev/null
-/*
- * 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@
- */
-#import <mach/i386/vm_types.h>
-
-#define KB(x) (1024*(x))
-#define MB(x) (1024*KB(x))
-
-unsigned int
-sizememory(
- unsigned int cnvmem
-)
-{
- vm_offset_t end_of_memory;
-#define SCAN_INCR KB(64)
-#define SCAN_LEN 8
-#define SCAN_LIM MB(512)
-
- printf("\nSizing memory... ");
-
- if (readKeyboardShiftFlags() & 0x2) { /* left SHIFT key depressed */
- printf("[aborted]");
- end_of_memory = KB(memsize(1)) + MB(1);
- }
- else {
- /*
- * First scan beginning at start of
- * extended memory using a reasonably
- * large segment size.
- */
- end_of_memory = scan_memory(
- KB(1024),
- KB(cnvmem),
- SCAN_INCR,
- SCAN_LEN,
- SCAN_LIM);
-
- /*
- * Now scan the top segment a page at
- * a time to find the actual end of
- * extended memory.
- */
- if (end_of_memory > KB(1024))
- end_of_memory = scan_memory(
- end_of_memory - SCAN_INCR,
- KB(cnvmem),
- KB(4),
- SCAN_LEN,
- end_of_memory);
- }
-
- return (end_of_memory / 1024);
-}
+++ /dev/null
-/*
- * 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>
-
- .file "start.s"
-TEXT
-LABEL(boot_start)
- jmp _boot
- . = boot_start + 0x1000
+++ /dev/null
-/*
- * 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@
- */
-#import <stddef.h>
-#import "kernBootStruct.h"
-
-main()
-{
- KERNBOOTSTRUCT kb;
- printf("EISA info size: %d bytes\n",sizeof(EISA_slot_info_t));
- printf("reserved size: %d bytes\n",sizeof(kb._reserved));
- printf("offset of APM: %d\n",offsetof(KERNBOOTSTRUCT, apm_config));
- printf("offset of config: %d\n",offsetof(KERNBOOTSTRUCT, config));
- printf("space left at end: %d\n",65536 - (offsetof(KERNBOOTSTRUCT, config) + sizeof(kb.config)));
-}
#include "vers.h"
-char bootPrompt[] = "\n\nDarwin Intel boot v" I386BOOT_VERSION "\n"
- "%dK conventional / %dK total memory\n\n";
+char bootPrompt[] = "\n\nDarwin/x86 boot v" I386BOOT_VERSION "\n"
+ "%dK conventional / %dK extended memory\n\n"
+ "Darwin/x86 will start up in %d seconds, or you can:\n"
+ " Type -v and press Return to start up Darwin/x86 with "
+ "diagnostic messages\n"
+ " Type ? and press Return to learn about advanced startup "
+ "options\n"
+ " Type any other character to stop Darwin/x86 from "
+ "starting up automatically\n";
SA_OBJS = prf.o printf.o zalloc.o \
string.o strtol.o error.o \
- setjmp.o qsort.o
+ setjmp.o qsort.o bswap.o
SFILES = setjmp.s
CFILES = prf.c printf.c zalloc.c \
string.c strtol.c error.c \
- qsort.c
+ qsort.c bswap.c
HFILES = memory.h
EXPORTED_HFILES = libsa.h kernBootStruct.h memory.h
INSTALLED_SA_HFILES = libsa.h
--- /dev/null
+/*
+ * 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 "libsa.h"
+
+unsigned long bswap32( unsigned long data )
+{
+ __asm__ volatile("bswap %0"
+ : "=r" (data)
+ : "0" (data));
+ return data;
+}
#ifndef __BOOT_KERNBOOTSTRUCT_H
#define __BOOT_KERNBOOTSTRUCT_H
-/* The config table has room for 13 drivers if their config files
- * are the maximum size allowed.
+/*
+ * Maximum number of boot drivers that can be loaded.
*/
-#define CONFIG_SIZE (13 * 4096)
+#define NDRIVERS 500
-/* Maximum number of boot drivers supported, assuming their
- * config files fit in the bootstruct.
+/*
+ * Types of boot driver that may be loaded by the booter.
*/
-#define NDRIVERS 64
+enum {
+ kBootDriverTypeInvalid = 0,
+ kBootDriverTypeKEXT = 1,
+ kBootDriverTypeMKEXT = 2
+};
typedef struct {
- char * address; // address where driver was loaded
- int size; // entry point for driver
+ unsigned long address; // address where driver was loaded
+ unsigned long size; // number of bytes
+ unsigned long type; // driver type
} driver_config_t;
+/*
+ * APM BIOS information.
+ */
typedef struct {
- unsigned short major_vers; // == 0 if not present
- unsigned short minor_vers;
- unsigned long cs32_base;
- unsigned long cs16_base;
- unsigned long ds_base;
- unsigned long cs_length;
- unsigned long ds_length;
- unsigned long entry_offset;
+ unsigned short major_vers; // == 0 if not present
+ unsigned short minor_vers;
+ unsigned long cs32_base;
+ unsigned long cs16_base;
+ unsigned long ds_base;
+ unsigned long cs_length;
+ unsigned long ds_length;
+ unsigned long entry_offset;
union {
struct {
- unsigned long mode_16 :1;
- unsigned long mode_32 :1;
- unsigned long idle_slows_cpu :1;
- unsigned long reserved :29;
+ unsigned long mode_16 :1;
+ unsigned long mode_32 :1;
+ unsigned long idle_slows_cpu :1;
+ unsigned long reserved :29;
} f;
unsigned long data;
} flags;
- unsigned long connected;
+ unsigned long connected;
} APM_config_t;
-typedef struct _EISA_slot_info_t {
- union {
- struct {
- unsigned char duplicateID :4;
- unsigned char slotType :1;
- unsigned char prodIDPresent :1;
- unsigned char dupIDPresent :1;
- } s;
- unsigned char d;
- } u_ID;
- unsigned char configMajor;
- unsigned char configMinor;
- unsigned short checksum;
- unsigned char numFunctions;
- union {
- struct {
- unsigned char fnTypesPresent :1;
- unsigned char memoryPresent :1;
- unsigned char irqPresent :1;
- unsigned char dmaPresent :1;
- unsigned char portRangePresent :1;
- unsigned char portInitPresent :1;
- unsigned char freeFormPresent :1;
- unsigned char reserved :1;
- } s;
- unsigned char d;
- } u_resources;
- unsigned char id[8];
-} EISA_slot_info_t;
-
-typedef struct _EISA_func_info_t {
- unsigned char slot;
- unsigned char function;
- unsigned char reserved[2];
- unsigned char data[320];
-} EISA_func_info_t;
-
-#define NUM_EISA_SLOTS 64
-
+/*
+ * PCI bus information.
+ */
typedef struct _PCI_bus_info_t {
union {
struct {
} PCI_bus_info_t;
/*
- * Video information..
+ * Video information.
*/
struct boot_video {
- unsigned long v_baseAddr; /* Base address of video memory */
- unsigned long v_display; /* Display Code (if Applicable */
- unsigned long v_rowBytes; /* Number of bytes per pixel row */
- unsigned long v_width; /* Width */
- unsigned long v_height; /* Height */
- unsigned long v_depth; /* Pixel Depth */
+ unsigned long v_baseAddr; // Base address of video memory
+ unsigned long v_display; // Display Code (if Applicable
+ unsigned long v_rowBytes; // Number of bytes per pixel row
+ unsigned long v_width; // Width
+ unsigned long v_height; // Height
+ unsigned long v_depth; // Pixel Depth
};
-typedef struct boot_video boot_video;
-
-#define BOOT_STRING_LEN 160
-
-typedef struct {
- short version;
- char bootString[BOOT_STRING_LEN]; // string we booted with
- int magicCookie; // KERNBOOTMAGIC if struct valid
- int numIDEs; // how many IDE drives
- int rootdev; // booters guess as to rootdev
- int convmem; // conventional memory
- int extmem; // extended memory
- char boot_file[128]; // name of the kernel we booted
- int first_addr0; // first address for kern convmem
- int diskInfo[4]; // bios info for bios dev 80-83
- int graphicsMode; // did we boot in graphics mode?
- int kernDev; // device kernel was fetched from
- int numBootDrivers; // number of drivers loaded by booter
- char * configEnd; // pointer to end of config files
- int kaddr; // kernel load address
- int ksize; // size of kernel
- void * rld_entry; // entry point for standalone rld
-
- driver_config_t driverConfig[NDRIVERS];
- APM_config_t apm_config;
-
- char _reserved[7500];
+typedef struct boot_video boot_video;
- boot_video video;
+#define GRAPHICS_MODE 1
+#define TEXT_MODE 0
- PCI_bus_info_t pciInfo;
-
- int eisaConfigFunctions;
- EISA_slot_info_t eisaSlotInfo[NUM_EISA_SLOTS];
+#define BOOT_STRING_LEN 160
+#define CONFIG_SIZE (12 * 4096)
- char config[CONFIG_SIZE]; // the config file contents
+typedef struct {
+ short version;
+ char bootString[BOOT_STRING_LEN]; // boot arguments
+ int magicCookie; // KERNBOOTMAGIC
+ int numIDEs; // number of IDE drives
+ int rootdev; // root device
+ int convmem; // conventional memory
+ int extmem; // extended memory
+ char bootFile[128]; // kernel file name
+ int firstAddr0; // first address for kern convmem
+ int diskInfo[4]; // info for bios dev 80-83
+ int graphicsMode; // booted in graphics mode?
+ int kernDev; // device kernel was fetched from
+ int numBootDrivers; // number of drivers loaded
+ char * configEnd; // pointer to end of config files
+ int kaddr; // kernel load address
+ int ksize; // size of kernel
+ driver_config_t driverConfig[NDRIVERS];
+ char _reserved[2052];
+ boot_video video;
+ PCI_bus_info_t pciInfo;
+ APM_config_t apmConfig;
+ char config[CONFIG_SIZE];
} KERNBOOTSTRUCT;
-#define GRAPHICS_MODE 1
-#define TEXT_MODE 0
-
#define KERNSTRUCT_ADDR ((KERNBOOTSTRUCT *) 0x11000)
#define KERNBOOTMAGIC 0xa7a7a7a7
-#if 0
-#ifndef EISA_CONFIG_ADDR
-#define EISA_CONFIG_ADDR 0x20000
-#define EISA_CONFIG_LEN 0x10000
-#endif
-#endif
-
#ifndef KERNEL
extern KERNBOOTSTRUCT * kernBootStruct;
#endif
/*
* zalloc.c
*/
-#define ZALLOC_NODES 384
-
extern void malloc_init(char * start, int size, int nodes);
extern void * malloc(size_t size);
extern void free(void * start);
extern struct segment_command *
getsegbynamefromheader(struct mach_header * mhp, char * segname);
+/*
+ * bswap.c
+ */
+extern unsigned long bswap32( unsigned long data );
+
#endif /* !__BOOT_LIBSA_H */
#define BOOTER_ADDR 0x003000 // start of booter code
#define BOOTER_LEN 0x00B000
#define STACK_ADDR 0x00FFF0
-#define BOOTSTRUCT_ADDR 0x011000
-#define BOOTSTRUCT_LEN 0x00F000 // it's slightly smaller
-#define EISA_CONFIG_ADDR 0x020000
-#define EISA_CONFIG_LEN 0x010000
-#define RLD_ADDR 0x030000
+#define BOOTSTRUCT_ADDR 0x011000 // it's slightly smaller
+#define BOOTSTRUCT_LEN 0x00F000
+#define RLD_ADDR 0x030000 // not used
#define RLD_LEN 0x070000
#define VIDEO_ADDR 0x0A0000 // unusable space
#define VIDEO_LEN 0x060000
-#define KERNEL_ADDR 0x100000
-#define KERNEL_LEN 0x400000
-#define RLD_MEM_ADDR 0x500000
-#define RLD_MEM_LEN 0x100000
-#define ZALLOC_ADDR 0x600000
+#define KERNEL_ADDR 0x100000 // 14Mb kernel + drivers
+#define KERNEL_LEN 0xe00000
+#define ZALLOC_ADDR 0xf00000 // 1Mb for zalloc
#define ZALLOC_LEN 0x100000
-#define MODULE_ADDR 0x700000 // to be used for compression..
-#define MODULE_LEN 0x080000
-#define KSYM_ADDR 0x780000
-#define KSYM_LEN 0x080000 // 512k
-#define TFTP_ADDR 0x800000 // 8MB
-#define TFTP_LEN 0x400000 // 4MB buffer size
+#define TFTP_ADDR 0x1000000 // 8Mb download buffer
+#define TFTP_LEN 0x800000
-/* these are physical values */
+/* These are physical values */
-#define CONVENTIONAL_LEN 0x0A0000 // 640k
-#define EXTENDED_ADDR 0x100000 // 1024k
-#define KERNEL_BOOT_ADDR KERNEL_ADDR /* load at 1Mb */
-
-#define SAIO_TABLE_POINTER (BOOTER_ADDR + SAIO_TABLE_PTR_OFFSET)
-#define SAIO_TABLE_PTR_OFFSET 0x30
+#define CONVENTIONAL_LEN 0x0A0000 // 640k
+#define EXTENDED_ADDR 0x100000 // 1024k
+#define KERNEL_BOOT_ADDR KERNEL_ADDR // load at 1Mb
#define ptov(paddr) ((paddr) - MEMBASE)
#define vtop(vaddr) ((vaddr) + MEMBASE)
* Limits to the size of various things...
*/
-/* We need a minimum of 12Mb of system memory. */
-#define MIN_SYS_MEM_KB (12 * 1024)
+/*
+ * We need a minimum of 24Mb of system memory.
+ */
+#define MIN_SYS_MEM_KB (24 * 1024)
#endif /* !__BOOT_MEMORY_H */
static void zdelete(zmem * zp, int ndx);
static void zcoalesce(void);
-#define ZALLOC_NODES 384
+#define ZALLOC_NODES 1024
static void malloc_error()
{
int memsize(int which)
{
- if (which) {
- get_memsize(&bb);
- return (bb.edx.rr << 16) | bb.eax.rr;
+ int size;
+
+ if ( which )
+ {
+ // Get the total system memory discovered by the
+ // BIOS in kilobytes.
+
+ get_memsize(&bb);
+ size = (bb.edx.rr << 16) | bb.eax.rr;
+
+ // Convert to extended memory size.
+
+ size = ( size > 1024 ) ? size - 1024 : 0;
}
- else {
- /* conventional memory */
+ else
+ {
+ // Get amount of conventional memory available.
+
bb.intno = 0x12;
bios(&bb);
- return bb.eax.rr;
+ size = bb.eax.rr;
}
+ return size;
}
void video_mode(int mode)
(bb.ebx.r.h == 'P') &&
(bb.ebx.r.l == 'M')) {
/* Success */
- kbp->apm_config.major_vers = bb.eax.r.h;
- kbp->apm_config.minor_vers = bb.eax.r.l;
- kbp->apm_config.flags.data = bb.ecx.rr;
+ kbp->apmConfig.major_vers = bb.eax.r.h;
+ kbp->apmConfig.minor_vers = bb.eax.r.l;
+ kbp->apmConfig.flags.data = bb.ecx.rr;
return 1;
}
return 0;
bios(&bb);
if (bb.flags.cf == 0) {
/* Success */
- kbp->apm_config.cs32_base = (bb.eax.rr) << 4;
- kbp->apm_config.entry_offset = bb.ebx.rx;
- kbp->apm_config.cs16_base = (bb.ecx.rr) << 4;
- kbp->apm_config.ds_base = (bb.edx.rr) << 4;
- if (kbp->apm_config.major_vers >= 1 &&
- kbp->apm_config.minor_vers >= 1) {
- kbp->apm_config.cs_length = bb.esi.rr;
- kbp->apm_config.ds_length = bb.edi.rr;
+ kbp->apmConfig.cs32_base = (bb.eax.rr) << 4;
+ kbp->apmConfig.entry_offset = bb.ebx.rx;
+ kbp->apmConfig.cs16_base = (bb.ecx.rr) << 4;
+ kbp->apmConfig.ds_base = (bb.edx.rr) << 4;
+ if (kbp->apmConfig.major_vers >= 1 &&
+ kbp->apmConfig.minor_vers >= 1) {
+ kbp->apmConfig.cs_length = bb.esi.rr;
+ kbp->apmConfig.ds_length = bb.edi.rr;
} else {
- kbp->apm_config.cs_length =
- kbp->apm_config.ds_length = 64 * 1024;
+ kbp->apmConfig.cs_length =
+ kbp->apmConfig.ds_length = 64 * 1024;
}
- kbp->apm_config.connected = 1;
+ kbp->apmConfig.connected = 1;
return 1;
}
return 0;
#include "libsaio.h"
-BOOL verbose_mode;
+BOOL gVerboseMode;
BOOL errors;
/*
{
va_list ap;
- if (verbose_mode)
+ if (gVerboseMode)
{
va_start(ap, fmt);
prf(fmt, ap, putchar, 0);
+++ /dev/null
-/*
- * 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@
- */
-/*
- * Copyright 1994 NeXT Computer, Inc.
- * All rights reserved.
- */
-
-#ifndef __LIBSAIO_DRIVERS_H
-#define __LIBSAIO_DRIVERS_H
-
-struct driver_info {
- char *name;
- char *bundle;
- char *version;
- char *configTable;
- char *tableName;
- char *locationTag;
- int flags;
-};
-
-#define DRIVER_FLAG_NONE 0x00
-#define DRIVER_FLAG_INTERESTING 0x01
-#define DRIVER_FLAG_CONFIG_ADDED 0x02
-
-#define DRIVER_NOT_FOUND 0x0
-#define DRIVER_VERSION_MISMATCH 0x1
-
-extern int driverMissing;
-
-#endif /* !__LIBSAIO_DRIVERS_H */
if ( head.magic == MH_MAGIC )
{
-#if 0
- printf("oneway fat binary found\n"); sleep(1);
-#endif 1
return loadmacho(&head, dev, fd, entry, addr, size, file_offset);
}
else if ( file_offset == 0 &&
// loadmacho
int
-loadmacho(
- struct mach_header * head,
- int dev,
- int io,
- entry_t * rentry,
- char ** raddr,
- int * rsize,
- int file_offset
-)
+loadmacho( struct mach_header * head,
+ int dev,
+ int io,
+ entry_t * rentry,
+ char ** raddr,
+ int * rsize,
+ int file_offset )
{
- int ncmds;
- unsigned cmds, cp;
+ int ncmds;
+ void * cmds;
+ void * cp;
+ unsigned int entry = 0;
+ int vmsize = 0;
+ unsigned int vmaddr = ~0;
+ unsigned int vmend = 0;
+
struct xxx_thread_command {
unsigned long cmd;
unsigned long cmdsize;
unsigned long flavor;
unsigned long count;
i386_thread_state_t state;
- } *th;
- unsigned int entry = 0;
- int vmsize = 0;
- unsigned int vmaddr = ~0;
+ } * th;
// XXX should check cputype
- cmds = (unsigned int) malloc(head->sizeofcmds);
- b_lseek(io, sizeof (struct mach_header) + file_offset, 0);
+ cmds = malloc(head->sizeofcmds);
+ b_lseek(io, sizeof(struct mach_header) + file_offset, 0);
if ( read(io, (char *) cmds, head->sizeofcmds) != head->sizeofcmds )
{
case LC_SEGMENT:
addr = (scp->vmaddr & 0x3fffffff) + (int)*raddr;
if ( scp->filesize )
- {
- // Is this an OK assumption?
- // if the filesize is zero, it doesn't
- // take up any virtual space...
- // (Hopefully this only excludes PAGEZERO.)
- // Also, ignore linkedit segment when
- // computing size, because we will erase
- // the linkedit segment later.
-
- if ( strncmp(scp->segname, SEG_LINKEDIT,
- sizeof(scp->segname)) != 0)
- vmsize += scp->vmsize;
-
- vmaddr = min(vmaddr, addr);
+ {
+ vmsize += scp->vmsize;
+ vmaddr = min(vmaddr, addr);
+ vmend = max(vmend, addr + scp->vmsize);
// Zero any space at the end of the segment.
+
bzero((char *)(addr + scp->filesize),
- scp->vmsize - scp->filesize);
+ scp->vmsize - scp->filesize);
// FIXME: check to see if we overflow
// the available space (should be passed in
// as the size argument).
#if 0
- printf("LC_SEGMENT\n");
- printf("LS;file_off %x; fos %x; fsize %x ; addr %x \n",
- scp->fileoff, file_offset,scp->filesize, addr);
+ printf("LC: fileoff %x, filesize %x, off %x, addr %x\n",
+ scp->fileoff, scp->filesize, file_offset, addr);
sleep(1);
#endif
kernBootStruct->rootdev = (dev & 0xffffff00) | devMajor[Dev(dev)];
- free((char *) cmds);
+ free(cmds);
+
*rentry = (entry_t)( (int) entry & 0x3fffffff );
- *rsize = vmsize;
+ *rsize = vmend - vmaddr;
*raddr = (char *)vmaddr;
-#if 0
- printf("suceesful load;vmaddr=%x; vmsize=%x;entry=%x\n", vmaddr, vmsize,entry);
- sleep(5);
-#endif
-
return 0;
shread:
- free((char *) cmds);
- error("loadmacho: read error\n");
+ free(cmds);
return -1;
}
extern void initKernBootStruct(void);
/* console.c */
-extern BOOL verbose_mode;
+extern BOOL gVerboseMode;
extern void putchar(int ch);
extern int getchar(void);
extern int printf(const char *format, ...);
#include "libsaio.h"
#include "kernBootStruct.h"
#include "stringConstants.h"
-#include "drivers.h"
#include "legacy/configTablePrivate.h"
extern KERNBOOTSTRUCT *kernBootStruct;
char * gFilename;
-#ifdef DISABLED
-static char * deviceDirectory;
-#endif
-
extern int ram_debug_sarld; // in load.c
#define DCACHE 1
return (nb);
}
-#ifdef DISABLED
/*==========================================================================
*
*
free((void *)dirp);
return 0;
}
-#endif /* DISABLED */
/*==========================================================================
* get next entry in a directory.
#if DCACHE
cacheFlush(dcache);
#endif
-
-#ifdef DISABLED
- deviceDirectory = NULL;
-#endif /* DISABLED */
}
-
/***************************************************************************
*
* Network functions.
io->i_error = 0;
}
-
/***************************************************************************
*
* Dispatch functions.
struct dirstuff *
opendir(char * path)
{
- error("Unsupported function: opendir\n");
- return 0;
+ return disk_opendir(path);
}
/*==========================================================================
int
closedir(struct dirstuff * dirp)
{
- error("Unsupported function: closedir\n");
- return 0;
+ return disk_closedir(dirp);
}
/*==========================================================================
struct direct *
readdir(struct dirstuff * dirp)
{
- error("Unsupported function: readdir\n");
- return NULL;
+ return disk_readdir(dirp);
}
/*==========================================================================
#if CHECK_CAREFULLY /* iob[] is in BSS, so it is guaranteed to be zero. */
if (open_init == 0) {
+ int i;
for (i = 0; i < NFILES; i++)
iob[i].i_flgs = 0;
open_init = 1;
*/
-#import "rcz_common.h"
-#import "unistd.h"
+#include "rcz_common.h"
+#include <stdlib.h>
+#include <unistd.h>
static unsigned short que[QLEN];
#define REWIND -1
// extern int read(int fd, char *buf, int len);
+extern int b_lseek(int fdesc, unsigned int addr, int ptr);
static unsigned char *buf;
static int buf_count;
{
unsigned int c, j, k, jmatch, jabove;
int length;
- unsigned int even_length, word, token, version;
+ unsigned int even_length, word, token;
unsigned char *outorigin = out;
length = rcz_file_size(in_fd);
* @APPLE_LICENSE_HEADER_END@
*/
#include <stdio.h>
-
+#include <stdlib.h>
#include <mach/mach.h>
+#include <mach/mach_error.h>
#include <sys/file.h>
#include <mach-o/loader.h>
#include <architecture/byte_order.h>
+#include <unistd.h>
int infile, outfile;
struct mach_header mh;
-unsigned cmds;
+void * cmds;
boolean_t swap_ends;
return x;
}
-main(argc, argv)
-int argc;
-char *argv[];
+int
+main(int argc, char *argv[])
{
kern_return_t result;
vm_address_t data;
int nc, ncmds;
- unsigned cp;
+ char * cp;
if (argc == 2) {
infile = open(argv[1], O_RDONLY);
else if (mh.magic == MH_CIGAM)
swap_ends = TRUE;
else {
- fprintf(stderr, "bad magic number %x\n", mh.magic);
+ fprintf(stderr, "bad magic number %lx\n", mh.magic);
exit(1);
}
}
lseek(infile, swap(scp->fileoff), L_SET);
- nc = read(infile, data, swap(scp->filesize));
+ nc = read(infile, (void *)data, swap(scp->filesize));
if (nc < 0) {
perror("read segment data");
exit(1);
exit(1);
}
- nc = write(outfile, data, vmsize);
+ nc = write(outfile, (void *)data, vmsize);
if (nc < vmsize) {
perror("write segment data");
exit(1);