13#define MODNAME "UpDate DownLoader"
18int CpuExecuteKmode(
void *function, ...);
23#define DEBUG_PRINTF(args...) printf(args)
25#define DEBUG_PRINTF(args...)
29#define MAX_MODULES 256
31#define alloca(size) __builtin_alloca(size)
34static void CopySection(
const void *module,
void *buffer,
unsigned int FileSize);
35static void *AllocMemory(
int nbytes);
107 unsigned int MemSize;
108 unsigned int BootMode;
112 unsigned int IOPRPBufferSize;
113 unsigned int NumModules;
114 const void **ModData;
119static int var_00001e20 = 0;
121static int var_00001850 = 0;
125#ifdef USE_EMBEDDED_IOPRP
126extern unsigned char IOPRP_img[];
127extern unsigned int size_IOPRP_img;
132 const void *ImageStart;
133 const void *RomdirStart;
134 const void *RomdirEnd;
139 const char *filename;
148 unsigned short int ExtInfoEntrySize;
153static void *GetIOPRPStat(
const void *start,
const void *end,
struct RomImgData *ImageStat)
155 const unsigned int *ptr, *ptr2;
160 while ((
unsigned int)ptr < (
unsigned int)end) {
163 if (ptr[0] == 0x45534552 && ptr2[-6] == 0x54 && (*(
unsigned short int *)&ptr2[-5] == 0) && (((ptr2[-4] + 0xF) & 0xFFFFFFF0) == offset)) {
164 ImageStat->ImageStart = start;
165 ImageStat->RomdirStart = ptr;
166 ImageStat->RomdirEnd = (
void *)((
unsigned int)ptr + *ptr2);
174 ImageStat->ImageStart = 0;
183 unsigned int padding;
189 unsigned int i, offset, ExtInfoOffset;
190 unsigned char filename_temp[12];
198 ((
unsigned int *)filename_temp)[0] = 0;
199 ((
unsigned int *)filename_temp)[1] = 0;
200 ((
unsigned int *)filename_temp)[2] = 0;
201 for (i = 0; *filename >= 0x21 && i <
sizeof(filename_temp); i++) {
202 filename_temp[i] = *filename;
206 if (ImageStat->RomdirStart != NULL) {
207 RomdirEntry = ImageStat->RomdirStart;
210 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])) {
212 stat->romdirent = RomdirEntry;
213 stat->data = (
void *)((u8 *)(ImageStat->ImageStart) + offset);
214 stat->extinfo = NULL;
216 if (RomdirEntry->ExtInfoEntrySize > 0) {
217 stat->extinfo = (
void *)((
unsigned int)ImageStat->RomdirEnd + ExtInfoOffset);
229 offset += (RomdirEntry->size + 0xF) & 0xFFFFFFF0;
230 ExtInfoOffset += RomdirEntry->ExtInfoEntrySize;
232 }
while (((
unsigned int *)RomdirEntry->name)[0] != 0x00000000);
253static void ScanImagesForFile(
const struct ImageData *ImageDataBuffer,
unsigned int NumFiles,
struct RomdirFileStat *stat,
const char *filename)
274 if (GetFileStatFromImage(&
ImageData->stat, filename, stat) != 0) {
275 DEBUG_PRINTF(
"File: %s, image: %s\n", filename,
ImageData->filename);
286 printf(
"kupdate: panic ! \'%s\' not found\n", filename);
288 printf(
"panic ! \'%s\' not found\n", filename);
294static void TerminateResidentLibraries(
const char *message,
unsigned int options,
int mode)
303 if ((LoadcoreData = GetLoadcoreInternalData()) != NULL) {
304 ModuleData = LoadcoreData->let_next;
305 while (ModuleData != NULL) {
306 NextModule = ModuleData->prev;
309 if (!(ModuleData->flags & 6)) {
310 ModuleData = NextModule;
313 }
else if ((ModuleData->flags & 6) == 2) {
314 ModuleData = NextModule;
318 ExportTable = ModuleData->exports;
319 if (ExportTable[1] != NULL && ExportTable[2] != NULL) {
320 int (*pexit)(
int arg1);
322 pexit = ExportTable[2];
326 ModuleData = NextModule;
333 volatile unsigned int *address, *delay;
338 (
volatile unsigned int *)0xbf801000,
339 (
volatile unsigned int *)0xbf801008},
340 {(
volatile unsigned int *)0xbf801400,
341 (
volatile unsigned int *)0xbf80100C},
342 {(
volatile unsigned int *)0xbf801404,
343 (
volatile unsigned int *)0xbf801014},
344 {(
volatile unsigned int *)0xbf801408,
345 (
volatile unsigned int *)0xbf801018},
346 {(
volatile unsigned int *)0xbf80140C,
347 (
volatile unsigned int *)0xbf801414},
348 {(
volatile unsigned int *)0xbf801410,
349 (
volatile unsigned int *)0xbf80141C},
354static volatile unsigned int *func_00000f80(
volatile unsigned int *address)
359 while (pSSBUS_regs->address != NULL) {
360 if (pSSBUS_regs->address == address)
365 return pSSBUS_regs->delay;
369void func_00001b38(
unsigned int arg1);
372static void TerminateResidentEntriesDI(
unsigned int options)
375 volatile unsigned int **pReg;
377 TerminateResidentLibraries(
" kupdate:di: Terminate resident Libraries\n", options, 0);
379 asm volatile(
"mfc0 %0, $15"
383 if (!(options & 1)) {
384 pReg = (prid < 0x10 || ((*(
volatile unsigned int *)0xbf801450) & 8)) ? *(
volatile unsigned int ***)0xbfc02008 : *(volatile unsigned int ***)0xbfc0200C;
386 while (pReg[0] != 0) {
387 if (func_00000f80(pReg[0]) != 0)
388 pReg[0] = (
void *)0xFF;
393 if (!(options & 2)) {
394 func_00001b38((prid < 0x10 || ((*(
volatile unsigned int *)0xbf801450) & 8)) ? *(
volatile unsigned int *)0xbfc02010 : *(volatile unsigned int *)0xbfc02014);
401 unsigned int ModuleType;
405 unsigned int text_size;
406 unsigned int data_size;
407 unsigned int bss_size;
408 unsigned int MemSize;
410 unsigned int unknown_24;
414void func_00001930(
void);
416void func_00001440(
void);
419enum IOP_MODULE_TYPES {
420 IOP_MOD_TYPE_COFF = 1,
429 unsigned int Ident_10;
430 const struct scnhdr *COFF_ScnHdr;
442 memcpy(&Ident_10, &((
struct coff_filehdr *)module)->f_opthdr, 4);
443 COFF_AoutHdr = (
AOUTHDR *)((
unsigned int)
module + sizeof(struct coff_filehdr));
444 COFF_ScnHdr = (
struct scnhdr *)((
unsigned int)
module + sizeof(struct coff_filehdr) + sizeof(AOUTHDR));
445 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) {
446 if (COFF_AoutHdr->vstamp != 0x7001) {
449 ModuleInfo->EntryPoint = (
void *)COFF_AoutHdr->entry;
450 ModuleInfo->gp = (
void *)COFF_AoutHdr->gp_value;
451 ModuleInfo->text_start = (
void *)COFF_AoutHdr->text_start;
455 ModuleInfo->MemSize = COFF_AoutHdr->bss_start + COFF_AoutHdr->bsize - COFF_AoutHdr->text_start;
465 ELF_phdr = (
elf_pheader_t *)((
unsigned int)
module + ELF_Hdr->phoff);
467 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)) {
468 ModuleInfo->ModuleType = ELF_Hdr->type == 0xFF80 ? IOP_MOD_TYPE_IRX : IOP_MOD_TYPE_ELF;
471 iopmod = (
struct iopmod *)((
unsigned int)
module + ELF_phdr->offset);
474 ModuleInfo->text_start = (
void *)ELF_phdr[1].vaddr;
489static void CopySection(
const void *module,
void *buffer,
unsigned int FileSize)
492 const unsigned int *src;
497 src_end = (
const void *)((
unsigned int)
module + (FileSize >> 2 << 2));
498 while ((
unsigned int)src < (
unsigned int)src_end) {
506static void ZeroSection(
unsigned int *buffer,
unsigned int NumWords)
508 while (NumWords > 0) {
516static void LoadELFModule(
const void *module)
522 ELF_phdr = (
elf_pheader_t *)((
unsigned int)
module + ELF_Hdr->phoff);
524 CopySection((
void *)((
unsigned int)module + ELF_phdr[1].offset), (
void *)ELF_phdr[1].vaddr, ELF_phdr[1].filesz);
526 if (ELF_phdr[1].filesz < ELF_phdr[1].memsz) {
527 ZeroSection((
unsigned int *)(ELF_phdr[1].vaddr + ELF_phdr[1].filesz), (ELF_phdr[1].memsz - ELF_phdr[1].filesz) >> 2);
532static void LoadCOFFModule(
const void *module)
535 const struct scnhdr *ScnHdr;
543 COFF_AoutHdr = (
AOUTHDR *)((
unsigned int)
module + sizeof(struct coff_filehdr));
544 ScnHdr = (
struct scnhdr *)((
unsigned int)
module + sizeof(struct coff_filehdr) + sizeof(AOUTHDR));
546 CopySection((
void *)((
unsigned int)module + ScnHdr[0].s_size), (
void *)COFF_AoutHdr->text_start, COFF_AoutHdr->tsize);
547 CopySection((
void *)((
unsigned int)module + COFF_AoutHdr->tsize), (
void *)COFF_AoutHdr->data_start, COFF_AoutHdr->dsize);
549 if (COFF_AoutHdr->bss_start != 0 && COFF_AoutHdr->bsize != 0) {
550 ZeroSection((
unsigned int *)COFF_AoutHdr->bss_start, COFF_AoutHdr->bsize >> 2);
560 unsigned int NumRelocs, i, SectionNum;
562 unsigned int temp, *WordPatchLocation;
565 ELF_phdr = (
elf_pheader_t *)((
unsigned int)
module + ELF_hdr->phoff);
570 if (
ModuleInfo->mod_id != (
void *)0xFFFFFFFF) {
574 ELF_shdr = (
elf_shdr_t *)((
unsigned int)
module + ELF_hdr->shoff);
576 CopySection((
void *)((
unsigned int)module + ELF_phdr[1].offset),
ModuleInfo->text_start, ELF_phdr[1].filesz);
579 if (ELF_phdr[1].filesz < ELF_phdr[1].memsz) {
580 ZeroSection((
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_phdr[1].filesz), (ELF_phdr[1].memsz - ELF_phdr[1].filesz) >> 2);
584 for (SectionNum = 0, CurrentELF_shdr = ELF_shdr + 1; SectionNum < ELF_hdr->shnum; SectionNum++, CurrentELF_shdr++) {
585 if (CurrentELF_shdr->type == SHT_REL) {
586 NumRelocs = CurrentELF_shdr->size / CurrentELF_shdr->entsize;
589 for (i = 0, ELF_relocation = (
elf_rel *)((
unsigned int)module + CurrentELF_shdr->offset); i < NumRelocs; i++, ELF_relocation++) {
592 switch (ELF_relocation->info & 0xFF) {
596 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset);
597 *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (((
unsigned int)
ModuleInfo->text_start + *(
short int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset)) & 0xFFFF);
600 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset);
601 *WordPatchLocation += (
unsigned int)
ModuleInfo->text_start;
606 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset);
607 *WordPatchLocation = (((
unsigned int)
ModuleInfo->text_start + ((*WordPatchLocation & 0x03FFFFFF) << 2 | ((
unsigned int)WordPatchLocation & 0xF0000000))) << 4 >> 6) | (*WordPatchLocation & 0xFC000000);
610 temp = (((
unsigned int)*(
unsigned short int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset)) << 16) + *(
short int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation[1].offset);
612 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation->offset);
613 *WordPatchLocation = (((temp >> 15) + 1) >> 1 & 0xFFFF) | (*WordPatchLocation & 0xFFFF0000);
614 WordPatchLocation = (
unsigned int *)((u8 *)(
ModuleInfo->text_start) + ELF_relocation[1].offset);
615 *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (temp & 0xFFFF);
632 unsigned short int newflags;
633 unsigned short int id;
634 unsigned short int flags;
638 unsigned int text_size;
639 unsigned int data_size;
640 unsigned int bss_size;
641 unsigned int unused1;
642 unsigned int unused2;
654 if (
ModuleInfo->mod_id != (
void *)0xFFFFFFFF) {
671 case IOP_MOD_TYPE_ELF:
672 LoadELFModule(module);
674 case IOP_MOD_TYPE_COFF:
675 LoadCOFFModule(module);
677 case IOP_MOD_TYPE_IRX:
699 int (*ModuleEntryPoint)(
int arg1);
703 TerminateResidentEntriesDI(options);
710 MemSizeInBytes =
ResetData->MemSize << 20;
713 switch (InitModuleInfo(
ResetData->ModData[0], &LoadedModules[0])) {
715 case IOP_MOD_TYPE_IRX:
716 LoadedModules[0].text_start = (
void *)((
unsigned int)
ResetData->StartAddress + 0x30);
718 case IOP_MOD_TYPE_COFF:
719 case IOP_MOD_TYPE_ELF:
720 LoadModule(
ResetData->ModData[0], &LoadedModules[0]);
731 ModuleEntryPoint = LoadedModules[0].EntryPoint;
732 FreeMemStart = (
void *)ModuleEntryPoint(MemSizeInBytes);
735 switch (InitModuleInfo(
ResetData->ModData[1], &LoadedModules[1])) {
737 case IOP_MOD_TYPE_IRX:
738 LoadedModules[1].text_start = (
void *)((
unsigned int)FreeMemStart + 0x30);
740 case IOP_MOD_TYPE_COFF:
741 case IOP_MOD_TYPE_ELF:
742 LoadModule(
ResetData->ModData[1], &LoadedModules[1]);
753 ResetData->StartAddress = LoadedModules[0].text_start;
755 ModuleEntryPoint = LoadedModules[1].EntryPoint;
760 *(
volatile unsigned char *)0x80000000 = 2;
764static void *ParseStartAddress(
const char **line)
771 while (*ptr >= 0x30) {
772 unsigned char character;
776 if (character <
':') {
778 }
else if (character <
'a') {
784 address = (
void *)(((
unsigned int)address << 4) + character);
794 unsigned short int data;
795 unsigned short int header;
802 const void *extinfo_end;
805 RomDirEnt = stat->romdirent;
806 extinfo_end = (
unsigned char *)stat->extinfo + (RomDirEnt->ExtInfoEntrySize >> 2 << 2);
809 while ((
unsigned int)
ExtInfoField < (
unsigned int)extinfo_end) {
810 unsigned int ExtInfoHeader;
814 if (ExtInfoHeader >> 24 == (
unsigned int)mode) {
828 int count, NumFilesRemaining, ImageFileIndexNumber;
833 unsigned int HighestFileVersionNum;
838 filename[
count] = *line;
841 }
while (count < 10 && *line >= 0x21);
843 filename[
count] =
'\0';
846 ImageFileIndexNumber = -1;
847 HighestFileVersionNum = 0;
848 NumFilesRemaining = NumFiles - 1;
850 ImageDataPtr = &ImageDataBuffer[NumFilesRemaining];
853 if (ImageDataPtr->filename != NULL) {
854 if (GetFileStatFromImage(&ImageDataPtr->stat, filename, &stat) != NULL) {
855 unsigned short int FileVersionNum;
857 ExtInfofield = GetFileInfo(&stat, 2);
859 GetFileInfo(&stat, 3);
862 if (ExtInfofield != NULL) {
863 FileVersionNum = ExtInfofield->data;
866 if (ImageFileIndexNumber < 0 || HighestFileVersionNum < FileVersionNum) {
867 ImageFileIndexNumber = NumFilesRemaining;
868 HighestFileVersionNum = FileVersionNum;
870 DEBUG_PRINTF(
"SelectModule: %s, %s, 0x%x\n", filename, ImageDataPtr->filename, FileVersionNum);
875 }
while (--NumFilesRemaining >= 0);
878 if (ImageFileIndexNumber >= 0) {
879 result = GetFileStatFromImage(&ImageDataBuffer[ImageFileIndexNumber].stat, filename, stat_out);
888static void DisplayModuleName(
int id,
const char *line)
893 for (i = 0; i < 11 && line[i] >=
' '; i++) {
894 filename[i] = line[i];
898 DEBUG_PRINTF(
"%d: %s\n",
id, filename);
905 unsigned int FilesRemaining, i, NumModules;
907 char filename_temp[16];
910 const void **ModList;
912 if ((
unsigned int)stat->data < (
unsigned int)stat->data + stat->romdirent->size) {
913 FilesRemaining = NumFiles - 1;
923 ResetData->StartAddress = ParseStartAddress(&ptr);
926 if (strncmp(ptr,
"!addr ", 6) == 0) {
928 ModList[NumModules] = (
void *)(((
unsigned int)ParseStartAddress(&ptr) << 2) + 1);
933 ModList[NumModules] = NULL;
934 }
else if (strncmp(ptr,
"!include ", 9) == 0) {
938 while ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
940 filename_temp[i] = *ptr;
946 filename_temp[i] =
'\0';
948 ScanImagesForFile(ImageDataBuffer, FilesRemaining, &FileStat, filename_temp);
949 ParseIOPBTCONF(ImageDataBuffer, FilesRemaining, &FileStat,
ResetData);
982 DisplayModuleName(
ResetData->NumModules, ptr);
984 if (SelectModuleFromImages(ImageDataBuffer, NumFiles, ptr, &ModuleFileStat) == NULL) {
988 ModList[NumModules] = ModuleFileStat.data;
993 ModList[NumModules] = NULL;
997 if ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
998 while ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
1004 if ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
1005 while ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size) {
1013 }
while ((
unsigned int)ptr < (
unsigned int)stat->data + stat->romdirent->size);
1017int _start(
int argc,
char *argv[])
1019 int ImageDataTotalSize;
1024 void *buffer, *IoprpBuffer;
1028 int fd, file_sz = 0, i, NumFiles;
1033 unsigned int BootMode4, BootMode3, options;
1037 BootMode4 = 0xFFFFFFFF;
1039 if ((BootModePtr = QueryBootMode(4)) != NULL) {
1040 BootMode4 = *(
unsigned char *)BootModePtr;
1042 if ((BootModePtr = QueryBootMode(3)) != NULL) {
1043 BootMode3 = *(
unsigned int *)((
unsigned char *)BootModePtr + 4);
1065 ImageDataTotalSize = (argc + 2) *
sizeof(
struct ImageData);
1066 ImageDataBuffer = alloca(ImageDataTotalSize);
1067 memset(ImageDataBuffer, 0, ImageDataTotalSize);
1069 TotalSize = MAX_MODULES *
sizeof(
void *) +
sizeof(
struct ResetData);
1070#ifdef USE_EMBEDDED_IOPRP
1071 TotalSize += ((size_IOPRP_img + 0xF) & ~0xF);
1083 if (strcmp(argv[i],
"-v") == 0) {
1087 if (strcmp(argv[i],
"-v") != 0)
1090 else if (strcmp(argv[i],
"-nobusini") == 0 || strcmp(argv[i],
"-nb") == 0) {
1092 }
else if (strcmp(argv[i],
"-nocacheini") == 0 || strcmp(argv[i],
"-nc") == 0) {
1110 if ((fd = open(argv[i], O_RDONLY)) < 0) {
1112 printf(
"kupdate: pannic ! file \'%s\' can't open\n", argv[i]);
1114 printf(
"file \'%s\' can't open\n", argv[i]);
1117 if (BootMode4 & 2) {
1125 file_sz = lseek(fd, 0, SEEK_END);
1126 lseek(fd, 0, SEEK_SET);
1131 TotalSize += (file_sz + 0xF) & ~0xF;
1150 if ((buffer = AllocMemory(TotalSize)) == NULL) {
1152 printf(
"kupdate: pannic ! can not alloc memory\n");
1154 printf(
"pannic ! can not alloc memory\n");
1157 if (BootMode4 & 2) {
1168 IoprpBuffer = (
void *)((
unsigned int)buffer + MAX_MODULES *
sizeof(
void *) +
sizeof(
struct ResetData));
1169 ResetData->IOPRPBuffer = (
void *)((
unsigned int)IoprpBuffer & 0x1FFFFF00);
1170 ResetData->MemSize = QueryMemSize() >> 20;
1173 if (BootMode3 & 0x00000080) {
1174 printf(
" Logical memory size 8MB ---> 2MB\n");
1181 if (GetIOPRPStat((
void *)0xbfc00000, (
void *)0xbfc10000, &ImageDataBuffer[0].stat) != NULL) {
1182 ImageDataBuffer[0].filename =
"ROM";
1185 if (BootMode3 & 0x00000100) {
1186 if (GetFileStatFromImage(&ImageDataBuffer[0].stat,
"OLDROM", &ROMStat) != 0 && GetIOPRPStat(ROMStat.data, (
const void *)((
const u8 *)(ROMStat.data) + 0x40000), &ImageDataBuffer[1].stat)) {
1187 memcpy(&ImageDataBuffer[0].stat, &ImageDataBuffer[1].stat,
sizeof(ImageDataBuffer[0].stat));
1188 printf(
" use alternate ROM image\n");
1194#ifdef USE_EMBEDDED_IOPRP
1196 if (size_IOPRP_img >= 0x10 && GetIOPRPStat(IOPRP_img, &IOPRP_img[size_IOPRP_img], &ImageDataBuffer[1].stat) != NULL) {
1197 ImageDataBuffer[1].filename =
"DATA";
1198 ResetData->IOPRPBuffer = (
void*)((
unsigned int)IOPRP_img & ~0xF);
1201 if (size_IOPRP_img >= 0x10) {
1202 memcpy(IoprpBuffer, IOPRP_img, size_IOPRP_img);
1203 if (GetIOPRPStat(IoprpBuffer, (
void *)((
unsigned int)IoprpBuffer + size_IOPRP_img), &ImageDataBuffer[1].stat) != NULL) {
1204 ImageDataBuffer[1].filename =
"DATA";
1205 IoprpBuffer = (
void *)((u8 *)IoprpBuffer + ((size_IOPRP_img + 0xF) & ~0xF));
1218 if (GetIOPRPStat(IoprpBuffer, (
void *)((u8 *)IoprpBuffer + 0x4000), &
ImageData->stat) != NULL) {
1220 IoprpBuffer = (
void *)((u8 *)IoprpBuffer + ((
ImageData->size + 0xF) & ~0xF));
1228 }
while (i < NumFiles);
1235 ScanImagesForFile(ImageDataBuffer, NumFiles, &FileStat,
"IOPBTCONF");
1236 ParseIOPBTCONF(ImageDataBuffer, NumFiles, &FileStat,
ResetData);
1238 ScanImagesForFile(ImageDataBuffer, 2, &FileStat,
"IOPBTCONF");
1239 ParseIOPBTCONF(ImageDataBuffer, 2, &FileStat,
ResetData);
1242 DEBUG_PRINTF(
"Beginning IOP bootup sequence.\n");
1245 TerminateResidentLibraries(
" kupdate:ei: Terminate resident Libraries\n", options, 2);
1246 CpuExecuteKmode(&BeginBootupSequence,
ResetData, options);
1257 return MODULE_NO_RESIDENT_END;
1259 return MODULE_RESIDENT_END;
1264static void *AllocMemory(
int nbytes)
1266 void *BlockTopAddress;
1269 BlockTopAddress = QueryBlockTopAddress((
void *)0x1860);
1270 BlockTopAddress = (
void *)((
unsigned int)BlockTopAddress & 0x7FFFFFFF);
1272 while ((result = QueryBlockSize(BlockTopAddress)) >= 0 || (result & 0x7FFFFFFF) < nbytes) {
1273 BlockTopAddress = QueryBlockTopAddress((
void *)(((
unsigned int)BlockTopAddress & 0x7FFFFFFF) + (result & 0x7FFFFFFF)));
1274 BlockTopAddress = (
void *)((
unsigned int)BlockTopAddress & 0x7FFFFFFF);
1276 }
while ((result & 0x7FFFFFFF) < nbytes);
1278 return AllocSysMemory(2, nbytes, BlockTopAddress);
u32 count
start sector of fragmented bd/file