Chameleon

Chameleon Commit Details

Date:2011-08-06 20:41:25 (9 years 3 months ago)
Author:Evan Lojewski
Commit:1305
Parents: 1304
Message:Cleanup arch makefiles. Begin merging of BootX source - will need cleaning up
Changes:
A/branches/xZenu/src/arch/ppc/ci/Control2.c
A/branches/xZenu/src/arch/ppc/include/fs.h
A/branches/xZenu/src/arch/ppc/include
A/branches/xZenu/src/arch/ppc/libclite/bswap.c
A/branches/xZenu/src/arch/ppc/libclite
A/branches/xZenu/src/arch/ppc/include/device_tree.h
A/branches/xZenu/src/arch/ppc/include/sl.h
A/branches/xZenu/src/arch/ppc/include/boot_args.h
A/branches/xZenu/src/arch/ppc/ci
A/branches/xZenu/src/arch/ppc/ci/ci_io.c
A/branches/xZenu/src/arch/ppc/include/libclite.h
A/branches/xZenu/src/arch/ppc/include/Makefile
A/branches/xZenu/src/arch/ppc/ci/MAC-PARTS.c
A/branches/xZenu/src/arch/ppc/libclite/Makefile
A/branches/xZenu/src/arch/ppc/include/ci.h
A/branches/xZenu/src/arch/ppc/include/sl_words.h
A/branches/xZenu/src/arch/ppc/ci/ci.c
A/branches/xZenu/src/arch/ppc/ci/Makefile
A/branches/xZenu/src/arch/ppc/ci/sl_words.c
M/branches/xZenu/src/arch/ppc/Makefile
M/branches/xZenu/src/arch/i386/Makefile
M/branches/xZenu/src/arch/armv5/Makefile
M/branches/xZenu/src/arch/x86_64/Makefile
M/branches/xZenu/src/arch/i386/cdboot/Makefile
M/branches/xZenu/src/arch/i386/libsaio/Makefile
M/branches/xZenu/src/arch/i386/boot0/Makefile
M/branches/xZenu/src/arch/i386/boot1/Makefile
M/branches/xZenu/src/arch/i386/boot2/Makefile

File differences

