X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8f6c56a50524aa785f7e596d52dddfb331e18961..89b3af67bb32e691275bf6fa803d1834b2284115:/bsd/kern/mach_fat.c diff --git a/bsd/kern/mach_fat.c b/bsd/kern/mach_fat.c index a9418aa8f..677ae0008 100644 --- a/bsd/kern/mach_fat.c +++ b/bsd/kern/mach_fat.c @@ -44,13 +44,8 @@ #include #include #include -#include - -/* XXX should be in common header */ -extern int grade_binary(cpu_type_t exectype, cpu_subtype_t execsubtype); - -#define CPU_TYPE_NATIVE (cpu_type()) -#define CPU_TYPE_CLASSIC CPU_TYPE_POWERPC +#include +#include /********************************************************************** * Routine: fatfile_getarch2() @@ -106,7 +101,7 @@ fatfile_getarch2( * Map portion that must be accessible directly into * kernel's map. */ - nfat_arch = NXSwapBigLongToHost(header->nfat_arch); + nfat_arch = OSSwapBigToHostInt32(header->nfat_arch); end_of_archs = (off_t)nfat_arch * sizeof(struct fat_arch) + sizeof(struct fat_header); @@ -124,6 +119,7 @@ fatfile_getarch2( if (end_of_archs > PAGE_SIZE || end_of_archs < (sizeof(struct fat_header)+sizeof(struct fat_arch))) return(LOAD_BADMACHO); + /* * Round size of fat_arch structures up to page boundry. */ @@ -143,15 +139,15 @@ fatfile_getarch2( /* * Check to see if right cpu type. */ - if(((cpu_type_t)NXSwapBigIntToHost(arch->cputype) & ~mask_bits) != req_cpu_type) + if(((cpu_type_t)OSSwapBigToHostInt32(arch->cputype) & ~mask_bits) != req_cpu_type) continue; /* * Get the grade of the cpu subtype. */ grade = grade_binary( - NXSwapBigIntToHost(arch->cputype), - NXSwapBigIntToHost(arch->cpusubtype)); + OSSwapBigToHostInt32(arch->cputype), + OSSwapBigToHostInt32(arch->cpusubtype)); /* * Remember it if it's the best we've seen. @@ -169,15 +165,15 @@ fatfile_getarch2( lret = LOAD_BADARCH; } else { archret->cputype = - NXSwapBigIntToHost(best_arch->cputype); + OSSwapBigToHostInt32(best_arch->cputype); archret->cpusubtype = - NXSwapBigIntToHost(best_arch->cpusubtype); + OSSwapBigToHostInt32(best_arch->cpusubtype); archret->offset = - NXSwapBigLongToHost(best_arch->offset); + OSSwapBigToHostInt32(best_arch->offset); archret->size = - NXSwapBigLongToHost(best_arch->size); + OSSwapBigToHostInt32(best_arch->size); archret->align = - NXSwapBigLongToHost(best_arch->align); + OSSwapBigToHostInt32(best_arch->align); lret = LOAD_SUCCESS; } @@ -188,8 +184,6 @@ fatfile_getarch2( return(lret); } -extern char classichandler[]; - load_return_t fatfile_getarch_affinity( struct vnode *vp, @@ -198,15 +192,15 @@ fatfile_getarch_affinity( int affinity) { load_return_t lret; - int handler = (classichandler[0] != 0); + int handler = (exec_archhandler_ppc.path[0] != 0); cpu_type_t primary_type, fallback_type; if (handler && affinity) { - primary_type = CPU_TYPE_CLASSIC; - fallback_type = CPU_TYPE_NATIVE; + primary_type = CPU_TYPE_POWERPC; + fallback_type = cpu_type(); } else { - primary_type = CPU_TYPE_NATIVE; - fallback_type = CPU_TYPE_CLASSIC; + primary_type = cpu_type(); + fallback_type = CPU_TYPE_POWERPC; } /* * Ignore the architectural bits when determining if an image @@ -240,7 +234,7 @@ fatfile_getarch( vm_offset_t data_ptr, struct fat_arch *archret) { - return fatfile_getarch2(vp, data_ptr, CPU_TYPE_NATIVE, 0, archret); + return fatfile_getarch2(vp, data_ptr, cpu_type(), 0, archret); } /********************************************************************** @@ -265,6 +259,6 @@ fatfile_getarch_with_bits( vm_offset_t data_ptr, struct fat_arch *archret) { - return fatfile_getarch2(vp, data_ptr, archbits | CPU_TYPE_NATIVE, 0, archret); + return fatfile_getarch2(vp, data_ptr, archbits | cpu_type(), 0, archret); }