1///////////////////////////////////////////////////////////////////////// 2// $Id$ 3///////////////////////////////////////////////////////////////////////// 4// 5// Copyright (C) 2002 MandrakeSoft S.A. 6// 7// MandrakeSoft S.A. 8// 43, rue d'Aboukir 9// 75002 Paris - France 10// http://www.linux-mandrake.com/ 11// http://www.mandrakesoft.com/ 12// 13// This library is free software; you can redistribute it and/or 14// modify it under the terms of the GNU Lesser General Public 15// License as published by the Free Software Foundation; either 16// version 2 of the License, or (at your option) any later version. 17// 18// This library is distributed in the hope that it will be useful, 19// but WITHOUT ANY WARRANTY; without even the implied warranty of 20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21// Lesser General Public License for more details. 22// 23// You should have received a copy of the GNU Lesser General Public 24// License along with this library; if not, write to the Free Software 25// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 27// 28// bochs.h is the master header file for all C++ code. It includes all 29// the system header files needed by bochs, and also includes all the bochs 30// C++ header files. Because bochs.h and the files that it includes has 31// structure and class definitions, it cannot be called from C code. 32// 33 34#ifndef BX_BOCHS_H 35# define BX_BOCHS_H 1 36 37#include "config.h" /* generated by configure script from config.h.in */ 38 39#ifndef __QNXNTO__ 40extern "C" { 41#endif 42 43#ifdef WIN32 44// In a win32 compile (including cygwin), windows.h is required for several 45// files in gui and iodev. It is important to include it here in a header 46// file so that WIN32-specific data types can be used in fields of classes. 47#include <windows.h> 48#endif 49 50#include <stdarg.h> 51#include <stdio.h> 52#include <stdlib.h> 53#if defined(__sun__) 54#undef EAX 55#undef ECX 56#undef EDX 57#undef EBX 58#undef ESP 59#undef EBP 60#undef ESI 61#undef EDI 62#undef EIP 63#undef CS 64#undef DS 65#undef ES 66#undef SS 67#undef FS 68#undef GS 69#endif 70#include <assert.h> 71#include <errno.h> 72 73#ifndef WIN32 74# include <unistd.h> 75#else 76# include <io.h> 77#endif 78#include <time.h> 79#if BX_WITH_MACOS 80# include <types.h> 81# include <stat.h> 82# include <cstdio> 83# include <unistd.h> 84#elif BX_WITH_CARBON 85# include <sys/types.h> 86# include <sys/stat.h> 87# include <sys/param.h> /* for MAXPATHLEN */ 88# include <sys/time.h> 89# include <utime.h> 90#else 91# ifndef WIN32 92# include <sys/time.h> 93# endif 94# include <sys/types.h> 95# include <sys/stat.h> 96#endif 97#include <ctype.h> 98#include <string.h> 99#include <fcntl.h> 100#include <limits.h> 101#ifdef macintosh 102# define SuperDrive "[fd:]" 103#endif 104 105#ifndef __QNXNTO__ 106} 107#endif 108 109#include "osdep.h" /* platform dependent includes and defines */ 110#include "bx_debug/debug.h" 111#include "bxversion.h" 112 113#include "gui/siminterface.h" 114 115// BX_SHARE_PATH should be defined by the makefile. If not, give it 116// a value of NULL to avoid compile problems. 117#ifndef BX_SHARE_PATH 118#define BX_SHARE_PATH NULL 119#endif 120 121// prototypes 122int bx_begin_simulation(int argc, char *argv[]); 123void bx_stop_simulation(); 124char *bx_find_bochsrc(void); 125int bx_parse_cmdline(int arg, int argc, char *argv[]); 126int bx_read_configuration(const char *rcfile); 127int bx_write_configuration(const char *rcfile, int overwrite); 128void bx_reset_options(void); 129Bit32u crc32(const Bit8u *buf, int len); 130// for param-tree testing only 131void print_tree(bx_param_c *node, int level = 0); 132 133// 134// some macros to interface the CPU and memory to external environment 135// so that these functions can be redirected to the debugger when 136// needed. 137// 138 139#define BXRS_PARAM_SPECIAL(parent, name, maxvalue, save_handler, restore_handler) \ 140{ \ 141 bx_param_num_c *param = new bx_param_num_c(parent, #name, "", "", 0, maxvalue, 0); \ 142 param->set_base(BASE_HEX); \ 143 param->set_sr_handlers(this, save_handler, restore_handler); \ 144} 145 146#define BXRS_PARAM_SPECIAL64(parent, name, save_handler, restore_handler) \ 147 BXRS_PARAM_SPECIAL(parent, name, BX_MAX_BIT64U, save_handler, restore_handler) 148#define BXRS_PARAM_SPECIAL32(parent, name, save_handler, restore_handler) \ 149 BXRS_PARAM_SPECIAL(parent, name, BX_MAX_BIT32U, save_handler, restore_handler) 150#define BXRS_PARAM_SPECIAL16(parent, name, save_handler, restore_handler) \ 151 BXRS_PARAM_SPECIAL(parent, name, BX_MAX_BIT16U, save_handler, restore_handler) 152#define BXRS_PARAM_SPECIAL8(parent, name, save_handler, restore_handler) \ 153 BXRS_PARAM_SPECIAL(parent, name, BX_MAX_BIT8U, save_handler, restore_handler) 154 155#define BXRS_HEX_PARAM_SIMPLE32(parent, name) \ 156 new bx_shadow_num_c(parent, #name, (Bit32u*)&(name), BASE_HEX) 157#define BXRS_HEX_PARAM_SIMPLE64(parent, name) \ 158 new bx_shadow_num_c(parent, #name, (Bit64u*)&(name), BASE_HEX) 159 160#define BXRS_HEX_PARAM_SIMPLE(parent, name) \ 161 new bx_shadow_num_c(parent, #name, &(name), BASE_HEX) 162#define BXRS_HEX_PARAM_FIELD(parent, name, field) \ 163 new bx_shadow_num_c(parent, #name, &(field), BASE_HEX) 164 165#define BXRS_DEC_PARAM_SIMPLE(parent, name) \ 166 new bx_shadow_num_c(parent, #name, &(name), BASE_DEC) 167#define BXRS_DEC_PARAM_FIELD(parent, name, field) \ 168 new bx_shadow_num_c(parent, #name, &(field), BASE_DEC) 169 170#define BXRS_PARAM_BOOL(parent, name, field) \ 171 new bx_shadow_bool_c(parent, #name, (bx_bool*)(&(field))) 172 173// =-=-=-=-=-=-=- Normal optimized use -=-=-=-=-=-=-=-=-=-=-=-=-=-= 174// some pc_systems functions just redirect to the IO devices so optimize 175// by eliminating call here 176// 177// #define BX_INP(addr, len) bx_pc_system.inp(addr, len) 178// #define BX_OUTP(addr, val, len) bx_pc_system.outp(addr, val, len) 179#define BX_INP(addr, len) bx_devices.inp(addr, len) 180#define BX_OUTP(addr, val, len) bx_devices.outp(addr, val, len) 181#define BX_TICK1() bx_pc_system.tick1() 182#define BX_TICKN(n) bx_pc_system.tickn(n) 183#define BX_INTR bx_pc_system.INTR 184#define BX_SET_INTR(b) bx_pc_system.set_INTR(b) 185#define BX_CPU_C bx_cpu_c 186#define BX_MEM_C bx_mem_c 187#define BX_HRQ (bx_pc_system.HRQ) 188 189#if BX_SUPPORT_SMP 190#define BX_CPU(x) (bx_cpu_array[x]) 191#else 192#define BX_CPU(x) (&bx_cpu) 193#endif 194 195#define BX_MEM(x) (&bx_mem) 196 197#define BX_SET_ENABLE_A20(enabled) bx_pc_system.set_enable_a20(enabled) 198#define BX_GET_ENABLE_A20() bx_pc_system.get_enable_a20() 199 200#if BX_SUPPORT_A20 201# define A20ADDR(x) ((bx_phy_address)(x) & bx_pc_system.a20_mask) 202#else 203# define A20ADDR(x) ((bx_phy_address)(x)) 204#endif 205 206#if BX_SUPPORT_SMP 207# define BX_TICK1_IF_SINGLE_PROCESSOR() \ 208 if (BX_SMP_PROCESSORS == 1) BX_TICK1() 209# define BX_TICKN_IF_SINGLE_PROCESSOR(n) \ 210 if (BX_SMP_PROCESSORS == 1) BX_TICKN(n) 211#else 212# define BX_TICK1_IF_SINGLE_PROCESSOR() BX_TICK1() 213# define BX_TICKN_IF_SINGLE_PROCESSOR(n) BX_TICKN(n) 214#endif 215 216// you can't use static member functions on the CPU, if there are going 217// to be 2 cpus. Check this early on. 218#if BX_SUPPORT_SMP 219# if BX_USE_CPU_SMF 220# error For SMP simulation, BX_USE_CPU_SMF must be 0. 221# endif 222#endif 223 224// 225// Ways for the the external environment to report back information 226// to the debugger. 227// 228 229#if BX_DEBUGGER 230# define BX_DBG_ASYNC_INTR bx_guard.async.irq 231# define BX_DBG_ASYNC_DMA bx_guard.async.dma 232 233# define BX_DBG_DMA_REPORT(addr, len, what, val) \ 234 if (bx_guard.report.dma) bx_dbg_dma_report(addr, len, what, val) 235# define BX_DBG_IAC_REPORT(vector, irq) \ 236 if (bx_guard.report.irq) bx_dbg_iac_report(vector, irq) 237# define BX_DBG_A20_REPORT(val) \ 238 if (bx_guard.report.a20) bx_dbg_a20_report(val) 239# define BX_DBG_IO_REPORT(port, size, op, val) \ 240 if (bx_guard.report.io) bx_dbg_io_report(port, size, op, val) 241# define BX_DBG_UCMEM_REPORT(addr, size, op, val) \ 242 if (bx_guard.report.ucmem) bx_dbg_ucmem_report(addr, size, op, val) 243# define BX_DBG_LIN_MEMORY_ACCESS(cpu, lin, phy, len, pl, rw, data) \ 244 bx_dbg_lin_memory_access(cpu, lin, phy, len, pl, rw, data) 245# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, rw, data) \ 246 bx_dbg_phy_memory_access(cpu, phy, len, rw, data) 247#else // #if BX_DEBUGGER 248// debugger not compiled in, use empty stubs 249# define BX_DBG_ASYNC_INTR 1 250# define BX_DBG_ASYNC_DMA 1 251# define BX_DBG_DMA_REPORT(addr, len, what, val) /* empty */ 252# define BX_DBG_IAC_REPORT(vector, irq) /* empty */ 253# define BX_DBG_A20_REPORT(val) /* empty */ 254# define BX_DBG_IO_REPORT(addr, size, op, val) /* empty */ 255# define BX_DBG_UCMEM_REPORT(addr, size, op, val) /* empty */ 256# define BX_DBG_LIN_MEMORY_ACCESS(cpu, lin, phy, len, pl, rw, data) /* empty */ 257# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, rw, data) /* empty */ 258#endif // #if BX_DEBUGGER 259 260#define MAGIC_LOGNUM 0x12345678 261 262typedef class BOCHSAPI logfunctions 263{ 264 char *prefix; 265// values of onoff: 0=ignore, 1=report, 2=ask, 3=fatal 266#define ACT_IGNORE 0 267#define ACT_REPORT 1 268#define ACT_ASK 2 269#define ACT_FATAL 3 270#define N_ACT 4 271 int onoff[N_LOGLEV]; 272 class iofunctions *logio; 273 // default log actions for all devices, declared and initialized 274 // in logio.cc. 275 BOCHSAPI_CYGONLY static int default_onoff[N_LOGLEV]; 276public: 277 logfunctions(void); 278 logfunctions(class iofunctions *); 279 ~logfunctions(void); 280 281 void info(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); 282 void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); 283 void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); 284 void pass(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); 285 void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3); 286 void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status); 287 void ask (int level, const char *prefix, const char *fmt, va_list ap); 288 void put(const char *); 289 void setio(class iofunctions *); 290 void setonoff(int loglev, int value) { 291 assert (loglev >= 0 && loglev < N_LOGLEV); 292 onoff[loglev] = value; 293 } 294 char *getprefix () { return prefix; } 295 int getonoff(int level) { 296 assert (level>=0 && level<N_LOGLEV); 297 return onoff[level]; 298 } 299 static void set_default_action (int loglev, int action) { 300 assert (loglev >= 0 && loglev < N_LOGLEV); 301 assert (action >= 0 && action < N_ACT); 302 default_onoff[loglev] = action; 303 } 304 static int get_default_action (int loglev) { 305 assert (loglev >= 0 && loglev < N_LOGLEV); 306 return default_onoff[loglev]; 307 } 308} logfunc_t; 309 310#define BX_LOGPREFIX_SIZE 51 311 312class BOCHSAPI iofunctions { 313 int magic; 314 char logprefix[BX_LOGPREFIX_SIZE]; 315 FILE *logfd; 316 class logfunctions *log; 317 void init(void); 318 void flush(void); 319 320// Log Class types 321public: 322 iofunctions(void); 323 iofunctions(FILE *); 324 iofunctions(int); 325 iofunctions(const char *); 326 ~iofunctions(void); 327 328 void out(int level, const char *pre, const char *fmt, va_list ap); 329 330 void init_log(const char *fn); 331 void init_log(int fd); 332 void init_log(FILE *fs); 333 void exit_log(); 334 void set_log_prefix(const char *prefix); 335 int get_n_logfns() { return n_logfn; } 336 logfunc_t *get_logfn(int index) { return logfn_list[index]; } 337 void add_logfn(logfunc_t *fn); 338 void remove_logfn(logfunc_t *fn); 339 void set_log_action(int loglevel, int action); 340 const char *getlevel(int i) { 341 static const char *loglevel[N_LOGLEV] = { 342 "DEBUG", 343 "INFO", 344 "ERROR", 345 "PANIC", 346 "PASS" 347 }; 348 if (i>=0 && i<N_LOGLEV) return loglevel[i]; 349 else return "?"; 350 } 351 char *getaction(int i) { 352 static const char *name[] = { "ignore", "report", "ask", "fatal" }; 353 assert (i>=ACT_IGNORE && i<N_ACT); 354 return (char *) name[i]; 355 } 356 357protected: 358 int n_logfn; 359#define MAX_LOGFNS 128 360 logfunc_t *logfn_list[MAX_LOGFNS]; 361 const char *logfn; 362}; 363 364typedef class BOCHSAPI iofunctions iofunc_t; 365 366#define SAFE_GET_IOFUNC() \ 367 ((io==NULL)? (io=new iofunc_t("/dev/stderr")) : io) 368#define SAFE_GET_GENLOG() \ 369 ((genlog==NULL)? (genlog=new logfunc_t(SAFE_GET_IOFUNC())) : genlog) 370 371#if BX_NO_LOGGING 372 373#define BX_INFO(x) 374#define BX_DEBUG(x) 375#define BX_ERROR(x) 376#define BX_PANIC(x) (LOG_THIS panic) x 377#define BX_PASS(x) (LOG_THIS pass) x 378 379#define BX_ASSERT(x) 380 381#else 382 383#define BX_INFO(x) (LOG_THIS info) x 384#define BX_DEBUG(x) (LOG_THIS ldebug) x 385#define BX_ERROR(x) (LOG_THIS error) x 386#define BX_PANIC(x) (LOG_THIS panic) x 387#define BX_PASS(x) (LOG_THIS pass) x 388 389#if BX_ASSERT_ENABLE 390 #define BX_ASSERT(x) do {if (!(x)) BX_PANIC(("failed assertion \"%s\" at %s:%d\n", #x, __FILE__, __LINE__));} while (0) 391#else 392 #define BX_ASSERT(x) 393#endif 394 395#endif 396 397BOCHSAPI extern iofunc_t *io; 398BOCHSAPI extern logfunc_t *genlog; 399 400#ifndef UNUSED 401# define UNUSED(x) ((void)x) 402#endif 403 404#if BX_SUPPORT_X86_64 405#define FMT_ADDRX FMT_ADDRX64 406#else 407#define FMT_ADDRX FMT_ADDRX32 408#endif 409 410#if BX_PHY_ADDRESS_LONG 411 #define FMT_PHY_ADDRX FMT_ADDRX64 412#else 413 #define FMT_PHY_ADDRX FMT_ADDRX32 414#endif 415 416#define FMT_LIN_ADDRX FMT_ADDRX 417 418#if BX_GDBSTUB 419// defines for GDB stub 420void bx_gdbstub_init(void); 421void bx_gdbstub_break(void); 422int bx_gdbstub_check(unsigned int eip); 423#define GDBSTUB_STOP_NO_REASON (0xac0) 424 425#if BX_SUPPORT_SMP 426#error GDB stub was written for single processor support. If multiprocessor support is added, then we can remove this check. 427// The big problem is knowing which CPU gdb is referring to. In other words, 428// what should we put for "n" in BX_CPU(n)->dbg_xlate_linear2phy() and 429// BX_CPU(n)->dword.eip, etc. 430#endif 431#endif 432 433typedef struct { 434 bx_bool floppy; 435 bx_bool keyboard; 436 bx_bool video; 437 bx_bool disk; 438 bx_bool pit; 439 bx_bool pic; 440 bx_bool bios; 441 bx_bool cmos; 442 bx_bool a20; 443 bx_bool interrupts; 444 bx_bool exceptions; 445 bx_bool debugger; 446 bx_bool mouse; 447 bx_bool io; 448 bx_bool dma; 449 bx_bool unsupported_io; 450 bx_bool serial; 451 bx_bool cdrom; 452 bx_bool print_timestamps; 453#if BX_DEBUGGER 454 bx_bool magic_break_enabled; 455#endif 456#if BX_GDBSTUB 457 bx_bool gdbstub_enabled; 458#endif 459#if BX_SUPPORT_APIC 460 bx_bool apic; 461 bx_bool ioapic; 462#endif 463#if BX_DEBUG_LINUX 464 bx_bool linux_syscall; 465#endif 466 void* record_io; 467} bx_debug_t; 468 469void CDECL bx_signal_handler(int signum); 470int bx_atexit(void); 471BOCHSAPI extern bx_debug_t bx_dbg; 472 473// memory access type (read/write/execute/rw) 474#define BX_READ 0 475#define BX_WRITE 1 476#define BX_EXECUTE 2 477#define BX_RW 3 478 479#include "memory/memory.h" 480#include "pc_system.h" 481#include "plugin.h" 482#include "gui/gui.h" 483#include "gui/textconfig.h" 484#include "gui/keymap.h" 485 486/* --- EXTERNS --- */ 487 488#if BX_GUI_SIGHANDLER 489extern bx_bool bx_gui_sighandler; 490#endif 491 492// This value controls how often each I/O device's periodic() method 493// gets called. The timer is set up in iodev/devices.cc. 494#define BX_IODEV_HANDLER_PERIOD 100 // microseconds 495//#define BX_IODEV_HANDLER_PERIOD 10 // microseconds 496 497#define BX_PATHNAME_LEN 512 498 499#define BX_KBD_XT_TYPE 0 500#define BX_KBD_AT_TYPE 1 501#define BX_KBD_MF_TYPE 2 502 503#define BX_N_OPTROM_IMAGES 4 504#define BX_N_OPTRAM_IMAGES 4 505#define BX_N_SERIAL_PORTS 4 506#define BX_N_PARALLEL_PORTS 2 507#define BX_N_PCI_SLOTS 5 508#define BX_N_USER_PLUGINS 8 509 510void bx_center_print(FILE *file, const char *line, unsigned maxwidth); 511 512#include "instrument.h" 513 514// These are some convenience macros which abstract out accesses between 515// a variable in native byte ordering to/from guest (x86) memory, which is 516// always in little endian format. You must deal with alignment (if your 517// system cares) and endian rearranging. Don't assume anything. You could 518// put some platform specific asm() statements here, to make use of native 519// instructions to help perform these operations more efficiently than C++. 520 521 522#ifdef BX_LITTLE_ENDIAN 523 524#define WriteHostWordToLittleEndian(hostPtr, nativeVar16) \ 525 *((Bit16u*)(hostPtr)) = (nativeVar16) 526#define WriteHostDWordToLittleEndian(hostPtr, nativeVar32) \ 527 *((Bit32u*)(hostPtr)) = (nativeVar32) 528#define WriteHostQWordToLittleEndian(hostPtr, nativeVar64) \ 529 *((Bit64u*)(hostPtr)) = (nativeVar64) 530 531#define ReadHostWordFromLittleEndian(hostPtr, nativeVar16) \ 532 (nativeVar16) = *((Bit16u*)(hostPtr)) 533#define ReadHostDWordFromLittleEndian(hostPtr, nativeVar32) \ 534 (nativeVar32) = *((Bit32u*)(hostPtr)) 535#define ReadHostQWordFromLittleEndian(hostPtr, nativeVar64) \ 536 (nativeVar64) = *((Bit64u*)(hostPtr)) 537 538#define CopyHostWordLittleEndian(hostAddrDst, hostAddrSrc) \ 539 (* (Bit16u *)(hostAddrDst)) = (* (Bit16u *)(hostAddrSrc)); 540#define CopyHostDWordLittleEndian(hostAddrDst, hostAddrSrc) \ 541 (* (Bit32u *)(hostAddrDst)) = (* (Bit32u *)(hostAddrSrc)); 542#define CopyHostQWordLittleEndian(hostAddrDst, hostAddrSrc) \ 543 (* (Bit64u *)(hostAddrDst)) = (* (Bit64u *)(hostAddrSrc)); 544 545#else 546 547#define WriteHostWordToLittleEndian(hostPtr, nativeVar16) { \ 548 ((Bit8u *)(hostPtr))[0] = (Bit8u) (nativeVar16); \ 549 ((Bit8u *)(hostPtr))[1] = (Bit8u) ((nativeVar16)>>8); \ 550} 551#define WriteHostDWordToLittleEndian(hostPtr, nativeVar32) { \ 552 ((Bit8u *)(hostPtr))[0] = (Bit8u) (nativeVar32); \ 553 ((Bit8u *)(hostPtr))[1] = (Bit8u) ((nativeVar32)>>8); \ 554 ((Bit8u *)(hostPtr))[2] = (Bit8u) ((nativeVar32)>>16); \ 555 ((Bit8u *)(hostPtr))[3] = (Bit8u) ((nativeVar32)>>24); \ 556} 557#define WriteHostQWordToLittleEndian(hostPtr, nativeVar64) { \ 558 ((Bit8u *)(hostPtr))[0] = (Bit8u) (nativeVar64); \ 559 ((Bit8u *)(hostPtr))[1] = (Bit8u) ((nativeVar64)>>8); \ 560 ((Bit8u *)(hostPtr))[2] = (Bit8u) ((nativeVar64)>>16); \ 561 ((Bit8u *)(hostPtr))[3] = (Bit8u) ((nativeVar64)>>24); \ 562 ((Bit8u *)(hostPtr))[4] = (Bit8u) ((nativeVar64)>>32); \ 563 ((Bit8u *)(hostPtr))[5] = (Bit8u) ((nativeVar64)>>40); \ 564 ((Bit8u *)(hostPtr))[6] = (Bit8u) ((nativeVar64)>>48); \ 565 ((Bit8u *)(hostPtr))[7] = (Bit8u) ((nativeVar64)>>56); \ 566} 567 568#define ReadHostWordFromLittleEndian(hostPtr, nativeVar16) { \ 569 (nativeVar16) = ((Bit16u) ((Bit8u *)(hostPtr))[0]) | \ 570 (((Bit16u) ((Bit8u *)(hostPtr))[1])<<8) ; \ 571} 572#define ReadHostDWordFromLittleEndian(hostPtr, nativeVar32) { \ 573 (nativeVar32) = ((Bit32u) ((Bit8u *)(hostPtr))[0]) | \ 574 (((Bit32u) ((Bit8u *)(hostPtr))[1])<<8) | \ 575 (((Bit32u) ((Bit8u *)(hostPtr))[2])<<16) | \ 576 (((Bit32u) ((Bit8u *)(hostPtr))[3])<<24); \ 577} 578#define ReadHostQWordFromLittleEndian(hostPtr, nativeVar64) { \ 579 (nativeVar64) = ((Bit64u) ((Bit8u *)(hostPtr))[0]) | \ 580 (((Bit64u) ((Bit8u *)(hostPtr))[1])<<8) | \ 581 (((Bit64u) ((Bit8u *)(hostPtr))[2])<<16) | \ 582 (((Bit64u) ((Bit8u *)(hostPtr))[3])<<24) | \ 583 (((Bit64u) ((Bit8u *)(hostPtr))[4])<<32) | \ 584 (((Bit64u) ((Bit8u *)(hostPtr))[5])<<40) | \ 585 (((Bit64u) ((Bit8u *)(hostPtr))[6])<<48) | \ 586 (((Bit64u) ((Bit8u *)(hostPtr))[7])<<56); \ 587} 588 589#define CopyHostWordLittleEndian(hostAddrDst, hostAddrSrc) { \ 590 ((Bit8u *)(hostAddrDst))[0] = ((Bit8u *)(hostAddrSrc))[0]; \ 591 ((Bit8u *)(hostAddrDst))[1] = ((Bit8u *)(hostAddrSrc))[1]; \ 592} 593#define CopyHostDWordLittleEndian(hostAddrDst, hostAddrSrc) { \ 594 ((Bit8u *)(hostAddrDst))[0] = ((Bit8u *)(hostAddrSrc))[0]; \ 595 ((Bit8u *)(hostAddrDst))[1] = ((Bit8u *)(hostAddrSrc))[1]; \ 596 ((Bit8u *)(hostAddrDst))[2] = ((Bit8u *)(hostAddrSrc))[2]; \ 597 ((Bit8u *)(hostAddrDst))[3] = ((Bit8u *)(hostAddrSrc))[3]; \ 598} 599#define CopyHostQWordLittleEndian(hostAddrDst, hostAddrSrc) { \ 600 ((Bit8u *)(hostAddrDst))[0] = ((Bit8u *)(hostAddrSrc))[0]; \ 601 ((Bit8u *)(hostAddrDst))[1] = ((Bit8u *)(hostAddrSrc))[1]; \ 602 ((Bit8u *)(hostAddrDst))[2] = ((Bit8u *)(hostAddrSrc))[2]; \ 603 ((Bit8u *)(hostAddrDst))[3] = ((Bit8u *)(hostAddrSrc))[3]; \ 604 ((Bit8u *)(hostAddrDst))[4] = ((Bit8u *)(hostAddrSrc))[4]; \ 605 ((Bit8u *)(hostAddrDst))[5] = ((Bit8u *)(hostAddrSrc))[5]; \ 606 ((Bit8u *)(hostAddrDst))[6] = ((Bit8u *)(hostAddrSrc))[6]; \ 607 ((Bit8u *)(hostAddrDst))[7] = ((Bit8u *)(hostAddrSrc))[7]; \ 608} 609 610#endif 611 612#endif /* BX_BOCHS_H */ 613