14 #define MODNAME "UpDate DownLoader"
16 IRX_ID(MODNAME, 1, 1);
19 int CpuExecuteKmode(
void *
function, ...);
24 #define DEBUG_PRINTF(args...) printf(args)
26 #define DEBUG_PRINTF(args...)
29 #define FULL_UDNL 1 // Comment out to build a UDNL module that updates the IOP with only its payload.
30 #define MAX_MODULES 256
32 #define alloca(size) __builtin_alloca(size) // The homebrew PS2SDK lacks alloca.h.
35 static void CopySection(
const void *module,
void *buffer,
unsigned int FileSize);
36 static void *AllocMemory(
int nbytes);
108 unsigned int MemSize;
109 unsigned int BootMode;
113 unsigned int IOPRPBufferSize;
114 unsigned int NumModules;
115 const void **ModData;
120 static int var_00001e20 = 0;
122 static int var_00001850 = 0;
126 #ifdef USE_EMBEDDED_IOPRP
127 extern unsigned char IOPRP_img[];
128 extern unsigned int size_IOPRP_img;
133 const void *ImageStart;
134 const void *RomdirStart;
135 const void *RomdirEnd;
140 const char *filename;
149 unsigned short int ExtInfoEntrySize;
154 static void *GetIOPRPStat(
const void *start,
const void *end,
struct RomImgData *ImageStat)
156 const unsigned int *ptr, *ptr2;
161 while ((
unsigned int)ptr < (
unsigned int)end) {
164 if (ptr[0] == 0x45534552 && ptr2[-6] == 0x54 && (*(
unsigned short int *)&ptr2[-5] == 0) && (((ptr2[-4] + 0xF) & 0xFFFFFFF0) == offset)) {
165 ImageStat->ImageStart = start;
166 ImageStat->RomdirStart = ptr;
167 ImageStat->RomdirEnd = (
void *)((
unsigned int)ptr + *ptr2);
175 ImageStat->ImageStart = 0;
184 unsigned int padding;
190 unsigned int i, offset, ExtInfoOffset;
191 unsigned char filename_temp[12];
199 ((
unsigned int *)filename_temp)[0] = 0;
200 ((
unsigned int *)filename_temp)[1] = 0;
201 ((
unsigned int *)filename_temp)[2] = 0;
202 for (i = 0; *filename >= 0x21 && i <
sizeof(filename_temp); i++) {
203 filename_temp[i] = *filename;
207 if (ImageStat->RomdirStart != NULL) {
208 RomdirEntry = ImageStat->RomdirStart;
211 if (((
unsigned int *)filename_temp)[0] == ((
unsigned int *)RomdirEntry->name)[0] && ((
unsigned int *)filename_temp)[1] == ((
unsigned int *)RomdirEntry->name)[1] && (*(
unsigned short int *)&((
unsigned int *)filename_temp)[2] == *(
unsigned short int *)&((
unsigned int *)RomdirEntry->name)[2])) {
213 stat->romdirent = RomdirEntry;
214 stat->data = (
void *)((u8 *)(ImageStat->ImageStart) + offset);
215 stat->extinfo = NULL;
217 if (RomdirEntry->ExtInfoEntrySize > 0) {
218 stat->extinfo = (
void *)((
unsigned int)ImageStat->RomdirEnd + ExtInfoOffset);
230 offset += (RomdirEntry->size + 0xF) & 0xFFFFFFF0;
231 ExtInfoOffset += RomdirEntry->ExtInfoEntrySize;
233 }
while (((
unsigned int *)RomdirEntry->name)[0] != 0x00000000);
254 static void ScanImagesForFile(
const struct ImageData *ImageDataBuffer,
unsigned int NumFiles,
struct RomdirFileStat *stat,
const char *filename)
275 if (GetFileStatFromImage(&
ImageData->stat, filename, stat) != 0) {
276 DEBUG_PRINTF(
"File: %s, image: %s\n", filename,
ImageData->filename);
287 printf(
"kupdate: panic ! \'%s\' not found\n", filename);
289 printf(
"panic ! \'%s\' not found\n", filename);
295 static void TerminateResidentLibraries(
const char *message,
unsigned int options,
int mode)
304 if ((LoadcoreData = GetLoadcoreInternalData()) != NULL) {
305 ModuleData = LoadcoreData->let_next;
306 while (ModuleData != NULL) {
307 NextModule = ModuleData->prev;
310 if (!(ModuleData->flags & 6)) {
311 ModuleData = NextModule;
314 }
else if ((ModuleData->flags & 6) == 2) {
315 ModuleData = NextModule;
319 ExportTable = ModuleData->exports;
320 if (ExportTable[1] != NULL && ExportTable[2] != NULL) {
321 int (*pexit)(
int arg1);
323 pexit = ExportTable[2];
327 ModuleData = NextModule;
334 volatile unsigned int *address, *delay;
339 (
volatile unsigned int *)0xbf801000,
340 (
volatile unsigned int *)0xbf801008},
341 {(
volatile unsigned int *)0xbf801400,
342 (
volatile unsigned int *)0xbf80100C},
343 {(
volatile unsigned int *)0xbf801404,
344 (
volatile unsigned int *)0xbf801014},
345 {(
volatile unsigned int *)0xbf801408,
346 (
volatile unsigned int *)0xbf801018},
347 {(
volatile unsigned int *)0xbf80140C,
348 (
volatile unsigned int *)0xbf801414},
349 {(
volatile unsigned int *)0xbf801410,
350 (
volatile unsigned int *)0xbf80141C},
355 static volatile unsigned int *func_00000f80(
volatile unsigned int *address)
360 while (pSSBUS_regs->address != NULL) {
361 if (pSSBUS_regs->address == address)
366 return pSSBUS_regs->delay;
370 void func_00001b38(
unsigned int arg1);
373 static void TerminateResidentEntriesDI(
unsigned int options)
376 volatile unsigned int **pReg;
378 TerminateResidentLibraries(
" kupdate:di: Terminate resident Libraries\n", options, 0);
382 if (!(options & 1)) {
383 pReg = (prid < 0x10 || ((*(
volatile unsigned int *)0xbf801450) & 8)) ? *(
volatile unsigned int ***)0xbfc02008 : *(
volatile unsigned int ***)0xbfc0200C;
385 while (pReg[0] != 0) {
386 if (func_00000f80(pReg[0]) != 0)
387 pReg[0] = (
void *)0xFF;
392 if (!(options & 2)) {
393 func_00001b38((prid < 0x10 || ((*(
volatile unsigned int *)0xbf801450) & 8)) ? *(
volatile unsigned int *)0xbfc02010 : *(
volatile unsigned int *)0xbfc02014);
400 unsigned int ModuleType;
404 unsigned int text_size;
405 unsigned int data_size;
406 unsigned int bss_size;
407 unsigned int MemSize;
409 unsigned int unknown_24;
413 void func_00001930(
void);
415 void func_00001440(
void);
418 enum IOP_MODULE_TYPES {
419 IOP_MOD_TYPE_COFF = 1,
428 unsigned int Ident_10;
429 const struct scnhdr *COFF_ScnHdr;
441 memcpy(&Ident_10, &((
struct coff_filehdr *)module)->f_opthdr, 4);
444 if (((
struct coff_filehdr *)module)->f_magic == MIPSELMAGIC && COFF_AoutHdr->magic == OMAGIC && ((
struct coff_filehdr *)module)->f_nscns < 0x20 && ((Ident_10 & 0x0002FFFF) == 0x20038) && COFF_ScnHdr->s_paddr == COFF_AoutHdr->text_start) {
445 if (COFF_AoutHdr->vstamp != 0x7001) {
448 ModuleInfo->EntryPoint = (
void *)COFF_AoutHdr->entry;
449 ModuleInfo->gp = (
void *)COFF_AoutHdr->gp_value;
450 ModuleInfo->text_start = (
void *)COFF_AoutHdr->text_start;
454 ModuleInfo->MemSize = COFF_AoutHdr->bss_start + COFF_AoutHdr->bsize - COFF_AoutHdr->text_start;
464 ELF_phdr = (
elf_pheader_t *)((
unsigned int)module + ELF_Hdr->phoff);
466 if (((
unsigned short int *)ELF_Hdr->ident)[2] == 0x101 && ELF_Hdr->machine == 8 && ELF_Hdr->phentsize ==
sizeof(
elf_pheader_t) && ELF_Hdr->phnum == 2 && (ELF_phdr->type == (SHT_LOPROC | SHT_LOPROC_IOPMOD)) && (ELF_Hdr->type == ELF_TYPE_SCE_IRX || ELF_Hdr->type == 2)) {
467 ModuleInfo->ModuleType = ELF_Hdr->type == 0xFF80 ? IOP_MOD_TYPE_IRX : IOP_MOD_TYPE_ELF;
470 iopmod = (
struct iopmod *)((
unsigned int)module + ELF_phdr->offset);
473 ModuleInfo->text_start = (
void *)ELF_phdr[1].vaddr;
488 static void CopySection(
const void *module,
void *buffer,
unsigned int FileSize)
491 const unsigned int *src;
496 src_end = (
const void *)((
unsigned int)module + (FileSize >> 2 << 2));
497 while ((
unsigned int)src < (
unsigned int)src_end) {
505 static void ZeroSection(
unsigned int *buffer,
unsigned int NumWords)
507 while (NumWords > 0) {
515 static void LoadELFModule(
const void *module)
521 ELF_phdr = (
elf_pheader_t *)((
unsigned int)module + ELF_Hdr->phoff);
523 CopySection((
void *)((
unsigned int)module + ELF_phdr[1].offset), (
void *)ELF_phdr[1].vaddr, ELF_phdr[1].filesz);
525 if (ELF_phdr[1].filesz < ELF_phdr[1].memsz) {
526 ZeroSection((
unsigned int *)(ELF_phdr[1].vaddr + ELF_phdr[1].filesz), (ELF_phdr[1].memsz - ELF_phdr[1].filesz) >> 2);
531 static void LoadCOFFModule(
const void *module)
534 const struct scnhdr *ScnHdr;
545 CopySection((
void *)((
unsigned int)module + ScnHdr[0].s_size), (
void *)COFF_AoutHdr->text_start, COFF_AoutHdr->tsize);
546 CopySection((
void *)((
unsigned int)module + COFF_AoutHdr->tsize), (
void *)COFF_AoutHdr->data_start, COFF_AoutHdr->dsize);
548 if (COFF_AoutHdr->bss_start != 0 && COFF_AoutHdr->bsize != 0) {
549 ZeroSection((
unsigned int *)COFF_AoutHdr->bss_start, COFF_AoutHdr->bsize >> 2);
559 unsigned int NumRelocs, i, SectionNum;
561 unsigned int temp, *WordPatchLocation;
564 ELF_phdr = (
elf_pheader_t *)((
unsigned int)module + ELF_hdr->phoff);
569 if (
ModuleInfo->mod_id != (
void *)0xFFFFFFFF) {
573 ELF_shdr = (
elf_shdr_t *)((
unsigned int)module + ELF_hdr->shoff);
575 CopySection((
void *)((
unsigned int)module + ELF_phdr[1].offset),
ModuleInfo->text_start, ELF_phdr[1].filesz);
578 if (ELF_phdr[1].filesz < ELF_phdr[1].memsz) {
579 ZeroSection((
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_phdr[1].filesz), (ELF_phdr[1].memsz - ELF_phdr[1].filesz) >> 2);
583 for (SectionNum = 0, CurrentELF_shdr = ELF_shdr + 1; SectionNum < ELF_hdr->shnum; SectionNum++, CurrentELF_shdr++) {
584 if (CurrentELF_shdr->type == SHT_REL) {
585 NumRelocs = CurrentELF_shdr->size / CurrentELF_shdr->entsize;
588 for (i = 0, ELF_relocation = (
elf_rel *)((
unsigned int)module + CurrentELF_shdr->offset); i < NumRelocs; i++, ELF_relocation++) {
591 switch (ELF_relocation->info & 0xFF) {
595 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset);
596 *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (((
unsigned int)
ModuleInfo->text_start + *(
short int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset)) & 0xFFFF);
599 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset);
600 *WordPatchLocation += (
unsigned int)
ModuleInfo->text_start;
605 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset);
606 *WordPatchLocation = (((
unsigned int)
ModuleInfo->text_start + ((*WordPatchLocation & 0x03FFFFFF) << 2 | ((
unsigned int)WordPatchLocation & 0xF0000000))) << 4 >> 6) | (*WordPatchLocation & 0xFC000000);
609 temp = (((
unsigned int)*(
unsigned short int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset)) << 16) + *(
short int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation[1].offset);
611 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset);
612 *WordPatchLocation = (((temp >> 15) + 1) >> 1 & 0xFFFF) | (*WordPatchLocation & 0xFFFF0000);
613 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation[1].offset);
614 *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (temp & 0xFFFF);
630 unsigned short int version;
631 unsigned short int newflags;
632 unsigned short int id;
633 unsigned short int flags;
637 unsigned int text_size;
638 unsigned int data_size;
639 unsigned int bss_size;
640 unsigned int unused1;
641 unsigned int unused2;
653 if (
ModuleInfo->mod_id != (
void *)0xFFFFFFFF) {
670 case IOP_MOD_TYPE_ELF:
671 LoadELFModule(module);
673 case IOP_MOD_TYPE_COFF:
674 LoadCOFFModule(module);
676 case IOP_MOD_TYPE_IRX:
698 int (*ModuleEntryPoint)(
int arg1);
702 TerminateResidentEntriesDI(options);
709 MemSizeInBytes =
ResetData->MemSize << 20;
712 switch (InitModuleInfo(
ResetData->ModData[0], &LoadedModules[0])) {
714 case IOP_MOD_TYPE_IRX:
715 LoadedModules[0].text_start = (
void *)((
unsigned int)
ResetData->StartAddress + 0x30);
717 case IOP_MOD_TYPE_COFF:
718 case IOP_MOD_TYPE_ELF:
719 LoadModule(
ResetData->ModData[0], &LoadedModules[0]);
730 ModuleEntryPoint = LoadedModules[0].EntryPoint;
731 FreeMemStart = (
void *)ModuleEntryPoint(MemSizeInBytes);
734 switch (InitModuleInfo(
ResetData->ModData[1], &LoadedModules[1])) {
736 case IOP_MOD_TYPE_IRX:
737 LoadedModules[1].text_start = (
void *)((
unsigned int)FreeMemStart + 0x30);
739 case IOP_MOD_TYPE_COFF:
740 case IOP_MOD_TYPE_ELF:
741 LoadModule(
ResetData->ModData[1], &LoadedModules[1]);
752 ResetData->StartAddress = LoadedModules[0].text_start;
754 ModuleEntryPoint = LoadedModules[1].EntryPoint;
759 *(
volatile unsigned char *)0x80000000 = 2;
763 static void *ParseStartAddress(
const char **line)
770 while (*ptr >= 0x30) {
771 unsigned char character;
775 if (character <
':') {
777 }
else if (character <
'a') {
783 address = (
void *)(((
unsigned int)address << 4) + character);
793 unsigned short int data;
794 unsigned short int header;
801 const void *extinfo_end;
804 RomDirEnt = stat->romdirent;
805 extinfo_end = (
unsigned char *)stat->extinfo + (RomDirEnt->ExtInfoEntrySize >> 2 << 2);
808 while ((
unsigned int)
ExtInfoField < (
unsigned int)extinfo_end) {
809 unsigned int ExtInfoHeader;
813 if (ExtInfoHeader >> 24 == (
unsigned int)mode) {
827 int count, NumFilesRemaining, ImageFileIndexNumber;
832 unsigned int HighestFileVersionNum;
837 filename[
count] = *line;
840 }
while (count < 10 && *line >= 0x21);
842 filename[
count] =
'\0';
845 ImageFileIndexNumber = -1;
846 HighestFileVersionNum = 0;
847 NumFilesRemaining = NumFiles - 1;
849 ImageDataPtr = &ImageDataBuffer[NumFilesRemaining];
852 if (ImageDataPtr->filename != NULL) {
853 if (GetFileStatFromImage(&ImageDataPtr->stat, filename, &stat) != NULL) {
854 unsigned short int FileVersionNum;
856 ExtInfofield = GetFileInfo(&stat, 2);
858 GetFileInfo(&stat, 3);
861 if (ExtInfofield != NULL) {
862 FileVersionNum = ExtInfofield->data;
865 if (ImageFileIndexNumber < 0 || HighestFileVersionNum < FileVersionNum) {
866 ImageFileIndexNumber = NumFilesRemaining;
867 HighestFileVersionNum = FileVersionNum;
869 DEBUG_PRINTF(
"SelectModule: %s, %s, 0x%x\n", filename, ImageDataPtr->filename, FileVersionNum);
874 }
while (--NumFilesRemaining >= 0);
877 if (ImageFileIndexNumber >= 0) {
878 result = GetFileStatFromImage(&ImageDataBuffer[ImageFileIndexNumber].stat, filename, stat_out);
887 static void DisplayModuleName(
int id,
const char *line)
892 for (i = 0; i < 11 && line[i] >=
' '; i++) {
893 filename[i] = line[i];
897 DEBUG_PRINTF(
"%d: %s\n",
id, filename);
904 unsigned int FilesRemaining, i, NumModules;
906 char filename_temp[16];
909 const void **ModList;
911 if ((
unsigned int)stat->data < (
unsigned int)stat->data + stat->romdirent->size) {
912 FilesRemaining = NumFiles - 1;
922 ResetData->StartAddress = ParseStartAddress(&ptr);
925 if (strncmp(ptr,
"!addr ", 6) == 0) {
927 ModList[NumModules] = (
void *)(((
unsigned int)ParseStartAddress(&ptr) << 2) + 1);
932 ModList[NumModules] = NULL;
933 }
else if (strncmp(ptr,
"!include ", 9) == 0) {
937 while ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
939 filename_temp[i] = *ptr;
945 filename_temp[i] =
'\0';
947 ScanImagesForFile(ImageDataBuffer, FilesRemaining, &FileStat, filename_temp);
948 ParseIOPBTCONF(ImageDataBuffer, FilesRemaining, &FileStat,
ResetData);
981 DisplayModuleName(
ResetData->NumModules, ptr);
983 if (SelectModuleFromImages(ImageDataBuffer, NumFiles, ptr, &ModuleFileStat) == NULL) {
987 ModList[NumModules] = ModuleFileStat.data;
992 ModList[NumModules] = NULL;
996 if ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
997 while ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
1003 if ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
1004 while ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
1012 }
while ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size);
1016 int _start(
int argc,
char *argv[])
1018 int ImageDataTotalSize;
1023 void *buffer, *IoprpBuffer;
1027 int fd, file_sz = 0, i, NumFiles;
1032 unsigned int BootMode4, BootMode3, options;
1036 BootMode4 = 0xFFFFFFFF;
1038 if ((BootModePtr = QueryBootMode(4)) != NULL) {
1039 BootMode4 = *(
unsigned char *)BootModePtr;
1041 if ((BootModePtr = QueryBootMode(3)) != NULL) {
1042 BootMode3 = *(
unsigned int *)((
unsigned char *)BootModePtr + 4);
1064 ImageDataTotalSize = (argc + 2) *
sizeof(
struct ImageData);
1065 ImageDataBuffer = alloca(ImageDataTotalSize);
1066 memset(ImageDataBuffer, 0, ImageDataTotalSize);
1068 TotalSize = MAX_MODULES *
sizeof(
void *) +
sizeof(
struct ResetData);
1069 #ifdef USE_EMBEDDED_IOPRP
1070 TotalSize += ((size_IOPRP_img + 0xF) & ~0xF);
1082 if (strcmp(argv[i],
"-v") == 0) {
1086 if (strcmp(argv[i],
"-v") != 0)
1089 else if (strcmp(argv[i],
"-nobusini") == 0 || strcmp(argv[i],
"-nb") == 0) {
1091 }
else if (strcmp(argv[i],
"-nocacheini") == 0 || strcmp(argv[i],
"-nc") == 0) {
1109 if ((fd = open(argv[i], O_RDONLY)) < 0) {
1111 printf(
"kupdate: pannic ! file \'%s\' can't open\n", argv[i]);
1113 printf(
"file \'%s\' can't open\n", argv[i]);
1116 if (BootMode4 & 2) {
1124 file_sz = lseek(fd, 0, SEEK_END);
1125 lseek(fd, 0, SEEK_SET);
1130 TotalSize += (file_sz + 0xF) & ~0xF;
1149 if ((buffer = AllocMemory(TotalSize)) == NULL) {
1151 printf(
"kupdate: pannic ! can not alloc memory\n");
1153 printf(
"pannic ! can not alloc memory\n");
1156 if (BootMode4 & 2) {
1167 IoprpBuffer = (
void *)((
unsigned int)buffer + MAX_MODULES *
sizeof(
void *) +
sizeof(
struct ResetData));
1168 ResetData->IOPRPBuffer = (
void *)((
unsigned int)IoprpBuffer & 0x1FFFFF00);
1169 ResetData->MemSize = QueryMemSize() >> 20;
1172 if (BootMode3 & 0x00000080) {
1173 printf(
" Logical memory size 8MB ---> 2MB\n");
1180 if (GetIOPRPStat((
void *)0xbfc00000, (
void *)0xbfc10000, &ImageDataBuffer[0].stat) != NULL) {
1181 ImageDataBuffer[0].filename =
"ROM";
1184 if (BootMode3 & 0x00000100) {
1185 if (GetFileStatFromImage(&ImageDataBuffer[0].stat,
"OLDROM", &ROMStat) != 0 && GetIOPRPStat(ROMStat.data, (
const void *)((
const u8 *)(ROMStat.data) + 0x40000), &ImageDataBuffer[1].stat)) {
1186 memcpy(&ImageDataBuffer[0].stat, &ImageDataBuffer[1].stat,
sizeof(ImageDataBuffer[0].stat));
1187 printf(
" use alternate ROM image\n");
1193 #ifdef USE_EMBEDDED_IOPRP
1195 if (size_IOPRP_img >= 0x10 && GetIOPRPStat(IOPRP_img, &IOPRP_img[size_IOPRP_img], &ImageDataBuffer[1].stat) != NULL) {
1196 ImageDataBuffer[1].filename =
"DATA";
1197 ResetData->IOPRPBuffer = (
void*)((
unsigned int)IOPRP_img & ~0xF);
1200 if (size_IOPRP_img >= 0x10) {
1201 memcpy(IoprpBuffer, IOPRP_img, size_IOPRP_img);
1202 if (GetIOPRPStat(IoprpBuffer, (
void *)((
unsigned int)IoprpBuffer + size_IOPRP_img), &ImageDataBuffer[1].stat) != NULL) {
1203 ImageDataBuffer[1].filename =
"DATA";
1204 IoprpBuffer = (
void *)((u8 *)IoprpBuffer + ((size_IOPRP_img + 0xF) & ~0xF));
1217 if (GetIOPRPStat(IoprpBuffer, (
void *)((u8 *)IoprpBuffer + 0x4000), &
ImageData->stat) != NULL) {
1219 IoprpBuffer = (
void *)((u8 *)IoprpBuffer + ((
ImageData->size + 0xF) & ~0xF));
1227 }
while (i < NumFiles);
1234 ScanImagesForFile(ImageDataBuffer, NumFiles, &FileStat,
"IOPBTCONF");
1235 ParseIOPBTCONF(ImageDataBuffer, NumFiles, &FileStat,
ResetData);
1237 ScanImagesForFile(ImageDataBuffer, 2, &FileStat,
"IOPBTCONF");
1238 ParseIOPBTCONF(ImageDataBuffer, 2, &FileStat,
ResetData);
1241 DEBUG_PRINTF(
"Beginning IOP bootup sequence.\n");
1244 TerminateResidentLibraries(
" kupdate:ei: Terminate resident Libraries\n", options, 2);
1245 CpuExecuteKmode(&BeginBootupSequence,
ResetData, options);
1256 return MODULE_NO_RESIDENT_END;
1258 return MODULE_RESIDENT_END;
1263 static void *AllocMemory(
int nbytes)
1265 void *BlockTopAddress;
1268 BlockTopAddress = QueryBlockTopAddress((
void *)0x1860);
1269 BlockTopAddress = (
void *)((
unsigned int)BlockTopAddress & 0x7FFFFFFF);
1271 while ((result = QueryBlockSize(BlockTopAddress)) >= 0 || (result & 0x7FFFFFFF) < nbytes) {
1272 BlockTopAddress = QueryBlockTopAddress((
void *)(((
unsigned int)BlockTopAddress & 0x7FFFFFFF) + (result & 0x7FFFFFFF)));
1273 BlockTopAddress = (
void *)((
unsigned int)BlockTopAddress & 0x7FFFFFFF);
1275 }
while ((result & 0x7FFFFFFF) < nbytes);
1277 return AllocSysMemory(2, nbytes, BlockTopAddress);