]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/bios_emulator/x86emu/ops.c
Merge branch 'master' of git://git.denx.de/u-boot-usb
[karo-tx-uboot.git] / drivers / bios_emulator / x86emu / ops.c
index d334fb5b1cf311bd2b7922c2682aac03c03fd50b..2bb5e2d9d508112124275397cd48d41e3fc845fc 100644 (file)
@@ -1,7 +1,7 @@
 /****************************************************************************
 *                      Realmode X86 Emulator Library
 *
-*  Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+*  Copyright (C) 2007 Freescale Semiconductor, Inc.
 *  Jason Jin <Jason.jin@freescale.com>
 *
 *              Copyright (C) 1991-2004 SciTech Software, Inc.
 * calls is especially important; otherwise mistakes in coding an
 * "add" would represent a nightmare in maintenance.
 *
-* Jason ported this file to u-boot. place all the function pointer in
-* the got2 sector. Removed some opcode.
-*
 ****************************************************************************/
 
+#include <common.h>
 #include "x86emu/x86emui.h"
 
-#if defined(CONFIG_BIOSEMU)
-
 /*----------------------------- Implementation ----------------------------*/
 
 /* constant arrays to do several instructions in just one function */
 
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
 static char *x86emu_GenOpName[8] = {
     "ADD", "OR", "ADC", "SBB", "AND", "SUB", "XOR", "CMP"};
 #endif
 
 /* used by several opcodes  */
