Index: branches/xZenu/src/modules/uClibcxx/Makefile =================================================================== --- branches/xZenu/src/modules/uClibcxx/Makefile (revision 1316) +++ branches/xZenu/src/modules/uClibcxx/Makefile (revision 1317) @@ -8,7 +8,7 @@ DIR = uClibc++ # sstream fstream MODULE_OBJS = uClibc++ abi algorithm associative_base bitset \ - complex del_op del_opnt del_opv del_opvnt \ + del_op del_opnt del_opv del_opvnt \ deque eh_alloc eh_globals exception \ func_exception iomanip char_traits \ iterator limits list locale \ @@ -17,5 +17,7 @@ stack stdexcept streambuf string typeinfo \ utility valarray vector support \ ios iostream istream ostream +#temporarily disabled for ppc +I386_OBJS = complex include ../MakeInc.dir \ No newline at end of file Index: branches/xZenu/src/modules/klibc/Makefile =================================================================== --- branches/xZenu/src/modules/klibc/Makefile (revision 1316) +++ branches/xZenu/src/modules/klibc/Makefile (revision 1317) @@ -8,7 +8,7 @@ DIR = klibc -MODULE_OBJS = klibc zalloc\ +MODULE_OBJS = klibc zalloc __extendsfdf2\ __ashldi3 __ashrdi3 __clzsi2 __divdi3 __divsi3 \ __lshrdi3 __moddi3 __modsi3 __udivdi3 \ __udivmoddi4 __udivmodsi4 __udivsi3 \ Index: branches/xZenu/src/arch/ppc/include/device_tree.h =================================================================== --- branches/xZenu/src/arch/ppc/include/device_tree.h (revision 1316) +++ branches/xZenu/src/arch/ppc/include/device_tree.h (revision 1317) @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * 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. - * - * This 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@ - */ -/* - * device_tree.h - Data structures for the flattened device tree. - * - * Copyright (c) 1998-2000 Apple Computer, Inc. - * - * DRI: Josh de Cesare - */ - -#ifndef _BOOTX_DEVICE_TREE_H_ -#define _BOOTX_DEVICE_TREE_H_ - -#define kPropNameLength (32) -#define kPropValueMaxLength (0x100000) - -struct DTProperty { - char name[kPropNameLength]; // NUL terminated property name - unsigned long length; // Length (bytes) of property value that follows - //unsigned long value[1]; // Variable length value of property - // Padded to a multiple of a longword -}; -typedef struct DTProperty DTProperty, *DTPropertyPtr; - -struct DTNode { - unsigned long nProperties; // Number of props[] elements (0 => end of list) - unsigned long nChildren; // Number of children[] elements - //DTProperty props[]; // nProperties DeviceTreeNodeProperty structs - //DTNode children[]; // nChildren DeviceTreeNode structs -}; -typedef struct DTNode DTNode, *DTNodePtr; - -#endif /* ! _BOOTX_DEVICE_TREE_H_ */ Index: branches/xZenu/src/arch/ppc/include/boot_args.h =================================================================== --- branches/xZenu/src/arch/ppc/include/boot_args.h (revision 1316) +++ branches/xZenu/src/arch/ppc/include/boot_args.h (revision 1317) @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * 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. - * - * This 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@ - */ -/* - * boot_args.h - Data stuctures for the information passed to the kernel. - * - * Copyright (c) 1998-2003 Apple Computer, Inc. - * - * DRI: Josh de Cesare - */ - -#ifndef _BOOTX_BOOT_ARGS_H_ -#define _BOOTX_BOOT_ARGS_H_ - -// 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 */ -}; -typedef struct Boot_Video Boot_Video, *Boot_Video_Ptr; - - -// DRAM Bank definitions - describes physical memory layout. -#define kMaxDRAMBanks (26) /* maximum number of DRAM banks */ - -struct DRAMBank { - unsigned long base; /* physical base of DRAM bank */ - unsigned long size; /* size of bank */ -}; -typedef struct DRAMBank DRAMBank, *DRAMBankPtr; - - -// Boot argument structure - passed into kernel at boot time. - -#define kBootArgsRevision (1) -#define kBootArgsVersion1 (1) -#define kBootArgsVersion2 (2) - -#define BOOT_LINE_LENGTH (256) - -struct boot_args { - unsigned short Revision; /* Revision of boot_args structure */ - unsigned short Version; /* Version of boot_args structure */ - char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */ - DRAMBank PhysicalDRAM[kMaxDRAMBanks]; /* base/range pairs for the 26 DRAM banks */ - Boot_Video Video; /* Video Information */ - unsigned long machineType; /* Machine Type (gestalt) */ - void *deviceTreeP; /* Base of flattened device tree */ - unsigned long deviceTreeLength; /* Length of flattened tree */ - unsigned long topOfKernelData; /* Last address of kernel data area*/ -}; -typedef struct boot_args boot_args, *boot_args_ptr; - -struct compressed_kernel_header { - u_int32_t signature; - u_int32_t compress_type; - u_int32_t adler32; - u_int32_t uncompressed_size; - u_int32_t compressed_size; - u_int32_t reserved[11]; - char platform_name[64]; - char root_path[256]; - u_int8_t data[0]; -}; -typedef struct compressed_kernel_header compressed_kernel_header; - -#endif /* ! _BOOTX_BOOT_ARGS_H_ */ Index: branches/xZenu/src/arch/ppc/include/fs.h =================================================================== --- branches/xZenu/src/arch/ppc/include/fs.h (revision 1316) +++ branches/xZenu/src/arch/ppc/include/fs.h (revision 1317) @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple Inc. All rights reserved. - * - * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. The rights granted to you under the License - * may not be used to create, or enable the creation or redistribution of, - * unlawful or unlicensed copies of an Apple operating system, or to - * circumvent, violate, or enable the circumvention or violation of, any - * terms of an Apple operating system software license agreement. - * - * Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ - */ - -/* - * fs.h - Externs for the File System Modules - * - * Copyright (c) 1999-2004 Apple Computer, Inc. - * - * DRI: Josh de Cesare - */ - -#ifndef _BOOTX_FS_H_ -#define _BOOTX_FS_H_ - -// Externs for fs.c -extern long LoadFile(char *fileSpec); -extern long LoadThinFatFile(char *fileSpec, void **binary); -extern long GetFileInfo(char *dirSpec, char *name, long *flags, long *time); -extern long GetDirEntry(char *dirSpec, unsigned long *dirIndex, char **name, - long *flags, long *time); -extern long DumpDir(char *dirSpec); -extern long GetFSUUID(char *devSpec, char *uuidStr); -extern long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr); - -// Externs for cache.c -extern unsigned long gCacheHits; -extern unsigned long gCacheMisses; -extern unsigned long gCacheEvicts; - -extern void CacheInit(CICell ih, long chunkSize); -extern long CacheRead(CICell ih, char *buffer, long long offset, - long length, long cache); - -// Externs for net.c -extern CICell NetInitPartition(char *devSpec); -extern long NetLoadFile(CICell ih, char *filePath); -extern long NetGetDirEntry(CICell ih, char *dirPath, - unsigned long *dirIndex, char **name, - long *flags, long *time); - -// Externs for hfs.c -// Note: the offset parameters are only used by mach-o routines. -// We don't support mach-o binaries > 4 GB. -extern long HFSInitPartition(CICell ih); -extern long HFSLoadFile(CICell ih, char *filePath); -extern long HFSReadFile(CICell ih, char *filePath, - void *base, unsigned long offset, - unsigned long length); -extern long HFSGetDirEntry(CICell ih, char *dirPath, - unsigned long *dirIndex, char **name, - long *flags, long *time); -extern long HFSGetUUID(CICell ih, char *uuidStr); - -// Externs for ufs.c -extern long UFSInitPartition(CICell ih); -extern long UFSLoadFile(CICell ih, char *filePath); -extern long UFSReadFile(CICell ih, char *filePath, - void *base, unsigned long offset, - unsigned long length); -extern long UFSGetDirEntry(CICell ih, char *dirPath, - unsigned long *dirIndex, char **name, - long *flags, long *time); -extern long UFSGetUUID(CICell ih, char *uuidStr); - -// Externs for ext2.c -extern long Ext2InitPartition(CICell ih); -extern long Ext2LoadFile(CICell ih, char *filePath); -extern long Ext2GetDirEntry(CICell ih, char *dirPath, - unsigned long *dirIndex, char **name, - long *flags, long *time); -extern long Ext2GetUUID(CICell ih, char *uuidStr); - -#endif /* ! _BOOTX_FS_H_ */ Index: branches/xZenu/src/arch/ppc/include/sl.h =================================================================== --- branches/xZenu/src/arch/ppc/include/sl.h (revision 1316) +++ branches/xZenu/src/arch/ppc/include/sl.h (revision 1317) @@ -158,31 +158,7 @@ #include #include #include -#include -#include -// types for plist.c -typedef enum { - kTagTypeNone = 0, - kTagTypeDict, - kTagTypeKey, - kTagTypeString, - kTagTypeInteger, - kTagTypeData, - kTagTypeDate, - kTagTypeFalse, - kTagTypeTrue, - kTagTypeArray -} TagType; - -struct Tag { - TagType type; - char *string; - struct Tag *tag; - struct Tag *tagNext; -}; -typedef struct Tag Tag, *TagPtr; - // Externs for main.c extern char *gVectorSaveAddr; extern long gKernelEntryPoint; @@ -199,7 +175,6 @@ extern char gHaveKernelCache; extern char gBootDevice[256]; extern char gBootFile[256]; -extern TagPtr gBootDict; extern char gTempStr[4096]; @@ -223,73 +198,4 @@ extern CICell gStdOutIH; extern CICell gKeyboardIH; -// useful to activate debug logs near when a problem happens -//extern int gDebugCount; - -extern long ThinFatBinary(void **binary, unsigned long *length); -extern long GetDeviceType(char *devSpec); -extern long ConvertFileSpec(char *fileSpec, char *devSpec, char **filePath); -extern long MatchThis(CICell phandle, char *string); -extern void *AllocateBootXMemory(long size); -extern long AllocateKernelMemory(long size); -extern long AllocateMemoryRange(char *rangeName, long start, long length); -extern unsigned long Adler32(unsigned char *buffer, long length); - -// Externs for macho.c -extern long ThinFatBinaryMachO(void **binary, unsigned long *length); -extern long DecodeMachO(void *binary); - -// Externs for elf.c -extern long ThinFatBinaryElf(void **binary, unsigned long *length); -extern long DecodeElf(void *binary); - -// Externs for device_tree.c -extern long FlattenDeviceTree(void); -extern CICell SearchForNode(CICell ph, long top, char *prop, char *value); -extern CICell SearchForNodeMatching(CICell ph, long top, char *value); - -// Externs for display.c -extern long InitDisplays(int fill); -extern long DrawSplashScreen(long stage); -extern long DrawFailedBootPicture(void); -extern void GetMainScreenPH(Boot_Video_Ptr video, int setProperties); -void SplashPreview(void *src, u_int8_t * saveunder, u_int32_t savelen); -void SplashProgress(u_int8_t * saveunder, int32_t firstBlob, int32_t select); - -// Externs for bmdecompress.c -extern int DecompressData(void *srcbase, void *dstbase, - int dw, int dh, int bytesPerPixel, int rowbytes); - -// Externs for drivers.c -extern long LoadDrivers(char *dirPath); - -// Externs for config.c -extern long InitConfig(void); -extern long ParseConfigFile(char *addr); - -// Externs for lzss.c -extern int decompress_lzss(u_int8_t *dst, u_int8_t *src, u_int32_t srclen); - - -// Externs for plist.c -extern TagPtr GetProperty(TagPtr dict, char *key); -extern long ParseXML(char *buffer, TagPtr *dict); -extern void FreeTag(TagPtr tag); -#if PLIST_DEBUG -extern void DumpTag(TagPtr tag, long depth); -#endif - - -// Externs/types for raid.c -typedef struct RAIDMember *RAIDDevicePtr; - -extern int isRAIDPath(char *devSpec); -extern int isRAIDDevice(void *ih); -extern long LookForRAID(TagPtr bootDict); -extern RAIDDevicePtr RAIDOpen(char *devSpec); -extern void RAIDClose(RAIDDevicePtr raid); -extern long RAIDRead(RAIDDevicePtr raid, long a, long n, long long offset); -extern long RAIDSeek(RAIDDevicePtr raid, long long position); - - #endif /* ! _BOOTX_SL_H_ */ Index: branches/xZenu/src/arch/ppc/boot2/Control2.c =================================================================== --- branches/xZenu/src/arch/ppc/boot2/Control2.c (revision 0) +++ branches/xZenu/src/arch/ppc/boot2/Control2.c (revision 1317) @@ -0,0 +1,527 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * 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. + * + * This 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@ + */ +/* + * Control2.c - OF replacement driver for Control. + * + * Copyright (c) 1998-2000 Apple Computer, Inc. + * + * DRI: Josh de Cesare + */ + +const char *gControl2Source[] = { + "\" /chaos/control\" find-device " + "-1 value bankB? " + "-1 value REGS " + "-1 value FB-ADDRESS " + "-1 value phys-regs " + "-1 value phys-fb-address " + "0 value mono-mode? " + "0 value width " + "0 value height " + "0 value sense-code " + "0 value ext-sense " + "h# F301B000 constant RADACAL " + "h# F301B000 constant RADACAL-base " + "variable RGB-temp " + "struct " + "( 000 ) d# 16 field >C.CUR-LINE " + "( 010 ) d# 16 field >C.VFPEQ " + "( 020 ) d# 16 field >C.VFP " + "( 030 ) d# 16 field >C.VAL " + "( 040 ) d# 16 field >C.VBP " + "( 050 ) d# 16 field >C.VBPEQ " + "( 060 ) d# 16 field >C.VSYNC " + "( 070 ) d# 16 field >C.VHLINE " + "( 080 ) d# 16 field >C.PIPED " + "( 090 ) d# 16 field >C.HPIX " + "( 0A0 ) d# 16 field >C.HFP " + "( 0B0 ) d# 16 field >C.HAL " + "( 0C0 ) d# 16 field >C.HBWAY " + "( 0D0 ) d# 16 field >C.HSP " + "( 0E0 ) d# 16 field >C.HEQ " + "( 0F0 ) d# 16 field >C.HLFLN " + "( 100 ) d# 16 field >C.HSERR " + "( 110 ) d# 16 field >C.CNTTST " + "( 120 ) d# 16 field >C.TEST " + "( 130 ) d# 16 field >C.GBASE " + "( 140 ) d# 16 field >C.ROW-WORDS " + "( 150 ) d# 16 field >C.MON-SENSE " + "( 160 ) d# 16 field >C.ENABLE " + "( 170 ) d# 16 field >C.GSC-DIVIDE " + "( 180 ) d# 16 field >C.REFRESH-COUNT " + "( 190 ) d# 16 field >C.INT-ENABLE " + "( 1A0 ) d# 16 field >C.INT-STATUS " + "drop " + "struct " + "d# 16 field >R.REG-ADDR " + "d# 16 field >R.CRSR-PALETTE " + "d# 16 field >R.REG-DATA " + "d# 16 field >R.COLOR-PALETTE " + "drop " + "create k512x384@60 " + "h# 0E1B6210 L, " + "d# 811 w, d# 810 w, d# 42 w, d# 23 w, d# 4 w, d# 812 w, d# 814 w, d# 48 w, " + "d# 318 w, d# 305 w, d# 49 w, d# 15 w, d# 319 w, d# 8 w, d# 160 w, d# 304 w, " + "d# 2 w, d# 512 w, d# 384 w, " + "create k640x480@67 " + "h# 0E1B0210 L, " + "d# 1045 w, d# 1042 w, d# 82 w, d# 43 w, d# 4 w, d# 1048 w, d# 1050 w, d# 72 w, " + "d# 430 w, d# 393 w, d# 73 w, d# 31 w, d# 431 w, d# 16 w, d# 216 w, d# 400 w, " + "d# 2 w, d# 640 w, d# 480 w, " + "create k640x870@75 " + "h# 172A0310 L, " + "d# 1831 w, d# 1828 w, d# 88 w, d# 46 w, d# 4 w, d# 1834 w, d# 1836 w, d# 72 w, " + "d# 414 w, d# 393 w, d# 73 w, d# 39 w, d# 415 w, d# 20 w, d# 208 w, d# 376 w, " + "d# 2 w, d# 640 w, d# 870 w, " + "create k640x480@60VGA " + "h# 17250210 L, " + "d# 1037 w, d# 1026 w, d# 66 w, d# 34 w, d# 2 w, d# 1048 w, d# 1050 w, d# 64 w, " + "d# 398 w, d# 385 w, d# 65 w, d# 47 w, d# 399 w, d# 24 w, d# 200 w, d# 352 w, " + "d# 2 w, d# 640 w, d# 480 w, " + "create k832x624@75 " + "h# 172A0310 L, " + "d# 1331 w, d# 1330 w, d# 82 w, d# 43 w, d# 4 w, d# 1332 w, d# 1334 w, d# 136 w, " + "d# 574 w, d# 553 w, d# 137 w, d# 31 w, d# 575 w, d# 16 w, d# 288 w, d# 544 w, " + "d# 2 w, d# 832 w, d# 624 w, " + "create k1024x768@75 " + "h# 0B1C0310 L, " + "d# 1603 w, d# 1600 w, d# 64 w, d# 34 w, d# 4 w, d# 1606 w, d# 1608 w, d# 128 w, " + "d# 662 w, d# 641 w, d# 129 w, d# 47 w, d# 663 w, d# 24 w, d# 332 w, d# 616 w, " + "d# 2 w, d# 1024 w, d# 768 w, " + "create k1152x870@75 " + "h# 133D0310 L, " + "d# 1825 w, d# 1822 w, d# 82 w, d# 43 w, d# 4 w, d# 1828 w, d# 1830 w, d# 128 w, " + "d# 726 w, d# 705 w, d# 129 w, d# 63 w, d# 727 w, d# 32 w, d# 364 w, d# 664 w, " + "d# 2 w, d# 1152 w, d# 870 w, " + ": SENSE! 5 ms regs >C.MON-SENSE rl! 5 ms ; " + ": SENSE@ 5 ms regs >C.MON-SENSE rl@ 5 ms ; " + ": MON-SENSE ( -- ) " + "o# 70 sense! " + "sense@ 6 >> 7 and dup to sense-code " + "dup 6 < if " + "b# 1000000 or " + "else drop " + "o# 30 sense! " + "sense@ 2 >> b# 110000 and " + "o# 50 sense! " + "sense@ dup 4 >> b# 000100 and swap 5 >> b# 001000 and or or " + "o# 60 sense! sense@ 7 >> b# 000011 and or " + "to ext-sense " + "then " + "o# 70 sense! " + "; " + ": get-mode ( -- mode-table mono-mode? ) " + "sense-code case " + "0 of " + "false " + "k1152x870@75 " + "endof " + "1 of " + "true " + "k640x870@75 " + "endof " + "2 of " + "false " + "k512x384@60 " + "endof " + "3 of " + "true " + "k1152x870@75 " + "endof " + "5 of " + "false " + "k640x870@75 " + "endof " + "6 of " + "ext-sense case " + "3 of " + "false " + "k832x624@75 " + "endof " + "h# 0b of " + "false " + "k1024x768@75 " + "endof " + "h# 23 of " + "false " + "k1152x870@75 " + "endof " + "drop " + "false " + "k640x480@67 " + "0 endcase " + "endof " + "7 of " + "ext-sense case " + "h# 2d of " + "false " + "k832x624@75 " + "endof " + "h# 3a of " + "false " + "k1024x768@75 " + "endof " + "h# 17 of " + "false " + "k640x480@60VGA " + "endof " + "h# 3f of " + "false " + "0 " + "endof " + "drop " + "false " + "k640x480@67 " + "0 endcase " + "endof " + "drop " + "false " + "k640x480@67 " + "0 endcase " + "; " + "HEADERLESS " + "create std-16 " + "\" \"(000000 0000AA 00AA00 00AAAA AA0000 AA00AA AA5500 AAAAAA)\" $c, " + "\" \"(555555 5555FF 55FF55 55FFFF FF5555 FF55FF FFFF55 FFFFFF)\" $c, " + "create std-gamma " + "\" \"(00 05 09 0B 0E 10 13 15 17 19 1B 1D 1E 20 22 24)\" $c, " + "\" \"(25 27 28 2A 2C 2D 2F 30 31 33 34 36 37 38 3A 3B)\" $c, " + "\" \"(3C 3E 3F 40 42 43 44 45 47 48 49 4A 4B 4D 4E 4F)\" $c, " + "\" \"(50 51 52 54 55 56 57 58 59 5A 5B 5C 5E 5F 60 61)\" $c, " + "\" \"(62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71)\" $c, " + "\" \"(72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 81)\" $c, " + "\" \"(81 82 83 84 85 86 87 88 89 8A 8B 8C 8C 8D 8E 8F)\" $c, " + "\" \"(90 91 92 93 94 95 95 96 97 98 99 9A 9B 9B 9C 9D)\" $c, " + "\" \"(9E 9F A0 A1 A1 A2 A3 A4 A5 A6 A6 A7 A8 A9 AA AB)\" $c, " + "\" \"(AB AC AD AE AF B0 B0 B1 B2 B3 B4 B4 B5 B6 B7 B8)\" $c, " + "\" \"(B8 B9 BA BB BC BC BD BE BF C0 C0 C1 C2 C3 C3 C4)\" $c, " + "\" \"(C5 C6 C7 C7 C8 C9 CA CA CB CC CD CD CE CF D0 D0)\" $c, " + "\" \"(D1 D2 D3 D3 D4 D5 D6 D6 D7 D8 D9 D9 DA DB DC DC)\" $c, " + "\" \"(DD DE DF DF E0 E1 E1 E2 E3 E4 E4 E5 E6 E7 E7 E8)\" $c, " + "\" \"(E9 E9 EA EB EC EC ED EE EE EF F0 F1 F1 F2 F3 F3)\" $c, " + "\" \"(F4 F5 F5 F6 F7 F8 F8 F9 FA FA FB FC FC FD FE FF)\" $c, " + ": c+ ( adr -- adr+1 val ) " + "dup 1+ swap c@ " + "; " + ": c!+ ( adr val -- adr+1 ) " + "swap dup 1+ -rot c! " + "; " + ": do-gamma " + "std-gamma + c@ " + "; " + ": anti-gamma ( val -- orig ) " + "h# 100 0 do " + "std-gamma i + c@ over >= if " + "drop i unloop exit " + "then " + "loop " + "drop h# ff " + "; " + ": W@++ ( addr -- addr word ) " + "dup 2+ swap w@ " + "; " + ": CLUT@ ( -- ) " + "3 0 do RADACAL-base >R.COLOR-PALETTE rb@ loop 2 ms " + "; " + ": CLUT! ( -- ) " + "3 0 do RADACAL-base >R.COLOR-PALETTE rb! loop 2 ms " + "; " + ": RAD-REG-ADDR! " + "RADACAL-base >R.REG-ADDR rb! 2 ms " + "; " + ": RAD! ( c a -- ) " + "( a ) rad-reg-addr! " + "( c ) RADACAL-base >R.REG-DATA rb! 2 ms " + "; " + ": init-RADACAL ( val -- ) " + "( val ) h# 20 rad! " + "bankb? 1 and h# 21 rad! " + "0 h# 10 rad! " + "0 h# 11 rad! " + "; " + "h# F3016000 constant vPortB " + "h# F3016400 constant vDDRB " + "h# F3017400 constant vSHR " + "h# F3017600 constant vACR " + "h# F3017800 constant vPCR " + "h# F3017A00 constant vIFR " + "h# F3017C00 constant vIER " + "h# 0C constant kSRModeIn " + "h# 1C constant kSRModeOut " + "h# 04 constant kSRIReq " + "h# 10 constant kByteAckBit " + "h# DF constant kAssertTIP " + "h# 20 constant kNegateTIP " + "h# EF constant kAssertByteAck " + "h# 10 constant kNegateByteAck " + "h# 30 constant kTIPByteAckNeg " + "h# 08 constant kTREQBit " + ": setByteAck " + "vPortB rb@ swap if " + "kAssertByteAck and " + "else " + "kNegateByteAck or " + "then " + "vPortB rb! " + "; " + ": ToggleByteAck " + "vPortB rb@ kByteAckBit and setByteAck " + "; " + ": setTIP " + "vPortB rb@ swap if " + "kAssertTIP and " + "else " + "kTIPByteAckNeg or " + "then " + "vPortB rb! " + "; " + ": ?TREQ vPortB rb@ kTREQbit and 0= ; " + ": WaitTREQ " + "begin " + "?TREQ until " + "; " + ": WaitVIAInt " + "begin " + "vIFR rb@ kSRIReq and until " + "; " + ": WaitATTN " + "WaitVIAInt " + "vSHR rb@ drop " + "; " + ": get-response ( -- ) " + "WaitATTN " + "true setTIP " + "begin " + "WaitATTN " + "?TREQ while " + "ToggleByteAck " + "repeat " + "false setTIP " + "false setByteAck " + "WaitATTN " + "; " + ": start-send ( c -- ) " + "kSRModeOut vACR rb! " + "( c ) vSHR rb! " + "true setTIP " + "; " + ": cuda-write { _adr _len ; _actual _data } " + "?TREQ if get-response then " + "_adr c@ start-send " + "begin " + "WaitVIAInt " + "?TREQ while " + "vSHR rb@ drop " + "false setTIP " + "get-response " + "_adr c@ start-send " + "repeat " + "1 -> _actual " + "_len 1 ?do " + "_adr i + c@ vSHR rb! " + "_actual 1+ -> _actual " + "ToggleByteAck " + "WaitVIAInt " + "loop " + "2 ms " + "kSRModeIn vACR rb! " + "vSHR rb@ drop " + "false setTIP " + "false setByteAck " + "_actual " + "; " + ": cuda-read ( _adr _len -- _actual ) " + "get-response " + "nip " + "; " + "8 buffer: athens-data \" \"(012250FFFF)\" athens-data swap move " + "8 buffer: athens-rsp " + ": write-IIC ( -- ) " + "athens-data 5 cuda-write drop " + "athens-rsp 3 cuda-read drop " + "; " + ": init-ATHENS ( P2Mux N2 D2 -- ) " + "4 1 do " + "i athens-data 3 + c! ( val ) athens-data 4 + c! " + "( athens-data 5 dump cr ) " + "write-IIC " + "loop " + "; " + ": ping-CONTROL ( enable-bit -- ) " + "5 ms " + "dup 8 or swap " + "dup regs >C.TEST rl! 5 ms " + "swap dup regs >C.TEST rl! 5 ms " + "swap dup regs >C.TEST rl! 5 ms " + "swap dup regs >C.TEST rl! 5 ms " + "2drop " + "; " + ": reset-CONTROL " + "h# 433 ping-CONTROL " + "1 regs >C.GSC-DIVIDE rl! " + "; " + ": enable-CONTROL " + "h# 033 ping-CONTROL " + "; " + ": init-CONTROL ( tbl-ptr -- ) " + "-1 to bankb? " + "phys-fb-address dup h# 1000 _I_G do-map " + "h# 31 regs >C.ENABLE rl! " + "h# 12345678 phys-fb-address rl! " + "regs >C.ENABLE rl@ drop " + "h# 12345678 phys-fb-address rl@ <> " + "phys-fb-address h# 1000 do-unmap " + "if " + "0 to bankb? " + "phys-fb-address h# 600000 or to phys-fb-address " + "then " + "dup @ ( dup .h ) lbsplit init-ATHENS init-RADACAL cell+ " + "d# 16 0 do " + "w@++ ( dup .d ) regs >C.VFPEQ i 4 << + ( dup .h cr ) rl! " + "loop " + "w@++ regs >C.GSC-DIVIDE rl! " + "w@++ dup to width regs >C.ROW-WORDS rl! " + "w@ to height " + "h# 31 bankB? not 8 and or " + "little? 2 and or regs >C.ENABLE rl! " + "0 regs >C.GBASE rl! " + "h# 01e4 regs >C.REFRESH-COUNT rl! " + "0 regs >C.INT-ENABLE rl! " + "; " + ": my-open " + "\" assigned-addresses\" get-my-property " + "abort\" no REG property\" ( prop-adr prop-len ) " + "begin " + "dup 0> while " + "decode-int h# FF and >r decode-int drop decode-int >r " + "8 - swap 8 + swap ( prop-adr prop-len ) " + "r> r> case " + "h# 14 of " + "to phys-regs " + "endof " + "h# 18 of " + "h# 00800000 + to phys-fb-address " + "endof " + "swap drop " + "endcase " + "repeat " + "2drop " + "phys-regs 0 my-space h# 02000000 or h# 1000 \" map-in\" $call-parent to regs " + "reset-CONTROL " + "mon-sense " + "get-mode swap to mono-mode? " + "( mode-dependent-table-addr ) " + "dup 0= if " + "abort " + "then " + "( mode-dependent-table-addr ) " + "init-CONTROL " + "std-16 0 d# 16 set-colors " + "enable-CONTROL " + "phys-fb-address 0 my-space h# 02000000 or width height * \" map-in\" $call-parent to fb-address " + "fb-address width height * 7 fill " + "default-font set-font " + "width height over 20 - char-width / over 20 - char-height / fb8-install " + "width #columns char-width * - 2/ to window-left " + "height #lines char-height * - 2/ to window-top " + "fb-address to frame-buffer-adr " + "width encode-int \" width\" property " + "height encode-int \" height\" property " + "width encode-int \" linebytes\" property " + "8 encode-int \" depth\" property " + "; " + ": my-close " + "fb-address height width * \" map-out\" $call-parent " + "regs h# 1000 \" map-out\" $call-parent " + "; " + "EXTERNAL " + ": DIMENSIONS " + "width height " + "; " + ": SET-COLORS ( adr index #indices ) " + "swap RAD-REG-ADDR! " + "( #indices ) 0 ?do ( adr ) " + "mono-mode? if " + "c+ h# 4d * >r ( red adr ) " + "c+ h# 97 * >r ( red green adr ) " + "c+ h# 1c * ( red green blue adr ) " + "r> + r> + 8 >> ( luminance ) " + "do-gamma " + "dup " + "dup " + "CLUT! " + "( adr ) " + "else " + "c+ do-gamma swap ( R adr ) " + "c+ do-gamma swap ( R G adr ) " + "c+ do-gamma swap ( R G B adr ) " + ">r swap rot CLUT! r> ( B G R ) " + "then " + "loop ( adr ) " + "drop " + "; " + ": GET-COLORS ( adr index #indices -- ) " + "swap ( index ) RAD-REG-ADDR! ( #indices ) 0 ?do " + "CLUT@ anti-gamma >r anti-gamma >r anti-gamma ( R ) " + "c!+ r> c!+ r> c!+ " + "loop " + "drop " + "; " + ": COLOR! ( r g b index -- ) " + ">r RGB-temp 2+ c! RGB-temp 1+ c! RGB-temp c! " + "RGB-temp r> 1 set-colors " + "; " + ": COLOR@ ( index -- r g b ) " + "RGB-temp swap 1 get-colors " + "RGB-temp c+ swap c+ swap c@ " + "; " + ": rect-setup ( adr|index x y w h -- w adr|index xy-adr h ) " + ">r >r width * + fb-address + r> -rot r> " + "; " + ": DRAW-RECTANGLE ( adr x y w h -- ) " + "rect-setup " + "( h ) 0 ?do ( w adr xy-adr ) " + "2dup 4 pick move " + "2 pick width d+ " + "loop " + "3drop " + "; " + ": FILL-RECTANGLE ( index x y w h -- ) " + "rect-setup ( w index xy-adr h ) " + "( h ) 0 ?do ( w index xy-adr ) " + "dup 3 pick 3 pick fill " + "width + " + "loop " + "3drop " + "; " + ": READ-RECTANGLE ( adr x y w h -- ) " + "rect-setup >r swap r> ( w xy-adr adr h ) " + "( h ) 0 ?do " + "2dup 4 pick move " + "width 3 pick d+ " + "loop " + "3drop " + "; " + "['] my-open is-install " + "['] my-close is-remove " +, + " device-end",0}; Index: branches/xZenu/src/arch/ppc/boot2/ci_io.c =================================================================== --- branches/xZenu/src/arch/ppc/boot2/ci_io.c (revision 0) +++ branches/xZenu/src/arch/ppc/boot2/ci_io.c (revision 1317) @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * 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. + * + * This 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@ + */ +/* + * ci_io.c - Primitive OF based IO function for libclite. + * + * Copyright (c) 1998-2002 Apple Computer, Inc. + * + * DRI: Josh de Cesare + */ + +#include +#include +#include + +#include + +int putchar(int ch) +{ + if ((ch == '\r') || (ch == '\n')) CallMethod(0, 0, SLWordsIH, "slw_cr"); + else CallMethod(1, 0, SLWordsIH, "slw_emit", ch); + + return ch; +} + +int puts(const char *str) +{ + while (*str != '\0') + putchar(*str++); + + putchar('\n'); + + return 0; +} + +int getchar() +{ + printf("ERROR: getchar not implimented.\n"); + while(1); +} \ No newline at end of file Index: branches/xZenu/src/arch/ppc/boot2/main.c =================================================================== --- branches/xZenu/src/arch/ppc/boot2/main.c (revision 0) +++ branches/xZenu/src/arch/ppc/boot2/main.c (revision 1317) @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +/* + * main.c - Main functions for BootX. + * + * Copyright (c) 1998-2004 Apple Computer, Inc. + * + * DRI: Josh de Cesare + */ + + +#include +#include +#include + +extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int)); + +static void Start(void *unused1, void *unused2, ClientInterfacePtr ciPtr); +static void Main(ClientInterfacePtr ciPtr); +static long InitEverything(ClientInterfacePtr ciPtr); +static long InitMemoryMap(void); +static long GetOFVersion(void); +static void malloc_error(char *addr, size_t size, const char *file, int line); + +const unsigned long StartTVector[2] = {(unsigned long)Start, 0}; + + +char gStackBaseAddr[0x8000]; + +long gOFVersion = 0; + +char *gKeyMap; + +long gRootAddrCells; +long gRootSizeCells; + +CICell gChosenPH; +CICell gMemoryMapPH; +CICell gStdOutPH; + +CICell gMMUIH; +CICell gMemoryIH; +CICell gStdOutIH; +CICell gKeyboardIH; + + +// Private Functions + +static void malloc_error(char *addr, size_t size, const char *file, int line) +{ + printf("\nMemory allocation error! Addr=0x%x, Size=0x%x, File=%s, Line=%d\n", (unsigned)addr, (unsigned)size, file, line); + while(1); +} + + +static void Start(void *unused1, void *unused2, ClientInterfacePtr ciPtr) +{ + long newSP; + + // Move the Stack to a chunk of the BSS + newSP = (long)gStackBaseAddr + sizeof(gStackBaseAddr) - 0x100; + __asm__ volatile("mr r1, %0" : : "r" (newSP)); + + Main(ciPtr); +} + +static void Main(ClientInterfacePtr ciPtr) +{ + long ret; + + ret = InitEverything(ciPtr); + if (ret != 0) Exit(); + +} +static long InitEverything(ClientInterfacePtr ciPtr) +{ + long ret, size; + CICell keyboardPH; + char name[32]; + + // Init the OF Client Interface. + ret = InitCI(ciPtr); + if (ret != 0) return -1; + + // Get the OF Version + gOFVersion = GetOFVersion(); + if (gOFVersion == 0) return -1; + + // Get the address and size cells for the root. + GetProp(Peer(0), "#address-cells", (char *)&gRootAddrCells, 4); + GetProp(Peer(0), "#size-cells", (char *)&gRootSizeCells, 4); + if ((gRootAddrCells > 2) || (gRootAddrCells > 2)) return -1; + + // Init the SL Words package. + ret = InitSLWords(); + if (ret != 0) return -1; + + + // Get the phandle for /chosen + gChosenPH = FindDevice("/chosen"); + if (gChosenPH == -1) return -1; + + // Init the Memory Map. + ret = InitMemoryMap(); + if (ret != 0) return -1; + + // Get IHandles for the MMU and Memory + size = GetProp(gChosenPH, "mmu", (char *)&gMMUIH, 4); + if (size != 4) { + printf("Failed to get the IH for the MMU.\n"); + return -1; + } + size = GetProp(gChosenPH, "memory", (char *)&gMemoryIH, 4); + if (size != 4) { + printf("Failed to get the IH for the Memory.\n"); + return -1; + } + + // Get stdout's IH, so that the boot display can be found. + ret = GetProp(gChosenPH, "stdout", (char *)&gStdOutIH, 4); + if (ret == 4) gStdOutPH = InstanceToPackage(gStdOutIH); + else gStdOutPH = gStdOutIH = 0; + + // Try to find the keyboard using chosen + ret = GetProp(gChosenPH, "stdin", (char *)&gKeyboardIH, 4); + if (ret != 4) gKeyboardIH = 0; + else { + keyboardPH = InstanceToPackage(gKeyboardIH); + ret = GetProp(keyboardPH, "name", name, 31); + if (ret != -1) { + name[ret] = '\0'; + if (strcmp(name, "keyboard") && strcmp(name, "kbd")) gKeyboardIH = 0; + } else gKeyboardIH = 0; + } + + // Try to the find the keyboard using open if chosen did not work. + if (gKeyboardIH == 0) gKeyboardIH = Open("keyboard"); + if (gKeyboardIH == 0) gKeyboardIH = Open("kbd"); + + // Get the key map set up, and make it up to date. + gKeyMap = InitKeyMap(gKeyboardIH); + if (gKeyMap == NULL) return -1; + UpdateKeyMap(); + + SetOutputLevel(kOutputLevelFull); + + // printf now works. + printf("\n\nMac OS X Loader\n"); + + // Claim memory for malloc. + if (Claim(kMallocAddr, kMallocSize, 0) == 0) { + printf("Claim for malloc failed.\n"); + return -1; + } + malloc_init((char *)kMallocAddr, kMallocSize, 768, malloc_error); + + + return 0; +} + +static long InitMemoryMap(void) +{ + long result; + + result = Interpret(0, 1, + " dev /chosen" + " new-device" + " \" memory-map\" device-name" + " active-package" + " device-end" + , &gMemoryMapPH); + + return result; +} + + +static long GetOFVersion(void) +{ + CICell ph; + char versStr[256], *tmpStr; + long vers, size; + + // Get the openprom package + ph = FindDevice("/openprom"); + if (ph == -1) return 0; + + // Get it's model property + size = GetProp(ph, "model", versStr, 255); + if (size == -1) return -1; + versStr[size] = '\0'; + + // Find the start of the number. + tmpStr = NULL; + if (!strncmp(versStr, "Open Firmware, ", 15)) { + tmpStr = versStr + 15; + } else if (!strncmp(versStr, "OpenFirmware ", 13)) { + tmpStr = versStr + 13; + } else return -1; + + // Clasify by each instance as needed... + switch (*tmpStr) { + case '1' : + vers = kOFVersion1x; + break; + + case '2' : + vers = kOFVersion2x; + break; + + case '3' : + vers = kOFVersion3x; + break; + + case '4' : + vers = kOFVersion4x; + break; + + default : + vers = 0; + break; + } + + return vers; +} \ No newline at end of file Index: branches/xZenu/src/arch/ppc/boot2/MAC-PARTS.c =================================================================== --- branches/xZenu/src/arch/ppc/boot2/MAC-PARTS.c (revision 0) +++ branches/xZenu/src/arch/ppc/boot2/MAC-PARTS.c (revision 1317) @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * 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. + * + * This 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@ + */ +/* + * MAC-PARTS.c - Tokenized version of New World mac-parts package. + * + * Copyright (c) 1999-2000 Apple Computer, Inc. + * + * DRI: Josh de Cesare + */ + +const char gMacParts[] = { +0xf1,0x08,0x9f,0x6a,0x00,0x00,0x05,0x7d,0x10,0x00,0x00,0x02,0x00,0xb5,0x08,0x00,0xba,0x10,0x00,0x00,0x00,0x2c,0xb5,0x08,0x01,0xba,0xa5,0xb5,0x08,0x02,0xb8,0xb5,0x08, +0x03,0xb7,0x12,0x0c,0x6d,0x61,0x78,0x2d,0x74,0x72,0x61,0x6e,0x73,0x66,0x65,0x72,0xc2,0xb5,0x08,0x04,0xb7,0x12,0x0a,0x62,0x6c,0x6f,0x63,0x6b,0x2d,0x73,0x69,0x7a,0x65, +0xc2,0xb5,0x08,0x05,0xb7,0x12,0x09,0x64,0x6d,0x61,0x2d,0x61,0x6c,0x6c,0x6f,0x63,0xc2,0xb5,0x08,0x06,0xb7,0x12,0x08,0x64,0x6d,0x61,0x2d,0x66,0x72,0x65,0x65,0xc2,0xb5, +0x08,0x07,0xb7,0x12,0x04,0x72,0x65,0x61,0x64,0xc2,0xb5,0x08,0x08,0xb7,0x12,0x05,0x77,0x72,0x69,0x74,0x65,0xc2,0xb5,0x08,0x09,0xb7,0x12,0x04,0x73,0x65,0x65,0x6b,0xc2, +0xb5,0x08,0x0a,0xb7,0x6f,0xc2,0xb5,0x08,0x0b,0xb7,0x6e,0xc2,0xb5,0x08,0x0c,0xb7,0x12,0x20,0x4d,0x41,0x43,0x2d,0x50,0x41,0x52,0x54,0x53,0x3a,0x20,0x65,0x72,0x72,0x6f, +0x72,0x20,0x6f,0x6e,0x20,0x46,0x49,0x4e,0x44,0x2d,0x50,0x41,0x43,0x4b,0x41,0x47,0x45,0x90,0x02,0x16,0xc2,0x01,0x1f,0x12,0x09,0x6d,0x61,0x63,0x2d,0x70,0x61,0x72,0x74, +0x73,0x02,0x01,0xb5,0x08,0x0d,0xb7,0x08,0x03,0x02,0x09,0xc2,0xb5,0x08,0x0e,0xb7,0x08,0x04,0x02,0x09,0xc2,0xb5,0x08,0x0f,0xb7,0x08,0x05,0x02,0x09,0xc2,0xb5,0x08,0x10, +0xb7,0x08,0x06,0x02,0x09,0xc2,0xb5,0x08,0x11,0xb7,0x08,0x07,0x02,0x09,0xc2,0xb5,0x08,0x12,0xb7,0x08,0x08,0x02,0x09,0xc2,0xb5,0x08,0x13,0xb7,0x08,0x09,0x02,0x09,0xc2, +0x08,0x00,0xb5,0x08,0x14,0xbd,0x10,0x00,0x00,0x50,0x4d,0xb5,0x08,0x15,0xba,0x10,0x00,0x41,0x00,0x00,0xb5,0x08,0x16,0xba,0xa5,0xb5,0x08,0x17,0xb8,0xa5,0xb5,0x08,0x18, +0xb8,0xc0,0xa5,0xb5,0x08,0x19,0xb8,0xc0,0xa5,0xb5,0x08,0x1a,0xb8,0xa5,0x5b,0xb5,0x08,0x1b,0xbe,0x5b,0xb5,0x08,0x1c,0xbe,0x5c,0xb5,0x08,0x1d,0xbe,0x5c,0xb5,0x08,0x1e, +0xbe,0x5c,0xb5,0x08,0x1f,0xbe,0x10,0x00,0x00,0x00,0x20,0xb5,0x08,0x20,0xbe,0x10,0x00,0x00,0x00,0x20,0xb5,0x08,0x21,0xbe,0x5c,0xb5,0x08,0x22,0xbe,0x5c,0xb5,0x08,0x23, +0xbe,0x5c,0xb5,0x08,0x24,0xbe,0x5c,0xb5,0x08,0x25,0xbe,0x5c,0xb5,0x08,0x26,0xbe,0x5c,0xb5,0x08,0x27,0xbe,0x5c,0xb5,0x08,0x28,0xbe,0x5c,0xb5,0x08,0x29,0xbe,0x5c,0xb5, +0x08,0x2a,0xbe,0x5c,0xb5,0x08,0x2b,0xbe,0x10,0x00,0x00,0x00,0x10,0xb5,0x08,0x2c,0xbe,0x46,0xb5,0x08,0x2d,0xbb,0xa5,0xd3,0xa5,0xd3,0xb5,0x08,0x2e,0xbb,0xa5,0xd3,0xa5, +0xd3,0xb5,0x08,0x2f,0xb7,0x08,0x14,0x08,0x1b,0x08,0x0a,0x08,0x15,0x3c,0x08,0x14,0x08,0x21,0x12,0x09,0x41,0x70,0x70,0x6c,0x65,0x5f,0x48,0x46,0x53,0x7a,0x34,0x08,0x14, +0x08,0x21,0x12,0x0a,0x41,0x70,0x70,0x6c,0x65,0x5f,0x42,0x6f,0x6f,0x74,0x7a,0x34,0x24,0x23,0xc2,0xb5,0x08,0x30,0xb7,0x10,0x00,0x00,0x00,0x14,0x1e,0xc2,0xb5,0x08,0x31, +0xb7,0x10,0x00,0x00,0x00,0x1c,0x1e,0xc2,0xb5,0x08,0x32,0xb7,0x10,0x00,0x00,0x00,0x7c,0x1e,0xc2,0xb5,0x08,0x33,0xb7,0x10,0x00,0x00,0x00,0x7e,0x1e,0xc2,0xb5,0x08,0x34, +0xb7,0xc2,0xb5,0x08,0x35,0xb7,0xa7,0x1e,0xc2,0xca,0x04,0x72,0x65,0x61,0x64,0x08,0x36,0xb7,0x08,0x11,0xc2,0xca,0x04,0x73,0x65,0x65,0x6b,0x08,0x37,0xb7,0x08,0x19,0x08, +0x00,0xd4,0xd8,0x08,0x13,0xc2,0xca,0x0b,0x72,0x65,0x61,0x64,0x2d,0x62,0x6c,0x6f,0x63,0x6b,0x73,0x08,0x38,0xb7,0x49,0x08,0x19,0x1e,0x08,0x00,0xd4,0x08,0x13,0x46,0x08, +0x00,0x20,0x08,0x11,0x08,0x00,0x21,0xc2,0xca,0x04,0x6f,0x70,0x65,0x6e,0x08,0x39,0xb7,0xa5,0xc3,0x08,0x02,0x02,0x02,0x50,0x14,0x00,0x2a,0x08,0x01,0x02,0x40,0xa7,0x4e, +0x34,0x14,0x00,0x1c,0xa0,0x6d,0x30,0x10,0x00,0x00,0x00,0x0a,0xa0,0x72,0x53,0xa2,0x14,0x00,0x07,0x55,0x13,0x00,0x05,0xb2,0x46,0xb2,0x31,0xa0,0x72,0xb2,0x13,0x00,0x09, +0xb2,0x46,0xa5,0xa5,0xa5,0xa5,0xb2,0x08,0x2d,0x77,0x08,0x2e,0x77,0x08,0x2d,0x6d,0x14,0x00,0x3e,0xa0,0x6d,0x10,0x00,0x00,0x00,0x0a,0xa0,0x72,0x08,0x2d,0x76,0xa2,0x14, +0x00,0x27,0x12,0x1f,0x4d,0x41,0x43,0x2d,0x50,0x41,0x52,0x54,0x53,0x3a,0x20,0x62,0x61,0x64,0x20,0x70,0x61,0x72,0x74,0x69,0x74,0x69,0x6f,0x6e,0x20,0x6e,0x75,0x6d,0x62, +0x65,0x72,0x90,0x92,0xa4,0xb2,0x49,0xa0,0x72,0x13,0x00,0x05,0xb2,0xa4,0xb2,0xc3,0x08,0x17,0x08,0x17,0xa4,0x3c,0x14,0x00,0x3a,0x08,0x00,0xa5,0x08,0x13,0x46,0x08,0x14, +0x08,0x00,0x08,0x11,0x46,0x08,0x14,0x08,0x1d,0x08,0x0b,0xa5,0x18,0x00,0x22,0x19,0xa6,0x1e,0x08,0x00,0xd4,0x08,0x13,0x46,0x08,0x14,0x08,0x00,0x08,0x11,0x46,0x08,0x2f, +0x14,0x00,0x0a,0x19,0xa6,0x1e,0xc3,0x08,0x17,0x1b,0xb2,0x15,0xff,0xe2,0xb2,0x08,0x17,0xa4,0x3d,0x14,0x00,0x77,0x08,0x17,0x08,0x00,0xd4,0x08,0x13,0x46,0x08,0x14,0x08, +0x00,0x08,0x11,0x46,0x08,0x14,0x08,0x1e,0x08,0x0b,0xc3,0x08,0x19,0x08,0x14,0x08,0x1f,0x08,0x0b,0xc3,0x08,0x1a,0x08,0x2e,0x6d,0x14,0x00,0x49,0x08,0x2f,0x14,0x00,0x0e, +0x08,0x19,0x08,0x00,0xd4,0x08,0x13,0x46,0x13,0x00,0x35,0xb2,0x12,0x2b,0x4d,0x41,0x43,0x2d,0x50,0x41,0x52,0x54,0x53,0x3a,0x20,0x73,0x70,0x65,0x63,0x69,0x66,0x69,0x65, +0x64,0x20,0x70,0x61,0x72,0x74,0x69,0x74,0x69,0x6f,0x6e,0x20,0x69,0x73,0x20,0x6e,0x6f,0x74,0x20,0x76,0x61,0x6c,0x69,0x64,0x90,0x92,0xa5,0x33,0xb2,0x13,0x00,0x06,0xb2, +0xa4,0x33,0xb2,0x13,0x00,0x33,0xb2,0x12,0x29,0x4d,0x41,0x43,0x2d,0x50,0x41,0x52,0x54,0x53,0x3a,0x20,0x63,0x61,0x6e,0x27,0x74,0x20,0x66,0x69,0x6e,0x64,0x20,0x61,0x20, +0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x20,0x70,0x61,0x72,0x74,0x69,0x74,0x69,0x6f,0x6e,0x90,0x92,0xa5,0x33,0xb2,0x08,0x17,0xa4,0x3d,0x14,0x00,0x08,0x08,0x17,0xc3,0x08, +0x02,0xb2,0x08,0x2e,0x6d,0x14,0x00,0xed,0x08,0x14,0xa7,0xa6,0x08,0x38,0x46,0x08,0x14,0x08,0x0a,0xc4,0x10,0x00,0x00,0x48,0x2b,0x1c,0x00,0x15,0x12,0x0e,0x68,0x66,0x73, +0x2d,0x70,0x6c,0x75,0x73,0x2d,0x66,0x69,0x6c,0x65,0x73,0xc6,0x00,0x69,0x10,0x00,0x00,0x42,0x44,0x1c,0x00,0x5e,0x08,0x14,0x08,0x32,0x08,0x0a,0x10,0x00,0x00,0x48,0x2b, +0x3c,0x14,0x00,0x40,0x08,0x14,0x08,0x33,0x47,0x08,0x34,0x08,0x0a,0x49,0x08,0x35,0x08,0x0a,0x08,0x14,0x08,0x30,0x08,0x0b,0x08,0x00,0x21,0x4c,0x20,0xc3,0x08,0x1a,0x20, +0x08,0x14,0x08,0x31,0x08,0x0a,0x1e,0x08,0x19,0x1e,0xc3,0x08,0x19,0x12,0x0e,0x68,0x66,0x73,0x2d,0x70,0x6c,0x75,0x73,0x2d,0x66,0x69,0x6c,0x65,0x73,0x13,0x00,0x0f,0xb2, +0x12,0x09,0x6d,0x61,0x63,0x2d,0x66,0x69,0x6c,0x65,0x73,0xb2,0xc6,0x00,0x05,0xa5,0x49,0xc5,0x50,0x14,0x00,0x3b,0x02,0x04,0x14,0x00,0x0c,0x08,0x2e,0x76,0x4a,0x08,0x0c, +0x13,0x00,0x29,0xb2,0x12,0x20,0x4d,0x41,0x43,0x2d,0x50,0x41,0x52,0x54,0x53,0x3a,0x20,0x65,0x72,0x72,0x6f,0x72,0x20,0x6f,0x6e,0x20,0x46,0x49,0x4e,0x44,0x2d,0x50,0x41, +0x43,0x4b,0x41,0x47,0x45,0x90,0x02,0x16,0xb2,0x13,0x00,0x22,0xb2,0x12,0x18,0x4d,0x41,0x43,0x2d,0x50,0x41,0x52,0x54,0x53,0x3a,0x20,0x62,0x61,0x64,0x20,0x70,0x61,0x72, +0x74,0x69,0x74,0x69,0x6f,0x6e,0x90,0x92,0xa5,0x33,0xb2,0xb2,0xa4,0xc2,0xca,0x05,0x63,0x6c,0x6f,0x73,0x65,0x08,0x3a,0xb7,0xc2,0xca,0x07,0x23,0x62,0x6c,0x6f,0x63,0x6b, +0x73,0x08,0x3b,0xb7,0x08,0x1a,0xc2,0xca,0x04,0x73,0x69,0x7a,0x65,0x08,0x3c,0xb7,0x08,0x1a,0x08,0x00,0xd4,0xc2,0xca,0x0a,0x6f,0x66,0x66,0x73,0x65,0x74,0x2d,0x6c,0x6f, +0x77,0x08,0x3d,0xb7,0x08,0x19,0x08,0x00,0xd4,0x46,0xc2,0xca,0x0b,0x6f,0x66,0x66,0x73,0x65,0x74,0x2d,0x68,0x69,0x67,0x68,0x08,0x3e,0xb7,0x08,0x19,0x08,0x00,0xd4,0x4d, +0xc2,0xca,0x04,0x6c,0x6f,0x61,0x64,0x08,0x3f,0xb7,0x46,0x12,0x2d,0x4d,0x41,0x43,0x2d,0x50,0x41,0x52,0x54,0x53,0x3a,0x20,0x4c,0x4f,0x41,0x44,0x20,0x28,0x6e,0x6f,0x6e, +0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,0x73,0x65,0x64,0x29,0x20,0x6e,0x6f,0x74,0x20,0x73,0x75,0x70,0x70,0x6f,0x72,0x74,0x65,0x64,0x90,0x02,0x16,0xc2,0xca,0x05,0x65,0x6a, +0x65,0x63,0x74,0x08,0x40,0xb7,0x12,0x05,0x65,0x6a,0x65,0x63,0x74,0x02,0x09,0xc2,0x01,0x27,0x00, +}; Index: branches/xZenu/src/arch/ppc/boot2/bootinfo.hdr =================================================================== --- branches/xZenu/src/arch/ppc/boot2/bootinfo.hdr (revision 0) +++ branches/xZenu/src/arch/ppc/boot2/bootinfo.hdr (revision 1317) @@ -0,0 +1,81 @@ + + +MacRISC MacRISC3 MacRISC4 + + +Boot Loader for Mac OS X. + + +1010 +00000000000000000000000000000000 +000000000000000000000000F8000000 +000000002B73732B0055735500F80000 +00000000F5799DF6004F792B0000F800 +0000000000F69D4E004F2B000000F800 +000000000000559D2A55F500000000F8 +000000000000F69D732B0000000000F8 +000000000000004F96F50000000000F8 +00000000000000799D4E0000000000F8 +0000000000002AF8559D0000000000F8 +00000000000079F6F59D4E00000000F8 +00000000004E4F00005573000000F800 +000000004F9D55F5004F9D4FF500F800 +0000F800557A56F50055567A2BF80000 +000000F8F8000000000000F8F8000000 +0000000000F8F8F8F8F8F80000000000 + +0000000000F7F7F7F7F7F70000000000 +000000F7F7F7F7F7F7F7F7F781000000 +0000F7F7F99E9EF9F7809E80F7810000 +00F7F7F7F8A4C856F77AA4F9F7F78100 +00F7F7F7F756C879F77AF9F7F7F78100 +F7F7F7F7F7F780C85580F8F7F7F7F781 +F7F7F7F7F7F756C89EF9F7F7F7F7F781 +F7F7F7F7F7F7F77AC1F8F7F7F7F7F781 +F7F7F7F7F7F7F7A4C879F7F7F7F7F781 +F7F7F7F7F7F7558180C8F7F7F7F7F781 +F7F7F7F7F7F7A456F8C879F7F7F7F781 +00F7F7F7F7797AF7F7809EF7F7F78100 +00F7F7F77AC880F8F77AC87AF8F78100 +000081F780A5FBF8F780FBA5F9810000 +0000008181F7F7F7F7F7F78181000000 +00000000008181818181810000000000 + +0000000000FFFFFFFFFFFF0000000000 +000000FFFFFFFFFFFFFFFFFFFF000000 +0000FFFFFFFFFFFFFFFFFFFFFFFF0000 +00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00 +00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00 +FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00 +00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00 +0000FFFFFFFFFFFFFFFFFFFFFFFF0000 +000000FFFFFFFFFFFFFFFFFFFF000000 +0000000000FFFFFFFFFFFF0000000000 + + +load-base +begin + dup 6 " </CHRP" $= if + 6 + dup 6 " -BOOT>" $= if + 8 + true + else + false + then + else + 1+ false + then +until +( xcoff-base ) +load-size over load-base - - +( xcoff-base xcoff-size ) +load-base swap move +init-program go + + + \ No newline at end of file Index: branches/xZenu/src/arch/ppc/boot2/ci.c =================================================================== --- branches/xZenu/src/arch/ppc/boot2/ci.c (revision 0) +++ branches/xZenu/src/arch/ppc/boot2/ci.c (revision 1317) @@ -0,0 +1,611 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * 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. + * + * This 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@ + */ +/* + * ci.c - Functions for accessing Open Firmware's Client Interface + * + * Copyright (c) 1998-2002 Apple Computer, Inc. + * + * DRI: Josh de Cesare + */ + +#include + +static ClientInterfacePtr gCIPtr; + +long InitCI(ClientInterfacePtr ciPtr) +{ + gCIPtr = ciPtr; + + return 0; +} + +long CallCI(CIArgs *ciArgsPtr) +{ + long ret; + + ret = (*gCIPtr)(ciArgsPtr); + return ret; +} + + +// Device Tree + +// Peer take a phandle and returns the next peer. +// It returns zero of there are no more peers. +CICell Peer(CICell phandle) +{ + CIArgs ciArgs; + CICell peer_ph; + long ret; + + ciArgs.service = "peer"; + ciArgs.nArgs = 1; + ciArgs.nReturns = 1; + ciArgs.args.peer.phandle = phandle; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + peer_ph = ciArgs.args.peer.peerPhandle; + + return peer_ph; +} + +// Child take a phandle and returns the first child. +// It returns zero of there in no child. +CICell Child(CICell phandle) +{ + CIArgs ciArgs; + CICell child_ph; + long ret; + + ciArgs.service = "child"; + ciArgs.nArgs = 1; + ciArgs.nReturns = 1; + ciArgs.args.child.phandle = phandle; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + child_ph = ciArgs.args.child.childPhandle; + + return child_ph; +} + +// Parent take a phandle and returns the parent node. +// It returns zero of if the phandle is the root node. +CICell Parent(CICell phandle) +{ + CIArgs ciArgs; + CICell parent_ph; + long ret; + + ciArgs.service = "parent"; + ciArgs.nArgs = 1; + ciArgs.nReturns = 1; + ciArgs.args.parent.childPhandle = phandle; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + parent_ph = ciArgs.args.parent.parentPhandle; + + return parent_ph; +} + +// FindDevice take a device spec and returns the phandle. +// It returns zero of if the device was not found. +CICell FindDevice(char *devSpec) +{ + CIArgs ciArgs; + CICell phandle; + long ret; + + ciArgs.service = "finddevice"; + ciArgs.nArgs = 1; + ciArgs.nReturns = 1; + ciArgs.args.finddevice.devSpec = devSpec; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + phandle = ciArgs.args.finddevice.phandle; + + return phandle; +} + +// InstanceToPath take an ihandle, buf and buflen. Set the device path +// to the package in buf upto buflen characters and returns the length +// Length will be -1 if the ihandle is invalid. +CICell InstanceToPath(CICell ihandle, char *buf, long buflen) +{ + CIArgs ciArgs; + CICell length; + long ret; + + ciArgs.service = "instance-to-path"; + ciArgs.nArgs = 3; + ciArgs.nReturns = 1; + ciArgs.args.instanceToPath.ihandle = ihandle; + ciArgs.args.instanceToPath.buf = buf; + ciArgs.args.instanceToPath.buflen = buflen; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + length = ciArgs.args.instanceToPath.length; + + return length; +} + +// InstanceToPackage take an ihandle and returns the phandle for it. +// returns -1 if the phandle can't be found. +CICell InstanceToPackage(CICell ihandle) +{ + CIArgs ciArgs; + CICell phandle; + long ret; + + ciArgs.service = "instance-to-package"; + ciArgs.nArgs = 1; + ciArgs.nReturns = 1; + ciArgs.args.instanceToPackage.ihandle = ihandle; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + phandle = ciArgs.args.instanceToPackage.phandle; + + return phandle; +} + +// InstanceToPackages + +// PackageToPath take a phandle, buf and buflen. Set the device path +// to the package in buf upto buflen characters and returns the length +// Length will be -1 if the phandle is invalid. +CICell PackageToPath(CICell phandle, char *buf, long buflen) +{ + CIArgs ciArgs; + CICell length; + long ret; + + if (gOFVersion >= kOFVersion2x) { + ciArgs.service = "package-to-path"; + ciArgs.nArgs = 3; + ciArgs.nReturns = 1; + ciArgs.args.packageToPath.phandle = phandle; + ciArgs.args.packageToPath.buf = buf; + ciArgs.args.packageToPath.buflen = buflen; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + length = ciArgs.args.packageToPath.length; + } else { + ret = CallMethod(3, 1, SLWordsIH, "slw_pwd", phandle, + (CICell)buf, buflen, &length); + if (ret != 0) return kCIError; + + buf[length] = '\0'; + } + + return length; +} + +// Canon + +// GetPropLen takes a phandle and prop name +// and returns the size of the property +// or -1 if the property is not valid. +CICell GetPropLen(CICell phandle, char *name) +{ + CIArgs ciArgs; + CICell size; + long ret; + + ciArgs.service = "getproplen"; + ciArgs.nArgs = 2; + ciArgs.nReturns = 1; + ciArgs.args.getproplen.phandle = phandle; + ciArgs.args.getproplen.name = name; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + size = ciArgs.args.getproplen.size; + + return size; +} + +// GetProp takes a phandle, prop name, buffer and length +// and copied the property value in to the buffer. +// returns -1 if the property is not valid. +CICell GetProp(CICell phandle, char *name, char *buf, long buflen) +{ + CIArgs ciArgs; + CICell size; + long ret; + + ciArgs.service = "getprop"; + ciArgs.nArgs = 4; + ciArgs.nReturns = 1; + ciArgs.args.getprop.phandle = phandle; + ciArgs.args.getprop.name = name; + ciArgs.args.getprop.buf = buf; + ciArgs.args.getprop.buflen = buflen; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + size = ciArgs.args.getprop.size; + + return size; +} + +// NextProp takes a phandle, prev name, and a buffer +// and copied the next property name in to the buffer. +// returns -1 if the property is not valid. +// returns 0 if the prev was the last property. +// returns 1 otherwise. +CICell NextProp(CICell phandle, char *previous, char *buf) +{ + CIArgs ciArgs; + CICell flag; + long ret; + + ciArgs.service = "nextprop"; + ciArgs.nArgs = 3; + ciArgs.nReturns = 1; + ciArgs.args.nextprop.phandle = phandle; + ciArgs.args.nextprop.previous = previous; + ciArgs.args.nextprop.buf = buf; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + flag = ciArgs.args.nextprop.flag; + + return flag; +} + +// SetProp takes a phandle, prop name, buffer and length +// and copied the buffer in to the property value. +// returns -1 if the property could not be set or created. +CICell SetProp(CICell phandle, char *name, char *buf, long buflen) +{ + CIArgs ciArgs; + CICell size; + long ret; + + ciArgs.service = "setprop"; + ciArgs.nArgs = 4; + ciArgs.nReturns = 1; + ciArgs.args.setprop.phandle = phandle; + ciArgs.args.setprop.name = name; + ciArgs.args.setprop.buf = buf; + ciArgs.args.setprop.buflen = buflen; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + size = ciArgs.args.setprop.size; + + return size; +} + + +// Device I/O + +// Open takes a device specifier and returns an iHandle +// It returns zero if the device can not be found or opened. +CICell Open(char *devSpec) +{ + CIArgs ciArgs; + CICell ihandle; + long ret; + + ciArgs.service = "open"; + ciArgs.nArgs = 1; + ciArgs.nReturns = 1; + ciArgs.args.open.devSpec = devSpec; + + ret = CallCI(&ciArgs); + if (ret != 0) return 0; + + ihandle = ciArgs.args.open.ihandle; + + return ihandle; +} + +// Close takes an iHandle and closes the device. +void Close(CICell ihandle) +{ + CIArgs ciArgs; + + ciArgs.service = "close"; + ciArgs.nArgs = 1; + ciArgs.nReturns = 0; + ciArgs.args.close.ihandle = ihandle; + + CallCI(&ciArgs); +} + +// Read takes an iHandle, an address and a length and return the actual +// Length read. Returns -1 if the operaction failed. +CICell Read(CICell ihandle, long addr, long length) +{ + CIArgs ciArgs; + long actual; + long ret; + + ciArgs.service = "read"; + ciArgs.nArgs = 3; + ciArgs.nReturns = 1; + ciArgs.args.read.ihandle = ihandle; + ciArgs.args.read.addr = addr; + ciArgs.args.read.length = length; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + actual = ciArgs.args.read.actual; + + // Spin the wait cursor. + Spin(); + + return actual; +} + +// Write takes an iHandle, an address and a length and return the actual +// Length written. Returns -1 if the operaction failed. +CICell Write(CICell ihandle, long addr, long length) +{ + CIArgs ciArgs; + long actual; + long ret; + + ciArgs.service = "write"; + ciArgs.nArgs = 3; + ciArgs.nReturns = 1; + ciArgs.args.write.ihandle = ihandle; + ciArgs.args.write.addr = addr; + ciArgs.args.write.length = length; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + actual = ciArgs.args.write.actual; + + return actual; +} + +// Seek takes an iHandle, and a 64 bit position +// and moves to that address in file. +// returns seeks result, or -1 if seek is not supported. +CICell Seek(CICell ihandle, long long position) +{ + CIArgs ciArgs; + long ret; + + ciArgs.service = "seek"; + ciArgs.nArgs = 3; + ciArgs.nReturns = 1; + ciArgs.args.seek.ihandle = ihandle; + ciArgs.args.seek.pos_high = position >> 32; + ciArgs.args.seek.pos_low = position & 0x00000000FFFFFFFFULL; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + ret = ciArgs.args.seek.result; + + return ret; +} + + +// Other Device Method Invocation + +// Call the specified method on the given iHandle with the listed arguments. +long CallMethod(long args, long rets, CICell iHandle, const char *method, ...) +{ + va_list argList; + CIArgs ciArgs; + long ret, cnt, error = kCINoError; + + va_start(argList, method); + + ciArgs.service = "call-method"; + ciArgs.nArgs = args + 2; + ciArgs.nReturns = rets + 1; + ciArgs.args.callMethod.iHandle = iHandle; + ciArgs.args.callMethod.method = method; + + for (cnt = 0; cnt < args; cnt++) { + ciArgs.args.callMethod.cells[args - cnt - 1] = va_arg(argList, CICell); + } + + ret = CallCI(&ciArgs); + if (ret != 0) error = kCIError; + else if (ciArgs.args.callMethod.cells[args] != 0) error = kCICatch; + + if (error == kCINoError) { + for (cnt = 0; cnt < rets; cnt++) { + *(va_arg(argList, CICell *)) = + ciArgs.args.callMethod.cells[args + rets - cnt]; + } + } + + va_end(argList); + + return error; +} + + +// Memory + +// Claim takes a virt address, a size, and an alignment. +// It return baseaddr or -1 for claim failed. +CICell Claim(CICell virt, CICell size, CICell align) +{ + CIArgs ciArgs; + CICell baseaddr; + long ret; + + if (gOFVersion >= kOFVersion2x) { + // Claim actually works, so use it. + ciArgs.service = "claim"; + ciArgs.nArgs = 3; + ciArgs.nReturns = 1; + ciArgs.args.claim.virt = virt; + ciArgs.args.claim.size = size; + ciArgs.args.claim.align = align; + + ret = CallCI(&ciArgs); + if (ret != 0) return kCIError; + + baseaddr = ciArgs.args.claim.baseaddr; + } else { + // Claim does not work. Do it by hand. + if ((gMMUIH == 0) || (gMMUIH == 0)) return kCIError; + + // Get the physical memory + ret = CallMethod(3, 1, gMemoryIH, "claim", virt, size, 0, &baseaddr); + if ((ret != kCINoError) || (virt != baseaddr)) return kCIError; + + // Get the logical memory + ret = CallMethod(3, 1, gMMUIH, "claim", virt, size, 0, &baseaddr); + if ((ret != kCINoError) || (virt != baseaddr)) return kCIError; + + // Map them together. + ret = CallMethod(4, 0, gMMUIH, "map", virt, virt, size, 0); + if (ret != kCINoError) return kCIError; + } + + return baseaddr; +} + +// Release takes a virt address, a size +void Release(CICell virt, CICell size) +{ + CIArgs ciArgs; + + ciArgs.service = "release"; + ciArgs.nArgs = 2; + ciArgs.nReturns = 0; + ciArgs.args.claim.virt = virt; + ciArgs.args.claim.size = size; + + CallCI(&ciArgs); +} + + +// Control Transfer + +// Boot trys to boot the bootspec +void Boot(char *bootspec) +{ + CIArgs ciArgs; + + ciArgs.service = "boot"; + ciArgs.nArgs = 1; + ciArgs.nReturns = 0; + ciArgs.args.boot.bootspec = bootspec; + + CallCI(&ciArgs); +} + +// Enter the user interface. +// Executing the 'go' command returns to the client. +void Enter(void) +{ + CIArgs ciArgs; + + ciArgs.service = "enter"; + ciArgs.nArgs = 0; + ciArgs.nReturns = 0; + + CallCI(&ciArgs); +} + +// Exit the client program. +void Exit(void) +{ + CIArgs ciArgs; + + ciArgs.service = "exit"; + ciArgs.nArgs = 0; + ciArgs.nReturns = 0; + + CallCI(&ciArgs); +} + +// Clain + +// Quiesce stops any async tasks in Open Firmware. +void Quiesce(void) +{ + CIArgs ciArgs; + + ciArgs.service = "quiesce"; + ciArgs.nArgs = 0; + ciArgs.nReturns = 0; + + CallCI(&ciArgs); +} + + +// User Interface + +// Interpret the given forth string with the listed arguments. +long Interpret(long args, long rets, const char *forthString, ...) +{ + va_list argList; + CIArgs ciArgs; + long ret, cnt, error = kCINoError; + + va_start(argList, forthString); + + ciArgs.service = "interpret"; + ciArgs.nArgs = args + 1; + ciArgs.nReturns = rets + 1; + ciArgs.args.interpret.forth = forthString; + + for (cnt = 0; cnt < args; cnt++) { + ciArgs.args.interpret.cells[args - cnt - 1] = va_arg(argList, CICell); + } + + ret = CallCI(&ciArgs); + if (ret != 0) error = kCIError; + else if (ciArgs.args.interpret.cells[args] != 0) error = kCICatch; + + if (error == kCINoError) { + for (cnt = 0; cnt < rets; cnt++) { + *(va_arg(argList, CICell *)) = + ciArgs.args.interpret.cells[args + rets - cnt]; + } + } + + va_end(argList); + + return error; +} Index: branches/xZenu/src/arch/ppc/boot2/Makefile =================================================================== --- branches/xZenu/src/arch/ppc/boot2/Makefile (revision 0) +++ branches/xZenu/src/arch/ppc/boot2/Makefile (revision 1317) @@ -0,0 +1,80 @@ +ROOT = $(shell pwd)/../../../../ +DIR = boot2 +SRCROOT = ${ROOT}/src +OBJROOT = $(ROOT)/obj/${ARCH}/${DIR} +SYMROOT = $(ROOT)/sym/${ARCH} +DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}/ +DOCROOT = $(ROOT)/doc + +INCLUDESDIR = ../include + +CFLAGS := $(RC_CFLAGS) $(OPTIM) $(MORECPP) -static -g -Wmost -Werror \ + -fno-builtin -DSAIO_INTERNAL_USER $(OMIT_FRAME_POINTER_CFLAG) \ + -fno-align-functions -fno-stack-protector \ + -msoft-float -nostdinc -include $(SRCROOT)/autoconf.h + +CPPFLAGS := $(CPPFLAGS) -static -nostdinc++ -Wmost -Werror \ + -fno-builtin -msoft-float \ + -fno-rtti -fno-exceptions \ + -include $(SRCROOT)/autoconf.h + + +DEFINES = -DNOTHING + +LIBSAIODIR = ../libclite + +INCLUDESDIR = ../include +INC = -I. -I$(SYMROOT) -I$(INCLUDESDIR) -I${SRCROOT}/include + + +LIBS= -L$(SYMROOT) -lclite +LIBDEP= libclite.a + +# enable boot2 to find boot_modules.c +VPATH = $(ROOT)/sym/modules/ + +OBJECTS = main ci_io ci Control2 MAC-PARTS sl_words boot_modules + + +DIRS_NEEDED = + +include ${ROOT}/Make.rules + +all: $(OBJROOT) $(SYMROOT) ${SYMROOT}/boot + +${SYMROOT}/boot: ${ACTUAL_OBJECTS} + @echo "\t[LD] boot.sys" + @$(CC) -nostdlib -arch ${ARCH} -static \ + -o $(SYMROOT)/boot.sys $(filter %.${ARCH}o,$^) `find $(ROOT)/obj/boot2_modules/ -name \*.${ARCH}o` $(LIBS) + + @# TODO: embed Symbols.dylib + + @$(SYMROOT)/../util/macho-to-xcoff $(SYMROOT)/boot.sys $(SYMROOT)/bootx.xcoff + @cp bootinfo.hdr $(SYMROOT)/bootx.bootinfo + @cat $(SYMROOT)/bootx.xcoff >> $(SYMROOT)/bootx.bootinfo + + @$(LD) -arch ${ARCH} \ + -undefined dynamic_lookup \ + -dylib -read_only_relocs suppress \ + -S -x -Z -dead_strip_dylibs \ + -no_uuid \ + $(filter %.${ARCH}o,$^) `find $(OBJROOT)/../../boot2_modules/ -name \*.${ARCH}o` $(LIBS) \ + -final_output Symbols \ + -macosx_version_min 10.6 \ + -o $(OBJROOT)/Symbols_LINKER_ONLY.dylib + + + + + +install: ${DSTROOT} $(SYMROOT)/boot + @echo "\t[CP] bootx.bootinfo" + @install -c -m 444 $(SYMROOT)/bootx.bootinfo ${DSTROOT} + @echo "\t[CP] bootx.xcoff" + @install -c -m 444 $(SYMROOT)/bootx.xcoff ${DSTROOT} + + @# TODO: copy Symbols (linker) so that other can extend w/o having the source + + +# dependencies +-include $(OBJROOT)/Makedep Index: branches/xZenu/src/arch/ppc/boot2/sl_words.c =================================================================== --- branches/xZenu/src/arch/ppc/boot2/sl_words.c (revision 0) +++ branches/xZenu/src/arch/ppc/boot2/sl_words.c (revision 1317) @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * 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. + * + * This 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@ + */ +/* + * sl_words.c - Forth and C code for the sl_words package. + * + * Copyright (c) 1998-2002 Apple Computer, Inc. + * + * DRI: Josh de Cesare + */ +#include +#include + +#if SL_DEBUG +void InitDebugWords(void); +#endif + +extern const char gMacParts[]; +extern const char *gControl2Source[]; + +CICell SLWordsIH = 0; + +long InitSLWords(void) +{ + long result, cnt; + + result = Interpret(0, 1, + " hex" + " unselect-dev" + + // Create the slWords pseudo-device + " \" /packages\" find-device" + " new-device" + " \" sl_words\" device-name" + + " : open true ;" + " : close ;" + + // Define all sl words here. + + // init the outputLevel + " 0 value outputLevel" + + // slw_set_output_level ( level -- ) + " : slw_set_output_level" + " dup 0= if 0 stdout ! then" + " to outputLevel" + " ;" + + // slw_emit ( ch -- ) + " : slw_emit 2 outputLevel <= if emit else drop then ;" + + // slw_cr ( -- ) + " : slw_cr 2 outputLevel <= if cr then ;" + + // Static init stuff for keyboard + " 0 value keyboardIH" + " 20 buffer: keyMap" + + // slw_init_keymap ( keyboardIH -- keyMap ) + " : slw_init_keymap" + " to keyboardIH" + " keyMap dup 20 0 fill" + " ;" + + // slw_update_keymap + " : slw_update_keymap { ; dpth }" + " depth -> dpth" + " keyboardIH if" + " \" get-key-map\" keyboardIH $call-method" + " depth dpth - 1 = if 20 then" + " 4 / 0 do" + " dup i 4 * + l@ keyMap i 4 * + tuck l@ or swap l!" + " loop drop" + " then" + " ;" + + // Set up the spin cursor stuff. + " 0 value screenIH" + " 0 value cursorAddr" + " 0 value cursorX" + " 0 value cursorY" + " 0 value cursorW" + " 0 value cursorH" + " 0 value cursorFrames" + " 0 value cursorPixelSize" + " 0 value cursorStage" + " 0 value cursorTime" + " 0 value cursorDelay" + + // slw_spin ( -- ) + " : slw_spin" + " screenIH 0<> cursorAddr 0<> and if" + " get-msecs dup cursorTime - cursorDelay >= if" + " to cursorTime" + " slw_update_keymap" + " cursorStage 1+ cursorFrames mod dup to cursorStage" + " cursorW cursorH * cursorPixelSize * * cursorAddr +" + " cursorX cursorY cursorW cursorH" + " \" draw-rectangle\" screenIH $call-method" + " else" + " drop" + " then" + " then" + " ;" + + // slw_spin_init ( screenIH cursorAddr cursorX cursorY cursorW cursorH--) + " : slw_spin_init" + " dup FFFF and to cursorH 10 >> drop" + " dup FFFF and to cursorW 10 >> to cursorPixelSize" + " dup FFFF and to cursorY 10 >> d# 1000 swap / to cursorDelay" + " dup FFFF and to cursorX 10 >> to cursorFrames" + " to cursorAddr to screenIH" + " ['] slw_spin to spin" + " ;" + + // slw_pwd ( phandle addr len -- act ) + " : slw_pwd" + " ['] pwd 138 - execute" + " ;" + + // slw_sum ( adr len -- sum ) + " : slw_sum { adr len }" + " len 0 tuck do" + " dup 1 and if 10000 or then" + " 1 >> adr i + c@ + ffff and" + " loop" + " ;" + + " device-end" + + " 0 0 \" sl_words\" $open-package" + + , &SLWordsIH); + + if (result != kCINoError) return result; + if (SLWordsIH == 0) return kCIError; + + if (gOFVersion < kOFVersion3x) { + result = Interpret(1, 0, + " dev /packages/obp-tftp" + " ['] load C + l!" + , kLoadSize); + if (result != kCINoError) return result; + } + + if (gOFVersion < kOFVersion3x) { + result = Interpret(1, 0, + " dev /packages/mac-parts" + " \" lame\" device-name" + " dev /packages" + " 1 byte-load" + " device-end" + , (long)gMacParts); + if (result != kCINoError) return result; + } + + if (gOFVersion < kOFVersion2x) { + for(cnt = 0; gControl2Source[cnt] != '\0'; cnt++) { + result = Interpret(0, 0, gControl2Source[cnt]); + if (result == kCIError) return kCIError; + if (result == kCICatch) return kCINoError; + } + } + +#if SL_DEBUG + InitDebugWords(); +#endif + + return kCINoError; +} + +#if SL_DEBUG +void InitDebugWords(void) +{ + Interpret(0, 0, + // .sc ( -- ) + " : .sc ?state-valid ci-regs 4+ l@ l@ dup 0= \" Bad Stack\" (abort\")" + " cr .\" Stack Trace\"" + " begin dup while dup 8 + l@ cr u. l@ repeat drop ;" + ); +} +#endif + +void SetOutputLevel(long level) +{ + CallMethod(1, 0, SLWordsIH, "slw_set_output_level", level); +} + + +char *InitKeyMap(CICell keyboardIH) +{ + long ret; + char *keyMap; + + ret = CallMethod(1, 1, SLWordsIH, "slw_init_keymap", + keyboardIH, (CICell *)&keyMap); + if (ret != kCINoError) return NULL; + + return keyMap; +} + +void UpdateKeyMap(void) +{ + CallMethod(0, 0, SLWordsIH, "slw_update_keymap"); +} + + +void SpinInit(CICell screenIH, char *cursorAddr, + long cursorX, long cursorY, + long cursorW, long cursorH, + long frames, long fps, + long pixelSize, long spare) +{ + CallMethod(6, 0, SLWordsIH, "slw_spin_init", + screenIH, (long)cursorAddr, + cursorX | (frames << 16), + cursorY | (fps << 16), + cursorW | (pixelSize << 16), + cursorH | (spare << 16)); +} + +void Spin(void) +{ + CallMethod(0, 0, SLWordsIH, "slw_spin"); +} + + +long GetPackageProperty(CICell phandle, char *propName, + char **propAddr, long *propLen) +{ + long ret, nameLen = strlen(propName); + + ret = Interpret(3, 2, "get-package-property if 0 0 then", + (CICell)propName, nameLen, phandle, + (CICell *)propAddr, (CICell *)propLen); + if ((ret != kCINoError) || (*propAddr == NULL)) return -1; + + return 0; +} Index: branches/xZenu/src/arch/ppc/Makefile =================================================================== --- branches/xZenu/src/arch/ppc/Makefile (revision 1316) +++ branches/xZenu/src/arch/ppc/Makefile (revision 1317) @@ -13,7 +13,7 @@ include ${ROOT}/Make.rules # The order of building is important. -SUBDIRS = libclite ci +SUBDIRS = libclite boot2 all install: ${OBJROOT} ${SYMROOT} @for i in ${SUBDIRS}; \ Index: branches/xZenu/src/util/dyldsymboltool.c =================================================================== --- branches/xZenu/src/util/dyldsymboltool.c (revision 1316) +++ branches/xZenu/src/util/dyldsymboltool.c (revision 1317) @@ -119,6 +119,7 @@ dylib.header.sizeofcmds = sizeof(dylib) - sizeof(struct mach_header);// + dylib.symtab.nsyms * sizeof(struct nlist) + dylib.symtab.strsize; dylib.header.magic = MH_MAGIC; + // TODO: make configurable *or* read from orig file dylib.header.cputype = CPU_TYPE_X86; dylib.header.cpusubtype = /*CPUSUBTYPE_I386*/ 3; dylib.header.filetype = MH_DYLIB;