Hardcode info record location for dry run

At dry-run time, the NanoKernel is not asked for the location of HWInfo.
The pointer block at 5FFFEFC0 is used instead. The location of
ConfigInfo was already hardcoded.

This neatens things up considerably, but will cause the dry-run Wedge to
crash on a machine with a Wedged address space. If the
NKLocateInfoRecord code can be cleaned up a bit, then it might be
restored.
This commit is contained in:
Elliot Nunn 2018-01-14 09:57:59 +08:00
parent 3fab004b24
commit 7c5857f00b
4 changed files with 2 additions and 112 deletions

View File

@ -26,7 +26,7 @@ Apps = :Apps:
{IM}Linker Ä {IM}Linker.c.o
ILink -d -t 'MPST' -c 'MPS ' -o {Targ} {MpwToolLibs68k} {Deps}
{Apps}TestWedge Ä {IM}Wedge.c.x {IM}NKShim.s.x
{Apps}TestWedge Ä {IM}Wedge.c.x
PPCLink -d -t 'APPL' -c 'siow' -o {Targ} {Deps} {SiowLibsPPC}
Rez -a "{RIncludes}SIOW.r" -d DEFAULT_SAVE_PREF=1 -o {Targ}

View File

@ -1,24 +0,0 @@
#pragma once
#include <MacTypes.h>
OSErr NKxprintf(char *);
enum {
kNKSystemInfo = 2,
kNKDiagInfo = 3,
kNKNanoKernelInfo = 4,
kNKProcessorInfo = 5,
kNKHWInfo = 6,
kNKProcessorState = 7,
};
OSErr NKLocateInfoRecord(long whichRecord, char **record, long *version, long *length);
OSErr NKKernelDebuggerCmd(char *cmd);

View File

@ -1,84 +0,0 @@
; MakeFunction sets up everything you need to make an assembly function
; callable from C and debuggable with a symbolic debugger. It does the following:
; - export the function's transition vector
; - export the function name
; - create a toc entry for the function's transition vector
; - create the transition vector, which must contain
; - the function entry point (the name of the function)
; - the TOC anchor (the predefined variable TOC[tc0])
; - tell PPCAsm to create a function entry point symbol for symbolic debuggers
; - create a csect for the function (one csect per function lets the
; linker do dead code stripping, resulting in smaller executables)
MACRO
MakeFunction &fnName
EXPORT &fnName[DS]
EXPORT .&fnName[PR]
TC &fnName[TC], &fnName[DS]
CSECT &fnName[DS]
DC.L .&fnName[PR]
DC.L TOC[tc0]
CSECT .&fnName[PR]
FUNCTION .&fnName[PR]
ENDM
linkageArea: set 24 ; constant comes from the PowerPC Runtime Architecture Document
CalleesParams: set 32 ; always leave space for GPR's 3-10
CalleesLocalVars: set 0 ; NKxprintf doesn't have any
numGPRs: set 0 ; num volitile GPR's (GPR's 13-31) used by NKxprintf
numFPRs: set 0 ; num volitile FPR's (FPR's 14-31) used by NKxprintf
spaceToSave: set linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs
; declare the C function DisplayAlert as external
import .DisplayAlert
import gHelloString ; global variable from C program
import gGoodbyeString ; global variable from C program
toc
tc gHelloString[TC], gHelloString
tc gGoodbyeString[TC], gGoodbyeString
; Call the MakeFunction macro, defined in MakeFunction.s to begin the function
MakeFunction NKxprintf
li r0, 96
sc
blr
MakeFunction NKLocateInfoRecord ; Lifted shamelessly from MPLibrary
stw r4,0x001C(SP)
stw r5,0x0020(SP)
stw r6,0x0024(SP)
li r0,107
sc
cmpwi r3,0
bnelr
lwz r7,0x001C(SP)
lwz r8,0x0020(SP)
lwz r9,0x0024(SP)
cmplwi cr5,r7,0x0000
cmplwi cr6,r8,0x0000
cmplwi cr7,r9,0x0000
beq cr5,$+0x0008 ; 0x00008440
stw r4,0x0000(r7)
beq cr6,$+0x0008 ; 0x00008448
stw r5,0x0000(r8)
beq cr7,$+0x0008 ; 0x00008450
stw r6,0x0000(r9)
blr
MakeFunction NKKernelDebuggerCmd
li r0, 200
sc
blr

View File

@ -1,5 +1,4 @@
#include "PPCInfoRecordsPriv.h"
#include "NKShim.h"
#include <MacTypes.h>
@ -734,7 +733,6 @@ void main(void)
{
char ci_tmp[kConfigInfoSize], hi_tmp[kHardwareInfoSize];
char *ci, *hi;
long nk_struct_ver, nk_struct_len;
int ret;
printf("Hello from the (dry-run) Wedge.\n");
@ -742,7 +740,7 @@ void main(void)
ci = (char *)0x68fef000UL;
printf(" ConfigInfo @ %08x\n", ci);
NKLocateInfoRecord(6, &hi, &nk_struct_ver, &nk_struct_len);
hi = *(char **)nkHWInfoPtr;
printf(" HardwareInfo @ %08x\n", hi);
printf("\n");