-static u8 (*genop_byte_operation[])(u8 d, u8 s) __attribute__ ((section(".got2"))) =
+static u8 (*genop_byte_operation[])(u8 d, u8 s) =
 {
     add_byte,          /* 00 */
     or_byte,           /* 01 */
@@ -101,7 +97,7 @@ static u8 (*genop_byte_operation[])(u8 d, u8 s) __attribute__ ((section(".got2")
     cmp_byte,          /* 07 */
 };
 
-static u16 (*genop_word_operation[])(u16 d, u16 s) __attribute__ ((section(".got2"))) =
+static u16 (*genop_word_operation[])(u16 d, u16 s) =
 {
     add_word,          /*00 */
     or_word,           /*01 */
@@ -113,7 +109,7 @@ static u16 (*genop_word_operation[])(u16 d, u16 s) __attribute__ ((section(".got
     cmp_word,          /*07 */
 };
 
-static u32 (*genop_long_operation[])(u32 d, u32 s) __attribute__ ((section(".got2"))) =
+static u32 (*genop_long_operation[])(u32 d, u32 s) =
 {
     add_long,          /*00 */
     or_long,           /*01 */
@@ -126,7 +122,7 @@ static u32 (*genop_long_operation[])(u32 d, u32 s) __attribute__ ((section(".got
 };
 
 /* used by opcodes 80, c0, d0, and d2. */
-static u8(*opcD0_byte_operation[])(u8 d, u8 s) __attribute__ ((section(".got2"))) =
+static u8(*opcD0_byte_operation[])(u8 d, u8 s) =
 {
     rol_byte,
     ror_byte,
@@ -139,7 +135,7 @@ static u8(*opcD0_byte_operation[])(u8 d, u8 s) __attribute__ ((section(".got2"))
 };
 
 /* used by opcodes c1, d1, and d3. */
-static u16(*opcD1_word_operation[])(u16 s, u8 d) __attribute__ ((section(".got2"))) =
+static u16(*opcD1_word_operation[])(u16 s, u8 d) =
 {
     rol_word,
     ror_word,
@@ -152,7 +148,7 @@ static u16(*opcD1_word_operation[])(u16 s, u8 d) __attribute__ ((section(".got2"
 };
 
 /* used by opcodes c1, d1, and d3. */
-static u32 (*opcD1_long_operation[])(u32 s, u8 d) __attribute__ ((section(".got2"))) =
+static u32 (*opcD1_long_operation[])(u32 s, u8 d) =
 {
     rol_long,
     ror_long,
@@ -164,7 +160,7 @@ static u32 (*opcD1_long_operation[])(u32 s, u8 d) __attribute__ ((section(".got2
     sar_long,
 };
 
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
 
 static char *opF6_names[8] =
   { "TEST\t", "", "NOT\t", "NEG\t", "MUL\t", "IMUL\t", "DIV\t", "IDIV\t" };
@@ -183,7 +179,7 @@ void x86emuOp_illegal_op(
 {
     START_OF_INSTR();
     if (M.x86.R_SP != 0) {
-       DECODE_PRINTF("ILLEGAL X86 OPCODE\n");
+       ERR_PRINTF("ILLEGAL X86 OPCODE\n");
        TRACE_REGS();
        DB( printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n",
            M.x86.R_CS, M.x86.R_IP-1,op1));
@@ -1285,7 +1281,7 @@ void x86emuOp_opc80_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -1363,7 +1359,7 @@ void x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -1479,7 +1475,7 @@ void x86emuOp_opc82_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -1555,7 +1551,7 @@ void x86emuOp_opc83_word_RM_IMM(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -2152,7 +2148,7 @@ void x86emuOp_pop_RM(u8 X86EMU_UNUSED(op1))
     DECODE_PRINTF("POP\t");
     FETCH_DECODE_MODRM(mod, rh, rl);
     if (rh != 0) {
-       DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
+       ERR_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
        HALT_SYS();
     }
     if (mod < 3) {
@@ -3087,7 +3083,7 @@ void x86emuOp_opcC0_byte_RM_MEM(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -3162,7 +3158,7 @@ void x86emuOp_opcC1_word_RM_MEM(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -3351,7 +3347,7 @@ void x86emuOp_mov_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
     DECODE_PRINTF("MOV\t");
     FETCH_DECODE_MODRM(mod, rh, rl);
     if (rh != 0) {
-       DECODE_PRINTF("ILLEGAL DECODE OF OPCODE c6\n");
+       ERR_PRINTF("ILLEGAL DECODE OF OPCODE c6\n");
        HALT_SYS();
     }
     if (mod < 3) {
@@ -3385,7 +3381,7 @@ void x86emuOp_mov_word_RM_IMM(u8 X86EMU_UNUSED(op1))
     DECODE_PRINTF("MOV\t");
     FETCH_DECODE_MODRM(mod, rh, rl);
     if (rh != 0) {
-       DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
+       ERR_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
        HALT_SYS();
     }
     if (mod < 3) {
@@ -3522,11 +3518,9 @@ Handles opcode 0xcc
 ****************************************************************************/
 void x86emuOp_int3(u8 X86EMU_UNUSED(op1))
 {
-    u16 tmp;
-
     START_OF_INSTR();
     DECODE_PRINTF("INT 3\n");
-    tmp = (u16) mem_access_word(3 * 4 + 2);
+    (void)mem_access_word(3 * 4 + 2);
     /* access the segment register */
     TRACE_AND_STEP();
        if (_X86EMU_intrTab[3]) {
@@ -3550,14 +3544,13 @@ Handles opcode 0xcd
 ****************************************************************************/
 void x86emuOp_int_IMM(u8 X86EMU_UNUSED(op1))
 {
-    u16 tmp;
     u8 intnum;
 
     START_OF_INSTR();
     DECODE_PRINTF("INT\t");
     intnum = fetch_byte_imm();
     DECODE_PRINTF2("%x\n", intnum);
-    tmp = mem_access_word(intnum * 4 + 2);
+    (void)mem_access_word(intnum * 4 + 2);
     TRACE_AND_STEP();
        if (_X86EMU_intrTab[intnum]) {
                (*_X86EMU_intrTab[intnum])(intnum);
@@ -3580,13 +3573,11 @@ Handles opcode 0xce
 ****************************************************************************/
 void x86emuOp_into(u8 X86EMU_UNUSED(op1))
 {
-    u16 tmp;
-
     START_OF_INSTR();
     DECODE_PRINTF("INTO\n");
     TRACE_AND_STEP();
     if (ACCESS_FLAG(F_OF)) {
-       tmp = mem_access_word(4 * 4 + 2);
+       (void)mem_access_word(4 * 4 + 2);
                if (_X86EMU_intrTab[4]) {
                        (*_X86EMU_intrTab[4])(4);
        } else {
@@ -3639,7 +3630,7 @@ void x86emuOp_opcD0_byte_RM_1(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -3710,7 +3701,7 @@ void x86emuOp_opcD1_word_RM_1(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -3812,7 +3803,7 @@ void x86emuOp_opcD2_byte_RM_CL(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -3885,7 +3876,7 @@ void x86emuOp_opcD3_word_RM_CL(u8 X86EMU_UNUSED(op1))
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -3977,7 +3968,7 @@ void x86emuOp_aam(u8 X86EMU_UNUSED(op1))
     DECODE_PRINTF("AAM\n");
     a = fetch_byte_imm();      /* this is a stupid encoding. */
     if (a != 10) {
-       DECODE_PRINTF("ERROR DECODING AAM\n");
+       ERR_PRINTF("ERROR DECODING AAM\n");
        TRACE_REGS();
        HALT_SYS();
     }
@@ -3994,11 +3985,9 @@ Handles opcode 0xd5
 ****************************************************************************/
 void x86emuOp_aad(u8 X86EMU_UNUSED(op1))
 {
-    u8 a;
-
     START_OF_INSTR();
     DECODE_PRINTF("AAD\n");
-    a = fetch_byte_imm();
+    (void)fetch_byte_imm();
     TRACE_AND_STEP();
     M.x86.R_AX = aad_word(M.x86.R_AX);
     DECODE_CLEAR_SEGOVR();
@@ -4454,7 +4443,7 @@ void x86emuOp_opcF6_byte_RM(u8 X86EMU_UNUSED(op1))
            test_byte(destval, srcval);
            break;
        case 1:
-           DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
+           ERR_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
            HALT_SYS();
            break;
        case 2:
@@ -4501,7 +4490,7 @@ void x86emuOp_opcF6_byte_RM(u8 X86EMU_UNUSED(op1))
            test_byte(*destreg, srcval);
            break;
        case 1:
-           DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
+           ERR_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
            HALT_SYS();
            break;
        case 2:
@@ -4570,7 +4559,7 @@ void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1))
                test_long(destval, srcval);
                break;
            case 1:
-               DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n");
+               ERR_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n");
                HALT_SYS();
                break;
            case 2:
@@ -4622,7 +4611,7 @@ void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1))
                test_word(destval, srcval);
                break;
            case 1:
-               DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n");
+               ERR_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n");
                HALT_SYS();
                break;
            case 2:
@@ -4677,7 +4666,7 @@ void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1))
                test_long(*destreg, srcval);
                break;
            case 1:
-               DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
+               ERR_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
                HALT_SYS();
                break;
            case 2:
@@ -4726,7 +4715,7 @@ void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1))
                test_word(*destreg, srcval);
                break;
            case 1:
-               DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
+               ERR_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
                HALT_SYS();
                break;
            case 2:
@@ -4870,7 +4859,7 @@ void x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1))
     /* Yet another special case instruction. */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -4890,7 +4879,7 @@ void x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1))
        case 5:
        case 6:
        case 7:
-           DECODE_PRINTF2("ILLEGAL OP MAJOR OP 0xFE MINOR OP %x \n", mod);
+           ERR_PRINTF2("ILLEGAL OP MAJOR OP 0xFE MINOR OP %x\n", mod);
            HALT_SYS();
            break;
        }
@@ -4934,7 +4923,7 @@ void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
     /* Yet another special case instruction. */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
        /* XXX DECODE_PRINTF may be changed to something more
           general, so that it is important to leave the strings
@@ -4972,7 +4961,7 @@ void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
            DECODE_PRINTF("PUSH\t");
            break;
        case 7:
-           DECODE_PRINTF("ILLEGAL DECODING OF OPCODE FF\t");
+           ERR_PRINTF("ILLEGAL DECODING OF OPCODE FF\t");
            HALT_SYS();
            break;
        }
@@ -5103,7 +5092,7 @@ void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
            M.x86.R_IP = *destreg;
            break;
        case 3:         /* jmp far ptr ... */
-           DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
+           ERR_PRINTF("OPERATION UNDEFINED 0XFF\n");
            TRACE_AND_STEP();
            HALT_SYS();
            break;
@@ -5115,7 +5104,7 @@ void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
            M.x86.R_IP = (u16) (*destreg);
            break;
        case 5:         /* jmp far ptr ... */
-           DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
+           ERR_PRINTF("OPERATION UNDEFINED 0XFF\n");
            TRACE_AND_STEP();
            HALT_SYS();
            break;
@@ -5145,7 +5134,7 @@ void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
 /***************************************************************************
  * Single byte operation code table:
  **************************************************************************/
-void (*x86emu_optab[256])(u8) __attribute__ ((section(".got2"))) =
+void (*x86emu_optab[256])(u8) =
 {
 /*  0x00 */ x86emuOp_genop_byte_RM_R,
 /*  0x01 */ x86emuOp_genop_word_RM_R,
@@ -5432,5 +5421,3 @@ void (*x86emu_optab[256])(u8) __attribute__ ((section(".got2"))) =
 /*  0xfe */ x86emuOp_opcFE_byte_RM,
 /*  0xff */ x86emuOp_opcFF_word_RM,
 };
-
-#endif