[7] | 1 | /*
|
---|
[217] | 2 | * Copyright (c) 2004, Apple Computer, Inc. All rights reserved.
|
---|
[7] | 3 | *
|
---|
[217] | 4 | * Redistribution and use in source and binary forms, with or without
|
---|
| 5 | * modification, are permitted provided that the following conditions
|
---|
| 6 | * are met:
|
---|
| 7 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 8 | * notice, this list of conditions and the following disclaimer.
|
---|
| 9 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 11 | * documentation and/or other materials provided with the distribution.
|
---|
| 12 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
---|
| 13 | * its contributors may be used to endorse or promote products derived
|
---|
| 14 | * from this software without specific prior written permission.
|
---|
[7] | 15 | *
|
---|
[217] | 16 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
|
---|
| 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
| 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
|
---|
| 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
| 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
| 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
| 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
---|
| 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
---|
| 25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
---|
| 26 | * POSSIBILITY OF SUCH DAMAGE.
|
---|
[7] | 27 | */
|
---|
| 28 | /* byte_sex.c */
|
---|
| 29 | #include <string.h>
|
---|
[217] | 30 | #include "stuff/target_arch.h"
|
---|
[7] | 31 | #include <mach-o/fat.h>
|
---|
| 32 | #include <mach-o/loader.h>
|
---|
[217] | 33 | #include <mach/m68k/thread_status.h>
|
---|
| 34 | #undef MACHINE_THREAD_STATE /* need to undef these to avoid warnings */
|
---|
| 35 | #undef MACHINE_THREAD_STATE_COUNT
|
---|
| 36 | #include <mach/ppc/thread_status.h>
|
---|
| 37 | #undef MACHINE_THREAD_STATE /* need to undef these to avoid warnings */
|
---|
| 38 | #undef MACHINE_THREAD_STATE_COUNT
|
---|
| 39 | #include <mach/m88k/thread_status.h>
|
---|
| 40 | #include <mach/i860/thread_status.h>
|
---|
| 41 | #include <mach/i386/thread_status.h>
|
---|
| 42 | #include <mach/hppa/thread_status.h>
|
---|
| 43 | #include <mach/sparc/thread_status.h>
|
---|
[7] | 44 | #include <mach-o/nlist.h>
|
---|
| 45 | #include <mach-o/reloc.h>
|
---|
| 46 | #include <mach-o/ranlib.h>
|
---|
| 47 | #include "stuff/bool.h"
|
---|
| 48 | #include "stuff/bytesex.h"
|
---|
| 49 |
|
---|
| 50 | __private_extern__
|
---|
[217] | 51 | long long
|
---|
| 52 | SWAP_LONG_LONG(
|
---|
| 53 | long long ll)
|
---|
| 54 | {
|
---|
| 55 | union {
|
---|
| 56 | char c[8];
|
---|
| 57 | long long ll;
|
---|
| 58 | } in, out;
|
---|
| 59 | in.ll = ll;
|
---|
| 60 | out.c[0] = in.c[7];
|
---|
| 61 | out.c[1] = in.c[6];
|
---|
| 62 | out.c[2] = in.c[5];
|
---|
| 63 | out.c[3] = in.c[4];
|
---|
| 64 | out.c[4] = in.c[3];
|
---|
| 65 | out.c[5] = in.c[2];
|
---|
| 66 | out.c[6] = in.c[1];
|
---|
| 67 | out.c[7] = in.c[0];
|
---|
| 68 | return(out.ll);
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | __private_extern__
|
---|
[7] | 72 | double
|
---|
| 73 | SWAP_DOUBLE(
|
---|
| 74 | double d)
|
---|
| 75 | {
|
---|
| 76 | union {
|
---|
| 77 | char c[8];
|
---|
| 78 | double d;
|
---|
| 79 | } in, out;
|
---|
| 80 | in.d = d;
|
---|
| 81 | out.c[0] = in.c[7];
|
---|
| 82 | out.c[1] = in.c[6];
|
---|
| 83 | out.c[2] = in.c[5];
|
---|
| 84 | out.c[3] = in.c[4];
|
---|
| 85 | out.c[4] = in.c[3];
|
---|
| 86 | out.c[5] = in.c[2];
|
---|
| 87 | out.c[6] = in.c[1];
|
---|
| 88 | out.c[7] = in.c[0];
|
---|
| 89 | return(out.d);
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | __private_extern__
|
---|
| 93 | float
|
---|
| 94 | SWAP_FLOAT(
|
---|
| 95 | float f)
|
---|
| 96 | {
|
---|
| 97 | union {
|
---|
| 98 | char c[7];
|
---|
| 99 | float f;
|
---|
| 100 | } in, out;
|
---|
| 101 | in.f = f;
|
---|
| 102 | out.c[0] = in.c[3];
|
---|
| 103 | out.c[1] = in.c[2];
|
---|
| 104 | out.c[2] = in.c[1];
|
---|
| 105 | out.c[3] = in.c[0];
|
---|
| 106 | return(out.f);
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | /*
|
---|
| 110 | * get_host_byte_sex() returns the enum constant for the byte sex of the host
|
---|
| 111 | * it is running on.
|
---|
| 112 | */
|
---|
| 113 | __private_extern__
|
---|
| 114 | enum byte_sex
|
---|
| 115 | get_host_byte_sex(
|
---|
| 116 | void)
|
---|
| 117 | {
|
---|
| 118 | unsigned long s;
|
---|
| 119 |
|
---|
| 120 | s = (BIG_ENDIAN_BYTE_SEX << 24) | LITTLE_ENDIAN_BYTE_SEX;
|
---|
| 121 | return((enum byte_sex)*((char *)&s));
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | __private_extern__
|
---|
| 125 | void
|
---|
| 126 | swap_fat_header(
|
---|
| 127 | struct fat_header *fat_header,
|
---|
| 128 | enum byte_sex target_byte_sex)
|
---|
| 129 | {
|
---|
| 130 | #ifdef __MWERKS__
|
---|
| 131 | enum byte_sex dummy;
|
---|
| 132 | dummy = target_byte_sex;
|
---|
| 133 | #endif
|
---|
| 134 |
|
---|
| 135 | fat_header->magic = SWAP_LONG(fat_header->magic);
|
---|
| 136 | fat_header->nfat_arch = SWAP_LONG(fat_header->nfat_arch);
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | __private_extern__
|
---|
| 140 | void
|
---|
| 141 | swap_fat_arch(
|
---|
| 142 | struct fat_arch *fat_archs,
|
---|
| 143 | unsigned long nfat_arch,
|
---|
| 144 | enum byte_sex target_byte_sex)
|
---|
| 145 | {
|
---|
| 146 | unsigned long i;
|
---|
| 147 | #ifdef __MWERKS__
|
---|
| 148 | enum byte_sex dummy;
|
---|
| 149 | dummy = target_byte_sex;
|
---|
| 150 | #endif
|
---|
| 151 |
|
---|
| 152 | for(i = 0; i < nfat_arch; i++){
|
---|
| 153 | fat_archs[i].cputype = SWAP_LONG(fat_archs[i].cputype);
|
---|
| 154 | fat_archs[i].cpusubtype = SWAP_LONG(fat_archs[i].cpusubtype);
|
---|
| 155 | fat_archs[i].offset = SWAP_LONG(fat_archs[i].offset);
|
---|
| 156 | fat_archs[i].size = SWAP_LONG(fat_archs[i].size);
|
---|
| 157 | fat_archs[i].align = SWAP_LONG(fat_archs[i].align);
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | __private_extern__
|
---|
| 162 | void
|
---|
| 163 | swap_mach_header(
|
---|
| 164 | struct mach_header *mh,
|
---|
| 165 | enum byte_sex target_byte_sex)
|
---|
| 166 | {
|
---|
| 167 | #ifdef __MWERKS__
|
---|
| 168 | enum byte_sex dummy;
|
---|
| 169 | dummy = target_byte_sex;
|
---|
| 170 | #endif
|
---|
| 171 | mh->magic = SWAP_LONG(mh->magic);
|
---|
| 172 | mh->cputype = SWAP_LONG(mh->cputype);
|
---|
| 173 | mh->cpusubtype = SWAP_LONG(mh->cpusubtype);
|
---|
| 174 | mh->filetype = SWAP_LONG(mh->filetype);
|
---|
| 175 | mh->ncmds = SWAP_LONG(mh->ncmds);
|
---|
| 176 | mh->sizeofcmds = SWAP_LONG(mh->sizeofcmds);
|
---|
| 177 | mh->flags = SWAP_LONG(mh->flags);
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | __private_extern__
|
---|
| 181 | void
|
---|
[217] | 182 | swap_mach_header_64(
|
---|
| 183 | struct mach_header_64 *mh,
|
---|
| 184 | enum byte_sex target_byte_sex)
|
---|
| 185 | {
|
---|
| 186 | #ifdef __MWERKS__
|
---|
| 187 | enum byte_sex dummy;
|
---|
| 188 | dummy = target_byte_sex;
|
---|
| 189 | #endif
|
---|
| 190 | mh->magic = SWAP_LONG(mh->magic);
|
---|
| 191 | mh->cputype = SWAP_LONG(mh->cputype);
|
---|
| 192 | mh->cpusubtype = SWAP_LONG(mh->cpusubtype);
|
---|
| 193 | mh->filetype = SWAP_LONG(mh->filetype);
|
---|
| 194 | mh->ncmds = SWAP_LONG(mh->ncmds);
|
---|
| 195 | mh->sizeofcmds = SWAP_LONG(mh->sizeofcmds);
|
---|
| 196 | mh->flags = SWAP_LONG(mh->flags);
|
---|
| 197 | mh->reserved = SWAP_LONG(mh->reserved);
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | __private_extern__
|
---|
| 201 | void
|
---|
[7] | 202 | swap_load_command(
|
---|
| 203 | struct load_command *lc,
|
---|
| 204 | enum byte_sex target_byte_sex)
|
---|
| 205 | {
|
---|
| 206 | #ifdef __MWERKS__
|
---|
| 207 | enum byte_sex dummy;
|
---|
| 208 | dummy = target_byte_sex;
|
---|
| 209 | #endif
|
---|
| 210 | lc->cmd = SWAP_LONG(lc->cmd);
|
---|
| 211 | lc->cmdsize = SWAP_LONG(lc->cmdsize);
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | __private_extern__
|
---|
| 215 | void
|
---|
| 216 | swap_segment_command(
|
---|
| 217 | struct segment_command *sg,
|
---|
| 218 | enum byte_sex target_byte_sex)
|
---|
| 219 | {
|
---|
| 220 | #ifdef __MWERKS__
|
---|
| 221 | enum byte_sex dummy;
|
---|
| 222 | dummy = target_byte_sex;
|
---|
| 223 | #endif
|
---|
| 224 | /* segname[16] */
|
---|
| 225 | sg->cmd = SWAP_LONG(sg->cmd);
|
---|
| 226 | sg->cmdsize = SWAP_LONG(sg->cmdsize);
|
---|
| 227 | sg->vmaddr = SWAP_LONG(sg->vmaddr);
|
---|
| 228 | sg->vmsize = SWAP_LONG(sg->vmsize);
|
---|
| 229 | sg->fileoff = SWAP_LONG(sg->fileoff);
|
---|
| 230 | sg->filesize = SWAP_LONG(sg->filesize);
|
---|
| 231 | sg->maxprot = SWAP_LONG(sg->maxprot);
|
---|
| 232 | sg->initprot = SWAP_LONG(sg->initprot);
|
---|
| 233 | sg->nsects = SWAP_LONG(sg->nsects);
|
---|
| 234 | sg->flags = SWAP_LONG(sg->flags);
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | __private_extern__
|
---|
| 238 | void
|
---|
[217] | 239 | swap_segment_command_64(
|
---|
| 240 | struct segment_command_64 *sg,
|
---|
| 241 | enum byte_sex target_byte_sex)
|
---|
| 242 | {
|
---|
| 243 | #ifdef __MWERKS__
|
---|
| 244 | enum byte_sex dummy;
|
---|
| 245 | dummy = target_byte_sex;
|
---|
| 246 | #endif
|
---|
| 247 | /* segname[16] */
|
---|
| 248 | sg->cmd = SWAP_LONG(sg->cmd);
|
---|
| 249 | sg->cmdsize = SWAP_LONG(sg->cmdsize);
|
---|
| 250 | sg->vmaddr = SWAP_LONG_LONG(sg->vmaddr);
|
---|
| 251 | sg->vmsize = SWAP_LONG_LONG(sg->vmsize);
|
---|
| 252 | sg->fileoff = SWAP_LONG_LONG(sg->fileoff);
|
---|
| 253 | sg->filesize = SWAP_LONG_LONG(sg->filesize);
|
---|
| 254 | sg->maxprot = SWAP_LONG(sg->maxprot);
|
---|
| 255 | sg->initprot = SWAP_LONG(sg->initprot);
|
---|
| 256 | sg->nsects = SWAP_LONG(sg->nsects);
|
---|
| 257 | sg->flags = SWAP_LONG(sg->flags);
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | __private_extern__
|
---|
| 261 | void
|
---|
[7] | 262 | swap_section(
|
---|
| 263 | struct section *s,
|
---|
| 264 | unsigned long nsects,
|
---|
| 265 | enum byte_sex target_byte_sex)
|
---|
| 266 | {
|
---|
| 267 | unsigned long i;
|
---|
| 268 | #ifdef __MWERKS__
|
---|
| 269 | enum byte_sex dummy;
|
---|
| 270 | dummy = target_byte_sex;
|
---|
| 271 | #endif
|
---|
| 272 |
|
---|
| 273 | for(i = 0; i < nsects; i++){
|
---|
| 274 | /* sectname[16] */
|
---|
| 275 | /* segname[16] */
|
---|
| 276 | s[i].addr = SWAP_LONG(s[i].addr);
|
---|
| 277 | s[i].size = SWAP_LONG(s[i].size);
|
---|
| 278 | s[i].offset = SWAP_LONG(s[i].offset);
|
---|
| 279 | s[i].align = SWAP_LONG(s[i].align);
|
---|
| 280 | s[i].reloff = SWAP_LONG(s[i].reloff);
|
---|
| 281 | s[i].nreloc = SWAP_LONG(s[i].nreloc);
|
---|
| 282 | s[i].flags = SWAP_LONG(s[i].flags);
|
---|
| 283 | s[i].reserved1 = SWAP_LONG(s[i].reserved1);
|
---|
| 284 | s[i].reserved2 = SWAP_LONG(s[i].reserved2);
|
---|
| 285 | }
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | __private_extern__
|
---|
| 289 | void
|
---|
[217] | 290 | swap_section_64(
|
---|
| 291 | struct section_64 *s,
|
---|
| 292 | unsigned long nsects,
|
---|
| 293 | enum byte_sex target_byte_sex)
|
---|
| 294 | {
|
---|
| 295 | unsigned long i;
|
---|
| 296 | #ifdef __MWERKS__
|
---|
| 297 | enum byte_sex dummy;
|
---|
| 298 | dummy = target_byte_sex;
|
---|
| 299 | #endif
|
---|
| 300 |
|
---|
| 301 | for(i = 0; i < nsects; i++){
|
---|
| 302 | /* sectname[16] */
|
---|
| 303 | /* segname[16] */
|
---|
| 304 | s[i].addr = SWAP_LONG_LONG(s[i].addr);
|
---|
| 305 | s[i].size = SWAP_LONG_LONG(s[i].size);
|
---|
| 306 | s[i].offset = SWAP_LONG(s[i].offset);
|
---|
| 307 | s[i].align = SWAP_LONG(s[i].align);
|
---|
| 308 | s[i].reloff = SWAP_LONG(s[i].reloff);
|
---|
| 309 | s[i].nreloc = SWAP_LONG(s[i].nreloc);
|
---|
| 310 | s[i].flags = SWAP_LONG(s[i].flags);
|
---|
| 311 | s[i].reserved1 = SWAP_LONG(s[i].reserved1);
|
---|
| 312 | s[i].reserved2 = SWAP_LONG(s[i].reserved2);
|
---|
| 313 | }
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | __private_extern__
|
---|
| 317 | void
|
---|
[7] | 318 | swap_symtab_command(
|
---|
| 319 | struct symtab_command *st,
|
---|
| 320 | enum byte_sex target_byte_sex)
|
---|
| 321 | {
|
---|
| 322 | #ifdef __MWERKS__
|
---|
| 323 | enum byte_sex dummy;
|
---|
| 324 | dummy = target_byte_sex;
|
---|
| 325 | #endif
|
---|
| 326 | st->cmd = SWAP_LONG(st->cmd);
|
---|
| 327 | st->cmdsize = SWAP_LONG(st->cmdsize);
|
---|
| 328 | st->symoff = SWAP_LONG(st->symoff);
|
---|
| 329 | st->nsyms = SWAP_LONG(st->nsyms);
|
---|
| 330 | st->stroff = SWAP_LONG(st->stroff);
|
---|
| 331 | st->strsize = SWAP_LONG(st->strsize);
|
---|
| 332 | }
|
---|
| 333 |
|
---|
| 334 | __private_extern__
|
---|
| 335 | void
|
---|
| 336 | swap_dysymtab_command(
|
---|
| 337 | struct dysymtab_command *dyst,
|
---|
| 338 | enum byte_sex target_byte_sex)
|
---|
| 339 | {
|
---|
| 340 | #ifdef __MWERKS__
|
---|
| 341 | enum byte_sex dummy;
|
---|
| 342 | dummy = target_byte_sex;
|
---|
| 343 | #endif
|
---|
| 344 | dyst->cmd = SWAP_LONG(dyst->cmd);
|
---|
| 345 | dyst->cmdsize = SWAP_LONG(dyst->cmdsize);
|
---|
| 346 | dyst->ilocalsym = SWAP_LONG(dyst->ilocalsym);
|
---|
| 347 | dyst->nlocalsym = SWAP_LONG(dyst->nlocalsym);
|
---|
| 348 | dyst->iextdefsym = SWAP_LONG(dyst->iextdefsym);
|
---|
| 349 | dyst->nextdefsym = SWAP_LONG(dyst->nextdefsym);
|
---|
| 350 | dyst->iundefsym = SWAP_LONG(dyst->iundefsym);
|
---|
| 351 | dyst->nundefsym = SWAP_LONG(dyst->nundefsym);
|
---|
| 352 | dyst->tocoff = SWAP_LONG(dyst->tocoff);
|
---|
| 353 | dyst->ntoc = SWAP_LONG(dyst->ntoc);
|
---|
| 354 | dyst->modtaboff = SWAP_LONG(dyst->modtaboff);
|
---|
| 355 | dyst->nmodtab = SWAP_LONG(dyst->nmodtab);
|
---|
| 356 | dyst->extrefsymoff = SWAP_LONG(dyst->extrefsymoff);
|
---|
| 357 | dyst->nextrefsyms = SWAP_LONG(dyst->nextrefsyms);
|
---|
| 358 | dyst->indirectsymoff = SWAP_LONG(dyst->indirectsymoff);
|
---|
| 359 | dyst->nindirectsyms = SWAP_LONG(dyst->nindirectsyms);
|
---|
| 360 | dyst->extreloff = SWAP_LONG(dyst->extreloff);
|
---|
| 361 | dyst->nextrel = SWAP_LONG(dyst->nextrel);
|
---|
| 362 | dyst->locreloff = SWAP_LONG(dyst->locreloff);
|
---|
| 363 | dyst->nlocrel = SWAP_LONG(dyst->nlocrel);
|
---|
| 364 | }
|
---|
| 365 |
|
---|
| 366 | __private_extern__
|
---|
| 367 | void
|
---|
| 368 | swap_symseg_command(
|
---|
| 369 | struct symseg_command *ss,
|
---|
| 370 | enum byte_sex target_byte_sex)
|
---|
| 371 | {
|
---|
| 372 | #ifdef __MWERKS__
|
---|
| 373 | enum byte_sex dummy;
|
---|
| 374 | dummy = target_byte_sex;
|
---|
| 375 | #endif
|
---|
| 376 | ss->cmd = SWAP_LONG(ss->cmd);
|
---|
| 377 | ss->cmdsize = SWAP_LONG(ss->cmdsize);
|
---|
| 378 | ss->offset = SWAP_LONG(ss->offset);
|
---|
| 379 | ss->size = SWAP_LONG(ss->size);
|
---|
| 380 | }
|
---|
| 381 |
|
---|
| 382 | __private_extern__
|
---|
| 383 | void
|
---|
| 384 | swap_fvmlib_command(
|
---|
| 385 | struct fvmlib_command *fl,
|
---|
| 386 | enum byte_sex target_byte_sex)
|
---|
| 387 | {
|
---|
| 388 | #ifdef __MWERKS__
|
---|
| 389 | enum byte_sex dummy;
|
---|
| 390 | dummy = target_byte_sex;
|
---|
| 391 | #endif
|
---|
| 392 | fl->cmd = SWAP_LONG(fl->cmd);
|
---|
| 393 | fl->cmdsize = SWAP_LONG(fl->cmdsize);
|
---|
| 394 | fl->fvmlib.name.offset = SWAP_LONG(fl->fvmlib.name.offset);
|
---|
| 395 | fl->fvmlib.minor_version = SWAP_LONG(fl->fvmlib.minor_version);
|
---|
| 396 | fl->fvmlib.header_addr = SWAP_LONG(fl->fvmlib.header_addr);
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 | __private_extern__
|
---|
| 400 | void
|
---|
| 401 | swap_dylib_command(
|
---|
| 402 | struct dylib_command *dl,
|
---|
| 403 | enum byte_sex target_byte_sex)
|
---|
| 404 | {
|
---|
| 405 | #ifdef __MWERKS__
|
---|
| 406 | enum byte_sex dummy;
|
---|
| 407 | dummy = target_byte_sex;
|
---|
| 408 | #endif
|
---|
| 409 | dl->cmd = SWAP_LONG(dl->cmd);
|
---|
| 410 | dl->cmdsize = SWAP_LONG(dl->cmdsize);
|
---|
| 411 | dl->dylib.name.offset = SWAP_LONG(dl->dylib.name.offset);
|
---|
| 412 | dl->dylib.timestamp = SWAP_LONG(dl->dylib.timestamp);
|
---|
| 413 | dl->dylib.current_version = SWAP_LONG(dl->dylib.current_version);
|
---|
| 414 | dl->dylib.compatibility_version =
|
---|
| 415 | SWAP_LONG(dl->dylib.compatibility_version);
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 | __private_extern__
|
---|
| 419 | void
|
---|
| 420 | swap_sub_framework_command(
|
---|
| 421 | struct sub_framework_command *sub,
|
---|
| 422 | enum byte_sex target_byte_sex)
|
---|
| 423 | {
|
---|
| 424 | #ifdef __MWERKS__
|
---|
| 425 | enum byte_sex dummy;
|
---|
| 426 | dummy = target_byte_sex;
|
---|
| 427 | #endif
|
---|
| 428 | sub->cmd = SWAP_LONG(sub->cmd);
|
---|
| 429 | sub->cmdsize = SWAP_LONG(sub->cmdsize);
|
---|
| 430 | sub->umbrella.offset = SWAP_LONG(sub->umbrella.offset);
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | __private_extern__
|
---|
| 434 | void
|
---|
| 435 | swap_sub_umbrella_command(
|
---|
| 436 | struct sub_umbrella_command *usub,
|
---|
| 437 | enum byte_sex target_byte_sex)
|
---|
| 438 | {
|
---|
| 439 | #ifdef __MWERKS__
|
---|
| 440 | enum byte_sex dummy;
|
---|
| 441 | dummy = target_byte_sex;
|
---|
| 442 | #endif
|
---|
| 443 | usub->cmd = SWAP_LONG(usub->cmd);
|
---|
| 444 | usub->cmdsize = SWAP_LONG(usub->cmdsize);
|
---|
| 445 | usub->sub_umbrella.offset = SWAP_LONG(usub->sub_umbrella.offset);
|
---|
| 446 | }
|
---|
| 447 |
|
---|
| 448 | __private_extern__
|
---|
| 449 | void
|
---|
| 450 | swap_sub_library_command(
|
---|
| 451 | struct sub_library_command *lsub,
|
---|
| 452 | enum byte_sex target_byte_sex)
|
---|
| 453 | {
|
---|
| 454 | #ifdef __MWERKS__
|
---|
| 455 | enum byte_sex dummy;
|
---|
| 456 | dummy = target_byte_sex;
|
---|
| 457 | #endif
|
---|
| 458 | lsub->cmd = SWAP_LONG(lsub->cmd);
|
---|
| 459 | lsub->cmdsize = SWAP_LONG(lsub->cmdsize);
|
---|
| 460 | lsub->sub_library.offset = SWAP_LONG(lsub->sub_library.offset);
|
---|
| 461 | }
|
---|
| 462 |
|
---|
| 463 | __private_extern__
|
---|
| 464 | void
|
---|
| 465 | swap_sub_client_command(
|
---|
| 466 | struct sub_client_command *csub,
|
---|
| 467 | enum byte_sex target_byte_sex)
|
---|
| 468 | {
|
---|
| 469 | #ifdef __MWERKS__
|
---|
| 470 | enum byte_sex dummy;
|
---|
| 471 | dummy = target_byte_sex;
|
---|
| 472 | #endif
|
---|
| 473 | csub->cmd = SWAP_LONG(csub->cmd);
|
---|
| 474 | csub->cmdsize = SWAP_LONG(csub->cmdsize);
|
---|
| 475 | csub->client.offset = SWAP_LONG(csub->client.offset);
|
---|
| 476 | }
|
---|
| 477 |
|
---|
| 478 | __private_extern__
|
---|
| 479 | void
|
---|
| 480 | swap_prebound_dylib_command(
|
---|
| 481 | struct prebound_dylib_command *pbdylib,
|
---|
| 482 | enum byte_sex target_byte_sex)
|
---|
| 483 | {
|
---|
| 484 | #ifdef __MWERKS__
|
---|
| 485 | enum byte_sex dummy;
|
---|
| 486 | dummy = target_byte_sex;
|
---|
| 487 | #endif
|
---|
| 488 | pbdylib->cmd = SWAP_LONG(pbdylib->cmd);
|
---|
| 489 | pbdylib->cmdsize = SWAP_LONG(pbdylib->cmdsize);
|
---|
| 490 | pbdylib->name.offset = SWAP_LONG(pbdylib->name.offset);
|
---|
| 491 | pbdylib->nmodules = SWAP_LONG(pbdylib->nmodules);
|
---|
| 492 | pbdylib->linked_modules.offset =
|
---|
| 493 | SWAP_LONG(pbdylib->linked_modules.offset);
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 | __private_extern__
|
---|
| 497 | void
|
---|
| 498 | swap_dylinker_command(
|
---|
| 499 | struct dylinker_command *dyld,
|
---|
| 500 | enum byte_sex target_byte_sex)
|
---|
| 501 | {
|
---|
| 502 | #ifdef __MWERKS__
|
---|
| 503 | enum byte_sex dummy;
|
---|
| 504 | dummy = target_byte_sex;
|
---|
| 505 | #endif
|
---|
| 506 | dyld->cmd = SWAP_LONG(dyld->cmd);
|
---|
| 507 | dyld->cmdsize = SWAP_LONG(dyld->cmdsize);
|
---|
| 508 | dyld->name.offset = SWAP_LONG(dyld->name.offset);
|
---|
| 509 | }
|
---|
| 510 |
|
---|
| 511 | __private_extern__
|
---|
| 512 | void
|
---|
| 513 | swap_fvmfile_command(
|
---|
| 514 | struct fvmfile_command *ff,
|
---|
| 515 | enum byte_sex target_byte_sex)
|
---|
| 516 | {
|
---|
| 517 | #ifdef __MWERKS__
|
---|
| 518 | enum byte_sex dummy;
|
---|
| 519 | dummy = target_byte_sex;
|
---|
| 520 | #endif
|
---|
| 521 | ff->cmd = SWAP_LONG(ff->cmd);
|
---|
| 522 | ff->cmdsize = SWAP_LONG(ff->cmdsize);
|
---|
| 523 | ff->name.offset = SWAP_LONG(ff->name.offset);
|
---|
| 524 | ff->header_addr = SWAP_LONG(ff->header_addr);
|
---|
| 525 | }
|
---|
| 526 |
|
---|
| 527 |
|
---|
| 528 | __private_extern__
|
---|
| 529 | void
|
---|
| 530 | swap_thread_command(
|
---|
| 531 | struct thread_command *ut,
|
---|
| 532 | enum byte_sex target_byte_sex)
|
---|
| 533 | {
|
---|
| 534 | #ifdef __MWERKS__
|
---|
| 535 | enum byte_sex dummy;
|
---|
| 536 | dummy = target_byte_sex;
|
---|
| 537 | #endif
|
---|
| 538 | ut->cmd = SWAP_LONG(ut->cmd);
|
---|
| 539 | ut->cmdsize = SWAP_LONG(ut->cmdsize);
|
---|
| 540 | }
|
---|
| 541 |
|
---|
| 542 | __private_extern__
|
---|
| 543 | void
|
---|
| 544 | swap_m68k_thread_state_regs(
|
---|
| 545 | struct m68k_thread_state_regs *cpu,
|
---|
| 546 | enum byte_sex target_byte_sex)
|
---|
| 547 | {
|
---|
| 548 | unsigned long i;
|
---|
| 549 | #ifdef __MWERKS__
|
---|
| 550 | enum byte_sex dummy;
|
---|
| 551 | dummy = target_byte_sex;
|
---|
| 552 | #endif
|
---|
| 553 |
|
---|
| 554 | for(i = 0; i < 8; i++)
|
---|
| 555 | cpu->dreg[i] = SWAP_LONG(cpu->dreg[i]);
|
---|
| 556 | for(i = 0; i < 8; i++)
|
---|
| 557 | cpu->areg[i] = SWAP_LONG(cpu->areg[i]);
|
---|
| 558 | cpu->pad0 = SWAP_SHORT(cpu->pad0);
|
---|
| 559 | cpu->sr = SWAP_SHORT(cpu->sr);
|
---|
| 560 | cpu->pc = SWAP_LONG(cpu->pc);
|
---|
| 561 | }
|
---|
| 562 |
|
---|
| 563 | __private_extern__
|
---|
| 564 | void
|
---|
| 565 | swap_m68k_thread_state_68882(
|
---|
| 566 | struct m68k_thread_state_68882 *fpu,
|
---|
| 567 | enum byte_sex target_byte_sex)
|
---|
| 568 | {
|
---|
| 569 | unsigned long i, tmp;
|
---|
| 570 | #ifdef __MWERKS__
|
---|
| 571 | enum byte_sex dummy;
|
---|
| 572 | dummy = target_byte_sex;
|
---|
| 573 | #endif
|
---|
| 574 |
|
---|
| 575 | for(i = 0; i < 8; i++){
|
---|
| 576 | tmp = SWAP_LONG(fpu->regs[i].fp[0]);
|
---|
| 577 | fpu->regs[i].fp[1] = SWAP_LONG(fpu->regs[i].fp[1]);
|
---|
| 578 | fpu->regs[i].fp[0] = SWAP_LONG(fpu->regs[i].fp[2]);
|
---|
| 579 | fpu->regs[i].fp[2] = tmp;
|
---|
| 580 | }
|
---|
| 581 | fpu->cr = SWAP_LONG(fpu->cr);
|
---|
| 582 | fpu->sr = SWAP_LONG(fpu->sr);
|
---|
| 583 | fpu->iar = SWAP_LONG(fpu->iar);
|
---|
| 584 | fpu->state = SWAP_LONG(fpu->state);
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 | __private_extern__
|
---|
| 588 | void
|
---|
| 589 | swap_m68k_thread_state_user_reg(
|
---|
| 590 | struct m68k_thread_state_user_reg *user_reg,
|
---|
| 591 | enum byte_sex target_byte_sex)
|
---|
| 592 | {
|
---|
| 593 | #ifdef __MWERKS__
|
---|
| 594 | enum byte_sex dummy;
|
---|
| 595 | dummy = target_byte_sex;
|
---|
| 596 | #endif
|
---|
| 597 | user_reg->user_reg = SWAP_LONG(user_reg->user_reg);
|
---|
| 598 | }
|
---|
| 599 |
|
---|
| 600 | __private_extern__
|
---|
| 601 | void
|
---|
| 602 | swap_ppc_thread_state_t(
|
---|
| 603 | ppc_thread_state_t *cpu,
|
---|
| 604 | enum byte_sex target_byte_sex)
|
---|
| 605 | {
|
---|
| 606 | cpu->srr0 = SWAP_LONG(cpu->srr0);
|
---|
| 607 | cpu->srr1 = SWAP_LONG(cpu->srr1);
|
---|
| 608 | cpu->r0 = SWAP_LONG(cpu->r0);
|
---|
| 609 | cpu->r1 = SWAP_LONG(cpu->r1);
|
---|
| 610 | cpu->r2 = SWAP_LONG(cpu->r2);
|
---|
| 611 | cpu->r3 = SWAP_LONG(cpu->r3);
|
---|
| 612 | cpu->r4 = SWAP_LONG(cpu->r4);
|
---|
| 613 | cpu->r5 = SWAP_LONG(cpu->r5);
|
---|
| 614 | cpu->r6 = SWAP_LONG(cpu->r6);
|
---|
| 615 | cpu->r7 = SWAP_LONG(cpu->r7);
|
---|
| 616 | cpu->r8 = SWAP_LONG(cpu->r8);
|
---|
| 617 | cpu->r9 = SWAP_LONG(cpu->r9);
|
---|
| 618 | cpu->r10 = SWAP_LONG(cpu->r10);
|
---|
| 619 | cpu->r11 = SWAP_LONG(cpu->r11);
|
---|
| 620 | cpu->r12 = SWAP_LONG(cpu->r12);
|
---|
| 621 | cpu->r13 = SWAP_LONG(cpu->r13);
|
---|
| 622 | cpu->r14 = SWAP_LONG(cpu->r14);
|
---|
| 623 | cpu->r15 = SWAP_LONG(cpu->r15);
|
---|
| 624 | cpu->r16 = SWAP_LONG(cpu->r16);
|
---|
| 625 | cpu->r17 = SWAP_LONG(cpu->r17);
|
---|
| 626 | cpu->r18 = SWAP_LONG(cpu->r18);
|
---|
| 627 | cpu->r19 = SWAP_LONG(cpu->r19);
|
---|
| 628 | cpu->r20 = SWAP_LONG(cpu->r20);
|
---|
| 629 | cpu->r21 = SWAP_LONG(cpu->r21);
|
---|
| 630 | cpu->r22 = SWAP_LONG(cpu->r22);
|
---|
| 631 | cpu->r23 = SWAP_LONG(cpu->r23);
|
---|
| 632 | cpu->r24 = SWAP_LONG(cpu->r24);
|
---|
| 633 | cpu->r25 = SWAP_LONG(cpu->r25);
|
---|
| 634 | cpu->r26 = SWAP_LONG(cpu->r26);
|
---|
| 635 | cpu->r27 = SWAP_LONG(cpu->r27);
|
---|
| 636 | cpu->r28 = SWAP_LONG(cpu->r28);
|
---|
| 637 | cpu->r29 = SWAP_LONG(cpu->r29);
|
---|
| 638 | cpu->r30 = SWAP_LONG(cpu->r30);
|
---|
| 639 | cpu->r31 = SWAP_LONG(cpu->r31);
|
---|
| 640 | cpu->cr = SWAP_LONG(cpu->cr);
|
---|
| 641 | cpu->xer = SWAP_LONG(cpu->xer);
|
---|
| 642 | cpu->lr = SWAP_LONG(cpu->lr);
|
---|
| 643 | cpu->ctr = SWAP_LONG(cpu->ctr);
|
---|
| 644 | cpu->mq = SWAP_LONG(cpu->mq);
|
---|
[217] | 645 | cpu->vrsave = SWAP_LONG(cpu->vrsave);
|
---|
[7] | 646 | }
|
---|
| 647 |
|
---|
| 648 | __private_extern__
|
---|
| 649 | void
|
---|
[217] | 650 | swap_ppc_thread_state64_t(
|
---|
| 651 | ppc_thread_state64_t *cpu,
|
---|
| 652 | enum byte_sex target_byte_sex)
|
---|
| 653 | {
|
---|
| 654 | cpu->srr0 = SWAP_LONG_LONG(cpu->srr0);
|
---|
| 655 | cpu->srr1 = SWAP_LONG_LONG(cpu->srr1);
|
---|
| 656 | cpu->r0 = SWAP_LONG_LONG(cpu->r0);
|
---|
| 657 | cpu->r1 = SWAP_LONG_LONG(cpu->r1);
|
---|
| 658 | cpu->r2 = SWAP_LONG_LONG(cpu->r2);
|
---|
| 659 | cpu->r3 = SWAP_LONG_LONG(cpu->r3);
|
---|
| 660 | cpu->r4 = SWAP_LONG_LONG(cpu->r4);
|
---|
| 661 | cpu->r5 = SWAP_LONG_LONG(cpu->r5);
|
---|
| 662 | cpu->r6 = SWAP_LONG_LONG(cpu->r6);
|
---|
| 663 | cpu->r7 = SWAP_LONG_LONG(cpu->r7);
|
---|
| 664 | cpu->r8 = SWAP_LONG_LONG(cpu->r8);
|
---|
| 665 | cpu->r9 = SWAP_LONG_LONG(cpu->r9);
|
---|
| 666 | cpu->r10 = SWAP_LONG_LONG(cpu->r10);
|
---|
| 667 | cpu->r11 = SWAP_LONG_LONG(cpu->r11);
|
---|
| 668 | cpu->r12 = SWAP_LONG_LONG(cpu->r12);
|
---|
| 669 | cpu->r13 = SWAP_LONG_LONG(cpu->r13);
|
---|
| 670 | cpu->r14 = SWAP_LONG_LONG(cpu->r14);
|
---|
| 671 | cpu->r15 = SWAP_LONG_LONG(cpu->r15);
|
---|
| 672 | cpu->r16 = SWAP_LONG_LONG(cpu->r16);
|
---|
| 673 | cpu->r17 = SWAP_LONG_LONG(cpu->r17);
|
---|
| 674 | cpu->r18 = SWAP_LONG_LONG(cpu->r18);
|
---|
| 675 | cpu->r19 = SWAP_LONG_LONG(cpu->r19);
|
---|
| 676 | cpu->r20 = SWAP_LONG_LONG(cpu->r20);
|
---|
| 677 | cpu->r21 = SWAP_LONG_LONG(cpu->r21);
|
---|
| 678 | cpu->r22 = SWAP_LONG_LONG(cpu->r22);
|
---|
| 679 | cpu->r23 = SWAP_LONG_LONG(cpu->r23);
|
---|
| 680 | cpu->r24 = SWAP_LONG_LONG(cpu->r24);
|
---|
| 681 | cpu->r25 = SWAP_LONG_LONG(cpu->r25);
|
---|
| 682 | cpu->r26 = SWAP_LONG_LONG(cpu->r26);
|
---|
| 683 | cpu->r27 = SWAP_LONG_LONG(cpu->r27);
|
---|
| 684 | cpu->r28 = SWAP_LONG_LONG(cpu->r28);
|
---|
| 685 | cpu->r29 = SWAP_LONG_LONG(cpu->r29);
|
---|
| 686 | cpu->r30 = SWAP_LONG_LONG(cpu->r30);
|
---|
| 687 | cpu->r31 = SWAP_LONG_LONG(cpu->r31);
|
---|
| 688 | cpu->cr = SWAP_LONG(cpu->cr);
|
---|
| 689 | cpu->xer = SWAP_LONG_LONG(cpu->xer);
|
---|
| 690 | cpu->lr = SWAP_LONG_LONG(cpu->lr);
|
---|
| 691 | cpu->ctr = SWAP_LONG_LONG(cpu->ctr);
|
---|
| 692 | cpu->vrsave = SWAP_LONG(cpu->vrsave);
|
---|
| 693 | }
|
---|
| 694 |
|
---|
| 695 | __private_extern__
|
---|
| 696 | void
|
---|
[7] | 697 | swap_ppc_float_state_t(
|
---|
| 698 | ppc_float_state_t *fpu,
|
---|
| 699 | enum byte_sex target_byte_sex)
|
---|
| 700 | {
|
---|
| 701 | unsigned long i;
|
---|
| 702 | #ifdef __MWERKS__
|
---|
| 703 | enum byte_sex dummy;
|
---|
| 704 | dummy = target_byte_sex;
|
---|
| 705 | #endif
|
---|
| 706 |
|
---|
| 707 | for(i = 0; i < 32; i++)
|
---|
| 708 | fpu->fpregs[i] = SWAP_DOUBLE(fpu->fpregs[i]);
|
---|
| 709 |
|
---|
| 710 | fpu->fpscr_pad = SWAP_LONG(fpu->fpscr_pad);
|
---|
| 711 | fpu->fpscr = SWAP_LONG(fpu->fpscr);
|
---|
| 712 | }
|
---|
| 713 |
|
---|
| 714 | __private_extern__
|
---|
| 715 | void
|
---|
| 716 | swap_ppc_exception_state_t(
|
---|
| 717 | ppc_exception_state_t *state,
|
---|
| 718 | enum byte_sex target_byte_sex)
|
---|
| 719 | {
|
---|
| 720 | unsigned long i;
|
---|
| 721 | #ifdef __MWERKS__
|
---|
| 722 | enum byte_sex dummy;
|
---|
| 723 | dummy = target_byte_sex;
|
---|
| 724 | #endif
|
---|
| 725 |
|
---|
| 726 | state->dar = SWAP_LONG(state->dar);
|
---|
| 727 | state->dsisr = SWAP_LONG(state->dsisr);
|
---|
| 728 | state->exception = SWAP_LONG(state->exception);
|
---|
| 729 | state->pad0 = SWAP_LONG(state->pad0);
|
---|
| 730 |
|
---|
| 731 | for(i = 0; i < 4; i++)
|
---|
| 732 | state->pad1[i] = SWAP_LONG(state->pad1[i]);
|
---|
| 733 | }
|
---|
| 734 |
|
---|
| 735 | __private_extern__
|
---|
| 736 | void
|
---|
| 737 | swap_m88k_thread_state_grf_t(
|
---|
| 738 | m88k_thread_state_grf_t *cpu,
|
---|
| 739 | enum byte_sex target_byte_sex)
|
---|
| 740 | {
|
---|
| 741 | #ifdef __MWERKS__
|
---|
| 742 | enum byte_sex dummy;
|
---|
| 743 | dummy = target_byte_sex;
|
---|
| 744 | #endif
|
---|
| 745 | cpu->r1 = SWAP_LONG(cpu->r1);
|
---|
| 746 | cpu->r2 = SWAP_LONG(cpu->r2);
|
---|
| 747 | cpu->r3 = SWAP_LONG(cpu->r3);
|
---|
| 748 | cpu->r4 = SWAP_LONG(cpu->r4);
|
---|
| 749 | cpu->r5 = SWAP_LONG(cpu->r5);
|
---|
| 750 | cpu->r6 = SWAP_LONG(cpu->r6);
|
---|
| 751 | cpu->r7 = SWAP_LONG(cpu->r7);
|
---|
| 752 | cpu->r8 = SWAP_LONG(cpu->r8);
|
---|
| 753 | cpu->r9 = SWAP_LONG(cpu->r9);
|
---|
| 754 | cpu->r10 = SWAP_LONG(cpu->r10);
|
---|
| 755 | cpu->r11 = SWAP_LONG(cpu->r11);
|
---|
| 756 | cpu->r12 = SWAP_LONG(cpu->r12);
|
---|
| 757 | cpu->r13 = SWAP_LONG(cpu->r13);
|
---|
| 758 | cpu->r14 = SWAP_LONG(cpu->r14);
|
---|
| 759 | cpu->r15 = SWAP_LONG(cpu->r15);
|
---|
| 760 | cpu->r16 = SWAP_LONG(cpu->r16);
|
---|
| 761 | cpu->r17 = SWAP_LONG(cpu->r17);
|
---|
| 762 | cpu->r18 = SWAP_LONG(cpu->r18);
|
---|
| 763 | cpu->r19 = SWAP_LONG(cpu->r19);
|
---|
| 764 | cpu->r20 = SWAP_LONG(cpu->r20);
|
---|
| 765 | cpu->r21 = SWAP_LONG(cpu->r21);
|
---|
| 766 | cpu->r22 = SWAP_LONG(cpu->r22);
|
---|
| 767 | cpu->r23 = SWAP_LONG(cpu->r23);
|
---|
| 768 | cpu->r24 = SWAP_LONG(cpu->r24);
|
---|
| 769 | cpu->r25 = SWAP_LONG(cpu->r25);
|
---|
| 770 | cpu->r26 = SWAP_LONG(cpu->r26);
|
---|
| 771 | cpu->r27 = SWAP_LONG(cpu->r27);
|
---|
| 772 | cpu->r28 = SWAP_LONG(cpu->r28);
|
---|
| 773 | cpu->r29 = SWAP_LONG(cpu->r29);
|
---|
| 774 | cpu->r30 = SWAP_LONG(cpu->r30);
|
---|
| 775 | cpu->r31 = SWAP_LONG(cpu->r31);
|
---|
| 776 | cpu->xip = SWAP_LONG(cpu->xip);
|
---|
| 777 | cpu->xip_in_bd = SWAP_LONG(cpu->xip_in_bd);
|
---|
| 778 | cpu->nip = SWAP_LONG(cpu->nip);
|
---|
| 779 | }
|
---|
| 780 |
|
---|
| 781 | __private_extern__
|
---|
| 782 | void
|
---|
| 783 | swap_m88k_thread_state_xrf_t(
|
---|
| 784 | m88k_thread_state_xrf_t *fpu,
|
---|
| 785 | enum byte_sex target_byte_sex)
|
---|
| 786 | {
|
---|
| 787 | enum byte_sex host_byte_sex;
|
---|
| 788 |
|
---|
| 789 | struct swapped_m88k_fpsr {
|
---|
| 790 | union {
|
---|
| 791 | struct {
|
---|
| 792 | unsigned afinx:BIT_WIDTH(0);
|
---|
| 793 | unsigned afovf:BIT_WIDTH(1);
|
---|
| 794 | unsigned afunf:BIT_WIDTH(2);
|
---|
| 795 | unsigned afdvz:BIT_WIDTH(3);
|
---|
| 796 | unsigned afinv:BIT_WIDTH(4);
|
---|
| 797 | unsigned :BITS_WIDTH(15,5);
|
---|
| 798 | unsigned xmod:BIT_WIDTH(16);
|
---|
| 799 | unsigned :BITS_WIDTH(31,17);
|
---|
| 800 | } fields;
|
---|
| 801 | unsigned long word;
|
---|
| 802 | } u;
|
---|
| 803 | } ssr;
|
---|
| 804 | struct swapped_m88k_fpcr {
|
---|
| 805 | union {
|
---|
| 806 | struct {
|
---|
| 807 | unsigned efinx:BIT_WIDTH(0);
|
---|
| 808 | unsigned efovf:BIT_WIDTH(1);
|
---|
| 809 | unsigned efunf:BIT_WIDTH(2);
|
---|
| 810 | unsigned efdvz:BIT_WIDTH(3);
|
---|
| 811 | unsigned efinv:BIT_WIDTH(4);
|
---|
| 812 | unsigned :BITS_WIDTH(13,5);
|
---|
| 813 | m88k_fpcr_rm_t rm:BITS_WIDTH(15,14);
|
---|
| 814 | unsigned :BITS_WIDTH(31,16);
|
---|
| 815 | } fields;
|
---|
| 816 | unsigned long word;
|
---|
| 817 | } u;
|
---|
| 818 | } scr;
|
---|
| 819 |
|
---|
| 820 | host_byte_sex = get_host_byte_sex();
|
---|
| 821 |
|
---|
| 822 | fpu->x1.x[0] = SWAP_LONG(fpu->x1.x[0]);
|
---|
| 823 | fpu->x1.x[1] = SWAP_LONG(fpu->x1.x[1]);
|
---|
| 824 | fpu->x1.x[2] = SWAP_LONG(fpu->x1.x[2]);
|
---|
| 825 | fpu->x1.x[3] = SWAP_LONG(fpu->x1.x[3]);
|
---|
| 826 | fpu->x2.x[0] = SWAP_LONG(fpu->x2.x[0]);
|
---|
| 827 | fpu->x2.x[1] = SWAP_LONG(fpu->x2.x[1]);
|
---|
| 828 | fpu->x2.x[2] = SWAP_LONG(fpu->x2.x[2]);
|
---|
| 829 | fpu->x2.x[3] = SWAP_LONG(fpu->x2.x[3]);
|
---|
| 830 | fpu->x3.x[0] = SWAP_LONG(fpu->x3.x[0]);
|
---|
| 831 | fpu->x3.x[1] = SWAP_LONG(fpu->x3.x[1]);
|
---|
| 832 | fpu->x3.x[2] = SWAP_LONG(fpu->x3.x[2]);
|
---|
| 833 | fpu->x3.x[3] = SWAP_LONG(fpu->x3.x[3]);
|
---|
| 834 | fpu->x4.x[0] = SWAP_LONG(fpu->x4.x[0]);
|
---|
| 835 | fpu->x4.x[1] = SWAP_LONG(fpu->x4.x[1]);
|
---|
| 836 | fpu->x4.x[2] = SWAP_LONG(fpu->x4.x[2]);
|
---|
| 837 | fpu->x4.x[3] = SWAP_LONG(fpu->x4.x[3]);
|
---|
| 838 | fpu->x5.x[0] = SWAP_LONG(fpu->x5.x[0]);
|
---|
| 839 | fpu->x5.x[1] = SWAP_LONG(fpu->x5.x[1]);
|
---|
| 840 | fpu->x5.x[2] = SWAP_LONG(fpu->x5.x[2]);
|
---|
| 841 | fpu->x5.x[3] = SWAP_LONG(fpu->x5.x[3]);
|
---|
| 842 | fpu->x6.x[0] = SWAP_LONG(fpu->x6.x[0]);
|
---|
| 843 | fpu->x6.x[1] = SWAP_LONG(fpu->x6.x[1]);
|
---|
| 844 | fpu->x6.x[2] = SWAP_LONG(fpu->x6.x[2]);
|
---|
| 845 | fpu->x6.x[3] = SWAP_LONG(fpu->x6.x[3]);
|
---|
| 846 | fpu->x7.x[0] = SWAP_LONG(fpu->x7.x[0]);
|
---|
| 847 | fpu->x7.x[1] = SWAP_LONG(fpu->x7.x[1]);
|
---|
| 848 | fpu->x7.x[2] = SWAP_LONG(fpu->x7.x[2]);
|
---|
| 849 | fpu->x7.x[3] = SWAP_LONG(fpu->x7.x[3]);
|
---|
| 850 | fpu->x8.x[0] = SWAP_LONG(fpu->x8.x[0]);
|
---|
| 851 | fpu->x8.x[1] = SWAP_LONG(fpu->x8.x[1]);
|
---|
| 852 | fpu->x8.x[2] = SWAP_LONG(fpu->x8.x[2]);
|
---|
| 853 | fpu->x8.x[3] = SWAP_LONG(fpu->x8.x[3]);
|
---|
| 854 | fpu->x9.x[0] = SWAP_LONG(fpu->x9.x[0]);
|
---|
| 855 | fpu->x9.x[1] = SWAP_LONG(fpu->x9.x[1]);
|
---|
| 856 | fpu->x9.x[2] = SWAP_LONG(fpu->x9.x[2]);
|
---|
| 857 | fpu->x9.x[3] = SWAP_LONG(fpu->x9.x[3]);
|
---|
| 858 | fpu->x10.x[0] = SWAP_LONG(fpu->x10.x[0]);
|
---|
| 859 | fpu->x10.x[1] = SWAP_LONG(fpu->x10.x[1]);
|
---|
| 860 | fpu->x10.x[2] = SWAP_LONG(fpu->x10.x[2]);
|
---|
| 861 | fpu->x10.x[3] = SWAP_LONG(fpu->x10.x[3]);
|
---|
| 862 | fpu->x11.x[0] = SWAP_LONG(fpu->x11.x[0]);
|
---|
| 863 | fpu->x11.x[1] = SWAP_LONG(fpu->x11.x[1]);
|
---|
| 864 | fpu->x11.x[2] = SWAP_LONG(fpu->x11.x[2]);
|
---|
| 865 | fpu->x11.x[3] = SWAP_LONG(fpu->x11.x[3]);
|
---|
| 866 | fpu->x12.x[0] = SWAP_LONG(fpu->x12.x[0]);
|
---|
| 867 | fpu->x12.x[1] = SWAP_LONG(fpu->x12.x[1]);
|
---|
| 868 | fpu->x12.x[2] = SWAP_LONG(fpu->x12.x[2]);
|
---|
| 869 | fpu->x12.x[3] = SWAP_LONG(fpu->x12.x[3]);
|
---|
| 870 | fpu->x13.x[0] = SWAP_LONG(fpu->x13.x[0]);
|
---|
| 871 | fpu->x13.x[1] = SWAP_LONG(fpu->x13.x[1]);
|
---|
| 872 | fpu->x13.x[2] = SWAP_LONG(fpu->x13.x[2]);
|
---|
| 873 | fpu->x13.x[3] = SWAP_LONG(fpu->x13.x[3]);
|
---|
| 874 | fpu->x14.x[0] = SWAP_LONG(fpu->x14.x[0]);
|
---|
| 875 | fpu->x14.x[1] = SWAP_LONG(fpu->x14.x[1]);
|
---|
| 876 | fpu->x14.x[2] = SWAP_LONG(fpu->x14.x[2]);
|
---|
| 877 | fpu->x14.x[3] = SWAP_LONG(fpu->x14.x[3]);
|
---|
| 878 | fpu->x15.x[0] = SWAP_LONG(fpu->x15.x[0]);
|
---|
| 879 | fpu->x15.x[1] = SWAP_LONG(fpu->x15.x[1]);
|
---|
| 880 | fpu->x15.x[2] = SWAP_LONG(fpu->x15.x[2]);
|
---|
| 881 | fpu->x15.x[3] = SWAP_LONG(fpu->x15.x[3]);
|
---|
| 882 | fpu->x16.x[0] = SWAP_LONG(fpu->x16.x[0]);
|
---|
| 883 | fpu->x16.x[1] = SWAP_LONG(fpu->x16.x[1]);
|
---|
| 884 | fpu->x16.x[2] = SWAP_LONG(fpu->x16.x[2]);
|
---|
| 885 | fpu->x16.x[3] = SWAP_LONG(fpu->x16.x[3]);
|
---|
| 886 | fpu->x17.x[0] = SWAP_LONG(fpu->x17.x[0]);
|
---|
| 887 | fpu->x17.x[1] = SWAP_LONG(fpu->x17.x[1]);
|
---|
| 888 | fpu->x17.x[2] = SWAP_LONG(fpu->x17.x[2]);
|
---|
| 889 | fpu->x17.x[3] = SWAP_LONG(fpu->x17.x[3]);
|
---|
| 890 | fpu->x18.x[0] = SWAP_LONG(fpu->x18.x[0]);
|
---|
| 891 | fpu->x18.x[1] = SWAP_LONG(fpu->x18.x[1]);
|
---|
| 892 | fpu->x18.x[2] = SWAP_LONG(fpu->x18.x[2]);
|
---|
| 893 | fpu->x18.x[3] = SWAP_LONG(fpu->x18.x[3]);
|
---|
| 894 | fpu->x19.x[0] = SWAP_LONG(fpu->x19.x[0]);
|
---|
| 895 | fpu->x19.x[1] = SWAP_LONG(fpu->x19.x[1]);
|
---|
| 896 | fpu->x19.x[2] = SWAP_LONG(fpu->x19.x[2]);
|
---|
| 897 | fpu->x19.x[3] = SWAP_LONG(fpu->x19.x[3]);
|
---|
| 898 | fpu->x20.x[0] = SWAP_LONG(fpu->x20.x[0]);
|
---|
| 899 | fpu->x20.x[1] = SWAP_LONG(fpu->x20.x[1]);
|
---|
| 900 | fpu->x20.x[2] = SWAP_LONG(fpu->x20.x[2]);
|
---|
| 901 | fpu->x20.x[3] = SWAP_LONG(fpu->x20.x[3]);
|
---|
| 902 | fpu->x21.x[0] = SWAP_LONG(fpu->x21.x[0]);
|
---|
| 903 | fpu->x21.x[1] = SWAP_LONG(fpu->x21.x[1]);
|
---|
| 904 | fpu->x21.x[2] = SWAP_LONG(fpu->x21.x[2]);
|
---|
| 905 | fpu->x21.x[3] = SWAP_LONG(fpu->x21.x[3]);
|
---|
| 906 | fpu->x22.x[0] = SWAP_LONG(fpu->x22.x[0]);
|
---|
| 907 | fpu->x22.x[1] = SWAP_LONG(fpu->x22.x[1]);
|
---|
| 908 | fpu->x22.x[2] = SWAP_LONG(fpu->x22.x[2]);
|
---|
| 909 | fpu->x22.x[3] = SWAP_LONG(fpu->x22.x[3]);
|
---|
| 910 | fpu->x23.x[0] = SWAP_LONG(fpu->x23.x[0]);
|
---|
| 911 | fpu->x23.x[1] = SWAP_LONG(fpu->x23.x[1]);
|
---|
| 912 | fpu->x23.x[2] = SWAP_LONG(fpu->x23.x[2]);
|
---|
| 913 | fpu->x23.x[3] = SWAP_LONG(fpu->x23.x[3]);
|
---|
| 914 | fpu->x24.x[0] = SWAP_LONG(fpu->x24.x[0]);
|
---|
| 915 | fpu->x24.x[1] = SWAP_LONG(fpu->x24.x[1]);
|
---|
| 916 | fpu->x24.x[2] = SWAP_LONG(fpu->x24.x[2]);
|
---|
| 917 | fpu->x24.x[3] = SWAP_LONG(fpu->x24.x[3]);
|
---|
| 918 | fpu->x25.x[0] = SWAP_LONG(fpu->x25.x[0]);
|
---|
| 919 | fpu->x25.x[1] = SWAP_LONG(fpu->x25.x[1]);
|
---|
| 920 | fpu->x25.x[2] = SWAP_LONG(fpu->x25.x[2]);
|
---|
| 921 | fpu->x25.x[3] = SWAP_LONG(fpu->x25.x[3]);
|
---|
| 922 | fpu->x26.x[0] = SWAP_LONG(fpu->x26.x[0]);
|
---|
| 923 | fpu->x26.x[1] = SWAP_LONG(fpu->x26.x[1]);
|
---|
| 924 | fpu->x26.x[2] = SWAP_LONG(fpu->x26.x[2]);
|
---|
| 925 | fpu->x26.x[3] = SWAP_LONG(fpu->x26.x[3]);
|
---|
| 926 | fpu->x27.x[0] = SWAP_LONG(fpu->x27.x[0]);
|
---|
| 927 | fpu->x27.x[1] = SWAP_LONG(fpu->x27.x[1]);
|
---|
| 928 | fpu->x27.x[2] = SWAP_LONG(fpu->x27.x[2]);
|
---|
| 929 | fpu->x27.x[3] = SWAP_LONG(fpu->x27.x[3]);
|
---|
| 930 | fpu->x28.x[0] = SWAP_LONG(fpu->x28.x[0]);
|
---|
| 931 | fpu->x28.x[1] = SWAP_LONG(fpu->x28.x[1]);
|
---|
| 932 | fpu->x28.x[2] = SWAP_LONG(fpu->x28.x[2]);
|
---|
| 933 | fpu->x28.x[3] = SWAP_LONG(fpu->x28.x[3]);
|
---|
| 934 | fpu->x29.x[0] = SWAP_LONG(fpu->x29.x[0]);
|
---|
| 935 | fpu->x29.x[1] = SWAP_LONG(fpu->x29.x[1]);
|
---|
| 936 | fpu->x29.x[2] = SWAP_LONG(fpu->x29.x[2]);
|
---|
| 937 | fpu->x29.x[3] = SWAP_LONG(fpu->x29.x[3]);
|
---|
| 938 | fpu->x30.x[0] = SWAP_LONG(fpu->x30.x[0]);
|
---|
| 939 | fpu->x30.x[1] = SWAP_LONG(fpu->x30.x[1]);
|
---|
| 940 | fpu->x30.x[2] = SWAP_LONG(fpu->x30.x[2]);
|
---|
| 941 | fpu->x30.x[3] = SWAP_LONG(fpu->x30.x[3]);
|
---|
| 942 | fpu->x31.x[0] = SWAP_LONG(fpu->x31.x[0]);
|
---|
| 943 | fpu->x31.x[1] = SWAP_LONG(fpu->x31.x[1]);
|
---|
| 944 | fpu->x31.x[2] = SWAP_LONG(fpu->x31.x[2]);
|
---|
| 945 | fpu->x31.x[3] = SWAP_LONG(fpu->x31.x[3]);
|
---|
| 946 |
|
---|
| 947 | if(target_byte_sex == host_byte_sex){
|
---|
| 948 | memcpy(&ssr, &(fpu->fpsr), sizeof(struct swapped_m88k_fpsr));
|
---|
| 949 | ssr.u.word = SWAP_LONG(ssr.u.word);
|
---|
| 950 | fpu->fpsr.afinx = ssr.u.fields.afinx;
|
---|
| 951 | fpu->fpsr.afovf = ssr.u.fields.afovf;
|
---|
| 952 | fpu->fpsr.afunf = ssr.u.fields.afunf;
|
---|
| 953 | fpu->fpsr.afdvz = ssr.u.fields.afdvz;
|
---|
| 954 | fpu->fpsr.afinv = ssr.u.fields.afinv;
|
---|
| 955 | fpu->fpsr.xmod = ssr.u.fields.xmod;
|
---|
| 956 |
|
---|
| 957 | memcpy(&scr, &(fpu->fpcr), sizeof(struct swapped_m88k_fpcr));
|
---|
| 958 | scr.u.word = SWAP_LONG(scr.u.word);
|
---|
| 959 | fpu->fpcr.efinx = scr.u.fields.efinx;
|
---|
| 960 | fpu->fpcr.efovf = scr.u.fields.efovf;
|
---|
| 961 | fpu->fpcr.efunf = scr.u.fields.efunf;
|
---|
| 962 | fpu->fpcr.efdvz = scr.u.fields.efdvz;
|
---|
| 963 | fpu->fpcr.efinv = scr.u.fields.efinv;
|
---|
| 964 | fpu->fpcr.rm = scr.u.fields.rm;
|
---|
| 965 | }
|
---|
| 966 | else{
|
---|
| 967 | ssr.u.fields.afinx = fpu->fpsr.afinx;
|
---|
| 968 | ssr.u.fields.afovf = fpu->fpsr.afovf;
|
---|
| 969 | ssr.u.fields.afunf = fpu->fpsr.afunf;
|
---|
| 970 | ssr.u.fields.afdvz = fpu->fpsr.afdvz;
|
---|
| 971 | ssr.u.fields.afinv = fpu->fpsr.afinv;
|
---|
| 972 | ssr.u.fields.xmod = fpu->fpsr.xmod;
|
---|
| 973 | ssr.u.word = SWAP_LONG(ssr.u.word);
|
---|
| 974 | memcpy(&(fpu->fpsr), &ssr, sizeof(struct swapped_m88k_fpsr));
|
---|
| 975 |
|
---|
| 976 | scr.u.fields.efinx = fpu->fpcr.efinx;
|
---|
| 977 | scr.u.fields.efovf = fpu->fpcr.efovf;
|
---|
| 978 | scr.u.fields.efunf = fpu->fpcr.efunf;
|
---|
| 979 | scr.u.fields.efdvz = fpu->fpcr.efdvz;
|
---|
| 980 | scr.u.fields.efinv = fpu->fpcr.efinv;
|
---|
| 981 | scr.u.fields.rm = fpu->fpcr.rm;
|
---|
| 982 | scr.u.word = SWAP_LONG(scr.u.word);
|
---|
| 983 | memcpy(&(fpu->fpcr), &scr, sizeof(struct swapped_m88k_fpcr));
|
---|
| 984 | }
|
---|
| 985 | }
|
---|
| 986 |
|
---|
| 987 | __private_extern__
|
---|
| 988 | void
|
---|
| 989 | swap_m88k_thread_state_user_t(
|
---|
| 990 | m88k_thread_state_user_t *user,
|
---|
| 991 | enum byte_sex target_byte_sex)
|
---|
| 992 | {
|
---|
| 993 | #ifdef __MWERKS__
|
---|
| 994 | enum byte_sex dummy;
|
---|
| 995 | dummy = target_byte_sex;
|
---|
| 996 | #endif
|
---|
| 997 | user->user = SWAP_LONG(user->user);
|
---|
| 998 | }
|
---|
| 999 |
|
---|
| 1000 | __private_extern__
|
---|
| 1001 | void
|
---|
| 1002 | swap_m88110_thread_state_impl_t(
|
---|
| 1003 | m88110_thread_state_impl_t *spu,
|
---|
| 1004 | enum byte_sex target_byte_sex)
|
---|
| 1005 | {
|
---|
| 1006 | unsigned long i;
|
---|
| 1007 | enum byte_sex host_byte_sex;
|
---|
| 1008 |
|
---|
| 1009 | struct swapped_m88110_bp_ctrl {
|
---|
| 1010 | union {
|
---|
| 1011 | struct {
|
---|
| 1012 | unsigned v:BIT_WIDTH(0);
|
---|
| 1013 | m88110_match_t addr_match:BITS_WIDTH(12,1);
|
---|
| 1014 | unsigned :BITS_WIDTH(26,13);
|
---|
| 1015 | unsigned rwm:BIT_WIDTH(27);
|
---|
| 1016 | unsigned rw:BIT_WIDTH(28);
|
---|
| 1017 | unsigned :BITS_WIDTH(31,29);
|
---|
| 1018 | } fields;
|
---|
| 1019 | unsigned long word;
|
---|
| 1020 | } u;
|
---|
| 1021 | } sbpc;
|
---|
| 1022 |
|
---|
| 1023 | struct swap_m88110_psr {
|
---|
| 1024 | union {
|
---|
| 1025 | struct {
|
---|
| 1026 | unsigned :BITS_WIDTH(1,0);
|
---|
| 1027 | unsigned mxm_dis:BIT_WIDTH(2);
|
---|
| 1028 | unsigned sfu1dis:BIT_WIDTH(3);
|
---|
| 1029 | unsigned :BITS_WIDTH(22,4);
|
---|
| 1030 | unsigned trace:BIT_WIDTH(23);
|
---|
| 1031 | unsigned :BIT_WIDTH(24);
|
---|
| 1032 | unsigned sm:BIT_WIDTH(25);
|
---|
| 1033 | unsigned sgn_imd:BIT_WIDTH(26);
|
---|
| 1034 | unsigned :BIT_WIDTH(27);
|
---|
| 1035 | unsigned c:BIT_WIDTH(28);
|
---|
| 1036 | unsigned se:BIT_WIDTH(29);
|
---|
| 1037 | unsigned le:BIT_WIDTH(30);
|
---|
| 1038 | unsigned supr:BIT_WIDTH(31);
|
---|
| 1039 | } fields;
|
---|
| 1040 | unsigned long word;
|
---|
| 1041 | } u;
|
---|
| 1042 | } spsr;
|
---|
| 1043 |
|
---|
| 1044 | struct swapped_m88110_fp_trap_status {
|
---|
| 1045 | union {
|
---|
| 1046 | struct {
|
---|
| 1047 | unsigned efinx:BIT_WIDTH(0);
|
---|
| 1048 | unsigned efovf:BIT_WIDTH(1);
|
---|
| 1049 | unsigned efunf:BIT_WIDTH(2);
|
---|
| 1050 | unsigned efdvz:BIT_WIDTH(3);
|
---|
| 1051 | unsigned efinv:BIT_WIDTH(4);
|
---|
| 1052 | unsigned priv:BIT_WIDTH(5);
|
---|
| 1053 | unsigned unimp:BIT_WIDTH(6);
|
---|
| 1054 | unsigned int:BIT_WIDTH(7);
|
---|
| 1055 | unsigned sfu1_disabled:BIT_WIDTH(8);
|
---|
| 1056 | unsigned :BITS_WIDTH(13,9);
|
---|
| 1057 | m88110_iresult_size_t iresult_size:BITS_WIDTH(15,14);
|
---|
| 1058 | unsigned :BITS_WIDTH(31,16);
|
---|
| 1059 | } fields;
|
---|
| 1060 | unsigned long word;
|
---|
| 1061 | } u;
|
---|
| 1062 | } sfps;
|
---|
| 1063 |
|
---|
| 1064 | host_byte_sex = get_host_byte_sex();
|
---|
| 1065 |
|
---|
| 1066 | if(target_byte_sex == host_byte_sex){
|
---|
| 1067 | for(i = 0; i < M88110_N_DATA_BP; i++){
|
---|
| 1068 | spu->data_bp[i].addr = SWAP_LONG(spu->data_bp[i].addr);
|
---|
| 1069 | memcpy(&sbpc, &(spu->data_bp[i].ctrl),
|
---|
| 1070 | sizeof(struct swapped_m88110_bp_ctrl));
|
---|
| 1071 | sbpc.u.word = SWAP_LONG(sbpc.u.word);
|
---|
| 1072 | spu->data_bp[i].ctrl.v = sbpc.u.fields.v;
|
---|
| 1073 | spu->data_bp[i].ctrl.addr_match = sbpc.u.fields.addr_match;
|
---|
| 1074 | spu->data_bp[i].ctrl.rwm = sbpc.u.fields.rwm;
|
---|
| 1075 | spu->data_bp[i].ctrl.rw = sbpc.u.fields.rw;
|
---|
| 1076 | }
|
---|
| 1077 |
|
---|
| 1078 | memcpy(&spsr, &(spu->psr), sizeof(struct swap_m88110_psr));
|
---|
| 1079 | spsr.u.word = SWAP_LONG(spsr.u.word);
|
---|
| 1080 | spu->psr.mxm_dis = spsr.u.fields.mxm_dis;
|
---|
| 1081 | spu->psr.sfu1dis = spsr.u.fields.sfu1dis;
|
---|
| 1082 | spu->psr.trace = spsr.u.fields.trace;
|
---|
| 1083 | spu->psr.sm = spsr.u.fields.sm;
|
---|
| 1084 | spu->psr.sgn_imd = spsr.u.fields.sgn_imd;
|
---|
| 1085 | spu->psr.c = spsr.u.fields.c;
|
---|
| 1086 | spu->psr.se = spsr.u.fields.se;
|
---|
| 1087 | spu->psr.le = spsr.u.fields.le;
|
---|
| 1088 | spu->psr.supr = spsr.u.fields.supr;
|
---|
| 1089 |
|
---|
| 1090 | memcpy(&sfps, &(spu->fp_trap_status),
|
---|
| 1091 | sizeof(struct swapped_m88110_fp_trap_status));
|
---|
| 1092 | sfps.u.word = SWAP_LONG(sfps.u.word);
|
---|
| 1093 | spu->fp_trap_status.efinx = sfps.u.fields.efinx;
|
---|
| 1094 | spu->fp_trap_status.efovf = sfps.u.fields.efovf;
|
---|
| 1095 | spu->fp_trap_status.efunf = sfps.u.fields.efunf;
|
---|
| 1096 | spu->fp_trap_status.efdvz = sfps.u.fields.efdvz;
|
---|
| 1097 | spu->fp_trap_status.efinv = sfps.u.fields.efinv;
|
---|
| 1098 | spu->fp_trap_status.priv = sfps.u.fields.priv;
|
---|
| 1099 | spu->fp_trap_status.unimp = sfps.u.fields.unimp;
|
---|
| 1100 | spu->fp_trap_status.sfu1_disabled = sfps.u.fields.sfu1_disabled;
|
---|
| 1101 | spu->fp_trap_status.iresult_size = sfps.u.fields.iresult_size;
|
---|
| 1102 | }
|
---|
| 1103 | else{
|
---|
| 1104 | for(i = 0; i < M88110_N_DATA_BP; i++){
|
---|
| 1105 | spu->data_bp[i].addr = SWAP_LONG(spu->data_bp[i].addr);
|
---|
| 1106 | sbpc.u.fields.v = spu->data_bp[i].ctrl.v;
|
---|
| 1107 | sbpc.u.fields.addr_match = spu->data_bp[i].ctrl.addr_match;
|
---|
| 1108 | sbpc.u.fields.rwm = spu->data_bp[i].ctrl.rwm;
|
---|
| 1109 | sbpc.u.fields.rw = spu->data_bp[i].ctrl.rw;
|
---|
| 1110 | sbpc.u.word = SWAP_LONG(sbpc.u.word);
|
---|
| 1111 | memcpy(&(spu->data_bp[i].ctrl), &sbpc,
|
---|
| 1112 | sizeof(struct swapped_m88110_bp_ctrl));
|
---|
| 1113 | }
|
---|
| 1114 |
|
---|
| 1115 | spsr.u.fields.mxm_dis = spu->psr.mxm_dis;
|
---|
| 1116 | spsr.u.fields.sfu1dis = spu->psr.sfu1dis;
|
---|
| 1117 | spsr.u.fields.trace = spu->psr.trace;
|
---|
| 1118 | spsr.u.fields.sm = spu->psr.sm;
|
---|
| 1119 | spsr.u.fields.sgn_imd = spu->psr.sgn_imd;
|
---|
| 1120 | spsr.u.fields.c = spu->psr.c;
|
---|
| 1121 | spsr.u.fields.se = spu->psr.se;
|
---|
| 1122 | spsr.u.fields.le = spu->psr.le;
|
---|
| 1123 | spsr.u.fields.supr = spu->psr.supr;
|
---|
| 1124 | spsr.u.word = SWAP_LONG(spsr.u.word);
|
---|
| 1125 | memcpy(&(spu->psr), &spsr, sizeof(struct swap_m88110_psr));
|
---|
| 1126 |
|
---|
| 1127 | sfps.u.fields.efinx = spu->fp_trap_status.efinx;
|
---|
| 1128 | sfps.u.fields.efovf = spu->fp_trap_status.efovf;
|
---|
| 1129 | sfps.u.fields.efunf = spu->fp_trap_status.efunf;
|
---|
| 1130 | sfps.u.fields.efdvz = spu->fp_trap_status.efdvz;
|
---|
| 1131 | sfps.u.fields.efinv = spu->fp_trap_status.efinv;
|
---|
| 1132 | sfps.u.fields.priv = spu->fp_trap_status.priv;
|
---|
| 1133 | sfps.u.fields.unimp = spu->fp_trap_status.unimp;
|
---|
| 1134 | sfps.u.fields.sfu1_disabled = spu->fp_trap_status.sfu1_disabled;
|
---|
| 1135 | sfps.u.fields.iresult_size = spu->fp_trap_status.iresult_size;
|
---|
| 1136 | sfps.u.word = SWAP_LONG(sfps.u.word);
|
---|
| 1137 | memcpy(&(spu->fp_trap_status), &sfps,
|
---|
| 1138 | sizeof(struct swapped_m88110_fp_trap_status));
|
---|
| 1139 | }
|
---|
| 1140 | spu->intermediate_result.x[0] =
|
---|
| 1141 | SWAP_LONG(spu->intermediate_result.x[0]);
|
---|
| 1142 | spu->intermediate_result.x[1] =
|
---|
| 1143 | SWAP_LONG(spu->intermediate_result.x[1]);
|
---|
| 1144 | spu->intermediate_result.x[2] =
|
---|
| 1145 | SWAP_LONG(spu->intermediate_result.x[2]);
|
---|
| 1146 | spu->intermediate_result.x[3] =
|
---|
| 1147 | SWAP_LONG(spu->intermediate_result.x[3]);
|
---|
| 1148 | }
|
---|
| 1149 |
|
---|
| 1150 | __private_extern__
|
---|
| 1151 | void
|
---|
| 1152 | swap_i860_thread_state_regs(
|
---|
| 1153 | struct i860_thread_state_regs *cpu,
|
---|
| 1154 | enum byte_sex target_byte_sex)
|
---|
| 1155 | {
|
---|
| 1156 | unsigned long i;
|
---|
| 1157 | #ifdef __MWERKS__
|
---|
| 1158 | enum byte_sex dummy;
|
---|
| 1159 | dummy = target_byte_sex;
|
---|
| 1160 | #endif
|
---|
| 1161 |
|
---|
| 1162 | for(i = 0; i < 31; i++)
|
---|
| 1163 | cpu->ireg[i] = SWAP_LONG(cpu->ireg[i]);
|
---|
| 1164 | for(i = 0; i < 30; i++)
|
---|
| 1165 | cpu->freg[i] = SWAP_LONG(cpu->freg[i]);
|
---|
| 1166 | cpu->psr = SWAP_LONG(cpu->psr);
|
---|
| 1167 | cpu->epsr = SWAP_LONG(cpu->epsr);
|
---|
| 1168 | cpu->db = SWAP_LONG(cpu->db);
|
---|
| 1169 | cpu->pc = SWAP_LONG(cpu->pc);
|
---|
| 1170 | cpu->_padding_ = SWAP_LONG(cpu->_padding_);
|
---|
| 1171 | cpu->Mres3 = SWAP_DOUBLE(cpu->Mres3);
|
---|
| 1172 | cpu->Ares3 = SWAP_DOUBLE(cpu->Ares3);
|
---|
| 1173 | cpu->Mres2 = SWAP_DOUBLE(cpu->Mres2);
|
---|
| 1174 | cpu->Ares2 = SWAP_DOUBLE(cpu->Ares2);
|
---|
| 1175 | cpu->Mres1 = SWAP_DOUBLE(cpu->Mres1);
|
---|
| 1176 | cpu->Ares1 = SWAP_DOUBLE(cpu->Ares1);
|
---|
| 1177 | cpu->Ires1 = SWAP_DOUBLE(cpu->Ires1);
|
---|
| 1178 | cpu->Lres3m = SWAP_DOUBLE(cpu->Lres3m);
|
---|
| 1179 | cpu->Lres2m = SWAP_DOUBLE(cpu->Lres2m);
|
---|
| 1180 | cpu->Lres1m = SWAP_DOUBLE(cpu->Lres1m);
|
---|
| 1181 | cpu->KR = SWAP_DOUBLE(cpu->KR);
|
---|
| 1182 | cpu->KI = SWAP_DOUBLE(cpu->KI);
|
---|
| 1183 | cpu->T = SWAP_DOUBLE(cpu->T);
|
---|
| 1184 | cpu->Fsr3 = SWAP_LONG(cpu->Fsr3);
|
---|
| 1185 | cpu->Fsr2 = SWAP_LONG(cpu->Fsr2);
|
---|
| 1186 | cpu->Fsr1 = SWAP_LONG(cpu->Fsr1);
|
---|
| 1187 | cpu->Mergelo32 = SWAP_LONG(cpu->Mergelo32);
|
---|
| 1188 | cpu->Mergehi32 = SWAP_LONG(cpu->Mergehi32);
|
---|
| 1189 | }
|
---|
| 1190 |
|
---|
| 1191 | __private_extern__
|
---|
| 1192 | void
|
---|
| 1193 | swap_i386_thread_state(
|
---|
| 1194 | i386_thread_state_t *cpu,
|
---|
| 1195 | enum byte_sex target_byte_sex)
|
---|
| 1196 | {
|
---|
| 1197 | #ifdef __MWERKS__
|
---|
| 1198 | enum byte_sex dummy;
|
---|
| 1199 | dummy = target_byte_sex;
|
---|
| 1200 | #endif
|
---|
| 1201 | cpu->eax = SWAP_LONG(cpu->eax);
|
---|
| 1202 | cpu->ebx = SWAP_LONG(cpu->ebx);
|
---|
| 1203 | cpu->ecx = SWAP_LONG(cpu->ecx);
|
---|
| 1204 | cpu->edx = SWAP_LONG(cpu->edx);
|
---|
| 1205 | cpu->edi = SWAP_LONG(cpu->edi);
|
---|
| 1206 | cpu->esi = SWAP_LONG(cpu->esi);
|
---|
| 1207 | cpu->ebp = SWAP_LONG(cpu->ebp);
|
---|
| 1208 | cpu->esp = SWAP_LONG(cpu->esp);
|
---|
| 1209 | cpu->ss = SWAP_LONG(cpu->ss);
|
---|
| 1210 | cpu->eflags = SWAP_LONG(cpu->eflags);
|
---|
| 1211 | cpu->eip = SWAP_LONG(cpu->eip);
|
---|
| 1212 | cpu->cs = SWAP_LONG(cpu->cs);
|
---|
| 1213 | cpu->ds = SWAP_LONG(cpu->ds);
|
---|
| 1214 | cpu->es = SWAP_LONG(cpu->es);
|
---|
| 1215 | cpu->fs = SWAP_LONG(cpu->fs);
|
---|
| 1216 | cpu->gs = SWAP_LONG(cpu->gs);
|
---|
| 1217 | }
|
---|
| 1218 |
|
---|
| 1219 | __private_extern__
|
---|
| 1220 | void
|
---|
| 1221 | swap_i386_thread_fpstate(
|
---|
| 1222 | i386_thread_fpstate_t *fpu,
|
---|
| 1223 | enum byte_sex target_byte_sex)
|
---|
| 1224 | {
|
---|
| 1225 | struct swapped_fp_control {
|
---|
| 1226 | union {
|
---|
| 1227 | struct {
|
---|
| 1228 | unsigned short
|
---|
| 1229 | :3,
|
---|
| 1230 | /*inf*/ :1,
|
---|
| 1231 | rc :2,
|
---|
| 1232 | pc :2,
|
---|
| 1233 | :2,
|
---|
| 1234 | precis :1,
|
---|
| 1235 | undfl :1,
|
---|
| 1236 | ovrfl :1,
|
---|
| 1237 | zdiv :1,
|
---|
| 1238 | denorm :1,
|
---|
| 1239 | invalid :1;
|
---|
| 1240 | } fields;
|
---|
| 1241 | unsigned short half;
|
---|
| 1242 | } u;
|
---|
| 1243 | } sfpc;
|
---|
| 1244 |
|
---|
| 1245 | struct swapped_fp_status {
|
---|
| 1246 | union {
|
---|
| 1247 | struct {
|
---|
| 1248 | unsigned short
|
---|
| 1249 | busy :1,
|
---|
| 1250 | c3 :1,
|
---|
| 1251 | tos :3,
|
---|
| 1252 | c2 :1,
|
---|
| 1253 | c1 :1,
|
---|
| 1254 | c0 :1,
|
---|
| 1255 | errsumm :1,
|
---|
| 1256 | stkflt :1,
|
---|
| 1257 | precis :1,
|
---|
| 1258 | undfl :1,
|
---|
| 1259 | ovrfl :1,
|
---|
| 1260 | zdiv :1,
|
---|
| 1261 | denorm :1,
|
---|
| 1262 | invalid :1;
|
---|
| 1263 | } fields;
|
---|
| 1264 | unsigned short half;
|
---|
| 1265 | } u;
|
---|
| 1266 | } sfps;
|
---|
| 1267 |
|
---|
| 1268 | struct swapped_fp_tag {
|
---|
| 1269 | union {
|
---|
| 1270 | struct {
|
---|
| 1271 | unsigned short
|
---|
| 1272 | tag7 :2,
|
---|
| 1273 | tag6 :2,
|
---|
| 1274 | tag5 :2,
|
---|
| 1275 | tag4 :2,
|
---|
| 1276 | tag3 :2,
|
---|
| 1277 | tag2 :2,
|
---|
| 1278 | tag1 :2,
|
---|
| 1279 | tag0 :2;
|
---|
| 1280 | } fields;
|
---|
| 1281 | unsigned short half;
|
---|
| 1282 | } u;
|
---|
| 1283 | } sfpt;
|
---|
| 1284 |
|
---|
| 1285 | struct swapped_fp_data_reg {
|
---|
| 1286 | unsigned short mant;
|
---|
| 1287 | unsigned short mant1 :16,
|
---|
| 1288 | mant2 :16,
|
---|
| 1289 | mant3 :16;
|
---|
| 1290 | union {
|
---|
| 1291 | struct {
|
---|
| 1292 | unsigned short sign :1,
|
---|
| 1293 | exp :15;
|
---|
| 1294 | } fields;
|
---|
| 1295 | unsigned short half;
|
---|
| 1296 | } u;
|
---|
| 1297 | } sfpd;
|
---|
| 1298 |
|
---|
| 1299 | struct swapped_sel {
|
---|
| 1300 | union {
|
---|
| 1301 | struct {
|
---|
| 1302 | unsigned short
|
---|
| 1303 | index :13,
|
---|
| 1304 | ti :1,
|
---|
| 1305 | rpl :2;
|
---|
| 1306 | } fields;
|
---|
| 1307 | unsigned short half;
|
---|
| 1308 | } u;
|
---|
| 1309 | } ss;
|
---|
| 1310 |
|
---|
| 1311 | enum byte_sex host_byte_sex;
|
---|
| 1312 | unsigned long i;
|
---|
| 1313 |
|
---|
| 1314 | host_byte_sex = get_host_byte_sex();
|
---|
| 1315 |
|
---|
| 1316 | fpu->environ.ip = SWAP_LONG(fpu->environ.ip);
|
---|
| 1317 | fpu->environ.opcode = SWAP_SHORT(fpu->environ.opcode);
|
---|
| 1318 | fpu->environ.dp = SWAP_LONG(fpu->environ.dp);
|
---|
| 1319 |
|
---|
| 1320 | if(target_byte_sex == host_byte_sex){
|
---|
| 1321 | memcpy(&sfpc, &(fpu->environ.control),
|
---|
| 1322 | sizeof(struct swapped_fp_control));
|
---|
| 1323 | sfpc.u.half = SWAP_SHORT(sfpc.u.half);
|
---|
| 1324 | fpu->environ.control.rc = sfpc.u.fields.rc;
|
---|
| 1325 | fpu->environ.control.pc = sfpc.u.fields.pc;
|
---|
| 1326 | fpu->environ.control.precis = sfpc.u.fields.precis;
|
---|
| 1327 | fpu->environ.control.undfl = sfpc.u.fields.undfl;
|
---|
| 1328 | fpu->environ.control.ovrfl = sfpc.u.fields.ovrfl;
|
---|
| 1329 | fpu->environ.control.zdiv = sfpc.u.fields.zdiv;
|
---|
| 1330 | fpu->environ.control.denorm = sfpc.u.fields.denorm;
|
---|
| 1331 | fpu->environ.control.invalid = sfpc.u.fields.invalid;
|
---|
| 1332 |
|
---|
| 1333 | memcpy(&sfps, &(fpu->environ.status),
|
---|
| 1334 | sizeof(struct swapped_fp_status));
|
---|
| 1335 | sfps.u.half = SWAP_SHORT(sfps.u.half);
|
---|
| 1336 | fpu->environ.status.busy = sfps.u.fields.busy;
|
---|
| 1337 | fpu->environ.status.c3 = sfps.u.fields.c3;
|
---|
| 1338 | fpu->environ.status.tos = sfps.u.fields.tos;
|
---|
| 1339 | fpu->environ.status.c2 = sfps.u.fields.c2;
|
---|
| 1340 | fpu->environ.status.c1 = sfps.u.fields.c1;
|
---|
| 1341 | fpu->environ.status.c0 = sfps.u.fields.c0;
|
---|
| 1342 | fpu->environ.status.errsumm = sfps.u.fields.errsumm;
|
---|
| 1343 | fpu->environ.status.stkflt = sfps.u.fields.stkflt;
|
---|
| 1344 | fpu->environ.status.precis = sfps.u.fields.precis;
|
---|
| 1345 | fpu->environ.status.undfl = sfps.u.fields.undfl;
|
---|
| 1346 | fpu->environ.status.ovrfl = sfps.u.fields.ovrfl;
|
---|
| 1347 | fpu->environ.status.zdiv = sfps.u.fields.zdiv;
|
---|
| 1348 | fpu->environ.status.denorm = sfps.u.fields.denorm;
|
---|
| 1349 | fpu->environ.status.invalid = sfps.u.fields.invalid;
|
---|
| 1350 |
|
---|
| 1351 | memcpy(&sfpt, &(fpu->environ.tag),
|
---|
| 1352 | sizeof(struct swapped_fp_tag));
|
---|
| 1353 | sfpt.u.half = SWAP_SHORT(sfpt.u.half);
|
---|
| 1354 | fpu->environ.tag.tag7 = sfpt.u.fields.tag7;
|
---|
| 1355 | fpu->environ.tag.tag6 = sfpt.u.fields.tag6;
|
---|
| 1356 | fpu->environ.tag.tag5 = sfpt.u.fields.tag5;
|
---|
| 1357 | fpu->environ.tag.tag4 = sfpt.u.fields.tag4;
|
---|
| 1358 | fpu->environ.tag.tag3 = sfpt.u.fields.tag3;
|
---|
| 1359 | fpu->environ.tag.tag2 = sfpt.u.fields.tag2;
|
---|
| 1360 | fpu->environ.tag.tag1 = sfpt.u.fields.tag1;
|
---|
| 1361 | fpu->environ.tag.tag0 = sfpt.u.fields.tag0;
|
---|
| 1362 |
|
---|
| 1363 | memcpy(&ss, &(fpu->environ.cs),
|
---|
| 1364 | sizeof(struct swapped_sel));
|
---|
| 1365 | ss.u.half = SWAP_SHORT(ss.u.half);
|
---|
| 1366 | fpu->environ.cs.index = ss.u.fields.index;
|
---|
| 1367 | fpu->environ.cs.ti = ss.u.fields.ti;
|
---|
| 1368 | fpu->environ.cs.rpl = ss.u.fields.rpl;
|
---|
| 1369 |
|
---|
| 1370 | memcpy(&ss, &(fpu->environ.ds),
|
---|
| 1371 | sizeof(struct swapped_sel));
|
---|
| 1372 | ss.u.half = SWAP_SHORT(ss.u.half);
|
---|
| 1373 | fpu->environ.ds.index = ss.u.fields.index;
|
---|
| 1374 | fpu->environ.ds.ti = ss.u.fields.ti;
|
---|
| 1375 | fpu->environ.ds.rpl = ss.u.fields.rpl;
|
---|
| 1376 |
|
---|
| 1377 | for(i = 0; i < 8; i++){
|
---|
| 1378 | memcpy(&sfpd, &(fpu->stack.ST[i]),
|
---|
| 1379 | sizeof(struct swapped_fp_data_reg));
|
---|
| 1380 | fpu->stack.ST[i].mant = SWAP_SHORT(sfpd.mant);
|
---|
| 1381 | fpu->stack.ST[i].mant1 = SWAP_SHORT(sfpd.mant1);
|
---|
| 1382 | fpu->stack.ST[i].mant2 = SWAP_SHORT(sfpd.mant2);
|
---|
| 1383 | fpu->stack.ST[i].mant3 = SWAP_SHORT(sfpd.mant3);
|
---|
| 1384 | sfpd.u.half = SWAP_SHORT(sfpd.u.half);
|
---|
| 1385 | fpu->stack.ST[i].exp = sfpd.u.fields.exp;
|
---|
| 1386 | fpu->stack.ST[i].sign = sfpd.u.fields.sign;
|
---|
| 1387 | }
|
---|
| 1388 | }
|
---|
| 1389 | else{
|
---|
| 1390 | sfpc.u.fields.rc = fpu->environ.control.rc;
|
---|
| 1391 | sfpc.u.fields.pc = fpu->environ.control.pc;
|
---|
| 1392 | sfpc.u.fields.precis = fpu->environ.control.precis;
|
---|
| 1393 | sfpc.u.fields.undfl = fpu->environ.control.undfl;
|
---|
| 1394 | sfpc.u.fields.ovrfl = fpu->environ.control.ovrfl;
|
---|
| 1395 | sfpc.u.fields.zdiv = fpu->environ.control.zdiv;
|
---|
| 1396 | sfpc.u.fields.denorm = fpu->environ.control.denorm;
|
---|
| 1397 | sfpc.u.fields.invalid = fpu->environ.control.invalid;
|
---|
| 1398 | sfpc.u.half = SWAP_SHORT(sfpc.u.half);
|
---|
| 1399 | memcpy(&(fpu->environ.control), &sfpc,
|
---|
| 1400 | sizeof(struct swapped_fp_control));
|
---|
| 1401 |
|
---|
| 1402 | sfps.u.fields.busy = fpu->environ.status.busy;
|
---|
| 1403 | sfps.u.fields.c3 = fpu->environ.status.c3;
|
---|
| 1404 | sfps.u.fields.tos = fpu->environ.status.tos;
|
---|
| 1405 | sfps.u.fields.c2 = fpu->environ.status.c2;
|
---|
| 1406 | sfps.u.fields.c1 = fpu->environ.status.c1;
|
---|
| 1407 | sfps.u.fields.c0 = fpu->environ.status.c0;
|
---|
| 1408 | sfps.u.fields.errsumm = fpu->environ.status.errsumm;
|
---|
| 1409 | sfps.u.fields.stkflt = fpu->environ.status.stkflt;
|
---|
| 1410 | sfps.u.fields.precis = fpu->environ.status.precis;
|
---|
| 1411 | sfps.u.fields.undfl = fpu->environ.status.undfl;
|
---|
| 1412 | sfps.u.fields.ovrfl = fpu->environ.status.ovrfl;
|
---|
| 1413 | sfps.u.fields.zdiv = fpu->environ.status.zdiv;
|
---|
| 1414 | sfps.u.fields.denorm = fpu->environ.status.denorm;
|
---|
| 1415 | sfps.u.fields.invalid = fpu->environ.status.invalid;
|
---|
| 1416 | sfps.u.half = SWAP_SHORT(sfps.u.half);
|
---|
| 1417 | memcpy(&(fpu->environ.status), &sfps,
|
---|
| 1418 | sizeof(struct swapped_fp_status));
|
---|
| 1419 |
|
---|
| 1420 | sfpt.u.fields.tag7 = fpu->environ.tag.tag7;
|
---|
| 1421 | sfpt.u.fields.tag6 = fpu->environ.tag.tag6;
|
---|
| 1422 | sfpt.u.fields.tag5 = fpu->environ.tag.tag5;
|
---|
| 1423 | sfpt.u.fields.tag4 = fpu->environ.tag.tag4;
|
---|
| 1424 | sfpt.u.fields.tag3 = fpu->environ.tag.tag3;
|
---|
| 1425 | sfpt.u.fields.tag2 = fpu->environ.tag.tag2;
|
---|
| 1426 | sfpt.u.fields.tag1 = fpu->environ.tag.tag1;
|
---|
| 1427 | sfpt.u.fields.tag0 = fpu->environ.tag.tag0;
|
---|
| 1428 | sfpt.u.half = SWAP_SHORT(sfpt.u.half);
|
---|
| 1429 | memcpy(&(fpu->environ.tag), &sfpt,
|
---|
| 1430 | sizeof(struct swapped_fp_tag));
|
---|
| 1431 |
|
---|
| 1432 | ss.u.fields.index = fpu->environ.cs.index;
|
---|
| 1433 | ss.u.fields.ti = fpu->environ.cs.ti;
|
---|
| 1434 | ss.u.fields.rpl = fpu->environ.cs.rpl;
|
---|
| 1435 | ss.u.half = SWAP_SHORT(ss.u.half);
|
---|
| 1436 | memcpy(&(fpu->environ.cs), &ss,
|
---|
| 1437 | sizeof(struct swapped_sel));
|
---|
| 1438 |
|
---|
| 1439 | ss.u.fields.index = fpu->environ.ds.index;
|
---|
| 1440 | ss.u.fields.ti = fpu->environ.ds.ti;
|
---|
| 1441 | ss.u.fields.rpl = fpu->environ.ds.rpl;
|
---|
| 1442 | ss.u.half = SWAP_SHORT(ss.u.half);
|
---|
| 1443 | memcpy(&(fpu->environ.cs), &ss,
|
---|
| 1444 | sizeof(struct swapped_sel));
|
---|
| 1445 |
|
---|
| 1446 | for(i = 0; i < 8; i++){
|
---|
| 1447 | sfpd.mant = SWAP_SHORT(fpu->stack.ST[i].mant);
|
---|
| 1448 | sfpd.mant1 = SWAP_SHORT(fpu->stack.ST[i].mant1);
|
---|
| 1449 | sfpd.mant2 = SWAP_SHORT(fpu->stack.ST[i].mant2);
|
---|
| 1450 | sfpd.mant3 = SWAP_SHORT(fpu->stack.ST[i].mant3);
|
---|
| 1451 | sfpd.u.fields.exp = fpu->stack.ST[i].exp;
|
---|
| 1452 | sfpd.u.fields.sign = fpu->stack.ST[i].sign;
|
---|
| 1453 | sfpd.u.half = SWAP_SHORT(sfpd.u.half);
|
---|
| 1454 | memcpy(&(fpu->stack.ST[i]), &sfpd,
|
---|
| 1455 | sizeof(struct swapped_fp_data_reg));
|
---|
| 1456 | }
|
---|
| 1457 | }
|
---|
| 1458 | }
|
---|
| 1459 |
|
---|
| 1460 | __private_extern__
|
---|
| 1461 | void
|
---|
| 1462 | swap_i386_thread_exceptstate(
|
---|
| 1463 | i386_thread_exceptstate_t *exc,
|
---|
| 1464 | enum byte_sex target_byte_sex)
|
---|
| 1465 | {
|
---|
| 1466 | struct swapped_err_code {
|
---|
| 1467 | union {
|
---|
| 1468 | struct err_code_normal {
|
---|
| 1469 | unsigned int :16,
|
---|
| 1470 | index :13,
|
---|
| 1471 | tbl :2,
|
---|
| 1472 | ext :1;
|
---|
| 1473 | } normal;
|
---|
| 1474 | struct err_code_pgfault {
|
---|
| 1475 | unsigned int :29,
|
---|
| 1476 | user :1,
|
---|
| 1477 | wrtflt :1,
|
---|
| 1478 | prot :1;
|
---|
| 1479 | } pgfault;
|
---|
| 1480 | unsigned long word;
|
---|
| 1481 | } u;
|
---|
| 1482 | } sec;
|
---|
| 1483 | unsigned long word;
|
---|
| 1484 | enum byte_sex host_byte_sex;
|
---|
| 1485 |
|
---|
| 1486 | host_byte_sex = get_host_byte_sex();
|
---|
| 1487 |
|
---|
| 1488 | exc->trapno = SWAP_LONG(exc->trapno);
|
---|
| 1489 | if(exc->trapno == 14){
|
---|
| 1490 | if(target_byte_sex == host_byte_sex){
|
---|
| 1491 | memcpy(&sec, &(exc->err), sizeof(struct swapped_err_code));
|
---|
| 1492 | sec.u.word = SWAP_LONG(sec.u.word);
|
---|
| 1493 | exc->err.pgfault.user = sec.u.pgfault.user;
|
---|
| 1494 | exc->err.pgfault.wrtflt = sec.u.pgfault.wrtflt;
|
---|
| 1495 | exc->err.pgfault.prot = sec.u.pgfault.prot;
|
---|
| 1496 | }
|
---|
| 1497 | else{
|
---|
| 1498 | sec.u.pgfault.prot = exc->err.pgfault.prot;
|
---|
| 1499 | sec.u.pgfault.wrtflt = exc->err.pgfault.wrtflt;
|
---|
| 1500 | sec.u.pgfault.user = exc->err.pgfault.user;
|
---|
| 1501 | sec.u.word = SWAP_LONG(sec.u.word);
|
---|
| 1502 | memcpy(&(exc->err), &sec, sizeof(struct swapped_err_code));
|
---|
| 1503 | }
|
---|
| 1504 | }
|
---|
| 1505 | else{
|
---|
| 1506 | if(target_byte_sex == host_byte_sex){
|
---|
| 1507 | memcpy(&sec, &(exc->err), sizeof(struct swapped_err_code));
|
---|
| 1508 | sec.u.word = SWAP_LONG(sec.u.word);
|
---|
| 1509 | word = sec.u.normal.index;
|
---|
| 1510 | exc->err.normal.index = SWAP_LONG(word);
|
---|
| 1511 | exc->err.normal.tbl = sec.u.normal.tbl;
|
---|
| 1512 | exc->err.normal.ext = sec.u.normal.ext;
|
---|
| 1513 | }
|
---|
| 1514 | else{
|
---|
| 1515 | sec.u.normal.ext = exc->err.normal.ext;
|
---|
| 1516 | sec.u.normal.tbl = exc->err.normal.tbl;
|
---|
| 1517 | word = exc->err.normal.index;
|
---|
| 1518 | sec.u.normal.index = SWAP_LONG(word);
|
---|
| 1519 | sec.u.word = SWAP_LONG(sec.u.word);
|
---|
| 1520 | memcpy(&(exc->err), &sec, sizeof(struct swapped_err_code));
|
---|
| 1521 | }
|
---|
| 1522 | }
|
---|
| 1523 | }
|
---|
| 1524 |
|
---|
| 1525 | __private_extern__
|
---|
| 1526 | void
|
---|
| 1527 | swap_i386_thread_cthreadstate(
|
---|
| 1528 | i386_thread_cthreadstate_t *user,
|
---|
| 1529 | enum byte_sex target_byte_sex)
|
---|
| 1530 | {
|
---|
| 1531 | #ifdef __MWERKS__
|
---|
| 1532 | enum byte_sex dummy;
|
---|
| 1533 | dummy = target_byte_sex;
|
---|
| 1534 | #endif
|
---|
| 1535 | user->self = SWAP_LONG(user->self);
|
---|
| 1536 | }
|
---|
| 1537 |
|
---|
| 1538 | __private_extern__
|
---|
| 1539 | void
|
---|
| 1540 | swap_hppa_integer_thread_state(
|
---|
| 1541 | struct hp_pa_integer_thread_state *regs,
|
---|
| 1542 | enum byte_sex target_byte_sex)
|
---|
| 1543 | {
|
---|
| 1544 | #ifdef __MWERKS__
|
---|
| 1545 | enum byte_sex dummy;
|
---|
| 1546 | dummy = target_byte_sex;
|
---|
| 1547 | #endif
|
---|
| 1548 | regs->ts_gr1 = SWAP_LONG(regs->ts_gr1);
|
---|
| 1549 | regs->ts_gr2 = SWAP_LONG(regs->ts_gr2);
|
---|
| 1550 | regs->ts_gr3 = SWAP_LONG(regs->ts_gr3);
|
---|
| 1551 | regs->ts_gr4 = SWAP_LONG(regs->ts_gr4);
|
---|
| 1552 | regs->ts_gr5 = SWAP_LONG(regs->ts_gr5);
|
---|
| 1553 | regs->ts_gr6 = SWAP_LONG(regs->ts_gr6);
|
---|
| 1554 | regs->ts_gr7 = SWAP_LONG(regs->ts_gr7);
|
---|
| 1555 | regs->ts_gr8 = SWAP_LONG(regs->ts_gr8);
|
---|
| 1556 | regs->ts_gr9 = SWAP_LONG(regs->ts_gr9);
|
---|
| 1557 | regs->ts_gr10 = SWAP_LONG(regs->ts_gr10);
|
---|
| 1558 | regs->ts_gr11 = SWAP_LONG(regs->ts_gr11);
|
---|
| 1559 | regs->ts_gr12 = SWAP_LONG(regs->ts_gr12);
|
---|
| 1560 | regs->ts_gr13 = SWAP_LONG(regs->ts_gr13);
|
---|
| 1561 | regs->ts_gr14 = SWAP_LONG(regs->ts_gr14);
|
---|
| 1562 | regs->ts_gr15 = SWAP_LONG(regs->ts_gr15);
|
---|
| 1563 | regs->ts_gr16 = SWAP_LONG(regs->ts_gr16);
|
---|
| 1564 | regs->ts_gr17 = SWAP_LONG(regs->ts_gr17);
|
---|
| 1565 | regs->ts_gr18 = SWAP_LONG(regs->ts_gr18);
|
---|
| 1566 | regs->ts_gr19 = SWAP_LONG(regs->ts_gr19);
|
---|
| 1567 | regs->ts_gr20 = SWAP_LONG(regs->ts_gr20);
|
---|
| 1568 | regs->ts_gr21 = SWAP_LONG(regs->ts_gr21);
|
---|
| 1569 | regs->ts_gr22 = SWAP_LONG(regs->ts_gr22);
|
---|
| 1570 | regs->ts_gr23 = SWAP_LONG(regs->ts_gr23);
|
---|
| 1571 | regs->ts_gr24 = SWAP_LONG(regs->ts_gr24);
|
---|
| 1572 | regs->ts_gr25 = SWAP_LONG(regs->ts_gr25);
|
---|
| 1573 | regs->ts_gr26 = SWAP_LONG(regs->ts_gr26);
|
---|
| 1574 | regs->ts_gr27 = SWAP_LONG(regs->ts_gr27);
|
---|
| 1575 | regs->ts_gr28 = SWAP_LONG(regs->ts_gr28);
|
---|
| 1576 | regs->ts_gr29 = SWAP_LONG(regs->ts_gr29);
|
---|
| 1577 | regs->ts_gr30 = SWAP_LONG(regs->ts_gr30);
|
---|
| 1578 | regs->ts_gr31 = SWAP_LONG(regs->ts_gr31);
|
---|
| 1579 | regs->ts_sr0 = SWAP_LONG(regs->ts_sr0);
|
---|
| 1580 | regs->ts_sr1 = SWAP_LONG(regs->ts_sr1);
|
---|
| 1581 | regs->ts_sr2 = SWAP_LONG(regs->ts_sr2);
|
---|
| 1582 | regs->ts_sr3 = SWAP_LONG(regs->ts_sr3);
|
---|
| 1583 | regs->ts_sar = SWAP_LONG(regs->ts_sar);
|
---|
| 1584 | }
|
---|
| 1585 |
|
---|
| 1586 | __private_extern__
|
---|
| 1587 | void swap_hppa_frame_thread_state(
|
---|
| 1588 | struct hp_pa_frame_thread_state *frame,
|
---|
| 1589 | enum byte_sex target_byte_sex)
|
---|
| 1590 | {
|
---|
| 1591 | #ifdef __MWERKS__
|
---|
| 1592 | enum byte_sex dummy;
|
---|
| 1593 | dummy = target_byte_sex;
|
---|
| 1594 | #endif
|
---|
| 1595 | frame->ts_pcsq_front = SWAP_LONG(frame->ts_pcsq_front);
|
---|
| 1596 | frame->ts_pcsq_back = SWAP_LONG(frame->ts_pcsq_back);
|
---|
| 1597 | frame->ts_pcoq_front = SWAP_LONG(frame->ts_pcoq_front);
|
---|
| 1598 | frame->ts_pcoq_back = SWAP_LONG(frame->ts_pcoq_back);
|
---|
| 1599 | frame->ts_psw = SWAP_LONG(frame->ts_psw);
|
---|
| 1600 | frame->ts_unaligned_faults = SWAP_LONG(frame->ts_unaligned_faults);
|
---|
| 1601 | frame->ts_fault_address = SWAP_LONG(frame->ts_fault_address);
|
---|
| 1602 | frame->ts_step_range_start = SWAP_LONG(frame->ts_step_range_start);
|
---|
| 1603 | frame->ts_step_range_stop = SWAP_LONG(frame->ts_step_range_stop);
|
---|
| 1604 | }
|
---|
| 1605 |
|
---|
| 1606 | __private_extern__
|
---|
| 1607 | void swap_hppa_fp_thread_state(
|
---|
| 1608 | struct hp_pa_fp_thread_state *fp,
|
---|
| 1609 | enum byte_sex target_byte_sex)
|
---|
| 1610 | {
|
---|
| 1611 | #ifdef __MWERKS__
|
---|
| 1612 | enum byte_sex dummy;
|
---|
| 1613 | dummy = target_byte_sex;
|
---|
| 1614 | #endif
|
---|
| 1615 | fp->ts_fp0 = SWAP_DOUBLE(fp->ts_fp0);
|
---|
| 1616 | fp->ts_fp1 = SWAP_DOUBLE(fp->ts_fp1);
|
---|
| 1617 | fp->ts_fp2 = SWAP_DOUBLE(fp->ts_fp2);
|
---|
| 1618 | fp->ts_fp3 = SWAP_DOUBLE(fp->ts_fp3);
|
---|
| 1619 | fp->ts_fp4 = SWAP_DOUBLE(fp->ts_fp4);
|
---|
| 1620 | fp->ts_fp5 = SWAP_DOUBLE(fp->ts_fp5);
|
---|
| 1621 | fp->ts_fp6 = SWAP_DOUBLE(fp->ts_fp6);
|
---|
| 1622 | fp->ts_fp7 = SWAP_DOUBLE(fp->ts_fp7);
|
---|
| 1623 | fp->ts_fp8 = SWAP_DOUBLE(fp->ts_fp8);
|
---|
| 1624 | fp->ts_fp9 = SWAP_DOUBLE(fp->ts_fp9);
|
---|
| 1625 | fp->ts_fp10 = SWAP_DOUBLE(fp->ts_fp10);
|
---|
| 1626 | fp->ts_fp11 = SWAP_DOUBLE(fp->ts_fp11);
|
---|
| 1627 | fp->ts_fp12 = SWAP_DOUBLE(fp->ts_fp12);
|
---|
| 1628 | fp->ts_fp13 = SWAP_DOUBLE(fp->ts_fp13);
|
---|
| 1629 | fp->ts_fp14 = SWAP_DOUBLE(fp->ts_fp14);
|
---|
| 1630 | fp->ts_fp15 = SWAP_DOUBLE(fp->ts_fp15);
|
---|
| 1631 | fp->ts_fp16 = SWAP_DOUBLE(fp->ts_fp16);
|
---|
| 1632 | fp->ts_fp17 = SWAP_DOUBLE(fp->ts_fp17);
|
---|
| 1633 | fp->ts_fp18 = SWAP_DOUBLE(fp->ts_fp18);
|
---|
| 1634 | fp->ts_fp19 = SWAP_DOUBLE(fp->ts_fp19);
|
---|
| 1635 | fp->ts_fp20 = SWAP_DOUBLE(fp->ts_fp20);
|
---|
| 1636 | fp->ts_fp21 = SWAP_DOUBLE(fp->ts_fp21);
|
---|
| 1637 | fp->ts_fp22 = SWAP_DOUBLE(fp->ts_fp22);
|
---|
| 1638 | fp->ts_fp23 = SWAP_DOUBLE(fp->ts_fp23);
|
---|
| 1639 | fp->ts_fp24 = SWAP_DOUBLE(fp->ts_fp24);
|
---|
| 1640 | fp->ts_fp25 = SWAP_DOUBLE(fp->ts_fp25);
|
---|
| 1641 | fp->ts_fp26 = SWAP_DOUBLE(fp->ts_fp26);
|
---|
| 1642 | fp->ts_fp27 = SWAP_DOUBLE(fp->ts_fp27);
|
---|
| 1643 | fp->ts_fp28 = SWAP_DOUBLE(fp->ts_fp28);
|
---|
| 1644 | fp->ts_fp29 = SWAP_DOUBLE(fp->ts_fp29);
|
---|
| 1645 | fp->ts_fp30 = SWAP_DOUBLE(fp->ts_fp30);
|
---|
| 1646 | fp->ts_fp31 = SWAP_DOUBLE(fp->ts_fp31);
|
---|
| 1647 | }
|
---|
| 1648 |
|
---|
| 1649 | __private_extern__
|
---|
| 1650 | void
|
---|
| 1651 | swap_sparc_thread_state_regs(
|
---|
| 1652 | struct sparc_thread_state_regs *cpu,
|
---|
| 1653 | enum byte_sex target_byte_sex)
|
---|
| 1654 | {
|
---|
| 1655 | struct swapped_psr {
|
---|
| 1656 | union {
|
---|
| 1657 | struct {
|
---|
| 1658 | unsigned int
|
---|
| 1659 | cwp:BITS_WIDTH(4,0),
|
---|
| 1660 | et:BIT_WIDTH(5),
|
---|
| 1661 | ps:BIT_WIDTH(6),
|
---|
| 1662 | s:BIT_WIDTH(7),
|
---|
| 1663 | pil:BITS_WIDTH(11,8),
|
---|
| 1664 | ef:BIT_WIDTH(12),
|
---|
| 1665 | ec:BIT_WIDTH(13),
|
---|
| 1666 | reserved:BITS_WIDTH(19,14),
|
---|
| 1667 | icc:BITS_WIDTH(23,20),
|
---|
| 1668 | ver:BITS_WIDTH(27,24),
|
---|
| 1669 | impl:BITS_WIDTH(31,28);
|
---|
| 1670 | } fields;
|
---|
| 1671 | unsigned int word;
|
---|
| 1672 | } u;
|
---|
| 1673 | } spsr;
|
---|
| 1674 | struct p_status *pr_status;
|
---|
| 1675 | enum byte_sex host_byte_sex;
|
---|
| 1676 |
|
---|
| 1677 | host_byte_sex = get_host_byte_sex();
|
---|
| 1678 |
|
---|
| 1679 | cpu->regs.r_pc = SWAP_LONG(cpu->regs.r_pc);
|
---|
| 1680 | cpu->regs.r_npc = SWAP_LONG(cpu->regs.r_npc);
|
---|
| 1681 | cpu->regs.r_y = SWAP_LONG(cpu->regs.r_y);
|
---|
| 1682 | cpu->regs.r_g1 = SWAP_LONG(cpu->regs.r_g1);
|
---|
| 1683 | cpu->regs.r_g2 = SWAP_LONG(cpu->regs.r_g2);
|
---|
| 1684 | cpu->regs.r_g3 = SWAP_LONG(cpu->regs.r_g3);
|
---|
| 1685 | cpu->regs.r_g4 = SWAP_LONG(cpu->regs.r_g4);
|
---|
| 1686 | cpu->regs.r_g5 = SWAP_LONG(cpu->regs.r_g5);
|
---|
| 1687 | cpu->regs.r_g6 = SWAP_LONG(cpu->regs.r_g6);
|
---|
| 1688 | cpu->regs.r_g7 = SWAP_LONG(cpu->regs.r_g7);
|
---|
| 1689 | cpu->regs.r_o0 = SWAP_LONG(cpu->regs.r_o0);
|
---|
| 1690 | cpu->regs.r_o1 = SWAP_LONG(cpu->regs.r_o1);
|
---|
| 1691 | cpu->regs.r_o2 = SWAP_LONG(cpu->regs.r_o2);
|
---|
| 1692 | cpu->regs.r_o3 = SWAP_LONG(cpu->regs.r_o3);
|
---|
| 1693 | cpu->regs.r_o4 = SWAP_LONG(cpu->regs.r_o4);
|
---|
| 1694 | cpu->regs.r_o5 = SWAP_LONG(cpu->regs.r_o5);
|
---|
| 1695 | cpu->regs.r_o6 = SWAP_LONG(cpu->regs.r_o6);
|
---|
| 1696 | cpu->regs.r_o7 = SWAP_LONG(cpu->regs.r_o7);
|
---|
| 1697 |
|
---|
| 1698 | pr_status = (struct p_status *) &(cpu->regs.r_psr);
|
---|
| 1699 | if(target_byte_sex == host_byte_sex){
|
---|
| 1700 | memcpy(&spsr, &(cpu->regs.r_psr), sizeof(struct swapped_psr));
|
---|
| 1701 | spsr.u.word = SWAP_LONG(spsr.u.word);
|
---|
| 1702 | pr_status->PSRREG.psr_bits.cwp = spsr.u.fields.cwp;
|
---|
| 1703 | pr_status->PSRREG.psr_bits.ps = spsr.u.fields.ps;
|
---|
| 1704 | pr_status->PSRREG.psr_bits.s = spsr.u.fields.s;
|
---|
| 1705 | pr_status->PSRREG.psr_bits.pil = spsr.u.fields.pil;
|
---|
| 1706 | pr_status->PSRREG.psr_bits.ef = spsr.u.fields.ef;
|
---|
| 1707 | pr_status->PSRREG.psr_bits.ec = spsr.u.fields.ec;
|
---|
| 1708 | pr_status->PSRREG.psr_bits.reserved = spsr.u.fields.reserved;
|
---|
| 1709 | pr_status->PSRREG.psr_bits.icc = spsr.u.fields.icc;
|
---|
| 1710 | pr_status->PSRREG.psr_bits.et = spsr.u.fields.ver;
|
---|
| 1711 | pr_status->PSRREG.psr_bits.impl = spsr.u.fields.impl;
|
---|
| 1712 | }
|
---|
| 1713 | else{
|
---|
| 1714 | spsr.u.fields.cwp = pr_status->PSRREG.psr_bits.cwp;
|
---|
| 1715 | spsr.u.fields.ps = pr_status->PSRREG.psr_bits.ps;
|
---|
| 1716 | spsr.u.fields.s = pr_status->PSRREG.psr_bits.s;
|
---|
| 1717 | spsr.u.fields.pil = pr_status->PSRREG.psr_bits.pil;
|
---|
| 1718 | spsr.u.fields.ef = pr_status->PSRREG.psr_bits.ef;
|
---|
| 1719 | spsr.u.fields.ec = pr_status->PSRREG.psr_bits.ec;
|
---|
| 1720 | spsr.u.fields.reserved = pr_status->PSRREG.psr_bits.reserved;
|
---|
| 1721 | spsr.u.fields.icc = pr_status->PSRREG.psr_bits.icc;
|
---|
| 1722 | spsr.u.fields.ver = pr_status->PSRREG.psr_bits.et;
|
---|
| 1723 | spsr.u.fields.impl = pr_status->PSRREG.psr_bits.impl;
|
---|
| 1724 | spsr.u.word = SWAP_LONG(spsr.u.word);
|
---|
| 1725 | memcpy(&(cpu->regs.r_psr), &spsr, sizeof(struct swapped_psr));
|
---|
| 1726 | }
|
---|
| 1727 | }
|
---|
| 1728 |
|
---|
| 1729 | __private_extern__
|
---|
| 1730 | void
|
---|
| 1731 | swap_sparc_thread_state_fpu(
|
---|
| 1732 | struct sparc_thread_state_fpu *fpu,
|
---|
| 1733 | enum byte_sex target_byte_sex)
|
---|
| 1734 | {
|
---|
| 1735 | struct swapped_fsr {
|
---|
| 1736 | union {
|
---|
| 1737 | struct {
|
---|
| 1738 | unsigned int
|
---|
| 1739 | cexc:BITS_WIDTH(4,0),
|
---|
| 1740 | aexc:BITS_WIDTH(9,5),
|
---|
| 1741 | fcc:BITS_WIDTH(11,10),
|
---|
| 1742 | pr:BIT_WIDTH(12),
|
---|
| 1743 | qne:BIT_WIDTH(13),
|
---|
| 1744 | ftt:BITS_WIDTH(16,14),
|
---|
| 1745 | res:BITS_WIDTH(22,17),
|
---|
| 1746 | tem:BITS_WIDTH(27,23),
|
---|
| 1747 | rp:BITS_WIDTH(29,28),
|
---|
| 1748 | rd:BITS_WIDTH(31,30);
|
---|
| 1749 | } fields;
|
---|
| 1750 | unsigned int word;
|
---|
| 1751 | } u;
|
---|
| 1752 | } sfsr;
|
---|
| 1753 | unsigned long i;
|
---|
| 1754 | struct f_status *fpu_status;
|
---|
| 1755 | enum byte_sex host_byte_sex;
|
---|
| 1756 |
|
---|
| 1757 | host_byte_sex = get_host_byte_sex();
|
---|
| 1758 |
|
---|
| 1759 |
|
---|
| 1760 | /* floating point registers */
|
---|
| 1761 | for(i = 0; i < 16; i++) /* 16 doubles */
|
---|
| 1762 | fpu->fpu.fpu_fr.Fpu_dregs[i] =
|
---|
| 1763 | SWAP_DOUBLE(fpu->fpu.fpu_fr.Fpu_dregs[i]);
|
---|
| 1764 |
|
---|
| 1765 | fpu->fpu.Fpu_q[0].FQu.whole = SWAP_DOUBLE(fpu->fpu.Fpu_q[0].FQu.whole);
|
---|
| 1766 | fpu->fpu.Fpu_q[1].FQu.whole = SWAP_DOUBLE(fpu->fpu.Fpu_q[1].FQu.whole);
|
---|
| 1767 | fpu->fpu.Fpu_flags = SWAP_LONG(fpu->fpu.Fpu_flags);
|
---|
| 1768 | fpu->fpu.Fpu_extra = SWAP_LONG(fpu->fpu.Fpu_extra);
|
---|
| 1769 | fpu->fpu.Fpu_qcnt = SWAP_LONG(fpu->fpu.Fpu_qcnt);
|
---|
| 1770 |
|
---|
| 1771 | fpu_status = (struct f_status *) &(fpu->fpu.Fpu_fsr);
|
---|
| 1772 | if(target_byte_sex == host_byte_sex){
|
---|
| 1773 | memcpy(&sfsr, &(fpu->fpu.Fpu_fsr), sizeof(unsigned int));
|
---|
| 1774 | sfsr.u.word = SWAP_LONG(sfsr.u.word);
|
---|
| 1775 | fpu_status->FPUREG.Fpu_fsr_bits.rd = sfsr.u.fields.rd;
|
---|
| 1776 | fpu_status->FPUREG.Fpu_fsr_bits.rp = sfsr.u.fields.rp;
|
---|
| 1777 | fpu_status->FPUREG.Fpu_fsr_bits.tem = sfsr.u.fields.tem;
|
---|
| 1778 | fpu_status->FPUREG.Fpu_fsr_bits.res = sfsr.u.fields.res;
|
---|
| 1779 | fpu_status->FPUREG.Fpu_fsr_bits.ftt = sfsr.u.fields.ftt;
|
---|
| 1780 | fpu_status->FPUREG.Fpu_fsr_bits.qne = sfsr.u.fields.qne;
|
---|
| 1781 | fpu_status->FPUREG.Fpu_fsr_bits.pr = sfsr.u.fields.pr;
|
---|
| 1782 | fpu_status->FPUREG.Fpu_fsr_bits.fcc = sfsr.u.fields.fcc;
|
---|
| 1783 | fpu_status->FPUREG.Fpu_fsr_bits.aexc = sfsr.u.fields.aexc;
|
---|
| 1784 | fpu_status->FPUREG.Fpu_fsr_bits.cexc = sfsr.u.fields.cexc;
|
---|
| 1785 | }
|
---|
| 1786 | else{
|
---|
| 1787 | sfsr.u.fields.rd = fpu_status->FPUREG.Fpu_fsr_bits.rd;
|
---|
| 1788 | sfsr.u.fields.rp = fpu_status->FPUREG.Fpu_fsr_bits.rp;
|
---|
| 1789 | sfsr.u.fields.tem = fpu_status->FPUREG.Fpu_fsr_bits.tem;
|
---|
| 1790 | sfsr.u.fields.res = fpu_status->FPUREG.Fpu_fsr_bits.res;
|
---|
| 1791 | sfsr.u.fields.ftt = fpu_status->FPUREG.Fpu_fsr_bits.ftt;
|
---|
| 1792 | sfsr.u.fields.qne = fpu_status->FPUREG.Fpu_fsr_bits.qne;
|
---|
| 1793 | sfsr.u.fields.pr = fpu_status->FPUREG.Fpu_fsr_bits.pr;
|
---|
| 1794 | sfsr.u.fields.fcc = fpu_status->FPUREG.Fpu_fsr_bits.fcc;
|
---|
| 1795 | sfsr.u.fields.aexc = fpu_status->FPUREG.Fpu_fsr_bits.aexc;
|
---|
| 1796 | sfsr.u.fields.cexc = fpu_status->FPUREG.Fpu_fsr_bits.cexc;
|
---|
| 1797 | sfsr.u.word = SWAP_LONG(sfsr.u.word);
|
---|
| 1798 | memcpy(&(fpu->fpu.Fpu_fsr), &sfsr, sizeof(struct swapped_fsr));
|
---|
| 1799 | }
|
---|
| 1800 | }
|
---|
| 1801 |
|
---|
| 1802 | __private_extern__
|
---|
| 1803 | void
|
---|
| 1804 | swap_ident_command(
|
---|
| 1805 | struct ident_command *id_cmd,
|
---|
| 1806 | enum byte_sex target_byte_sex)
|
---|
| 1807 | {
|
---|
| 1808 | #ifdef __MWERKS__
|
---|
| 1809 | enum byte_sex dummy;
|
---|
| 1810 | dummy = target_byte_sex;
|
---|
| 1811 | #endif
|
---|
| 1812 | id_cmd->cmd = SWAP_LONG(id_cmd->cmd);
|
---|
| 1813 | id_cmd->cmdsize = SWAP_LONG(id_cmd->cmdsize);
|
---|
| 1814 | }
|
---|
| 1815 |
|
---|
| 1816 | __private_extern__
|
---|
| 1817 | void
|
---|
| 1818 | swap_routines_command(
|
---|
| 1819 | struct routines_command *r_cmd,
|
---|
| 1820 | enum byte_sex target_byte_sex)
|
---|
| 1821 | {
|
---|
| 1822 | #ifdef __MWERKS__
|
---|
| 1823 | enum byte_sex dummy;
|
---|
| 1824 | dummy = target_byte_sex;
|
---|
| 1825 | #endif
|
---|
| 1826 | r_cmd->cmd = SWAP_LONG(r_cmd->cmd);
|
---|
| 1827 | r_cmd->cmdsize = SWAP_LONG(r_cmd->cmdsize);
|
---|
| 1828 | r_cmd->init_address = SWAP_LONG(r_cmd->init_address);
|
---|
| 1829 | r_cmd->init_module = SWAP_LONG(r_cmd->init_module);
|
---|
| 1830 | r_cmd->reserved1 = SWAP_LONG(r_cmd->reserved1);
|
---|
| 1831 | r_cmd->reserved2 = SWAP_LONG(r_cmd->reserved2);
|
---|
| 1832 | r_cmd->reserved3 = SWAP_LONG(r_cmd->reserved3);
|
---|
| 1833 | r_cmd->reserved4 = SWAP_LONG(r_cmd->reserved4);
|
---|
| 1834 | r_cmd->reserved5 = SWAP_LONG(r_cmd->reserved5);
|
---|
| 1835 | r_cmd->reserved6 = SWAP_LONG(r_cmd->reserved6);
|
---|
| 1836 | }
|
---|
| 1837 |
|
---|
| 1838 | __private_extern__
|
---|
| 1839 | void
|
---|
[217] | 1840 | swap_routines_command_64(
|
---|
| 1841 | struct routines_command_64 *r_cmd,
|
---|
| 1842 | enum byte_sex target_byte_sex)
|
---|
| 1843 | {
|
---|
| 1844 | #ifdef __MWERKS__
|
---|
| 1845 | enum byte_sex dummy;
|
---|
| 1846 | dummy = target_byte_sex;
|
---|
| 1847 | #endif
|
---|
| 1848 | r_cmd->cmd = SWAP_LONG(r_cmd->cmd);
|
---|
| 1849 | r_cmd->cmdsize = SWAP_LONG(r_cmd->cmdsize);
|
---|
| 1850 | r_cmd->init_address = SWAP_LONG_LONG(r_cmd->init_address);
|
---|
| 1851 | r_cmd->init_module = SWAP_LONG_LONG(r_cmd->init_module);
|
---|
| 1852 | r_cmd->reserved1 = SWAP_LONG_LONG(r_cmd->reserved1);
|
---|
| 1853 | r_cmd->reserved2 = SWAP_LONG_LONG(r_cmd->reserved2);
|
---|
| 1854 | r_cmd->reserved3 = SWAP_LONG_LONG(r_cmd->reserved3);
|
---|
| 1855 | r_cmd->reserved4 = SWAP_LONG_LONG(r_cmd->reserved4);
|
---|
| 1856 | r_cmd->reserved5 = SWAP_LONG_LONG(r_cmd->reserved5);
|
---|
| 1857 | r_cmd->reserved6 = SWAP_LONG_LONG(r_cmd->reserved6);
|
---|
| 1858 | }
|
---|
| 1859 |
|
---|
| 1860 | __private_extern__
|
---|
| 1861 | void
|
---|
[7] | 1862 | swap_twolevel_hints_command(
|
---|
| 1863 | struct twolevel_hints_command *hints_cmd,
|
---|
| 1864 | enum byte_sex target_byte_sex)
|
---|
| 1865 | {
|
---|
| 1866 | #ifdef __MWERKS__
|
---|
| 1867 | enum byte_sex dummy;
|
---|
| 1868 | dummy = target_byte_sex;
|
---|
| 1869 | #endif
|
---|
| 1870 | hints_cmd->cmd = SWAP_LONG(hints_cmd->cmd);
|
---|
| 1871 | hints_cmd->cmdsize = SWAP_LONG(hints_cmd->cmdsize);
|
---|
| 1872 | hints_cmd->offset = SWAP_LONG(hints_cmd->offset);
|
---|
| 1873 | hints_cmd->nhints = SWAP_LONG(hints_cmd->nhints);
|
---|
| 1874 | }
|
---|
| 1875 |
|
---|
| 1876 | __private_extern__
|
---|
| 1877 | void
|
---|
| 1878 | swap_twolevel_hint(
|
---|
| 1879 | struct twolevel_hint *hints,
|
---|
| 1880 | unsigned long nhints,
|
---|
| 1881 | enum byte_sex target_byte_sex)
|
---|
| 1882 | {
|
---|
| 1883 | struct swapped_twolevel_hint {
|
---|
| 1884 | union {
|
---|
| 1885 | struct {
|
---|
| 1886 | unsigned long
|
---|
| 1887 | itoc:24,
|
---|
| 1888 | isub_image:8;
|
---|
| 1889 | } fields;
|
---|
| 1890 | unsigned long word;
|
---|
| 1891 | } u;
|
---|
| 1892 | } shint;
|
---|
| 1893 |
|
---|
| 1894 | unsigned long i;
|
---|
| 1895 | enum byte_sex host_byte_sex;
|
---|
| 1896 |
|
---|
| 1897 | host_byte_sex = get_host_byte_sex();
|
---|
| 1898 |
|
---|
| 1899 | for(i = 0; i < nhints; i++){
|
---|
| 1900 | if(target_byte_sex == host_byte_sex){
|
---|
| 1901 | memcpy(&shint, hints + i, sizeof(struct swapped_twolevel_hint));
|
---|
| 1902 | shint.u.word = SWAP_LONG(shint.u.word);
|
---|
| 1903 | hints[i].itoc = shint.u.fields.itoc;
|
---|
| 1904 | hints[i].isub_image = shint.u.fields.isub_image;
|
---|
| 1905 | }
|
---|
| 1906 | else{
|
---|
| 1907 | shint.u.fields.isub_image = hints[i].isub_image;
|
---|
| 1908 | shint.u.fields.itoc = hints[i].itoc;
|
---|
| 1909 | shint.u.word = SWAP_LONG(shint.u.word);
|
---|
| 1910 | memcpy(hints + i, &shint, sizeof(struct swapped_twolevel_hint));
|
---|
| 1911 | }
|
---|
| 1912 | }
|
---|
| 1913 | }
|
---|
| 1914 |
|
---|
| 1915 | __private_extern__
|
---|
| 1916 | void
|
---|
| 1917 | swap_prebind_cksum_command(
|
---|
| 1918 | struct prebind_cksum_command *cksum_cmd,
|
---|
| 1919 | enum byte_sex target_byte_sex)
|
---|
| 1920 | {
|
---|
| 1921 | #ifdef __MWERKS__
|
---|
| 1922 | enum byte_sex dummy;
|
---|
| 1923 | dummy = target_byte_sex;
|
---|
| 1924 | #endif
|
---|
| 1925 | cksum_cmd->cmd = SWAP_LONG(cksum_cmd->cmd);
|
---|
| 1926 | cksum_cmd->cmdsize = SWAP_LONG(cksum_cmd->cmdsize);
|
---|
| 1927 | cksum_cmd->cksum = SWAP_LONG(cksum_cmd->cksum);
|
---|
| 1928 | }
|
---|
| 1929 |
|
---|
| 1930 | __private_extern__
|
---|
| 1931 | void
|
---|
| 1932 | swap_nlist(
|
---|
| 1933 | struct nlist *symbols,
|
---|
| 1934 | unsigned long nsymbols,
|
---|
| 1935 | enum byte_sex target_byte_sex)
|
---|
| 1936 | {
|
---|
| 1937 | unsigned long i;
|
---|
| 1938 | #ifdef __MWERKS__
|
---|
| 1939 | enum byte_sex dummy;
|
---|
| 1940 | dummy = target_byte_sex;
|
---|
| 1941 | #endif
|
---|
| 1942 |
|
---|
| 1943 | for(i = 0; i < nsymbols; i++){
|
---|
| 1944 | symbols[i].n_un.n_strx = SWAP_LONG(symbols[i].n_un.n_strx);
|
---|
| 1945 | /* n_type */
|
---|
| 1946 | /* n_sect */
|
---|
| 1947 | symbols[i].n_desc = SWAP_SHORT(symbols[i].n_desc);
|
---|
| 1948 | symbols[i].n_value = SWAP_LONG(symbols[i].n_value);
|
---|
| 1949 | }
|
---|
| 1950 | }
|
---|
| 1951 |
|
---|
| 1952 | __private_extern__
|
---|
| 1953 | void
|
---|
[217] | 1954 | swap_nlist_64(
|
---|
| 1955 | struct nlist_64 *symbols,
|
---|
| 1956 | unsigned long nsymbols,
|
---|
| 1957 | enum byte_sex target_byte_sex)
|
---|
| 1958 | {
|
---|
| 1959 | unsigned long i;
|
---|
| 1960 | #ifdef __MWERKS__
|
---|
| 1961 | enum byte_sex dummy;
|
---|
| 1962 | dummy = target_byte_sex;
|
---|
| 1963 | #endif
|
---|
| 1964 |
|
---|
| 1965 | for(i = 0; i < nsymbols; i++){
|
---|
| 1966 | symbols[i].n_un.n_strx = SWAP_LONG(symbols[i].n_un.n_strx);
|
---|
| 1967 | /* n_type */
|
---|
| 1968 | /* n_sect */
|
---|
| 1969 | symbols[i].n_desc = SWAP_SHORT(symbols[i].n_desc);
|
---|
| 1970 | symbols[i].n_value = SWAP_LONG_LONG(symbols[i].n_value);
|
---|
| 1971 | }
|
---|
| 1972 | }
|
---|
| 1973 |
|
---|
| 1974 | __private_extern__
|
---|
| 1975 | void
|
---|
[7] | 1976 | swap_ranlib(
|
---|
| 1977 | struct ranlib *ranlibs,
|
---|
| 1978 | unsigned long nranlibs,
|
---|
| 1979 | enum byte_sex target_byte_sex)
|
---|
| 1980 | {
|
---|
| 1981 | unsigned long i;
|
---|
| 1982 | #ifdef __MWERKS__
|
---|
| 1983 | enum byte_sex dummy;
|
---|
| 1984 | dummy = target_byte_sex;
|
---|
| 1985 | #endif
|
---|
| 1986 |
|
---|
| 1987 | for(i = 0; i < nranlibs; i++){
|
---|
| 1988 | ranlibs[i].ran_un.ran_strx = SWAP_LONG(ranlibs[i].ran_un.ran_strx);
|
---|
| 1989 | ranlibs[i].ran_off = SWAP_LONG(ranlibs[i].ran_off);
|
---|
| 1990 | }
|
---|
| 1991 | }
|
---|
| 1992 |
|
---|
| 1993 | __private_extern__
|
---|
| 1994 | void
|
---|
| 1995 | swap_relocation_info(
|
---|
| 1996 | struct relocation_info *relocs,
|
---|
| 1997 | unsigned long nrelocs,
|
---|
| 1998 | enum byte_sex target_byte_sex)
|
---|
| 1999 | {
|
---|
| 2000 | unsigned long i;
|
---|
| 2001 | enum byte_sex host_byte_sex;
|
---|
| 2002 | enum bool to_host_byte_sex, scattered;
|
---|
| 2003 |
|
---|
| 2004 | struct swapped_relocation_info {
|
---|
| 2005 | long r_address;
|
---|
| 2006 | union {
|
---|
| 2007 | struct {
|
---|
| 2008 | unsigned int
|
---|
| 2009 | r_type:4,
|
---|
| 2010 | r_extern:1,
|
---|
| 2011 | r_length:2,
|
---|
| 2012 | r_pcrel:1,
|
---|
| 2013 | r_symbolnum:24;
|
---|
| 2014 | } fields;
|
---|
| 2015 | unsigned long word;
|
---|
| 2016 | } u;
|
---|
| 2017 | } sr;
|
---|
| 2018 |
|
---|
| 2019 | struct swapped_scattered_relocation_info {
|
---|
| 2020 | unsigned long word;
|
---|
| 2021 | long r_value;
|
---|
| 2022 | } *ssr;
|
---|
| 2023 |
|
---|
| 2024 | host_byte_sex = get_host_byte_sex();
|
---|
| 2025 | to_host_byte_sex = (enum bool)(target_byte_sex == host_byte_sex);
|
---|
| 2026 |
|
---|
| 2027 | for(i = 0; i < nrelocs; i++){
|
---|
| 2028 | if(to_host_byte_sex)
|
---|
| 2029 | scattered = (enum bool)(
|
---|
| 2030 | (SWAP_LONG(relocs[i].r_address) & R_SCATTERED) != 0);
|
---|
| 2031 | else
|
---|
| 2032 | scattered = (enum bool)
|
---|
| 2033 | (((relocs[i].r_address) & R_SCATTERED) != 0);
|
---|
| 2034 | if(scattered == FALSE){
|
---|
| 2035 | if(to_host_byte_sex){
|
---|
| 2036 | memcpy(&sr, relocs + i, sizeof(struct relocation_info));
|
---|
| 2037 | sr.r_address = SWAP_LONG(sr.r_address);
|
---|
| 2038 | sr.u.word = SWAP_LONG(sr.u.word);
|
---|
| 2039 | relocs[i].r_address = sr.r_address;
|
---|
| 2040 | relocs[i].r_symbolnum = sr.u.fields.r_symbolnum;
|
---|
| 2041 | relocs[i].r_pcrel = sr.u.fields.r_pcrel;
|
---|
| 2042 | relocs[i].r_length = sr.u.fields.r_length;
|
---|
| 2043 | relocs[i].r_extern = sr.u.fields.r_extern;
|
---|
| 2044 | relocs[i].r_type = sr.u.fields.r_type;
|
---|
| 2045 | }
|
---|
| 2046 | else{
|
---|
| 2047 | sr.r_address = relocs[i].r_address;
|
---|
| 2048 | sr.u.fields.r_symbolnum = relocs[i].r_symbolnum;
|
---|
| 2049 | sr.u.fields.r_length = relocs[i].r_length;
|
---|
| 2050 | sr.u.fields.r_pcrel = relocs[i].r_pcrel;
|
---|
| 2051 | sr.u.fields.r_extern = relocs[i].r_extern;
|
---|
| 2052 | sr.u.fields.r_type = relocs[i].r_type;
|
---|
| 2053 | sr.r_address = SWAP_LONG(sr.r_address);
|
---|
| 2054 | sr.u.word = SWAP_LONG(sr.u.word);
|
---|
| 2055 | memcpy(relocs + i, &sr, sizeof(struct relocation_info));
|
---|
| 2056 | }
|
---|
| 2057 | }
|
---|
| 2058 | else{
|
---|
| 2059 | ssr = (struct swapped_scattered_relocation_info *)(relocs + i);
|
---|
| 2060 | ssr->word = SWAP_LONG(ssr->word);
|
---|
| 2061 | ssr->r_value = SWAP_LONG(ssr->r_value);
|
---|
| 2062 | }
|
---|
| 2063 | }
|
---|
| 2064 | }
|
---|
| 2065 |
|
---|
| 2066 | __private_extern__
|
---|
| 2067 | void
|
---|
| 2068 | swap_indirect_symbols(
|
---|
| 2069 | unsigned long *indirect_symbols,
|
---|
| 2070 | unsigned long nindirect_symbols,
|
---|
| 2071 | enum byte_sex target_byte_sex)
|
---|
| 2072 | {
|
---|
| 2073 | unsigned long i;
|
---|
| 2074 | #ifdef __MWERKS__
|
---|
| 2075 | enum byte_sex dummy;
|
---|
| 2076 | dummy = target_byte_sex;
|
---|
| 2077 | #endif
|
---|
| 2078 |
|
---|
| 2079 | for(i = 0; i < nindirect_symbols; i++)
|
---|
| 2080 | indirect_symbols[i] = SWAP_LONG(indirect_symbols[i]);
|
---|
| 2081 | }
|
---|
| 2082 |
|
---|
| 2083 | __private_extern__
|
---|
| 2084 | void
|
---|
| 2085 | swap_dylib_reference(
|
---|
| 2086 | struct dylib_reference *refs,
|
---|
| 2087 | unsigned long nrefs,
|
---|
| 2088 | enum byte_sex target_byte_sex)
|
---|
| 2089 | {
|
---|
| 2090 | struct swapped_dylib_reference {
|
---|
| 2091 | union {
|
---|
| 2092 | struct {
|
---|
| 2093 | unsigned long
|
---|
| 2094 | flags:8,
|
---|
| 2095 | isym:24;
|
---|
| 2096 | } fields;
|
---|
| 2097 | unsigned long word;
|
---|
| 2098 | } u;
|
---|
| 2099 | } sref;
|
---|
| 2100 |
|
---|
| 2101 | unsigned long i;
|
---|
| 2102 | enum byte_sex host_byte_sex;
|
---|
| 2103 |
|
---|
| 2104 | host_byte_sex = get_host_byte_sex();
|
---|
| 2105 |
|
---|
| 2106 | for(i = 0; i < nrefs; i++){
|
---|
| 2107 | if(target_byte_sex == host_byte_sex){
|
---|
| 2108 | memcpy(&sref, refs + i, sizeof(struct swapped_dylib_reference));
|
---|
| 2109 | sref.u.word = SWAP_LONG(sref.u.word);
|
---|
| 2110 | refs[i].flags = sref.u.fields.flags;
|
---|
| 2111 | refs[i].isym = sref.u.fields.isym;
|
---|
| 2112 | }
|
---|
| 2113 | else{
|
---|
| 2114 | sref.u.fields.isym = refs[i].isym;
|
---|
| 2115 | sref.u.fields.flags = refs[i].flags;
|
---|
| 2116 | sref.u.word = SWAP_LONG(sref.u.word);
|
---|
| 2117 | memcpy(refs + i, &sref, sizeof(struct swapped_dylib_reference));
|
---|
| 2118 | }
|
---|
| 2119 | }
|
---|
| 2120 |
|
---|
| 2121 | }
|
---|
| 2122 |
|
---|
| 2123 | __private_extern__
|
---|
| 2124 | void
|
---|
| 2125 | swap_dylib_module(
|
---|
| 2126 | struct dylib_module *mods,
|
---|
| 2127 | unsigned long nmods,
|
---|
| 2128 | enum byte_sex target_byte_sex)
|
---|
| 2129 | {
|
---|
| 2130 | unsigned long i;
|
---|
| 2131 | #ifdef __MWERKS__
|
---|
| 2132 | enum byte_sex dummy;
|
---|
| 2133 | dummy = target_byte_sex;
|
---|
| 2134 | #endif
|
---|
| 2135 |
|
---|
| 2136 | for(i = 0; i < nmods; i++){
|
---|
| 2137 | mods[i].module_name = SWAP_LONG(mods[i].module_name);
|
---|
| 2138 | mods[i].iextdefsym = SWAP_LONG(mods[i].iextdefsym);
|
---|
| 2139 | mods[i].nextdefsym = SWAP_LONG(mods[i].nextdefsym);
|
---|
| 2140 | mods[i].irefsym = SWAP_LONG(mods[i].irefsym);
|
---|
| 2141 | mods[i].nrefsym = SWAP_LONG(mods[i].nrefsym);
|
---|
| 2142 | mods[i].ilocalsym = SWAP_LONG(mods[i].ilocalsym);
|
---|
| 2143 | mods[i].nlocalsym = SWAP_LONG(mods[i].nlocalsym);
|
---|
| 2144 | mods[i].iextrel = SWAP_LONG(mods[i].iextrel);
|
---|
| 2145 | mods[i].nextrel = SWAP_LONG(mods[i].nextrel);
|
---|
| 2146 | mods[i].iinit_iterm = SWAP_LONG(mods[i].iinit_iterm);
|
---|
| 2147 | mods[i].ninit_nterm = SWAP_LONG(mods[i].ninit_nterm);
|
---|
| 2148 | mods[i].objc_module_info_addr =
|
---|
| 2149 | SWAP_LONG(mods[i].objc_module_info_addr);
|
---|
| 2150 | mods[i].objc_module_info_size =
|
---|
| 2151 | SWAP_LONG(mods[i].objc_module_info_size);
|
---|
| 2152 | }
|
---|
| 2153 | }
|
---|
| 2154 |
|
---|
| 2155 | __private_extern__
|
---|
| 2156 | void
|
---|
[217] | 2157 | swap_dylib_module_64(
|
---|
| 2158 | struct dylib_module_64 *mods,
|
---|
| 2159 | unsigned long nmods,
|
---|
| 2160 | enum byte_sex target_byte_sex)
|
---|
| 2161 | {
|
---|
| 2162 | unsigned long i;
|
---|
| 2163 | #ifdef __MWERKS__
|
---|
| 2164 | enum byte_sex dummy;
|
---|
| 2165 | dummy = target_byte_sex;
|
---|
| 2166 | #endif
|
---|
| 2167 |
|
---|
| 2168 | for(i = 0; i < nmods; i++){
|
---|
| 2169 | mods[i].module_name = SWAP_LONG(mods[i].module_name);
|
---|
| 2170 | mods[i].iextdefsym = SWAP_LONG(mods[i].iextdefsym);
|
---|
| 2171 | mods[i].nextdefsym = SWAP_LONG(mods[i].nextdefsym);
|
---|
| 2172 | mods[i].irefsym = SWAP_LONG(mods[i].irefsym);
|
---|
| 2173 | mods[i].nrefsym = SWAP_LONG(mods[i].nrefsym);
|
---|
| 2174 | mods[i].ilocalsym = SWAP_LONG(mods[i].ilocalsym);
|
---|
| 2175 | mods[i].nlocalsym = SWAP_LONG(mods[i].nlocalsym);
|
---|
| 2176 | mods[i].iextrel = SWAP_LONG(mods[i].iextrel);
|
---|
| 2177 | mods[i].nextrel = SWAP_LONG(mods[i].nextrel);
|
---|
| 2178 | mods[i].iinit_iterm = SWAP_LONG(mods[i].iinit_iterm);
|
---|
| 2179 | mods[i].ninit_nterm = SWAP_LONG(mods[i].ninit_nterm);
|
---|
| 2180 | mods[i].objc_module_info_addr =
|
---|
| 2181 | SWAP_LONG_LONG(mods[i].objc_module_info_addr);
|
---|
| 2182 | mods[i].objc_module_info_size =
|
---|
| 2183 | SWAP_LONG_LONG(mods[i].objc_module_info_size);
|
---|
| 2184 | }
|
---|
| 2185 | }
|
---|
| 2186 |
|
---|
| 2187 | __private_extern__
|
---|
| 2188 | void
|
---|
[7] | 2189 | swap_dylib_table_of_contents(
|
---|
| 2190 | struct dylib_table_of_contents *tocs,
|
---|
| 2191 | unsigned long ntocs,
|
---|
| 2192 | enum byte_sex target_byte_sex)
|
---|
| 2193 | {
|
---|
| 2194 | unsigned long i;
|
---|
| 2195 | #ifdef __MWERKS__
|
---|
| 2196 | enum byte_sex dummy;
|
---|
| 2197 | dummy = target_byte_sex;
|
---|
| 2198 | #endif
|
---|
| 2199 |
|
---|
| 2200 | for(i = 0; i < ntocs; i++){
|
---|
| 2201 | tocs[i].symbol_index = SWAP_LONG(tocs[i].symbol_index);
|
---|
| 2202 | tocs[i].module_index = SWAP_LONG(tocs[i].module_index);
|
---|
| 2203 | }
|
---|
| 2204 | }
|
---|