branches/xZenu/src/arch/ppc/include/ci.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
* 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.h - Headers for the OF Client Interface Library
*
* Copyright (c) 1998-2002 Apple Computer, Inc.
*
* DRI: Josh de Cesare
*/
#ifndef _BOOTX_CI_H_
#define _BOOTX_CI_H_
#define kCINoError (0)
#define kCIError (-1)
#define kCICatch (-2)
typedef long CICell;
struct CIArgs {
char *service;
CICell nArgs;
CICell nReturns;
union {
struct {// nArgs=1 + args, nReturns=1 + rets
const char *forth;
CICell cells[6 + 1 + 6];
} interpret;
struct {// nArgs=2 + args, nReturns=1 + rets
const char *method;
CICell iHandle;
CICell cells[6 + 1 + 6];
} callMethod;
struct {// nArgs=1, nReturns=1( device-specifier -- ihandle )
char *devSpec; // IN parameter
CICell ihandle;// RETURN value
} open;
struct {// nArgs=1, nReturns=0( ihandle -- )
CICell ihandle;// IN parameter
} close;
struct { // nArgs=3, nReturns=1 ( ihandle addr length -- actual )
CICell ihandle;
CICell addr;
CICell length;
CICell actual;
} read;
struct { // nArgs=3, nReturns=1 ( ihandle addr length -- actual )
CICell ihandle;
CICell addr;
CICell length;
CICell actual;
} write;
struct { // nArgs=3, nReturns=1 ( ihandle pos.high pos.low -- result )
CICell ihandle;
CICell pos_high;
CICell pos_low;
CICell result;
} seek;
struct {// nArgs=3, nReturns=1
CICell virt;
CICell size;
CICell align;
CICell baseaddr;
} claim;
struct {// nArgs=2, nReturns=0
CICell virt;
CICell size;
} release;
struct {// nArgs=1, nReturns=1( phandle -- peer-phandle )
CICell phandle; // IN parameter
CICell peerPhandle;// RETURN value
} peer;
struct {// nArgs=1, nReturns=1( phandle -- child-phandle )
CICell phandle;// IN parameter
CICell childPhandle;// RETURN value
} child;
struct {// nArgs=1, nReturns=1( phandle -- parent-phandle )
CICell childPhandle;// IN parameter
CICell parentPhandle;// RETURN value
} parent;
struct {// nArgs=1, nReturns=1( devSpec -- phandle )
char *devSpec; // IN parameter
CICell phandle; // RETURN value
} finddevice;
struct { // nArgs=3, nReturns=1 ( ihandle buf buflen -- length )
CICell ihandle; // IN ihandle
char *buf; // IN buf
CICell buflen; // IN buflen
CICell length; // RETURN length
} instanceToPath;
struct { // nArgs=1, nReturns=1 ( ihandle -- phandle )
CICell ihandle; // IN ihandle
CICell phandle; // RETURN phandle
} instanceToPackage;
struct { // nArgs=3, nReturns=1 ( phandle buf buflen -- length )
CICell phandle; // IN phandle
char *buf; // IN buf
CICell buflen; // IN buflen
CICell length; // RETURN length
} packageToPath;
struct {// nArgs=2, nReturns=1( phandle name -- size )
CICell phandle;// IN parameter
char *name;// IN parameter
CICell size;// RETURN value
} getproplen;
struct {// nArgs=4, nReturns=1( phandle name buf buflen -- size )
CICell phandle;// IN parameter
char *name;// IN parameter
char *buf;// IN parameter
CICell buflen;// IN parameter
CICell size;// RETURN value
} getprop;
struct {// nArgs=3, nReturns=1( phandle previous buf -- flag )
CICell phandle;// IN parameter
char *previous;// IN parameter
char *buf;// IN parameter
CICell flag;// RETURN value
} nextprop;
struct {// nArgs=4, nReturns=1( phandle name buf buflen -- size )
CICell phandle;// IN parameter
char *name;// IN parameter
char *buf;// IN parameter
CICell buflen;// IN parameter
CICell size;// RETURN value
} setprop;
struct {// nArgs=1, nReturns=0
char *bootspec;
} boot;
} args;
};
typedef struct CIArgs CIArgs;
typedef long (*ClientInterfacePtr)(CIArgs *args);
// ci.c
long InitCI(ClientInterfacePtr ciPtr);
long CallCI(CIArgs *ciArgsPtr);
// Device Tree
CICell Peer(CICell phandle);
CICell Child(CICell phandle);
CICell Parent(CICell phandle);
CICell FindDevice(char *devSpec);
CICell InstanceToPath(CICell ihandle, char *buf, long buflen);
CICell InstanceToPackage(CICell ihandle);
CICell PackageToPath(CICell phandle, char *buf, long buflen);
CICell GetPropLen(CICell phandle, char *name);
CICell GetProp(CICell phandle, char *name, char *buf, long buflen);
CICell NextProp(CICell phandle, char *previous, char *buf);
CICell SetProp(CICell phandle, char *name, char *buf, long buflen);
// Device I/O
CICell Open(char *devSpec);
void Close(CICell ihandle);
CICell Read(CICell ihandle, long addr, long length);
CICell Write(CICell ihandle, long addr, long length);
CICell Seek(CICell ihandle, long long position);
// Call Method
long CallMethod(long args, long rets, CICell iHandle, const char *method, ...);
// Memory
CICell Claim(CICell virt, CICell size, CICell align);
void Release(CICell virt, CICell size);
// Control Transfer
void Boot(char *bootspec);
void Enter(void);
void Exit(void);
void Quiesce(void);
// Interpret
long Interpret(long args, long rets, const char *forthString, ...);
#endif /* ! _BOOTX_CI_H_ */
branches/xZenu/src/arch/ppc/include/sl_words.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* 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.h - Headers for the Secondary Loader Words.
*
* Copyright (c) 1998-2000 Apple Computer, Inc.
*
* DRI: Josh de Cesare
*/
#ifndef _BOOTX_SL_WORDS_H_
#define _BOOTX_SL_WORDS_H_
#include <ci.h>
// The iHandle for the SL Words.
extern CICell SLWordsIH;
// Call InitSLWords before using SLWordsIH.
// outputLevel is used to supress output.
// 0 - all off
// 1 - OF stdout only
// 2 - SLW's emit and cr.
// 3 - ???
extern long InitSLWords(void);
// Suported words.
// slw_set_output_level ( level -- )
// set the current output level.
extern void SetOutputLevel(long level);
// slw_emit ( ch -- ) Output Level: 2
// calls emit ( ch -- )
extern void Emit(char ch);
// slw_cr ( -- ) Output Level: 2
// calls cr ( -- )
extern void CR(void);
// slw_init_keymap ( keyboardIH -- keyMap )
// sets the ihandle for the keyboard and
// puts the address of the keyMap on the stack
extern char *InitKeyMap(CICell keyboardIH);
// slw_update_keymap ( -- )
// Called by slw_spin to make sure all the keys are caught.
extern void UpdateKeyMap(void);
// slw_spin_init ( screenIH cursorAddr cursorX cursorY cursorW cursorH --)
// Sets up the wait cursor.
extern void SpinInit(CICell screenIH, char *cursorAddr,
long cursorX, long cursorY,
long cursorW, long cursorH,
long frames, long fps,
long pixelSize, long spare);
// slw_spin ( -- )
// Spins the wait cursor.
extern void Spin(void);
extern long GetPackageProperty(CICell phandle, char *propName,
char **propAddr, long *propLen);
// slw_pwd ( phandle addr len -- act )
// does pwd the hard way.
#define SL_DEBUG (0)
/*
.sc ( -- )
does a simple stack crawl.
*/
#endif /* ! _BOOTX_SL_WORDS_H_ */
branches/xZenu/src/arch/ppc/include/device_tree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* 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_ */
branches/xZenu/src/arch/ppc/include/sl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/*
* 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.h - Headers for configuring the Secondary Loader
*
* Copyright (c) 1998-2005 Apple Computer, Inc.
*
* DRI: Josh de Cesare
*/
#ifndef _BOOTX_SL_H_
#define _BOOTX_SL_H_
// i.e. should we put up our failure screen; else back to OF
#define kFailToBoot (1)
/*
Memory Map: assumed 96 MB (temporarily bumping to 112 MB for 4359362)
Physical Address
Open Firmware Version 3x, 4x, ...
00000000 - 00003FFF : Exception Vectors
00004000 - 057FFFFF : Free Memory
// 05800000 - 05FFFFFF : OF Image (top 8 MB reserved) [96 MB map]
06800000 - 06FFFFFF : OF Image (top 8 MB reserved) [112 MB map]
Logical Address
// 96 MB map (currently unused - 4363357 tracks re-adoption)
00000000 - 00003FFF : Exception Vectors
00004000 - 03FFFFFF : Kernel Image, Boot Struct and Drivers (~64 MB)
04000000 - 04FFFFFF : File Load Area (16 MB) [80 MB]
05000000 - 053FFFFF : FS Cache (4 MB) [84 MB]
05400000 - 055FFFFF : Malloc Zone (2 MB)[86 MB]
05600000 - 057FFFFF : BootX Image (2 MB)[88 MB]
05800000 - 05FFFFFF : Unused/OF (8 MB)[96 MB]
// 112 MB map (per 4359362)
00000000 - 00003FFF : Exception Vectors
00004000 - 03FFFFFF : Kernel Image, Boot Struct and Drivers (~64 MB)
04000000 - 05FFFFFF : File Load Area (32 MB) [96 MB]
06000000 - 063FFFFF : FS Cache (4 MB) [100 MB]
06400000 - 065FFFFF : Malloc Zone (2 MB)[102 MB]
06600000 - 067FFFFF : BootX Image (2 MB)[104 MB]
06800000 - 06FFFFFF : Unused/OF (8 MB)[112 MB]
*/
#define kVectorAddr (0x00000000)
#define kVectorSize (0x00004000)
// OF 3.x
#define kImageAddr (0x00004000)
#define kImageSize (0x03FFC000)
// OF 1.x 2.x
#define kImageAddr0 (0x00004000)
#define kImageSize0 (0x002FC000)
#define kImageAddr1 (0x00300000)
#define kImageSize1 (0x00200000)
#define kImageAddr1Phys (0x05800000)
#define kImageAddr2 (0x00500000)
#define kImageSize2 (0x03B00000)
#define kLoadAddr (0x04000000)
#define kLoadSize (0x02000000)// 32 MB @ 64
#define kMaxMKextSize (0x01000000)// only allow 16 MB of drivers
#define kFSCacheAddr (0x06000000)
#define kFSCacheSize (0x00400000)// 4 MB @ 96
#define kMallocAddr (0x06400000)
#define kMallocSize (0x00200000)// 2 MB @ 100
#define kMallocAddr_H (0x06400000)// ditto for hibernate
#define kMallocSize_H (0x00200000)
#define kImageAddr_H (0x07000000)// fallback for hiberate image buffer
// Default Output Level
#define kOutputLevelOff (0)
#define kOutputLevelFull (16)
// OF versions
#define kOFVersion1x (0x01000000)
#define kOFVersion2x (0x02000000)
#define kOFVersion3x (0x03000000)
#define kOFVersion4x (0x04000000)
// Device Types
enum {
kUnknownDeviceType = 0,
kNetworkDeviceType,
kBlockDeviceType
};
// File Permissions and Types
enum {
kPermOtherExecute = 1 << 0,
kPermOtherWrite = 1 << 1,
kPermOtherRead = 1 << 2,
kPermGroupExecute = 1 << 3,
kPermGroupWrite = 1 << 4,
kPermGroupRead = 1 << 5,
kPermOwnerExecute = 1 << 6,
kPermOwnerWrite = 1 << 7,
kPermOwnerRead = 1 << 8,
kPermMask = 0x1FF,
kOwnerNotRoot = 1 << 9,
kFileTypeUnknown = 0x0 << 16,
kFileTypeFlat = 0x1 << 16,
kFileTypeDirectory = 0x2 << 16,
kFileTypeLink = 0x3 << 16,
kFileTypeMask = 0x3 << 16
};
// Key Numbers
#define kCommandKey (0x200)
#define kOptKey (0x201)
#define kShiftKey (0x202)
#define kControlKey (0x203)
#define kDeleteKey (0x204)
// Mac OS X Booter Signature 'MOSX'
#define kMacOSXSignature (0x4D4F5358)
// Boot Modes
enum {
kBootModeNormal = 0,
kBootModeSafe,
kBootModeSecure
};
#include <sys/types.h>
#include <stdint.h>
#include <stdio.h>
#include <ci.h>
#include <sl_words.h>
#include <libclite.h>
#include <fs.h>
#include <boot_args.h>
// 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;
extern long gDeviceTreeAddr;
extern long gDeviceTreeSize;
extern long gBootArgsAddr;
extern long gBootArgsSize;
extern long gSymbolTableAddr;
extern long gSymbolTableSize;
extern long gBootMode;
extern long gBootDeviceType;
extern long gBootFileType;
extern char gHaveKernelCache;
extern char gBootDevice[256];
extern char gBootFile[256];
extern TagPtr gBootDict;
extern char gTempStr[4096];
extern long *gDeviceTreeMMTmp;
extern long gOFVersion;
extern char *gKeyMap;
extern long gRootAddrCells;
extern long gRootSizeCells;
extern CICell gChosenPH;
extern CICell gOptionsPH;
extern CICell gScreenPH;
extern CICell gMemoryMapPH;
extern CICell gStdOutPH;
extern CICell gMMUIH;
extern CICell gMemoryIH;
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_ */
branches/xZenu/src/arch/ppc/include/boot_args.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* 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_ */
branches/xZenu/src/arch/ppc/include/Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#
# Generated by the NeXT Project Builder.
#
# NOTE: Do NOT change this file -- Project Builder maintains it.
#
# Put all of your customizations in files called Makefile.preamble
# and Makefile.postamble (both optional), and Makefile will include them.
#
NAME = include
PROJECTVERSION = 2.8
PROJECT_TYPE = Component
HFILES = boot_args.h ci.h device_tree.h fs.h libclite.h sl.h\
sl_words.h
OTHERSRCS = Makefile.preamble Makefile Makefile.postamble
MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
CODE_GEN_STYLE = DYNAMIC
MAKEFILE = subproj.make
LIBS =
DEBUG_LIBS = $(LIBS)
PROF_LIBS = $(LIBS)
NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc
WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc
PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc
NEXTSTEP_JAVA_COMPILER = /usr/bin/javac
WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe
PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac
include $(MAKEFILEDIR)/platform.make
-include Makefile.preamble
include $(MAKEFILEDIR)/$(MAKEFILE)
-include Makefile.postamble
-include Makefile.dependencies
branches/xZenu/src/arch/ppc/include/libclite.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* 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@
*/
/*
* libclite.h - Headers for the LibC Lite Functions
*
* Ported from i386's libsa and libsaio
*
* Copyright (c) 1998-2002 Apple Computer, Inc.
*
* DRI: Josh de Cesare
*/
#ifndef _BOOTX_LIBCLITE_H_
#define _BOOTX_LIBCLITE_H_
#include <sys/types.h>
#include <stdarg.h>
#include <stddef.h>
// ci_io.c
extern int putchar(int ch);
extern int puts(const char *str);
// bswap.c
extern int16_t bswap16(int16_t data);
extern int32_t bswap32(int32_t data);
#endif /* ! _BOOTX_LIBCLITE_H_ */
branches/xZenu/src/arch/ppc/include/fs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* 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_ */
branches/xZenu/src/arch/ppc/libclite/Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
ROOT = $(shell pwd)/../../../../
DIR = libclite
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
INC = -I. -I$(SYMROOT) -I$(INCLUDESDIR) -I${SRCROOT}/include
OBJECTS = bswap
LIBS = libclite.a
LIBS := $(addprefix $(SYMROOT)/, $(LIBS))
DIRS_NEEDED =
include ${ROOT}/Make.rules
all: $(OBJROOT) $(SYMROOT) $(LIBS)
$(LIBS): ${ACTUAL_OBJECTS}
@echo "\t[RM] $@"
@rm -f $@
@echo "\t[AR] $(@F)"
@ar q $@ $^ &> /dev/null
@echo "\t[RANLIB] $(@F)"
@ranlib $(SYMROOT)/$(@F)
# dependencies
-include $(OBJROOT)/Makedep
branches/xZenu/src/arch/ppc/libclite/bswap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* 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@
*/
/*
* bswap.c - Endian Swapping functions.
*
* Copyright (c) 2000 Apple Computer, Inc.
*
* DRI: Josh de Cesare
*/
#include <libclite.h>
int16_t bswap16(int16_t data)
{
int16_t tmpData;
__asm__ volatile("sthbrx %0, 0, %1" : : "r" (data), "r" (&tmpData));
return tmpData;
}
int32_t bswap32(int32_t data)
{
int32_t tmpData;
__asm__ volatile("stwbrx %0, 0, %1" : : "r" (data), "r" (&tmpData));
return tmpData;
}
branches/xZenu/src/arch/ppc/ci/Control2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
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# 16field>C.CUR-LINE "
"( 010 )d# 16field>C.VFPEQ "
"( 020 )d# 16field>C.VFP "
"( 030 )d# 16field>C.VAL "
"( 040 )d# 16field>C.VBP "
"( 050 )d# 16field>C.VBPEQ "
"( 060 )d# 16field>C.VSYNC "
"( 070 )d# 16field>C.VHLINE "
"( 080 )d# 16field>C.PIPED "
"( 090 )d# 16field>C.HPIX "
"( 0A0 )d# 16field>C.HFP "
"( 0B0 )d# 16field>C.HAL "
"( 0C0 )d# 16field>C.HBWAY "
"( 0D0 )d# 16field>C.HSP "
"( 0E0 )d# 16field>C.HEQ "
"( 0F0 )d# 16field>C.HLFLN "
"( 100 )d# 16field>C.HSERR "
"( 110 )d# 16field>C.CNTTST "
"( 120 )d# 16field>C.TEST "
"( 130 )d# 16field>C.GBASE "
"( 140 )d# 16field>C.ROW-WORDS "
"( 150 )d# 16field>C.MON-SENSE "
"( 160 )d# 16field>C.ENABLE "
"( 170 )d# 16field>C.GSC-DIVIDE "
"( 180 )d# 16field>C.REFRESH-COUNT "
"( 190 )d# 16field>C.INT-ENABLE "
"( 1A0 )d# 16field>C.INT-STATUS "
"drop "
"struct "
"d# 16field>R.REG-ADDR "
"d# 16field>R.CRSR-PALETTE "
"d# 16field>R.REG-DATA "
"d# 16field>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! "
"0h# 10 rad! "
"0h# 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! "
"; "
": ?TREQvPortB 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 widthregs >C.ROW-WORDS rl! "
"w@ to height "
"h# 31 bankB? not 8 and or "
"little? 2 and orregs >C.ENABLE rl! "
"0regs >C.GBASE rl! "
"h# 01e4regs >C.REFRESH-COUNT rl! "
"0regs >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};
branches/xZenu/src/arch/ppc/ci/ci_io.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* 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 <ci.h>
#include <sl_words.h>
#include <libclite.h>
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;
}
branches/xZenu/src/arch/ppc/ci/MAC-PARTS.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* 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,
};
branches/xZenu/src/arch/ppc/ci/ci.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
/*
* 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 <sl.h>
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;
// intercept software RAID's virtual devices
if(isRAIDPath(devSpec))
return (CICell)RAIDOpen(devSpec);
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;
if(isRAIDDevice((void*)ihandle)) {
RAIDClose((RAIDDevicePtr)ihandle);
return;
}
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;
if(isRAIDDevice((void*)ihandle))
return RAIDRead((RAIDDevicePtr)ihandle, addr, length, -1);
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;
if(isRAIDDevice((void*)ihandle)) {
printf("who's trying to write to RAID?!\n");
return -1;
}
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;
if(isRAIDDevice((void*)ihandle))
return RAIDSeek((RAIDDevicePtr)ihandle, position);
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;
}
branches/xZenu/src/arch/ppc/ci/Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
ROOT = $(shell pwd)/../../../../
DIR = ci
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
INC = -I. -I$(SYMROOT) -I$(INCLUDESDIR) -I${SRCROOT}/include
OBJECTS = ci_io ci Control2 MAC-PARTS sl_words
LIBS = libci.a
LIBS := $(addprefix $(SYMROOT)/, $(LIBS))
DIRS_NEEDED =
include ${ROOT}/Make.rules
all: $(OBJROOT) $(SYMROOT) $(LIBS)
$(LIBS): ${ACTUAL_OBJECTS}
@echo "\t[RM] $@"
@rm -f $@
@echo "\t[AR] $(@F)"
@ar q $@ $^ &> /dev/null
@echo "\t[RANLIB] $(@F)"
@ranlib $(SYMROOT)/$(@F)
# dependencies
-include $(OBJROOT)/Makedep
branches/xZenu/src/arch/ppc/ci/sl_words.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
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 <string.h>
#include <sl.h>
#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;
}
branches/xZenu/src/arch/ppc/Makefile
55
66
77
8
9
8
9
1010
1111
1212
1313
1414
1515
16
16
1717
1818
1919
#
ROOT = $(shell pwd)/../../../
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386
SYMROOT = $(ROOT)/sym/i386
OBJROOT = $(ROOT)/obj/${ARCH}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}
DOCROOT = $(ROOT)/doc
include ${ROOT}/Make.rules
# The order of building is important.
SUBDIRS =
SUBDIRS = libclite ci
all: ${OBJROOT} ${SYMROOT}
@for i in ${SUBDIRS}; \
branches/xZenu/src/arch/i386/libsaio/Makefile
11
22
33
4
5
6
4
5
6
77
88
99
ROOT = $(shell pwd)/../../../../
DIR = libsaio
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386/${DIR}
SYMROOT = $(ROOT)/sym/i386
DSTROOT = $(ROOT)/dst/usr/standalone/i386/
OBJROOT = $(ROOT)/obj/${ARCH}/${DIR}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}/
DOCROOT = $(ROOT)/doc
UTILDIR = ../util
branches/xZenu/src/arch/i386/boot0/Makefile
11
22
33
4
5
6
4
5
6
77
88
99
ROOT = $(shell pwd)/../../../../
DIR = boot0
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386/${DIR}
SYMROOT = $(ROOT)/sym/i386
DSTROOT = $(ROOT)/dst/usr/standalone/i386/
OBJROOT = $(ROOT)/obj/${ARCH}/${DIR}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}/
DOCROOT = $(ROOT)/doc
include ${ROOT}/Make.rules
branches/xZenu/src/arch/i386/boot1/Makefile
11
22
33
4
5
6
4
5
6
77
88
99
ROOT = $(shell pwd)/../../../../
DIR = boot1
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386/${DIR}
SYMROOT = $(ROOT)/sym/i386
DSTROOT = $(ROOT)/dst/usr/standalone/i386/
OBJROOT = $(ROOT)/obj/${ARCH}/${DIR}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}/
DOCROOT = $(ROOT)/doc
include ${ROOT}/Make.rules
branches/xZenu/src/arch/i386/boot2/Makefile
11
22
33
4
5
6
4
5
6
77
88
99
ROOT = $(shell pwd)/../../../../
DIR = boot2
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386/${DIR}
SYMROOT = $(ROOT)/sym/i386
DSTROOT = $(ROOT)/dst/usr/standalone/i386/
OBJROOT = $(ROOT)/obj/${ARCH}/${DIR}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}/
DOCROOT = $(ROOT)/doc
OPTIM = -Oz
branches/xZenu/src/arch/i386/cdboot/Makefile
11
22
33
4
5
6
4
5
6
77
88
99
ROOT = $(shell pwd)/../../../../
DIR = cdboot
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386/${DIR}
SYMROOT = $(ROOT)/sym/i386
DSTROOT = $(ROOT)/dst/usr/standalone/i386/
OBJROOT = $(ROOT)/obj/${ARCH}/${DIR}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}/
DOCROOT = $(ROOT)/doc
include ${ROOT}/Make.rules
branches/xZenu/src/arch/i386/Makefile
55
66
77
8
9
10
8
9
10
1111
1212
1313
#
ROOT = $(shell pwd)/../../../
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386
SYMROOT = $(ROOT)/sym/i386
DSTROOT = $(ROOT)/dst/usr/standalone/i386
OBJROOT = $(ROOT)/obj/${ARCH}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}
DOCROOT = $(ROOT)/doc
include ${ROOT}/Make.rules
branches/xZenu/src/arch/armv5/Makefile
55
66
77
8
9
8
9
1010
1111
1212
#
ROOT = $(shell pwd)/../../../
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386
SYMROOT = $(ROOT)/sym/i386
OBJROOT = $(ROOT)/obj/${ARCH}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}
DOCROOT = $(ROOT)/doc
branches/xZenu/src/arch/x86_64/Makefile
55
66
77
8
9
8
9
1010
1111
1212
#
ROOT = $(shell pwd)/../../../
SRCROOT = ${ROOT}/src
OBJROOT = $(ROOT)/obj/i386
SYMROOT = $(ROOT)/sym/i386
OBJROOT = $(ROOT)/obj/${ARCH}
SYMROOT = $(ROOT)/sym/${ARCH}
DSTROOT = $(ROOT)/dst/usr/standalone/${ARCH}
DOCROOT = $(ROOT)/doc

Archive Download the corresponding diff file

Revision: 1305