Browse Source

RS690E VGA display works correctly

1. Porting the 3A+690E x86emu module to 2G+690e platform and it works
   correctly.
2. The HT frequency is adjusted to 800MHz.
3. The start address of PCI IO and memory space are adjusted according
   to the 3A+690E platform.
4. The framebuffer address(0xb0000000) doesn't map through TLB. The
   pcitlb.c is added in start.S, but it doesn't work.
5. Fix the IO-read/write base from 0xa000_0000 to 0x0000_0000 in
   sys/linux/io.h.
master
LI Wengang 15 years ago
committed by LIU Qi
parent
commit
1449210142
  1. 374
      Targets/Bonito2g690e/Bonito/loongson2g_HT_init.S
  2. 107
      Targets/Bonito2g690e/Bonito/pcitlb.S
  3. 14
      Targets/Bonito2g690e/Bonito/start.S
  4. 46
      Targets/Bonito2g690e/Bonito/tgt_machdep.c
  5. 7614
      Targets/Bonito2g690e/Bonito/vgarom.c
  6. 32
      Targets/Bonito2g690e/conf/Bonito.2g690e
  7. 6
      Targets/Bonito2g690e/pci/pci_machdep.c
  8. 13
      Targets/Bonito2g690e/pci/rs690/nb_pre.c
  9. 2
      conf/files
  10. 11
      fb/cfb_console.c
  11. 9
      sys/linux/io.h
  12. 896
      x86emu/int10/generic.c
  13. 661
      x86emu/int10/helper_exec.c
  14. 309
      x86emu/int10/helper_mem.c
  15. 3031
      x86emu/int10/radeon_init.c
  16. 255
      x86emu/int10/radeon_reg.h
  17. 64
      x86emu/int10/rs690_struct.c
  18. 39
      x86emu/int10/rs690_struct.h
  19. 1474
      x86emu/int10/theater_out.c
  20. 96
      x86emu/int10/theater_out.h
  21. 64
      x86emu/int10/vesa.h
  22. 589
      x86emu/int10/vesafb.c
  23. 4
      x86emu/int10/x86emu/src/x86emu/debug.c
  24. 3
      x86emu/int10/x86emu/src/x86emu/decode.c
  25. 17
      x86emu/int10/x86emu/src/x86emu/ops.c
  26. 15
      x86emu/int10/x86emu/src/x86emu/x86emu/debug.h
  27. 1450
      x86emu/int10/xf86int10.c
  28. 93
      x86emu/int10/xf86int10.h
  29. 90
      x86emu/int10/xf86x86emu.c

374
Targets/Bonito2g690e/Bonito/loongson2g_HT_init.S

@ -7,10 +7,10 @@
######################################################
#define HT_32bit_TRANS
#define WITH_HT
//#define HT_800M
#define HT_800M
//#define HT_16bit
//#define HT_RECONNECT
#define HT_REG_TRANS
#define HT_RECONNECT
//#define HT_REG_TRANS
######################################################
#ifdef HT_32bit_TRANS //PCI CFG : TYPE 0:
@ -20,11 +20,10 @@
dli t2, 0x900000003ff02400
1:
#if 1
//map HT: PCI IO : 0x90000efd_fc000000 --> 0x18000000
//map 0x90000efd_fd000000 --> 0x19000000
//map HT: PCI CFG: 0x90000efd_fe000000 --> 0x1a000000
//map HT: PCI CFG: 0x90000efd_ff000000 --> 0x1b000000
//map HT: PCI IO : 0x90000cfd_fc000000 --> 0x18000000
//map 0x90000cfd_fd000000 --> 0x19000000
//map HT: PCI CFG: 0x90000cfd_fe000000 --> 0x1a000000
//map HT: PCI CFG: 0x90000cfd_ff000000 --> 0x1b000000
dli t1, 0x0000000018000000
sd t1, 0x0(t0)
dli t1, 0xfffffffffc000000
@ -41,6 +40,7 @@
dli t1, 0x00000c00000000f6
sd t1, 0x88(t0)
#if 0
//HT: PCI LO BASE
//map 0x90000e00_00000000 --> 0x10000000
dli t1, 0x0000000010000000
@ -49,6 +49,7 @@
sd t1, 0x50(t0)
dli t1, 0x00000c00000000f6
sd t1, 0x90(t0)
#endif
//HT: PCI HI BASE
//map 0x90000e00_10000000 --> 0x10000000
@ -61,97 +62,28 @@
#ifdef HT_REG_TRANS
//HT REG BASE
//map 0x90000efd_fb000000 --> 0x1e000000
//map 0x90000cfd_fb000000 --> 0x1e000000
dli t1, 0x000000001e000000
sd t1, 0x20(t0)
dli t1, 0xffffffffff000000
sd t1, 0x60(t0)
dli t1, 0x00000cfdfb0000f6
sd t1, 0xa0(t0)
#else
//HT RESEVER MEM
//map 0x90000c00_00000000 --> 0x1e000000
dli t1, 0x000000001e000000
sd t1, 0x20(t0)
dli t1, 0xffffffffff000000
sd t1, 0x60(t0)
dli t1, 0x00000c00000000f6
sd t1, 0xa0(t0)
#endif
daddiu t0, t0, 0x100
bne t0, t2, 1b
nop
#if 0
// change the dma addresssssssssssss
daddiu t0, t0, 0x300
TTYDBG("North HT dma changed!!!!!!!!!!!!!!!!!!!\r\n")
dli t1, 0x0000000000000000
sd t1, 0x0(t0)
dli t1, 0x0000000000000000
sd t1, 0x40(t0)
dli t1, 0x00000000000000f6
sd t1, 0x80(t0)
#endif
#else
/******************************************/
##################################### LEVEL-1 XBAR : CPU #########################################
###HT CFG : TYPE 0:
###map 0x90000efd_fe000000 --> 0x1fe80000, size 0x00080000
dli t1, 0x000000001fe80000
sd t1, 0x0(t0)
dli t1, 0xfffffffffff80000
sd t1, 0x40(t0)
dli t1, 0x00000cfdfe0000f6
sd t1, 0x80(t0)
###HT CFG : TYPE 1:
###map 0x90000efd_ff000000 --> 0x1e000000, size 0x01000000
dli t1, 0x000000001e000000
sd t1, 0x8(t0)
dli t1, 0xffffffffff000000
sd t1, 0x48(t0)
dli t1, 0x00000cfdff0000f6
sd t1, 0x88(t0)
###HT LOW MEM
###map 0x90000e00_00000000 --> 0x10000000, size 0x04000000
dli t1, 0x0000000010000000
sd t1, 0x10(t0)
dli t1, 0xfffffffffc000000
sd t1, 0x50(t0)
dli t1, 0x00000c00000000f6
sd t1, 0x90(t0)
###HT HIGH MEM
###map 0x90000e00_10000000 --> 0x14000000, size 0x04000000
dli t1, 0x0000000014000000
sd t1, 0x18(t0)
dli t1, 0xfffffffffc000000
sd t1, 0x58(t0)
dli t1, 0x00000c00140000f6
sd t1, 0x98(t0)
###HT IO
###map 0x90000efd_fc000000 --> 0x1fd00000, size 0x01000000
dli t1, 0x000000001fd00000
sd t1, 0x20(t0)
dli t1, 0xfffffffffff00000
sd t1, 0x60(t0)
dli t1, 0x00000cfdfc0000f6
sd t1, 0xa0(t0)
###HT BRIDGE CFG
###map 0x90000efd_fb000000 --> 0x1b000000, size 0x01000000
dli t1, 0x000000001b000000
sd t1, 0x28(t0)
dli t1, 0xffffffffff000000
sd t1, 0x68(t0)
dli t1, 0x00000cfdfb0000f6
sd t1, 0xa8(t0)
### ANY ELSE DEFAULY MEMORY
### Mapping 0x0 ---> 0x0, size 0x00001000_00000000
daddiu t0, t0, 0x100
bne t0, t2, 1b
nop
/******************************************/
#endif
#endif
@ -177,7 +109,7 @@
TTYDBG("DEBUG END......\r\n")
#endif
#if 1//Print all HT registers
#if 0//Print all HT registers
TTYDBG("Print all HT registers\r\n")
dli t2, 0x90000cfdfb000000
dli t3, 0x90000cfdfb000100
@ -349,24 +281,40 @@ ht_next_id :
sw t0, 0x4(t2)
TTYDBG("HT RX DMA address ENABLE done 1\r\n")
/*
li t0, 0xc0000000
sw t0, 0x8(t2)
li t0, 0x0000f000
sw t0, 0xc(t2)
*/
/*
li t0, 0xc0000000
#if 1
li a0, 0x3f000000
bleu msize, a0, 1f
nop
li t0, 0xc0000080
sw t0, 0x8(t2)
li t0, 0x00008000
li t0, 0x0080ff80
sw t0, 0xc(t2)
TTYDBG("HT RX DMA address ENABLE done 2\r\n")
*/
//li t0, 0xc0000000
//li t0, 0xc00000f0
//sw t0, 0x10(t2)
//li t0, 0xfdfcfffc
//li t0, 0x0070fff0
//sw t0, 0x14(t2)
////TTYDBG("HT RX DMA address ENABLE done 3\r\n")
//TTYDBG("HT RX DMA address ENABLE done 3\r\n")
b 2f
nop
#endif
1:
li t0, 0xc0000040
sw t0, 0x8(t2)
li t0, 0x0040ffc0
sw t0, 0xc(t2)
TTYDBG("HT RX DMA address ENABLE done 2\r\n")
2:
//li t0, 0xc00000f0
//sw t0, 0x10(t2)
//li t0, 0x0070fff0
//sw t0, 0x14(t2)
//TTYDBG("HT RX DMA address ENABLE done 3\r\n")
#endif
@ -423,8 +371,8 @@ ht_next_id :
#ifdef HT_800M//Set HT bridge to be 800Mhz
TTYDBG("Setting HyperTransport Controller to be 800Mhz\r\n")
dli t2, 0x90000cfdfb000000
#li t0, 0x2 //Frequency: 400 Mhz
li t0, 0x5 //Frequency: 800 Mhz
#li t0, 0x2 //Frequency: 400Mhz
li t0, 0x5 //Frequency: 800Mhz
sb t0, 0x49(t2)
lw a0, 0x48(t2)
bal hexserial
@ -459,10 +407,9 @@ ht_next_id :
bal hexserial
nop
li t1, 0xfbffffff
//li t1, 0xfbffffff
li t1, 0xffffffff
and a0, a0, t1
// li t1, 0x04000000
// or a0, a0, t1
sw a0, 0x0(t2)
lw a0, 0x0(t2)
@ -677,8 +624,8 @@ ht_next_id :
dli t0, 0x90000cfdfe000000
#li t1, 0x01 //DRIVER 16bit
li t1, 0x11
sb t1, 0x4b(t0)
lw a0, 0x48(t0)
sb t1, 0xcb(t0)
lw a0, 0xc8(t0)
bal hexserial
nop
TTYDBG("\r\n")
@ -687,8 +634,10 @@ ht_next_id :
//li t0, 0xba000000
dli t0, 0x90000cfdfe000000
li t1, 0x00
sb t1, 0x4b(t0)
lw a0, 0x48(t0)
sync
sb t1, 0xcb(t0)
sync
lw a0, 0xc8(t0)
bal hexserial
nop
TTYDBG("\r\n")
@ -701,126 +650,144 @@ ht_next_id :
dli t0, 0x90000cfdfe000000
#li t1, 0x2 //Frequency : 400Mhz
li t1, 0x5 //Frequency : 800Mhz
sb t1, 0x51(t0)
lw a0, 0x4c(t0)
bal hexserial
nop
TTYDBG("\r\n")
sync
sb t1, 0xd1(t0)
sync
lw a0, 0xd0(t0)
sync
//bal hexserial
//sync
//nop
//TTYDBG("\r\n")
#endif
#if 1 //Watch dog Trying
TTYDBG("Setting Watch Dog to make a WARM RESET\r\n")
#ifdef WD_DEBUG
TTYDBG("Setting Watch dog BAR\r\n")
nop
//li t0, 0xba00096c
dli t0, 0x90000cfdfe00096c
lw a0, 0(t0)
bal hexserial
nop
TTYDBG("\r\n")
#endif
//li t0, 0xba00096c
dli t0, 0x90000cfdfe00096c
li a0, 0x00001000
sw a0, 0(t0)
li t1, 10
//#define WD_DEBUG
TTYDBG("Watch dog Enable\r\n")
dli t0, 0x90000cfdfc000cd6
li a0, 0x00000069
sync
sb a0, 0(t0)
sync
li a0, 0x00000000
sb a0, 1(t0)
sync
lb a0, 1(t0)
sync
//bal hexserial
nop
TTYDBG("\r\n")
nop
dli t0, 0x90000cfdfc000cd6
li a0, 0x0000006c
sb a0, 0(t0)
li a0, 0x00000000
sb a0, 1(t0)
nop
li a0, 0x0000006d
sb a0, 0(t0)
li a0, 0x00000000
sb a0, 1(t0)
nop
li a0, 0x0000006e
sb a0, 0(t0)
li a0, 0x00000001
sb a0, 1(t0)
nop
li a0, 0x0000006f
sb a0, 0(t0)
li a0, 0x00000000
sb a0, 1(t0)
nop
#ifdef WD_DEBUG
lw a0, 0(t0)
lb a0, 1(t0)
bal hexserial
nop
TTYDBG("\r\n")
#endif
li t0, 0xb0001000
lw a0, 0x0(t0)
#ifdef WD_DEBUG
lb a0, 1(t0)
bal hexserial
nop
nop
TTYDBG("\r\n")
TTYDBG("Watch dog Disable\r\n")
//li t0, 0xba0009e8
dli t0, 0x90000cfdfe0009e8
lw a0, 0(t0)
TTYDBG("Watch dog base value\r\n")
li a0, 0x00000069
sb a0, 0(t0)
lb a0, 1(t0)
bal hexserial
nop
nop
TTYDBG("\r\n")
lw a0, 0(t0)
li a1, 0x04000000
or a0, a0, a1
sw a0, 0(t0)
nop
lw a0, 0(t0)
li a0, 0x0000006c
sb a0, 0(t0)
lb a0, 1(t0)
bal hexserial
nop
nop
TTYDBG("\r\n")
li t0, 0xb0001000
lw a0, 0x0(t0)
li a0, 0x0000006d
sb a0, 0(t0)
lb a0, 1(t0)
bal hexserial
nop
TTYDBG("\r\n")
TTYDBG("Watch dog Enable\r\n")
//li t0, 0xba0009e8
dli t0, 0x90000cfdfe0009e8
lw a0, 0(t0)
li a0, 0x0000006e
sb a0, 0(t0)
lb a0, 1(t0)
bal hexserial
nop
nop
TTYDBG("\r\n")
#endif
//li t0, 0xba0009e8
dli t0, 0x90000cfdfe0009e8
lw a0, 0(t0)
li a1, 0xfbffffff
and a0, a0, a1
sw a0, 0(t0)
nop
#ifdef WD_DEBUG
lw a0, 0(t0)
li a0, 0x0000006f
sb a0, 0(t0)
lb a0, 1(t0)
bal hexserial
nop
TTYDBG("\r\n")
li t0, 0xb0001000
lw a0, 0x0(t0)
#endif
TTYDBG("Watch dog decode enable\r\n")
dli t0, 0x90000cfdfe00a041
li a0, 0xff
sb a0, 0(t0)
lb a0, 0(t0)
bal hexserial
nop
TTYDBG("\r\n")
TTYDBG("Watch dog counter value\r\n")
li t0, 0xb0001000
lw a0, 0x8(t0)
TTYDBG("Watch dog control value\r\n")
dli t0, 0x90000c0000010000
sync
lw a0, 0(t0)
bal hexserial
nop
TTYDBG("\r\n")
#endif
li t0, 0xb0001000
li a0, 0x1
sw a0, 0x8(t0)
TTYDBG("Watch dog begin to work\r\n")
li t0, 0xb0001000
li t1, 0x1
sw t1, 0(t0)
li t1, 0x81
sw t1, 0(t0)
li t0, 0xb0001000
lw a0, 0x0(t0)
sync
lw a0, 4(t0)
bal hexserial
nop
TTYDBG("\r\n")
TTYDBG("Set Watch dog control value\r\n")
li a0, 0x15
sw a0, 4(t0)
nop
li a0, 0x01
sw a0, 0(t0)
nop
li a0, 0x81
sw a0, 0(t0)
nop
TTYDBG("Watch dog counter value\r\n")
li t0, 0xb0001000
li t1, 0x1
#if 0
1:
lw a0, 0x8(t0)
lw a0, 4(t0)
bal hexserial
nop
TTYDBG("\r\n")
lw a0, 0x8(t0)
lb a0, 4(t0)
bne a0, t1, 1b
nop
#endif
#endif
@ -829,6 +796,7 @@ ht_next_id :
dli t0, 0x90000cfdfb000000
li t1, 0x1f
1:
sync
lw a0, 0x44(t0)
#bal hexserial
nop
@ -842,6 +810,7 @@ ht_next_id :
li t1, 0x1f
3:
sync
lw a0, 0x44(t0)
li a1, 0x20
and a0, a0, a1
@ -850,6 +819,7 @@ ht_next_id :
nop
TTYDBG("\r\n")
sync
lw a0, 0x44(t0)
bal hexserial
nop
@ -861,6 +831,7 @@ ht_next_id :
dli t0, 0x90000cfdfb000000
li t1, 0x1f
1:
sync
lw a0, 0x44(t0)
#bal hexserial
nop
@ -874,6 +845,7 @@ ht_next_id :
li t1, 0x1f
3:
sync
lw a0, 0x44(t0)
li a1, 0x20
and a0, a0, a1
@ -882,20 +854,30 @@ ht_next_id :
nop
TTYDBG("\r\n")
sync
lw a0, 0x44(t0)
bal hexserial
nop
sync
lw a0, 0x48(t0)
bal hexserial
nop
TTYDBG("\r\n")
#endif
TTYDBG("\r\n")
#if 1
TTYDBG("Setting HyperTransport Southbridge back to be 8-bit width and 200Mhz for next RESET\r\n")
//li t0, 0xba000000
dli t0, 0x90000cfdfe000000
li t1, 0x00
sb t1, 0x4b(t0)
lw a0, 0x48(t0)
bal hexserial
sync
sb t1, 0xd1(t0)
sync
lw a0, 0xd0(t0)
sync
//bal hexserial
nop
TTYDBG("\r\n")
//li t1, 0x0
@ -915,6 +897,7 @@ crc_checking:
dli t0, 0x90000cfdfb000000
2:
sync
lw a0, 0x44(t0)
li a1, 0x300
and a0, a0, a1
@ -922,12 +905,14 @@ crc_checking:
beqz a0, 1f
nop
sync
lw a0, 0x44(t0)
bal hexserial
nop
TTYDBG("\r\nReset the Controller errror CRC bit\r\n")
nop
sync
lw a0, 0x44(t0)
li a1, 0xfffffcff
and a0, a0, a1
@ -945,6 +930,7 @@ crc_checking:
//li t0, 0xba000000
dli t0, 0x90000cfdfe000000
2:
sync
lw a0, 0x48(t0)
li a1, 0x300
and a0, a0, a1
@ -952,12 +938,14 @@ crc_checking:
beqz a0, 1f
nop
sync
lw a0, 0x48(t0)
bal hexserial
nop
TTYDBG("\r\nReset the Bridge errror CRC bit\r\n")
nop
sync
lw a0, 0x48(t0)
li a1, 0xfffffcff
and a0, a0, a1
@ -981,6 +969,7 @@ crc_checking:
#if 1//Read HT channel priority
TTYDBG("Read HT Channel priority\r\n")
dli t2, 0x90000cfdfb000000
sync
lw a0, 0x50(t2)
bal hexserial
nop
@ -1000,6 +989,7 @@ crc_checking:
nop
TTYDBG(" : ")
sync
lw a0, 0x0(t0)
bal hexserial
nop
@ -1040,6 +1030,7 @@ crc_checking:
nop
TTYDBG(" : ")
sync
lw a0, 0x0(t0)
bal hexserial
nop
@ -1160,6 +1151,7 @@ crc_checking:
li a0, 0xffff0000
sw a0, 0xb4(t0)
nop
sync
lw a0, 0xb4(t0)
bal hexserial
nop

107
Targets/Bonito2g690e/Bonito/pcitlb.S

@ -0,0 +1,107 @@
/*
* Now the function on 2g_+690e platform couldn't work
*/
li t0, 0x20000000
.set mips64
dmfc0 t1, COP_0_TLB_PG_MASK, 1
or t1, t1, t0
dmtc0 t1, COP_0_TLB_PG_MASK, 1
dmfc0 t0, COP_0_CONFIG, 3
ori t0, t0, 0x80
dmtc0 t0, COP_0_CONFIG, 3
.set mips3
li t0, 0xfff000
mtc0 t0, COP_0_TLB_PG_MASK # 16MB page
li t0, 15
li t3, 0xd0000000 # entry_hi
#dli t4, (0x00000e0010000000 >> 6)|0x17 # entry_lo, uncached, valid, dirty, global
li t4, 0x0e001000
#li t4, 0x0efdf000
.set mips64
dsll t4, t4, 10
.set mips3
ori t4, t4, 0x17
li t5, (0x1000000>>6) # 16M stride
li t6, 0x2000000 # VPN2 32M stride
.set mips64
1:
dmtc0 t3, COP_0_TLB_HI
daddu t3, t3, t6
dmtc0 t4, COP_0_TLB_LO0
daddu t4, t4, t5
dmtc0 t4, COP_0_TLB_LO1
daddu t4, t4, t5
.set mips3
mtc0 t0, COP_0_TLB_INDEX # 16MB page
nop
nop
nop
nop
nop
tlbwi # random++
bnez t0, 1b
addiu t0, t0, -1
###################################### Video RAM mapping ##########
li t0, 15
li t3, 0xf0000000 # entry_hi
#dli t4, (0x0000000070000000 >> 6)|0x1f # entry_lo, cached, valid, dirty, global
#if 1
li a0, 0x3f000000
bleu msize, a0, 1f
nop
li t4, 0x0000f000
b 2f
nop
#endif
1:
li t4, 0x00007000
2:
.set mips64
dsll t4, t4, 10
.set mips3
ori t4, t4, 0x1f
li t5, (0x1000000>>6) # 16M stride
li t6, 0x2000000 # VPN2 32M stride
.set mips64
1:
dmtc0 t3, COP_0_TLB_HI
daddu t3, t3, t6
dmtc0 t4, COP_0_TLB_LO0
daddu t4, t4, t5
dmtc0 t4, COP_0_TLB_LO1
daddu t4, t4, t5
.set mips3
addiu t1, t0, 16
mtc0 t1, COP_0_TLB_INDEX # 16MB page
nop
nop
nop
nop
nop
tlbwi
bnez t0, 1b
addiu t0, t0, -1

14
Targets/Bonito2g690e/Bonito/start.S

@ -1034,6 +1034,12 @@ gs_2f_v3_ddr2_cfg:
TTYDBG("Init tlb...\r\n")
bal tlb_init
nop
#if 1 /* TLB init */
TTYDBG("Init htpcitlb...\r\n")
#include "pcitlb.S" /* Fixme */
#endif
//TTYDBG("Init caches...\r\n")
#if 1
@ -1223,8 +1229,8 @@ bootnow:
la a0, start
li a1, 0xbfc00000
la a2, _edata
or a0, 0xa0000000
or a2, 0xa0000000
// or a0, 0xa0000000
// or a2, 0xa0000000
subu t1, a2, a0
srl t1, t1, 2
@ -1269,8 +1275,8 @@ zhb:
la a0, start
li a1, 0xbfc00000
la a2, _edata
or a0, 0xa0000000
or a2, 0xa0000000
// or a0, 0xa0000000
// or a2, 0xa0000000
/* subu s6, a2, a0*/
/* srl s6, s6, 2*/

46
Targets/Bonito2g690e/Bonito/tgt_machdep.c

@ -125,6 +125,7 @@ extern void *memset(void *, int, size_t);
int kbd_available;
int usb_kbd_available;;
int vga_available;
int vga_ok = 0;
static int md_pipefreq = 0;
static int md_cpufreq = 0;
@ -552,8 +553,7 @@ initmips(unsigned int memsz)
* is done after console has been initialized so it's safe
* to output configuration and debug information with printf.
*/
extern void vt82c686_init(void);
int psaux_init(void);
extern int psaux_init(void);
extern int video_hw_init (void);
extern int fb_init(unsigned long,unsigned long);
@ -571,6 +571,11 @@ tgt_devconfig()
#if (NMOD_X86EMU_INT10 > 0)||(NMOD_X86EMU >0)
SBD_DISPLAY("VGAI", 0);
rc = vga_bios_init();
#if defined(VESAFB)
SBD_DISPLAY("VESA", 0);
if(rc > 0)
vesafb_init();
#endif
#endif
#if (NMOD_X86EMU_INT10 == 0 && defined(RADEON7000))
SBD_DISPLAY("VGAI", 0);
@ -588,12 +593,11 @@ tgt_devconfig()
fbaddress = fbaddress &0xffffff00; //laster 8 bit
ioaddress = ioaddress &0xfffffff0; //laster 4 bit
printf("fbaddress 0x%x\tioaddress 0x%x\n",fbaddress, ioaddress);
#if NMOD_SISFB
fbaddress=sisfb_init_module();
#endif
printf("fbaddress 0x%x\tioaddress 0x%x\n",fbaddress, ioaddress);
#if NMOD_SMI712 > 0
fbaddress |= 0xb0000000;
//ioaddress |= 0xbfd00000;
@ -608,6 +612,21 @@ tgt_devconfig()
fbaddress |= 0xb0000000;
ioaddress |= 0xb0000000;
#endif
#if (SHARED_VRAM == 128)
fbaddress = 0xf8000000;//64M graph memory
#elif (SHARED_VRAM == 64)
fbaddress = 0xf8000000;//64M graph memory
#elif (SHARED_VRAM == 32)
fbaddress = 0xfe000000;//32 graph memory
#endif
/* lwg add.
* The address mapped from 0x10000000 to 0xf800000
* wouldn't work through tlb.
_*/
fbaddress = 0xb0000000; /* FIXME */
printf("begin fb_init\n");
fb_init(fbaddress, ioaddress);
printf("after fb_init\n");
@ -619,12 +638,21 @@ tgt_devconfig()
#if (NMOD_FRAMEBUFFER > 0) || (NMOD_VGACON > 0 )
if (rc > 0)
if(!getenv("novga")) vga_available=1;
else vga_available=0;
if(!getenv("novga"))
vga_available = 1;
else
vga_available = 0;
#endif
config_init();
configure();
//#if ((NMOD_VGACON >0) &&(PCI_IDSEL_VIA686B !=0)|| (PCI_IDSEL_CS5536 !=0))
/* rs690 pcie part post init */
pcie_post_init();
/* rs690 NB part post init */
nb_post_init();
/* sb600 last init routine */
sb_last_init();
#if NMOD_VGACON >0
if(getenv("nokbd")) rc=1;
else {
@ -632,8 +660,8 @@ tgt_devconfig()
rc=kbd_initialize();
}
printf("%s\n",kbd_error_msgs[rc]);
if(!rc){
kbd_available=1;
if (!rc) {
kbd_available = 1;
}
// psaux_init();
#endif

7614
Targets/Bonito2g690e/Bonito/vgarom.c

File diff suppressed because it is too large

32
Targets/Bonito2g690e/conf/Bonito.2g690e

@ -26,12 +26,27 @@ option LS2G_AMD
option MIPS
option INET
option LS2G_HT # Enable the IO cache coherent of HT
select amd_690e
#option USE_LPC_UART
#option MULTI_CHIP
#select sis_761e
select amd_690e
## VGA option ##
option RS690
option VGA_NO_ROM
option VGA_BASE=0xbe000000
option SHARED_VRAM=64
option GPU_UMA
option VESAFB
#option DEBUG_EMU_VGA
#select mod_x86emu # X86 emulation for VGA
select mod_x86emu_int10
select mod_framebuffer
select mod_vesa
select mod_vgacon
##############
## misc refer ##
select mod_flash_amd # AMD flash device programming
select mod_flash_intel # intel flash device programming
select mod_flash_sst # intel flash device programming
@ -46,7 +61,7 @@ select mod_elfload # ELF loading
#
select cmd_newmt
select cmd_setup
select mod_display
#select mod_display
select cmd_about # Display info about PMON
select cmd_boot # Boot wrapper
select cmd_mycmd
@ -81,10 +96,8 @@ select mod_uart_ns16550 # Standard UART driver
option CONS_BAUD=B115200
select ext2
#select fatfs
#select mod_x86emu # X86 emulation for VGA
option MY40IO
#select mod_x86emu_int10
select mod_vgacon
#option MY40IO
option NOPCINAMES # Save some space for x86emu
#option FASTBOOT
#select vt82c686 #via686a/b code
@ -127,9 +140,6 @@ pci* at pcibr?
ppb* at pci? dev ? function ? # PCI-PCI bridges
pci* at ppb? bus ?
#### USB
#uhci* at pci? dev ? function ?
#### SCSI support
#siop* at pci? dev ? function ? # Symbios/NCR 53c...
#scsibus* at siop?
@ -147,6 +157,8 @@ inphy* at mii? phy ? # Intel 82555 PHYs
rtk* at pci? dev ? function ?
#em* at pci? dev ? function ?
rte* at pci? dev ? function ?
#####USB Devices######
#uhci* at pci? dev ? function ?
#ohci0 at pci? dev ? function ?
#usb* at usbbus ?

6
Targets/Bonito2g690e/pci/pci_machdep.c

@ -91,7 +91,7 @@ _pci_hwinit(initialise, iot, memt)
/*
* Allocate and initialize PCI bus heads.
*/
pci_local_mem_pci_base= PCI_LOCAL_MEM_PCI_BASE;
/*
* PCI Bus 0
*/
@ -116,9 +116,9 @@ _pci_hwinit(initialise, iot, memt)
_pci_head = pd;
#ifdef LS2G_HT /* whd */
pb->minpcimemaddr = BONITO_PCILO1_BASE;
pb->minpcimemaddr = BONITO_PCILO0_BASE;
pb->nextpcimemaddr = BONITO_PCILO1_BASE+BONITO_PCILO_SIZE;
pb->minpciioaddr = PCI_IO_SPACE_BASE+0x000b000;
pb->minpciioaddr = PCI_IO_SPACE_BASE+0x0009000;
pb->nextpciioaddr = PCI_IO_SPACE_BASE+ BONITO_PCIIO_SIZE;
pb->pci_mem_base = BONITO_PCILO_BASE_VA;
pb->pci_io_base = BONITO_PCIIO_BASE_VA;

13
Targets/Bonito2g690e/pci/rs690/nb_pre.c

@ -34,6 +34,8 @@
/*---------------------------------------------------------------------*/
extern int memorysize_high;
/*
* nb_pre_init :
* NorthBridge init before PCI emulation
@ -42,7 +44,7 @@ void nb_pre_init(void)
{
pcitag_t nb_dev = _pci_make_tag(0, 0, 0);
DEBUG_INFO("+++++++++++++++++++++++++++++++++++++++++++++++++ NB PRE STAGE ++++++++++++++++++++++++++++++++++++\n");
DEBUG_INFO("+++++++++++++++++++++++++++++++++++++++++++++++ NB PRE STAGE ++++++++++++++++++++++++++++++++++++\n");
/* disable NB_BAR2_PM2 */
set_nbcfg_enable_bits(nb_dev, 0x4C, 1 << 17, 0 << 17);
@ -50,12 +52,19 @@ void nb_pre_init(void)
/* make preparation for pci_nb_cfg struct */
ati_nb_cfg.nb_revision = get_nb_revision();
/* Readjust the size of system_memory_tom_lo */
if(memorysize_high > (1000 << 20))
ati_nb_cfg.system_memory_tom_lo = 0x1000;
else
//ati_nb_cfg.system_memory_tom_lo = 0x800;
ati_nb_cfg.system_memory_tom_lo = 0x7c0;
/* setting TOM LOW basically */
_pci_conf_write(nb_dev, 0x90, ati_nb_cfg.system_memory_tom_lo << 20);
/* gfx pre init */
#if defined(CFG_UMA_SUPPORT) || defined (CFG_SP_SUPPORT)
gfx_pre_init();
gfx_pre_init();
#endif
/* report UMA information to user */

2
conf/files

@ -274,6 +274,7 @@ file x86emu/int10/helper_exec.c mod_x86emu_int10 needs-flag
file x86emu/int10/helper_mem.c mod_x86emu_int10 needs-flag
file x86emu/int10/xf86int10.c mod_x86emu_int10 needs-flag
file x86emu/int10/xf86x86emu.c mod_x86emu_int10 needs-flag
file x86emu/int10/rs690_struct.c mod_x86emu_int10 needs-flag
file x86emu/src/x86emu/debug.c mod_x86emu needs-flag
file x86emu/src/x86emu/decode.c mod_x86emu needs-flag
@ -287,6 +288,7 @@ file x86emu/src/biosemu/bios.c mod_x86emu needs-flag
file x86emu/src/biosemu/linuxpci.c mod_x86emu needs-flag
file x86emu/src/biosemu/biosemu.c mod_x86emu needs-flag
file x86emu/src/biosemu/freebiosvga.c mod_x86emu needs-flag
file x86emu/int10/vesafb.c mod_vesa & mod_framebuffer needs-flag
file fb/cfb_console.c mod_framebuffer needs-flag
file pmon/dev/kbd.c mod_vgacon needs-flag

11
fb/cfb_console.c

@ -1599,10 +1599,17 @@ int fb_init (unsigned long fbbase,unsigned long iobase)
pGD->winSizeX = 320;
pGD->winSizeY = 240;
#else
#if !defined(FB_XSIZE)
#define FB_XSIZE 800
#endif
#if !defined(FB_YSIZE)
#define FB_YSIZE 600
#endif
pGD->winSizeX = FB_XSIZE;
pGD->winSizeY = FB_YSIZE;
#endif
#endif
#if defined(CONFIG_VIDEO_1BPP)
pGD->gdfIndex = GDF__1BIT;
pGD->gdfBytesPP= 1;

9
sys/linux/io.h

@ -101,11 +101,14 @@ static inline unsigned char linux_inb_p(unsigned long port)
return __val;
}
#if !defined(LS2G_AMD) /* modify for x86emu */
#define readb(addr) (*(volatile unsigned char *)(0xa0000000|(long)(addr)))
#define readw(addr) ((*(volatile unsigned short *)(0xa0000000|(long)(addr))))
#define readl(addr) ((*(volatile unsigned int *)(0xa0000000|(long)(addr))))
#else
#define readb(addr) (*(volatile unsigned char *)(0x00000000|(long)(addr)))
#define readw(addr) ((*(volatile unsigned short *)(0x00000000|(long)(addr))))
#define readl(addr) ((*(volatile unsigned int *)(0x00000000|(long)(addr))))
#endif
#endif /* __LINUXIO_H_ */

896
x86emu/int10/generic.c

@ -13,35 +13,19 @@
#include "xf86x86emu.h"
#include "linux/io.h"
#include "mod_framebuffer.h"
#include "vesa.h"
#ifdef BONITOEL
# define vgaram_base 0xb00a0000
#endif
#ifdef CONFIG_PCI0_GAINT_MEM
# define vgaram_base 0xbeea0000
#endif
#ifdef CONFIG_PCI0_HUGE_MEM
# define vgaram_base 0xb48a0000
#endif
#ifdef CONFIG_PCI0_LARGE_MEM
# define vgaram_base 0xb50a0000
#endif
#ifndef vgaram_base
# define vgaram_base 0xb00a0000
#endif
#define vgaram_base (VGA_BASE + 0xa0000)
#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1)
static CARD8 read_b(xf86Int10InfoPtr pInt,int addr);
static CARD16 read_w(xf86Int10InfoPtr pInt,int addr);
static CARD32 read_l(xf86Int10InfoPtr pInt,int addr);
static void write_b(xf86Int10InfoPtr pInt,int addr, CARD8 val);
static void write_w(xf86Int10InfoPtr pInt,int addr, CARD16 val);
static void write_l(xf86Int10InfoPtr pInt,int addr, CARD32 val);
static CARD8 read_b(xf86Int10InfoPtr pInt, int addr);
static CARD16 read_w(xf86Int10InfoPtr pInt, int addr);
static CARD32 read_l(xf86Int10InfoPtr pInt, int addr);
static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val);
static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val);
static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val);
/*
* the emulator cannot pass a pointer to the current xf86Int10InfoRec
@ -49,412 +33,464 @@ static void write_l(xf86Int10InfoPtr pInt,int addr, CARD32 val);
*/
typedef struct {
int shift;
int entries;
void* base;
void* vRam;
void* sysMem;
char* alloc;
int shift;
int entries;
void *base;
void *vRam;
void *sysMem;
char *alloc;
} genericInt10Priv;
#define INTPriv(x) ((genericInt10Priv*)x->private)
int10MemRec genericMem = {
read_b,
read_w,
read_l,
write_b,
write_w,
write_l
read_b,
read_w,
read_l,
write_b,
write_w,
write_l
};
static void *sysMem = NULL;
#define CRT_C 24 /* 24 CRT Controller Registers */
#define ATT_C 21 /* 21 Attribute Controller Registers */
#define GRA_C 9 /* 9 Graphics Controller Registers */
#define SEQ_C 5 /* 5 Sequencer Registers */
#define MIS_C 1 /* 1 Misc Output Register */
#define CRT_C 24 /* 24 CRT Controller Registers */
#define ATT_C 21 /* 21 Attribute Controller Registers */
#define GRA_C 9 /* 9 Graphics Controller Registers */
#define SEQ_C 5 /* 5 Sequencer Registers */
#define MIS_C 1 /* 1 Misc Output Register */
/* VGA registers saving indexes */
#define CRT 0 /* CRT Controller Registers start */
#define ATT (CRT+CRT_C) /* Attribute Controller Registers start */
#define GRA (ATT+ATT_C) /* Graphics Controller Registers start */
#define SEQ (GRA+GRA_C) /* Sequencer Registers */
#define MIS (SEQ+SEQ_C) /* General Registers */
#define EXT (MIS+MIS_C) /* SVGA Extended Registers */
void vgadelay()
#define CRT 0 /* CRT Controller Registers start */
#define ATT (CRT+CRT_C) /* Attribute Controller Registers start */
#define GRA (ATT+ATT_C) /* Graphics Controller Registers start */
#define SEQ (GRA+GRA_C) /* Sequencer Registers */
#define MIS (SEQ+SEQ_C) /* General Registers */
#define EXT (MIS+MIS_C) /* SVGA Extended Registers */
static void vgadelay(void)
{
int i;
for(i=0;i<10;i++);
int i;
for (i = 0; i < 10; i++) ;
}
static unsigned char regs[60] = {
0x5F,0x4F,0x50,0x02,0x55,0x81,0xBF,0x1F, /* CR00-CR18 */
0x00,0x4F,0x0D,0x0E,0x0,0x0,0x0,0x0,
0x9C,0x00,0x8F,0x28,0x1F,0x96,0xB9,0xA3,
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, /* AR00-AR15 */
0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
0x0C,0x00,0x0F,0x08,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x0E,0x00, /* GR00-GR05 */
0xFF,
0x03,0x00,0x03,0x00,0x02, /* SR00-SR05 */
0x67, /* MISC_OUT */
0x5F, 0x4F, 0x50, 0x02, 0x55, 0x81, 0xBF, 0x1F, /* CR00-CR18 */
0x00, 0x4F, 0x0D, 0x0E, 0x0, 0x0, 0x0, 0x0,
0x9C, 0x00, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* AR00-AR15 */
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x0C, 0x00, 0x0F, 0x08, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, /* GR00-GR05 */
0xFF,
0x03, 0x00, 0x03, 0x00, 0x02, /* SR00-SR05 */
0x67, /* MISC_OUT */
};
static void outseq(int index, unsigned char val)
{
linux_outb(index, 0x3c4);
linux_outb(val, 0x3c5);
}
static unsigned char inseq(unsigned char index)
{
linux_outb(index, 0x3c4);
return linux_inb(0x3c5);
}
static void outcrtc(int index, unsigned char val)
{
linux_outb(index, 0x3d4);
linux_outb(val, 0x3d5);
}
static unsigned char incrtc(int index)
{
linux_outb(index, 0x3d4);
return linux_inb(0x3d5);
}
static void outgra(int index, unsigned char val)
{
linux_outb(index, 0x3ce);
linux_outb(val, 0x3cf);
}
static unsigned char ingra(int index)
{
linux_outb(index, 0x3ce);
return linux_inb(0x3cf);
}
static void outatt(int index, unsigned char val)
{
linux_inb(0x3da);
vgadelay();
linux_outb(index, 0x3c0);
vgadelay();
linux_outb(val, 0x3c0);
vgadelay();
}
static unsigned char inatt(int index)
{
linux_inb(0x3da);
vgadelay();
linux_outb(index, 0x3c0);
vgadelay();
return linux_inb(0x3c1);
}
static void setregs(const unsigned char *regs)
{
int i;
unsigned char val;
// misc
linux_outb(regs[MIS], 0x3c2);
// seq
outseq(0x0, 0x1);
outseq(0x01, regs[SEQ + 1] | 0x20);
outseq(0x01, regs[SEQ + 1] | 0x20);
for (i = 2; i < SEQ_C; i++) {
outseq(i, regs[SEQ + i]);
}
outseq(0x0, 0x3);
// crtc
// write enable
val = incrtc(0x11);
val &= 0x7F;
outcrtc(0x11, val);
// crtc setting
for (i = 0; i < CRT_C; i++) {
outcrtc(i, regs[CRT + i]);
}
// gra
for (i = 0; i < GRA_C; i++) {
outgra(i, regs[GRA + i]);
}
// att
for (i = 0; i < ATT_C; i++) {
outatt(i, regs[ATT + i]);
}
outseq(0x01, regs[SEQ + 1] & 0xDF);
linux_inb(0x3da);
vgadelay();
linux_outb(0x20, 0x3c0);
// misc readback
vgadelay();
linux_outb(0x67, 0x3c2);
}
extern struct pci_device *vga_dev;
static void outseq(int index, unsigned char val)
{
linux_outb(index, 0x3c4);
linux_outb(val, 0x3c5);
}
static unsigned char inseq(unsigned char index)
{
linux_outb(index, 0x3c4);
return linux_inb(0x3c5);
}
int vga_available =0 ;
static void outcrtc(int index, unsigned char val)
{
linux_outb(index, 0x3d4);
linux_outb(val, 0x3d5);
}
static unsigned char incrtc(int index)
{
linux_outb(index, 0x3d4);
return linux_inb(0x3d5);
}
static void outgra(int index, unsigned char val)
{
linux_outb(index, 0x3ce);
linux_outb(val, 0x3cf);
}
static unsigned char ingra(int index)
{
linux_outb(index, 0x3ce);
return linux_inb(0x3cf);
}
static void outatt(int index, unsigned char val)
{
linux_inb(0x3da);
vgadelay();
linux_outb(index, 0x3c0);
vgadelay();
linux_outb(val, 0x3c0);
vgadelay();
}
static unsigned char inatt(int index)
{
linux_inb(0x3da);
vgadelay();
linux_outb(index, 0x3c0);
vgadelay();
return linux_inb(0x3c1);
}
static void setregs(const unsigned char *regs)
{
int i;
unsigned char val;
// misc
linux_outb(regs[MIS], 0x3c2);
// seq
outseq(0x0, 0x1);
outseq(0x01, regs[SEQ + 1] | 0x20);
outseq(0x01, regs[SEQ + 1] | 0x20);
for (i = 2; i < SEQ_C; i++) {
outseq(i, regs[SEQ + i]);
}
outseq(0x0, 0x3);
// crtc
// write enable
val = incrtc(0x11);
val &= 0x7F;
outcrtc(0x11, val);
// crtc setting
for (i = 0; i < CRT_C; i++) {
outcrtc(i, regs[CRT + i]);
}
// gra
for (i = 0; i < GRA_C; i++) {
outgra(i, regs[GRA + i]);
}
// att
for (i = 0; i < ATT_C; i++) {
outatt(i, regs[ATT + i]);
}
outseq(0x01, regs[SEQ + 1] & 0xDF);
linux_inb(0x3da);
vgadelay();
linux_outb(0x20, 0x3c0);
// misc readback
vgadelay();
linux_outb(0x67, 0x3c2);
}
extern struct pci_device *vga_dev;
extern int vga_available;
extern int novga;
extern int vesa_mode;
extern struct vesamode *vesa_mode_head;
int vga_bios_init(void)
{
xf86Int10InfoPtr pInt;
int screen;
void* base = 0;
void* vbiosMem = 0;
legacyVGARec vga;
pInt = (xf86Int10InfoPtr)malloc(sizeof(xf86Int10InfoRec));
memset(pInt, 0, sizeof(xf86Int10InfoRec));
if (!xf86Int10ExecSetup(pInt))
goto error0;
pInt->mem = &genericMem;
pInt->private = (pointer)malloc(sizeof(genericInt10Priv));
memset(pInt->private, 0, sizeof(genericInt10Priv));
pInt->scrnIndex = 0; /* screen */
xf86Int10InfoPtr pInt;
int screen;
void *base = 0;
void *vbiosMem = 0;
legacyVGARec vga;
pInt = (xf86Int10InfoPtr) malloc(sizeof(xf86Int10InfoRec));
//pInt = (xf86Int10InfoPtr) calloc(1,sizeof(xf86Int10InfoRec));
memset(pInt, 0, sizeof(xf86Int10InfoRec));
if (!xf86Int10ExecSetup(pInt))
goto error0;
pInt->mem = &genericMem;
pInt->private = (pointer) malloc(sizeof(genericInt10Priv));
//pInt->private = (pointer) calloc(1,sizeof(genericInt10Priv));
memset(pInt->private, 0, sizeof(genericInt10Priv));
pInt->scrnIndex = 0; /* screen */
base = INTPriv(pInt)->base = malloc(0x100000);
//base = INTPriv(pInt)->base = 0x80000000+memorysize-0x100000;
base = INTPriv(pInt)->base = malloc(0x100000);
{
unsigned int val;
if(vga_dev==NULL){
printf("===no vga==\n");
return -1;
}
/* enable VGA legacy space decode */
val = _pci_conf_read(vga_dev->parent->pa.pa_tag, 0x3c);
val |= 1 << 19;
_pci_conf_write(vga_dev->parent->pa.pa_tag, 0x3c, val);
/* reallocate the prefetchable address */
}
/*
* we need to map video RAM MMIO as some chipsets map mmio
* registers into this range.
*/
INTPriv(pInt)->vRam=(void*)vgaram_base;
if (!sysMem) {
sysMem = malloc(BIOS_SIZE);
setup_system_bios(sysMem);
}
INTPriv(pInt)->sysMem = sysMem;
printf("memorysize=%lx,base=%lx,sysMem=%lx,vram=%lx\n",memorysize,INTPriv(pInt)->base,sysMem,INTPriv(pInt)->vRam);
printf("set up int\n");
setup_int_vect(pInt);
printf("set return trap\n");
set_return_trap(pInt);
vbiosMem = (char *)base + V_BIOS;
(void)memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
{
struct pci_device *pdev;
unsigned long romsize = 0;
unsigned long romaddress = 0;
unsigned char magic[2];
unsigned short ppcidata; /* pointer to pci data structure */
unsigned char pcisig[4]; /* signature of pci data structure */
unsigned char codetype;
if (vga_dev!=NULL)
{
pdev=vga_dev;
printk("Found VGA device: vendor=0x%04x, device=0x%04x\n", PCI_VENDOR(pdev->pa.pa_id),pdev->pa.pa_device);
}
else return -1;
if (PCI_VENDOR(pdev->pa.pa_id) == 0x102b) {
printk("skipping matrox cards\n");
return -1;
}
//if (PCI_VENDOR(pdev->pa.pa_id) == 0x1002 && pdev->pa.pa_device == 0x4750)
if (PCI_VENDOR(pdev->pa.pa_id) == 0x1002 && PCI_PRODUCT(pdev->pa.pa_id) == 0x4750)
MEM_WW(pInt,0xc015e,0x4750);
romaddress =_pci_conf_read(pdev->pa.pa_tag,0x30);
romaddress &= (~0x1);
/* enable rom address decode */
_pci_conf_write(pdev->pa.pa_tag,0x30,romaddress|1);
#if defined(LONGMENG)||defined(BONITOEL_CPCI)//||defined(NC2E)
{
extern unsigned char vgarom[];
romaddress = vgarom;
}
//#if 0
#ifdef RS690
{
pcitag_t vga_bridge = _pci_make_tag(0, 1, 0);
unsigned int val;
/* enable VGA legacy space decode */
val = _pci_conf_read(vga_bridge, 0x3c);
val |= 1 << 19;
_pci_conf_write(vga_bridge, 0x3c, val);
/* reallocate the prefetchable address */
#if 0
//_pci_conf_write(vga_bridge, 0x20, 0x16101600);
//_pci_conf_write(vga_bridge, 0x24, 0x15f01400);
printf("\n\nvga_bridge, 0x20=%x,0x24=%x\n\n\n",
_pci_conf_read(vga_bridge, 0x20),_pci_conf_read(vga_bridge, 0x24));
_pci_conf_write(vga_bridge, 0x20, 0x12101200);
_pci_conf_write(vga_bridge, 0x24, 0x11f01000);
#else
if (romaddress == 0) {
printk("No rom address assigned,skipped\n");
return -1;
}
#ifdef BONITOEL
//romaddress|=0x10000000;
/* using the old one */
#endif
}
#endif
#ifdef NC2E
if(!getenv("vga1"))
{
/*
* we need to map video RAM MMIO as some chipsets map mmio
* registers into this range.
*/
INTPriv(pInt)->vRam = (void *)vgaram_base;
if (!sysMem) {
sysMem = malloc(BIOS_SIZE);
setup_system_bios(sysMem);
}
INTPriv(pInt)->sysMem = sysMem;
printf("memorysize=%x,base=%lx,sysMem=%lx,vram=%lx\n", memorysize,
INTPriv(pInt)->base, sysMem, INTPriv(pInt)->vRam);
setup_int_vect(pInt);
set_return_trap(pInt);
vbiosMem = (char *)base + V_BIOS;
(void)memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
{
struct pci_device *pdev;
unsigned long romsize = 0;
unsigned long romaddress = 0;
unsigned char magic[2];
unsigned short ppcidata; /* pointer to pci data structure */
unsigned char pcisig[4]; /* signature of pci data structure */
unsigned char codetype;
if (vga_dev != NULL) {
pdev = vga_dev;
printk
("Found VGA device: vendor=0x%04x, device=0x%04x\n",
PCI_VENDOR(pdev->pa.pa_id),
PCI_PRODUCT(pdev->pa.pa_id));
} else
return -1;
if (PCI_VENDOR(pdev->pa.pa_id) == 0x102b) {
printk("skipping matrox cards\n");
return -1;
}
if (PCI_VENDOR(pdev->pa.pa_id) == 0x1002
&& PCI_PRODUCT(pdev->pa.pa_id) == 0x4750)
MEM_WW(pInt, 0xc015e, 0x4750);
romaddress = _pci_conf_read(pdev->pa.pa_tag, 0x30);
romaddress &= (~1);
/* enable rom address decode */
_pci_conf_write(pdev->pa.pa_tag, 0x30, romaddress | 1);
#if defined(RADEON7000) || defined(RS690) || defined(VESAFB)
{
extern unsigned char vgarom[];
romaddress = vgarom;
unsigned char *tmp;
romaddress = (unsigned long)vgarom;
tmp = (unsigned char *)vgarom;
printk("Here after vgarom romaddress:%x\n",tmp[4]);
printk(" vgarom romaddress:0x%x\n",romaddress);
}
#endif
if (romaddress == 0) {
printk("No rom address assigned,skipped\n");
return -1;
}
#if defined(BONITOEL) && !( defined(RADEON7000) || defined(VESAFB) || defined(RS690) )
romaddress |= 0x10000000;
#endif
printk("Rom base addr: %lx\n", romaddress);
#ifdef LS3_HT
magic[0] = *(unsigned char *)(romaddress);
magic[1] = *(unsigned char *)(romaddress + 1);
#else
magic[0] = readb(romaddress);
magic[1] = readb(romaddress + 1);
#endif
printk("Rom base addr: %lx\n",romaddress);
magic[0] = readb(romaddress);
magic[1] = readb(romaddress + 1);
if (magic[0]==0x55 && magic[1]==0xaa) {
printk("VGA bios found\n");
/* rom size is stored at offset 2,in 512 byte unit*/
romsize = (readb(romaddress + 2)) * 512;
printk("rom size is %ldk\n",romsize/1024);
ppcidata = readw(romaddress + 0x18);
printk("PCI data structure at offset %x\n",ppcidata);
pcisig[0] = readb(romaddress + ppcidata);
pcisig[1] = readb(romaddress + ppcidata + 1);
pcisig[2] = readb(romaddress + ppcidata + 2);
pcisig[3] = readb(romaddress + ppcidata + 3);
if (pcisig[0]!='P' || pcisig[1]!='C' ||
pcisig[2]!='I' || pcisig[3]!='R') {
printk("PCIR expected,read %c%c%c%c\n",
pcisig[0],pcisig[1],pcisig[2],pcisig[3]);
printk("Invalid pci signature found,give up\n");
return -1;
}
codetype = readb(romaddress + ppcidata + 0x14);
if (codetype != 0) {
printk("Not x86 code in rom,give up\n");
return -1;
}
} else {
printk("No valid bios found,magic=%x%x\n",magic[0],magic[1]);
return -1;
}
pInt->pdev = pdev;
memcpy(vbiosMem,(char *)(0xa0000000|romaddress),V_BIOS_SIZE);
#ifndef BONITOEL_CPCI
if (PCI_VENDOR(pdev->pa.pa_id) == 0x1002 && pdev->pa.pa_device == 0x4750)
MEM_WW(pInt,0xc015e,0x4750) ;
if (magic[0] == 0x55 && magic[1] == 0xaa) {
printk("VGA bios found\n");
/* rom size is stored at offset 2,in 512 byte unit */
#ifdef LS3_HT
romsize = (*(unsigned char *)(romaddress + 2)) * 512;
#else
romsize = (readb(romaddress + 2)) * 512;
#endif
}
pInt->BIOSseg = V_BIOS >> 4;
pInt->num = 0xe6;
printf("lock vga\n");
#ifndef DEVBD2E
//LockLegacyVGA(screen, &vga);
printk("rom size is %ldk\n", romsize / 1024);
#ifdef LS3_HT
ppcidata = *(unsigned int *)(romaddress + 0x18);
printk("PCI data structure at offset %x\n", ppcidata);
pcisig[0] = *(unsigned char *)(romaddress + ppcidata);
pcisig[1] = *(unsigned char *)(romaddress + ppcidata + 1);
pcisig[2] = *(unsigned char *)(romaddress + ppcidata + 2);
pcisig[3] = *(unsigned char *)(romaddress + ppcidata + 3);
#else
ppcidata = readw(romaddress + 0x18);
printk("PCI data structure at offset %x\n", ppcidata);
pcisig[0] = readb(romaddress + ppcidata);
pcisig[1] = readb(romaddress + ppcidata + 1);
pcisig[2] = readb(romaddress + ppcidata + 2);
pcisig[3] = readb(romaddress + ppcidata + 3);
#endif
printf("starting bios emu...\n");
//if(getenv("vgadebug")) X86EMU_trace_on();
printf("ax=%lx,bx=%lx,cx=%lx,dx=%lx\n",pInt->ax,pInt->bx,pInt->cx,pInt->dx);
xf86ExecX86int10(pInt);
printf("bios emu done\n");
#if 0
pInt->num = 0x10;
pInt->ax = 0x03;
xf86ExecX86int10(pInt);
if (pcisig[0] != 'P' || pcisig[1] != 'C' ||
pcisig[2] != 'I' || pcisig[3] != 'R') {
printk("PCIR expected,read %c%c%c%c\n",
pcisig[0], pcisig[1], pcisig[2],
pcisig[3]);
printk("Invalid pci signature found,give up\n");
return -1;
}
#ifdef LS3_HT
codetype = *(unsigned char *)(romaddress + ppcidata + 0x14);
#else
codetype = readb(romaddress + ppcidata + 0x14);
#endif
#ifndef DEVBD2E
//UnlockLegacyVGA(screen, &vga);
if (codetype != 0) {
printk("Not x86 code in rom,give up\n");
return -1;
}
#ifdef RS690
// fixup PCI ID
//*((volatile unsigned int *)(0xa0000000 | (romaddress + ppcidata + 4))) = _pci_conf_read(pdev->pa.pa_tag, 0x00);
*((volatile unsigned int *)((romaddress + ppcidata + 4))) = _pci_conf_read(pdev->pa.pa_tag, 0x00);
#endif
setregs(regs);
//linux_outb(0x67,0x3c2);
} else {
printk("No valid bios found,magic=%x%x\n", magic[0],
magic[1]);
return -1;
}
pInt->pdev = pdev;
memcpy(vbiosMem, (char *)(0x00000000 | romaddress),
V_BIOS_SIZE);
if (PCI_VENDOR(pdev->pa.pa_id) == 0x1002
&& PCI_PRODUCT(pdev->pa.pa_id) == 0x4750)
MEM_WW(pInt, 0xc015e, 0x4750);
}
#if 0
setregs(regs);
#else
pInt->BIOSseg = V_BIOS >> 4;
pInt->num = 0xe6;
printf("lock vga\n");
//LockLegacyVGA(screen, &vga);
printf("starting bios emu...\n");
M.x86.debug |= /*DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F | DEBUG_MEM_TRACE_F */ DEBUG_IO_TRACE_F | DEBUG_DECODE_F;
//X86EMU_trace_on();
printf("end of trace ......................................\n");
printf("ax=%lx,bx=%lx,cx=%lx,dx=%lx\n", pInt->ax, pInt->bx, pInt->cx, pInt->dx);
xf86ExecX86int10(pInt);
printf("just before emu done ax(0x%x)\n", pInt->ax);
printf("bios emu done\n");
#if 0
pInt->num = 0x10;
pInt->ax = 0x03;
xf86ExecX86int10(pInt);
#endif
//UnlockLegacyVGA(screen, &vga);
setregs(regs);
//linux_outb(0x67, 0x3c2);
#if NMOD_FRAMEBUFFER == 0
printf("setting text mode...\n");
//X86EMU_trace_on();
pInt->BIOSseg = V_BIOS >> 4;
pInt->num = 0x10;
pInt->ax = 0x0003;
xf86ExecX86int10(pInt);
printf("setting text mode...\n");
//X86EMU_trace_on();
pInt->BIOSseg = V_BIOS >> 4;
pInt->num = 0x10;
pInt->ax = 0x0003;
xf86ExecX86int10(pInt);
#else
printf("setting fb mode...\n");
pInt->BIOSseg = V_BIOS >> 4;
pInt->num = 0x10;
pInt->ax = 0x4f02;
pInt->bx = 0x4114;
xf86ExecX86int10(pInt);
if (pInt->ax != 0x004f)
printk("set vesa mode failed,ax=%x\n",pInt->ax);
#ifdef DEBUG
pInt->ax = 0x4f01; /* get mode information */
pInt->cx = 0x4114;
pInt->di = 0;
pInt->es = 0;
xf86ExecX86int10(pInt);
if (pInt->ax != 0x004f)
printk("get vesa mode info failed,ax=%x\n",pInt->ax);
printk("linelength=%x\n",MEM_RW(pInt,pInt->di+16));
printk("width=%x\n",MEM_RW(pInt,pInt->di+18));
printk("height=%x\n",MEM_RW(pInt,pInt->di+20));
printk("depth=%x\n",MEM_RB(pInt,pInt->di+25));
printk("pages=%x\n",MEM_RB(pInt,pInt->di+29));
printk("base=%x\n",MEM_RL(pInt,pInt->di+40));
printf("setting fb mode...\n");
pInt->BIOSseg = V_BIOS >> 4;
pInt->num = 0x10;
{
char *mode;
mode = getenv("vesa_mode");
if (mode != 0)
vesa_mode = strtol(mode, 0, 0);
else
vesa_mode = 0x00;
}
for(vesa_mode = 0; vesa_mode <= 24; vesa_mode++){
printk("\n\nvesa_mode : 0x%x\n", vesa_mode);
pInt->ax = 0x4f02;
// pInt->bx = 0x4114;
pInt->bx = (USE_LINEAR_FRAMEBUFFER | vesa_mode_head[vesa_mode].mode);
printk("ax %x bx %x\n", pInt->ax, pInt->bx);
xf86ExecX86int10(pInt);
if (pInt->ax != 0x004f){
printk("set vesa mode failed,ax=%x mode(0x%x)\n", pInt->ax, pInt->bx);
}else{
break;
}
}
#ifdef DEBUG
pInt->ax = 0x4f01; /* get mode information */
pInt->cx = 0x4114;
pInt->di = 0;
pInt->es = 0;
xf86ExecX86int10(pInt);
if (pInt->ax != 0x004f)
printk("get vesa mode info failed,ax=%x\n", pInt->ax);
printk("linelength=%x\n", MEM_RW(pInt, pInt->di + 16));
printk("width=%x\n", MEM_RW(pInt, pInt->di + 18));
printk("height=%x\n", MEM_RW(pInt, pInt->di + 20));
printk("depth=%x\n", MEM_RB(pInt, pInt->di + 25));
printk("pages=%x\n", MEM_RB(pInt, pInt->di + 29));
printk("base=%x\n", MEM_RL(pInt, pInt->di + 40));
#endif
#endif
#endif
#ifdef RADEON7000
//radeon_init_regbase();
//radeon_init_mode();
//radeon_engine_init();
//radeon_dump_regs();
#if 0
radeon_init_regbase();
radeon_init_mode();
radeon_engine_init();
//radeon_dump_regs();
#endif
free(pInt->private);
free(pInt);
free(sysMem);
free(base);
if(!getenv("novga")&&!novga) vga_available=1;
return 1;
error0:
free(pInt);
return -1;
}
free(pInt->private);
free(pInt);
free(sysMem);
free(base);
return 1;
error0:
free(pInt);
return -1;
}
Bool
MapCurrentInt10(xf86Int10InfoPtr pInt)
Bool MapCurrentInt10(xf86Int10InfoPtr pInt)
{
/* nothing to do here */
return TRUE;
/* nothing to do here */
return TRUE;
}
#define MMIO_IN8(base, offset) \
*(volatile CARD8 *)(((CARD8*)(base)) + (offset))
#define MMIO_IN16(base, offset) \
*(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
*(volatile CARD16 *)(((CARD8*)(base)) + (offset))
#define MMIO_IN32(base, offset) \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
*(volatile CARD32 *)(((CARD8*)(base)) + (offset))
#define MMIO_OUT8(base, offset, val) \
*(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
#define MMIO_OUT16(base, offset, val) \
*(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
*(volatile CARD16 *)(((CARD8*)(base)) + (offset)) = (val)
#define MMIO_OUT32(base, offset, val) \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
*(volatile CARD32 *)(((CARD8*)(base)) + (offset)) = (val)
#define OFF(addr) ((addr) & 0xffff)
#define SYS(addr) ((addr) >= SYS_BIOS)
@ -466,81 +502,87 @@ MapCurrentInt10(xf86Int10InfoPtr pInt)
#define VRAM(addr) ((addr >= V_RAM) && (addr < (V_RAM + VRAM_SIZE)))
#define V_ADDR_RB(addr) \
(VRAM(addr)) ? MMIO_IN8((CARD8*)VRAM_BASE,VRAM_ADDR(addr)) \
: *(CARD8*) V_ADDR(addr)
(VRAM((addr))) ? MMIO_IN8((CARD8*)VRAM_BASE,VRAM_ADDR((addr))) \
: *(CARD8*) V_ADDR((addr))
#define V_ADDR_RW(addr) \
(VRAM((addr))) ? MMIO_IN16((CARD16*)VRAM_BASE,VRAM_ADDR((addr))) \
: (*(CARD16*)V_ADDR((addr)))
(VRAM((addr))) ? MMIO_IN16((CARD16*)VRAM_BASE,VRAM_ADDR((addr))) \
: (*(CARD16*)V_ADDR((addr)))
#define V_ADDR_RL(addr) \
(VRAM((addr))) ? MMIO_IN32((CARD32*)VRAM_BASE,VRAM_ADDR((addr))) \
: (*(CARD32*)V_ADDR((addr)))
(VRAM((addr))) ? MMIO_IN32((CARD32*)VRAM_BASE,VRAM_ADDR((addr))) \
: (*(CARD32*)V_ADDR((addr)))
#define V_ADDR_WB(addr,val) \
if(VRAM((addr))) { \
MMIO_OUT8((CARD8*)VRAM_BASE,VRAM_ADDR((addr)),val); \
} else \
*(CARD8*) V_ADDR((addr)) = val;
if(VRAM((addr))) { \
MMIO_OUT8((CARD8*)VRAM_BASE,VRAM_ADDR((addr)),val); \
} else \
*(CARD8*) V_ADDR((addr)) = val;
#define V_ADDR_WW(addr,val) \
if(VRAM((addr))) \
MMIO_OUT16((CARD16*)VRAM_BASE,VRAM_ADDR((addr)),val); \
else \
*(CARD16*)(V_ADDR((addr))) = val;
#define V_ADDR_WL(addr,val) \
if (VRAM((addr))) \
MMIO_OUT32((CARD32*)VRAM_BASE,VRAM_ADDR((addr)),val); \
else \
*(CARD32*)(V_ADDR((addr))) = val;
if(VRAM((addr))) \
MMIO_OUT16((CARD16*)VRAM_BASE,VRAM_ADDR((addr)),val); \
else \
*(CARD16*)(V_ADDR((addr))) = val;
#define V_ADDR_WL(addr,val) \
if (VRAM((addr))) \
MMIO_OUT32((CARD32*)VRAM_BASE,VRAM_ADDR((addr)),val); \
else \
*(CARD32*)(V_ADDR((addr))) = val;
static CARD8
read_b(xf86Int10InfoPtr pInt, int addr)
static CARD8 read_b(xf86Int10InfoPtr pInt, int addr)
{
return V_ADDR_RB(addr);
return V_ADDR_RB(addr);
}
static CARD16
read_w(xf86Int10InfoPtr pInt, int addr)
static CARD16 read_w(xf86Int10InfoPtr pInt, int addr)
{
return (CARD16)(V_ADDR_RB(addr)) | ((CARD16)(V_ADDR_RB(addr + 1)) << 8);
// return V_ADDR_RW(addr);
#ifdef DEBUG_READ
printf("read_w %x %x %x\n", V_ADDR_RB(addr), ((CARD16)(V_ADDR_RB((addr + 1))) << 8),
(CARD16)(V_ADDR_RB(addr)) | ((CARD16)(V_ADDR_RB(addr + 1)) << 8));
#endif
return (CARD16)(V_ADDR_RB(addr)) | ((CARD16)(V_ADDR_RB(addr + 1)) << 8);
}
static CARD32
read_l(xf86Int10InfoPtr pInt, int addr)
static CARD32 read_l(xf86Int10InfoPtr pInt, int addr)
{
return (CARD32)(V_ADDR_RB(addr)) |
((CARD32)(V_ADDR_RB(addr + 1)) << 8) |
((CARD32)(V_ADDR_RB(addr + 2)) << 16) | ((CARD32)(V_ADDR_RB(addr + 3)) << 24);
// return V_ADDR_RL(addr);
return (CARD32)(V_ADDR_RB(addr)) |
((CARD32)(V_ADDR_RB(addr + 1)) << 8) |
((CARD32)(V_ADDR_RB(addr + 2)) << 16) | ((CARD32)(V_ADDR_RB(addr + 3)) << 24);
}
static void
write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
{
V_ADDR_WB(addr, (val & 0xff));
V_ADDR_WB(addr, (val & 0xff));
#ifdef DEBUG_WRITE
if (VRAM(addr) && val)
printf("%08x wb %x, rd %x\n", addr, val, read_b(pInt, addr));
#endif
}
static void
write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
{
V_ADDR_WB(addr, (val & 0xff));
V_ADDR_WB(addr+1, ((val >> 8) & 0xff));
V_ADDR_WB(addr, (val & 0xff));
V_ADDR_WB(addr+1, ((val >> 8) & 0xff));
#ifdef DEBUG_WRITE
if (VRAM(addr) && val)
printf("%08x ww %x, rd %x\n", addr, val, read_w(pInt, addr));
#endif
}
static void
write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
{
V_ADDR_WB(addr, (val & 0xff));
V_ADDR_WB(addr+1, ((val >> 8) & 0xff));
V_ADDR_WB(addr+2, ((val >> 16) & 0xff));
V_ADDR_WB(addr+3, ((val >> 24) & 0xff));
V_ADDR_WB(addr, (val & 0xff));
V_ADDR_WB(addr+1, ((val >> 8) & 0xff));
V_ADDR_WB(addr+2, ((val >> 16) & 0xff));
V_ADDR_WB(addr+3, ((val >> 24) & 0xff));
#ifdef DEBUG_WRITE
if (VRAM(addr) && val)
printf("%08x wl %x, rd %x\n", addr, val, read_l(pInt, addr));
#endif
}
pointer
xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
pointer xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
{
return V_ADDR(addr);
return V_ADDR(addr);
}

661
x86emu/int10/helper_exec.c

@ -24,9 +24,12 @@
#include "linux/io.h"
#include <dev/pci/pcivar.h>
//#define PRINT_PORT
#undef PRINT_PORT
#if !defined (_PC) && !defined (_PC_PCI)
static int pciCfg1in(CARD16 addr, CARD32 *val,int type);
static int pciCfg1out(CARD16 addr, CARD32 val,int type);
static int pciCfg1in(CARD16 addr, CARD32 * val, int type);
static int pciCfg1out(CARD16 addr, CARD32 val, int type);
#define PCI_BYTE 0
#define PCI_WORD 1
#define PCI_DWORD 2
@ -34,409 +37,395 @@ static int pciCfg1out(CARD16 addr, CARD32 val,int type);
#define REG pInt
int
setup_int(xf86Int10InfoPtr pInt)
int setup_int(xf86Int10InfoPtr pInt)
{
if (pInt != Int10Current) {
if (!MapCurrentInt10(pInt))
return -1;
Int10Current = pInt;
}
X86_EAX = (CARD32) pInt->ax;
X86_EBX = (CARD32) pInt->bx;
X86_ECX = (CARD32) pInt->cx;
X86_EDX = (CARD32) pInt->dx;
X86_ESI = (CARD32) pInt->si;
X86_EDI = (CARD32) pInt->di;
X86_EBP = (CARD32) pInt->bp;
X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4;
X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */
X86_DS = 0x40; /* standard pc ds */
X86_ES = pInt->es;
X86_FS = 0;
X86_GS = 0;
X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK;
return 0;
if (pInt != Int10Current) {
if (!MapCurrentInt10(pInt))
return -1;
Int10Current = pInt;
}
X86_EAX = (CARD32) pInt->ax;
X86_EBX = (CARD32) pInt->bx;
X86_ECX = (CARD32) pInt->cx;
X86_EDX = (CARD32) pInt->dx;
X86_ESI = (CARD32) pInt->si;
X86_EDI = (CARD32) pInt->di;
X86_EBP = (CARD32) pInt->bp;
X86_ESP = 0x1000;
X86_SS = pInt->stackseg >> 4;
X86_EIP = 0x0600;
X86_CS = 0x0; /* address of 'hlt' */
X86_DS = 0x40; /* standard pc ds */
X86_ES = pInt->es;
X86_FS = 0;
X86_GS = 0;
X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK;
return 0;
}
void
finish_int(xf86Int10InfoPtr pInt, int sig)
void finish_int(xf86Int10InfoPtr pInt, int sig)
{
pInt->ax = (CARD16) X86_EAX;
pInt->bx = (CARD16) X86_EBX;
pInt->cx = (CARD16) X86_ECX;
pInt->dx = (CARD16) X86_EDX;
pInt->si = (CARD16) X86_ESI;
pInt->di = (CARD16) X86_EDI;
pInt->es = (CARD16) X86_ES;
pInt->bp = (CARD16) X86_EBP;
pInt->flags = (CARD16) X86_FLAGS;
pInt->ax = (CARD16) X86_EAX;
pInt->bx = (CARD16) X86_EBX;
pInt->cx = (CARD16) X86_ECX;
pInt->dx = (CARD16) X86_EDX;
pInt->si = (CARD16) X86_ESI;
pInt->di = (CARD16) X86_EDI;
pInt->es = (CARD16) X86_ES;
pInt->bp = (CARD16) X86_EBP;
pInt->flags = (CARD16) X86_FLAGS;
}
/* general software interrupt handler */
CARD32
getIntVect(xf86Int10InfoPtr pInt,int num)
CARD32 getIntVect(xf86Int10InfoPtr pInt, int num)
{
return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4);
return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4);
}
void
pushw(xf86Int10InfoPtr pInt, CARD16 val)
void pushw(xf86Int10InfoPtr pInt, CARD16 val)
{
X86_ESP -= 2;
MEM_WW(pInt, ((CARD32) X86_SS << 4) + X86_SP, val);
X86_ESP -= 2;
MEM_WW(pInt, ((CARD32) X86_SS << 4) + X86_SP, val);
}
int
run_bios_int(int num, xf86Int10InfoPtr pInt)
int run_bios_int(int num, xf86Int10InfoPtr pInt)
{
CARD32 eflags;
CARD32 eflags;
#ifndef _PC
/* check if bios vector is initialized */
if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/
printf("Int CS=%X",MEM_RW(pInt,(num<<2)+2));
printf("Card BIOS on non-PC like platform not loaded\n");
//return 0;
//X86EMU_trace_on();
}
/* check if bios vector is initialized */
if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ? */
printf("Int CS=%X", MEM_RW(pInt, (num << 2) + 2));
printf("Card BIOS on non-PC like platform not loaded\n");
//return 0;
//X86EMU_trace_on();
}
#endif
#ifdef PRINT_INT
printf("calling card BIOS at: ");
printf("calling card BIOS at: ");
#endif
eflags = X86_EFLAGS;
eflags = X86_EFLAGS;
#if 0
eflags = eflags | IF_MASK;
X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK);
eflags = eflags | IF_MASK;
X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK);
#endif
pushw(pInt, eflags);
pushw(pInt, X86_CS);
pushw(pInt, X86_IP);
X86_CS = MEM_RW(pInt, (num << 2) + 2);
X86_IP = MEM_RW(pInt, num << 2);
pushw(pInt, eflags);
pushw(pInt, X86_CS);
pushw(pInt, X86_IP);
X86_CS = MEM_RW(pInt, (num << 2) + 2);
X86_IP = MEM_RW(pInt, num << 2);
#ifdef PRINT_INT
printf("0x%x:%lx\n", X86_CS, X86_EIP);
printf("0x%x:%lx\n", X86_CS, X86_EIP);
#endif
return 1;
return 1;
}
/* Debugging stuff */
void
dump_code(xf86Int10InfoPtr pInt)
void dump_code(xf86Int10InfoPtr pInt)
{
int i;
CARD32 lina = SEG_ADR((CARD32), X86_CS, IP);
printf("code at 0x%8.8x:\n", lina);
for (i=0; i<0x10; i++)
printf(" %2.2x", MEM_RB(pInt, lina + i));
printf("\n");
for (; i<0x20; i++)
printf(" %2.2x", MEM_RB(pInt, lina + i));
printf("\n");
int i;
CARD32 lina = SEG_ADR((CARD32), X86_CS, IP);
printf("code at 0x%8.8x:\n", lina);
for (i = 0; i < 0x10; i++)
printf(" %2.2x", MEM_RB(pInt, lina + i));
printf("\n");
for (; i < 0x20; i++)
printf(" %2.2x", MEM_RB(pInt, lina + i));
printf("\n");
}
void
dump_registers(xf86Int10InfoPtr pInt)
void dump_registers(xf86Int10InfoPtr pInt)
{
printf("EAX=0x%8.8x, EBX=0x%8.8x, ECX=0x%8.8x, EDX=0x%8.8x\n",
X86_EAX, X86_EBX, X86_ECX, X86_EDX);
printf( "ESP=0x%8.8x, EBP=0x%8.8x, ESI=0x%8.8x, EDI=0x%8.8x\n",
X86_ESP, X86_EBP, X86_ESI, X86_EDI);
printf( "CS=0x%4.4x, SS=0x%4.4x,"
" DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n",
X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS);
printf( "EIP=0x%8.8x, EFLAGS=0x%8.8x\n", X86_EIP, X86_EFLAGS);
X86_EAX, X86_EBX, X86_ECX, X86_EDX);
printf("ESP=0x%8.8x, EBP=0x%8.8x, ESI=0x%8.8x, EDI=0x%8.8x\n",
X86_ESP, X86_EBP, X86_ESI, X86_EDI);
printf("CS=0x%4.4x, SS=0x%4.4x,"
" DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n",
X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS);
printf("EIP=0x%8.8x, EFLAGS=0x%8.8x\n", X86_EIP, X86_EFLAGS);
}
void
stack_trace(xf86Int10InfoPtr pInt)
void stack_trace(xf86Int10InfoPtr pInt)
{
int i = 0;
CARD32 stack = SEG_ADR((CARD32), X86_SS, SP);
CARD32 tail = (CARD32)((X86_SS << 4) + 0x1000);
if (stack >= tail) return;
printf(" stack at 0x%8.8x:\n", stack);
for (; stack < tail; stack++) {
printf(" %2.2x", MEM_RB(pInt, stack));
i = (i + 1) % 0x10;
if (!i)
printf( "\n");
}
if (i)
printf("\n");
int i = 0;
CARD32 stack = SEG_ADR((CARD32), X86_SS, SP);
CARD32 tail = (CARD32) ((X86_SS << 4) + 0x1000);
if (stack >= tail)
return;
printf(" stack at 0x%8.8x:\n", stack);
for (; stack < tail; stack++) {
printf(" %2.2x", MEM_RB(pInt, stack));
i = (i + 1) % 0x10;
if (!i)
printf("\n");
}
if (i)
printf("\n");
}
int
port_rep_inb(xf86Int10InfoPtr pInt,
CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -1 : 1;
CARD32 dst = base;
register int inc = d_f ? -1 : 1;
CARD32 dst = base;
#ifdef PRINT_PORT
printf(" rep_insb(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
printf(" rep_insb(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
#endif
while (count--) {
MEM_WB(pInt, dst, x_inb(port));
dst += inc;
}
return dst - base;
while (count--) {
MEM_WB(pInt, dst, x_inb(port));
dst += inc;
}
return dst - base;
}
int
port_rep_inw(xf86Int10InfoPtr pInt,
CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -2 : 2;
CARD32 dst = base;
register int inc = d_f ? -2 : 2;
CARD32 dst = base;
#ifdef PRINT_PORT
printf(" rep_insw(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
printf(" rep_insw(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
#endif
while (count--) {
MEM_WW(pInt, dst, x_inw(port));
dst += inc;
}
return dst - base;
while (count--) {
MEM_WW(pInt, dst, x_inw(port));
dst += inc;
}
return dst - base;
}
int
port_rep_inl(xf86Int10InfoPtr pInt,
CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -4 : 4;
CARD32 dst = base;
register int inc = d_f ? -4 : 4;
CARD32 dst = base;
#ifdef PRINT_PORT
printf(" rep_insl(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
printf(" rep_insl(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
#endif
while (count--) {
MEM_WL(pInt, dst, x_inl(port));
dst += inc;
}
return dst - base;
while (count--) {
MEM_WL(pInt, dst, x_inl(port));
dst += inc;
}
return dst - base;
}
int
port_rep_outb(xf86Int10InfoPtr pInt,
CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -1 : 1;
CARD32 dst = base;
register int inc = d_f ? -1 : 1;
CARD32 dst = base;
#ifdef PRINT_PORT
printf(" rep_outb(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
printf(" rep_outb(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
#endif
while (count--) {
x_outb(port, MEM_RB(pInt, dst));
dst += inc;
}
return dst - base;
while (count--) {
x_outb(port, MEM_RB(pInt, dst));
dst += inc;
}
return dst - base;
}
int
port_rep_outw(xf86Int10InfoPtr pInt,
CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -2 : 2;
CARD32 dst = base;
register int inc = d_f ? -2 : 2;
CARD32 dst = base;
#ifdef PRINT_PORT
printf(" rep_outw(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
printf(" rep_outw(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
#endif
while (count--) {
x_outw(port, MEM_RW(pInt, dst));
dst += inc;
}
return dst - base;
while (count--) {
x_outw(port, MEM_RW(pInt, dst));
dst += inc;
}
return dst - base;
}
extern void delay(unsigned long val);
int
port_rep_outl(xf86Int10InfoPtr pInt,
CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -4 : 4;
CARD32 dst = base;
register int inc = d_f ? -4 : 4;
CARD32 dst = base;
#ifdef PRINT_PORT
printf(" rep_outl(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
printf(" rep_outl(%#x) %d bytes at %p %s\n",
port, count, base, d_f ? "up" : "down");
#endif
while (count--) {
x_outl(port, MEM_RL(pInt, dst));
dst += inc;
}
return dst - base;
while (count--) {
x_outl(port, MEM_RL(pInt, dst));
dst += inc;
}
return dst - base;
}
CARD8
x_inb(CARD16 port)
CARD8 x_inb(CARD16 port)
{
CARD8 val;
if (port == 0x40) {
Int10Current->inb40time++;
val = (CARD8)(Int10Current->inb40time >>
((Int10Current->inb40time & 1) << 3));
CARD8 val;
if (port == 0x40) {
Int10Current->inb40time++;
val = (CARD8) (Int10Current->inb40time >>
((Int10Current->inb40time & 1) << 3));
#ifdef PRINT_PORT
printf(" inb(%#x) = %2.2x\n", port, val);
printf(" inb(%#x) = %2.2x\n", port, val);
#endif
#ifdef __NOT_YET__
} else if (port < 0x0100) { /* Don't interfere with mainboard */
val = 0;
printf( "inb 0x%4.4x\n", port);
dump_registers(Int10Current);
stack_trace(Int10Current);
#endif /* __NOT_YET__ */
} else {
val = linux_inb(port);
if(port == 0x61){
static int sw = 0;
delay(5);
val = sw ? 0x00: 0x10;
sw = !sw;
}
} else if (port < 0x0100) { /* Don't interfere with mainboard */
val = 0;
printf("inb 0x%4.4x\n", port);
dump_registers(Int10Current);
stack_trace(Int10Current);
#endif /* __NOT_YET__ */
} else {
val = linux_inb(port);
if (port == 0x61) {
static int sw = 0;
delay(5);
val = sw ? 0x00: 0x10;
sw = !sw;
}
#ifdef PRINT_PORT
if(port!=0x3da&& port!=0x3ba&&port!=0x61) printf(" inb(%#x) = %2.2x\n", port, val);
if(port!=0x3da&& port!=0x3ba&&port!=0x61) printf(" inb(%#x) = %2.2x\n", port, val);
// printf(" inb(%#x) = %2.2x\n", port, val);
#endif
}
return val;
}
return val;
}
CARD16
x_inw(CARD16 port)
CARD16 x_inw(CARD16 port)
{
CARD16 val;
if (port == 0x5c) {
/*
* Emulate a PC98's timer. Typical resolution is 3.26 usec.
* Approximate this by dividing by 3.
* TODO: need complete!
*/
}else {
val = linux_inw(port);
}
CARD16 val;
if (port == 0x5c) {
/*
* Emulate a PC98's timer. Typical resolution is 3.26 usec.
* Approximate this by dividing by 3.
* TODO: need complete!
*/
} else {
val = linux_inw(port);
}
#ifdef PRINT_PORT
printf(" inw(%#x) = %4.4x\n", port, val);
printf(" inw(%#x) = %4.4x\n", port, val);
#endif
/*if(port==0x100a&&val==0x18f){
M.x86.debug=3;
}*/
return val;
/*if(port==0x100a&&val==0x18f){
M.x86.debug=3;
} */
return val;
}
void
x_outb(CARD16 port, CARD8 val)
void x_outb(CARD16 port, CARD8 val)
{
if ((port == 0x43) && (val == 0)) {
/*
* Emulate a PC's timer 0. Such timers typically have a resolution of
* some .838 usec per tick, but this can only provide 1 usec per tick.
* (Not that this matters much, given inherent emulation delays.) Use
* the bottom bit as a byte select. See inb(0x40) above.
*/
//TODO need complete
if ((port == 0x43) && (val == 0)) {
/*
* Emulate a PC's timer 0. Such timers typically have a resolution of
* some .838 usec per tick, but this can only provide 1 usec per tick.
* (Not that this matters much, given inherent emulation delays.) Use
* the bottom bit as a byte select. See inb(0x40) above.
*/
//TODO need complete
#ifdef PRINT_PORT
printf(" outb(%#x, %2.2x)\n", port, val);
printf(" outb(%#x, %2.2x)\n", port, val);
#endif
#ifdef __NOT_YET__
} else if (port < 0x0100) { /* Don't interfere with mainboard */
printf( "outb 0x%4.4x,0x%2.2x\n", port, val);
dump_registers(Int10Current);
stack_trace(Int10Current);
#endif /* __NOT_YET__ */
} else {
} else if (port < 0x0100) { /* Don't interfere with mainboard */
printf("outb 0x%4.4x,0x%2.2x\n", port, val);
dump_registers(Int10Current);
stack_trace(Int10Current);
#endif /* __NOT_YET__ */
} else {
#ifdef PRINT_PORT
printf(" outb(%#x, %2.2x)\n", port, val);
printf(" outb(%#x, %2.2x)\n", port, val);
#endif
linux_outb(val,port);
}
linux_outb(val, port);
}
}
void
x_outw(CARD16 port, CARD16 val)
void x_outw(CARD16 port, CARD16 val)
{
#ifdef PRINT_PORT
printf(" outw(%#x, %4.4x)\n", port, val);
if ((port == 0x3c4 && ((val & 0xff) == 0x13 || (val & 0xff) == 0x14)) || (port != 0x3c4))
printf("outw (%#x, %4.4x)\n", port, val);
#endif
#ifndef VGA_LYNX_0712
linux_outw(val,port);
linux_outw(val, port);
#else
if(port==0xd9c7){
}else linux_outw(val,port);
if (port == 0xd9c7) {
} else {
linux_outw(val, port);
}
#endif
}
CARD32
x_inl(CARD16 port)
CARD32 x_inl(CARD16 port)
{
CARD32 val;
CARD32 val;
#if !defined(_PC) && !defined(_PC_PCI)
if (!pciCfg1in(port, &val, PCI_DWORD))
if (!pciCfg1in(port, &val, PCI_DWORD))
#endif
val = linux_inl(port);
val = linux_inl(port);
#ifdef PRINT_PORT
if(port!=0xcf8&&port!=0xcfc) printf(" inl(%#x) = %8.8x\n", port, val);
if (port != 0xcf8 && port != 0xcfc)
printf(" inl(%#x) = %8.8x\n", port, val);
#endif
return val;
return val;
}
void
x_outl(CARD16 port, CARD32 val)
void x_outl(CARD16 port, CARD32 val)
{
#ifdef PRINT_PORT
if(port!=0xcfc&&port!=0xcf8) printf(" outl(%#x, %8.8x)\n", port, val);
if (port != 0xcfc && port != 0xcf8)
printf(" outl(%x, %8.8x)\n", port, val);
#endif
#if !defined(_PC) && !defined(_PC_PCI)
if (!pciCfg1out(port, val, PCI_DWORD))
if (!pciCfg1out(port, val, PCI_DWORD))
#endif
linux_outl(val,port);
linux_outl(val, port);
}
CARD8
Mem_rb(int addr)
CARD8 Mem_rb(int addr)
{
return (*Int10Current->mem->rb)(Int10Current, addr);
return (*Int10Current->mem->rb) (Int10Current, addr);
}
CARD16
Mem_rw(int addr)
CARD16 Mem_rw(int addr)
{
return (*Int10Current->mem->rw)(Int10Current, addr);
return (*Int10Current->mem->rw) (Int10Current, addr);
}
CARD32
Mem_rl(int addr)
CARD32 Mem_rl(int addr)
{
return (*Int10Current->mem->rl)(Int10Current, addr);
return (*Int10Current->mem->rl) (Int10Current, addr);
}
void
Mem_wb(int addr, CARD8 val)
void Mem_wb(int addr, CARD8 val)
{
(*Int10Current->mem->wb)(Int10Current, addr, val);
(*Int10Current->mem->wb) (Int10Current, addr, val);
}
void
Mem_ww(int addr, CARD16 val)
void Mem_ww(int addr, CARD16 val)
{
(*Int10Current->mem->ww)(Int10Current, addr, val);
(*Int10Current->mem->ww) (Int10Current, addr, val);
}
void
Mem_wl(int addr, CARD32 val)
void Mem_wl(int addr, CARD32 val)
{
(*Int10Current->mem->wl)(Int10Current, addr, val);
(*Int10Current->mem->wl) (Int10Current, addr, val);
}
#if !defined(_PC) && !defined(_PC_PCI)
static u32 PciCfg1Addr = 0;
@ -444,74 +433,100 @@ static u32 PciCfg1Addr = 0;
#define DEVFN(Cfg1Addr) ((Cfg1Addr & 0xff00) >> 8)
#define OFFSET(Cfg1Addr) (Cfg1Addr & 0xff)
static int
pciCfg1in(CARD16 addr, CARD32 *val,int type)
static int pciCfg1in(CARD16 addr, CARD32 * val, int type)
{
if (addr == 0xCF8) {
*(u32*)val = PciCfg1Addr;
return 1;
}
if (addr == 0xCFC) {
if (type==0) {
*val=_pci_conf_readn(_pci_make_tag(BUS(PciCfg1Addr),((DEVFN(PciCfg1Addr)>>3)&0x1f),(DEVFN(PciCfg1Addr)&0x7)),OFFSET(PciCfg1Addr),1);
if (addr == 0xCF8) {
*(u32 *) val = PciCfg1Addr;
return 1;
}
if (addr == 0xCFC) {
if (type == 0) {
*val =
_pci_conf_readn(_pci_make_tag
(BUS(PciCfg1Addr),
((DEVFN(PciCfg1Addr) >> 3) & 0x1f),
(DEVFN(PciCfg1Addr) & 0x7)),
OFFSET(PciCfg1Addr), 1);
#ifdef DEBUG_EMU_VGA
printk(" byte read configuration space,addr=%x,val=%x\n",PciCfg1Addr,*(u8*)val);
printk
(" byte read configuration space,addr=%x,val=%x\n",
PciCfg1Addr, *(u8 *) val);
#endif
}else if (type==1) {
*val=_pci_conf_readn(_pci_make_tag(BUS(PciCfg1Addr),((DEVFN(PciCfg1Addr)>>3)&0x1f),(DEVFN(PciCfg1Addr)&0x7)),OFFSET(PciCfg1Addr),2);
} else if (type == 1) {
*val =
_pci_conf_readn(_pci_make_tag
(BUS(PciCfg1Addr),
((DEVFN(PciCfg1Addr) >> 3) & 0x1f),
(DEVFN(PciCfg1Addr) & 0x7)),
OFFSET(PciCfg1Addr), 2);
#ifdef DEBUG_EMU_VGA
printk("word read configuration space,addr=%x,val=%x\n",PciCfg1Addr,*(u16*)val);
printk("word read configuration space,addr=%x,val=%x\n",
PciCfg1Addr, *(u16 *) val);
#endif
}else if (type==2) {
*val=_pci_conf_read(_pci_make_tag(BUS(PciCfg1Addr),((DEVFN(PciCfg1Addr)>>3)&0x1f),(DEVFN(PciCfg1Addr)&0x7)),OFFSET(PciCfg1Addr));
} else if (type == 2) {
*val =
_pci_conf_read(_pci_make_tag
(BUS(PciCfg1Addr),
((DEVFN(PciCfg1Addr) >> 3) & 0x1f),
(DEVFN(PciCfg1Addr) & 0x7)),
OFFSET(PciCfg1Addr));
#ifdef DEBUG_EMU_VGA
// printk(" dword read configuration space,addr=%x,val=%x\n",PciCfg1Addr,*(u32*)val);
#endif
}else{
*val=_pci_conf_read(_pci_make_tag(BUS(PciCfg1Addr),((DEVFN(PciCfg1Addr)>>3)&0x1f),(DEVFN(PciCfg1Addr)&0x7)),OFFSET(PciCfg1Addr));
//printk("wrong type for pci config op\n");
} else {
printk("wrong type for pci config op\n");
}
return 1;
}
return 1;
}
return 0;
return 0;
}
static int
pciCfg1out(CARD16 addr, CARD32 val,int type)
static int pciCfg1out(CARD16 addr, CARD32 val, int type)
{
if (addr == 0xCF8) {
PciCfg1Addr = val;
return 1;
}
if (addr == 0xCFC) {
if (addr == 0xCF8) {
PciCfg1Addr = val;
return 1;
}
if (addr == 0xCFC) {
#ifdef DEBUG_EMU_VGA
printk("write configuration space,addr=%x,val=%x,type=%d\n",PciCfg1Addr,val,type);
printk("write configuration space,addr=%x,val=%x,type=%d\n",
PciCfg1Addr, val, type);
#endif
if (type==0) {
_pci_conf_writen(_pci_make_tag(BUS(PciCfg1Addr),((DEVFN(PciCfg1Addr)>>3)&0x1f),(DEVFN(PciCfg1Addr)&0x7)),OFFSET(PciCfg1Addr),(u8)val,1);
}else if (type==1) {
_pci_conf_writen(_pci_make_tag(BUS(PciCfg1Addr),((DEVFN(PciCfg1Addr)>>3)&0x1f),(DEVFN(PciCfg1Addr)&0x7)),OFFSET(PciCfg1Addr),(u8)val,2);
}else if (type==2) {
_pci_conf_write(_pci_make_tag(BUS(PciCfg1Addr),((DEVFN(PciCfg1Addr)>>3)&0x1f),(DEVFN(PciCfg1Addr)&0x7)),OFFSET(PciCfg1Addr),(u8)val);
}else {
_pci_conf_write(_pci_make_tag(BUS(PciCfg1Addr),((DEVFN(PciCfg1Addr)>>3)&0x1f),(DEVFN(PciCfg1Addr)&0x7)),OFFSET(PciCfg1Addr),(u8)val);
//printk("wrong type for pci config op\n");
}
return 1;
}
return 0;
if (type == 0) {
_pci_conf_writen(_pci_make_tag
(BUS(PciCfg1Addr),
((DEVFN(PciCfg1Addr) >> 3) & 0x1f),
(DEVFN(PciCfg1Addr) & 0x7)),
OFFSET(PciCfg1Addr), (u8) val, 1);
} else if (type == 1) {
_pci_conf_writen(_pci_make_tag
(BUS(PciCfg1Addr),
((DEVFN(PciCfg1Addr) >> 3) & 0x1f),
(DEVFN(PciCfg1Addr) & 0x7)),
OFFSET(PciCfg1Addr), (u8) val, 2);
} else if (type == 2) {
_pci_conf_write(_pci_make_tag
(BUS(PciCfg1Addr),
((DEVFN(PciCfg1Addr) >> 3) & 0x1f),
(DEVFN(PciCfg1Addr) & 0x7)),
OFFSET(PciCfg1Addr), (u8) val);
} else {
printk("wrong type for pci config op\n");
}
return 1;
}
return 0;
}
#endif
CARD8
bios_checksum(CARD8 *start, int size)
CARD8 bios_checksum(CARD8 * start, int size)
{
CARD8 sum = 0;
CARD8 sum = 0;
while (size-- > 0)
sum += *start++;
return sum;
while (size-- > 0)
sum += *start++;
return sum;
}
/*
@ -532,24 +547,22 @@ bios_checksum(CARD8 *start, int size)
* the driver would have to load the vga-module prior to
* doing int10.
*/
void
LockLegacyVGA(int screenIndex,legacyVGAPtr vga)
void LockLegacyVGA(int screenIndex, legacyVGAPtr vga)
{
vga->save_msr = linux_inb(0x3CC);
vga->save_vse = linux_inb(0x3C3);
vga->save_46e8 = linux_inb(0x46e8);
vga->save_pos102 = linux_inb(0x102);
linux_outb(~(CARD8)0x03 & vga->save_msr,0x3C2);
linux_outb(~(CARD8)0x01 & vga->save_vse,0x3C3);
linux_outb(~(CARD8)0x08 & vga->save_46e8,0x4e68);
linux_outb(~(CARD8)0x01 & vga->save_pos102,0x102);
vga->save_msr = linux_inb(0x3CC);
vga->save_vse = linux_inb(0x3C3);
vga->save_46e8 = linux_inb(0x46e8);
vga->save_pos102 = linux_inb(0x102);
linux_outb(~(CARD8) 0x03 & vga->save_msr, 0x3C2);
linux_outb(~(CARD8) 0x01 & vga->save_vse, 0x3C3);
linux_outb(~(CARD8) 0x08 & vga->save_46e8, 0x4e68);
linux_outb(~(CARD8) 0x01 & vga->save_pos102, 0x102);
}
void
UnlockLegacyVGA(int screenIndex, legacyVGAPtr vga)
void UnlockLegacyVGA(int screenIndex, legacyVGAPtr vga)
{
linux_outb(vga->save_pos102,0x102);
linux_outb(vga->save_46e8,0x46e8);
linux_outb(vga->save_vse,0x3C3);
linux_outb(vga->save_msr,0x3C2);
linux_outb(vga->save_pos102, 0x102);
linux_outb(vga->save_46e8, 0x46e8);
linux_outb(vga->save_vse, 0x3C3);
linux_outb(vga->save_msr, 0x3C2);
}

309
x86emu/int10/helper_mem.c

@ -13,25 +13,25 @@
#define REG pInt
#ifdef DEBUG
void
dprint(unsigned long start, unsigned long size)
void dprint(unsigned long start, unsigned long size)
{
int i,j;
char *c = (char *)start;
for (j = 0; j < (size >> 4); j++) {
char *d = c;
printf("\n0x%lx: ",(unsigned long)c);
for (i = 0; i<16; i++)
printf("%2.2x ",(unsigned char) (*(c++)));
c = d;
for (i = 0; i<16; i++) {
printf("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ?
(unsigned char) (*(c)): '.');
c++;
int i, j;
char *c = (char *)start;
for (j = 0; j < (size >> 4); j++) {
char *d = c;
printf("\n0x%lx: ", (unsigned long)c);
for (i = 0; i < 16; i++)
printf("%2.2x ", (unsigned char)(*(c++)));
c = d;
for (i = 0; i < 16; i++) {
printf("%c", ((((CARD8) (*c)) > 32)
&& (((CARD8) (*c)) <
128)) ? (unsigned char)(*(c)) : '.');
c++;
}
}
}
printf("\n");
printf("\n");
}
#endif
@ -41,160 +41,155 @@ dprint(unsigned long start, unsigned long size)
* BIOS. Most of this information was pulled from
* dosemu.
*/
void
setup_int_vect(xf86Int10InfoPtr pInt)
void setup_int_vect(xf86Int10InfoPtr pInt)
{
int i;
printf("in setup_int_vect!");
/* let the int vects point to the SYS_BIOS seg */
for (i = 0; i < 0x80; i++) {
MEM_WW(pInt, i << 2, 0);
MEM_WW(pInt, (i << 2) + 2, SYS_BIOS >> 4);
}
reset_int_vect(pInt);
/* font tables default location (int 1F) */
MEM_WW(pInt,0x1f<<2,0xfa6e);
/* int 11 default location (Get Equipment Configuration) */
MEM_WW(pInt, 0x11 << 2, 0xf84d);
/* int 12 default location (Get Conventional Memory Size) */
MEM_WW(pInt, 0x12 << 2, 0xf841);
/* int 15 default location (I/O System Extensions) */
MEM_WW(pInt, 0x15 << 2, 0xf859);
/* int 1A default location (RTC, PCI and others) */
MEM_WW(pInt, 0x1a << 2, 0xff6e);
/* int 05 default location (Bound Exceeded) */
MEM_WW(pInt, 0x05 << 2, 0xff54);
/* int 08 default location (Double Fault) */
MEM_WW(pInt, 0x08 << 2, 0xfea5);
/* int 13 default location (Disk) */
MEM_WW(pInt, 0x13 << 2, 0xec59);
/* int 0E default location (Page Fault) */
MEM_WW(pInt, 0x0e << 2, 0xef57);
/* int 17 default location (Parallel Port) */
MEM_WW(pInt, 0x17 << 2, 0xefd2);
/* fdd table default location (int 1e) */
MEM_WW(pInt, 0x1e << 2, 0xefc7);
/* Set Equipment flag to VGA */
/*
i = MEM_RB(pInt, 0x0410) & 0xCF;
MEM_WB(pInt, 0x0410, i);
*/
MEM_WB(pInt, 0x0410, 0x67);
MEM_WB(pInt, 0x0411, 0x42);
printf("done!");
/* XXX Perhaps setup more of the BDA here. See also int42(0x00). */
int i;
printf("in setup_int_vect!");
/* let the int vects point to the SYS_BIOS seg */
for (i = 0; i < 0x80; i++) {
MEM_WW(pInt, i << 2, 0);
MEM_WW(pInt, (i << 2) + 2, SYS_BIOS >> 4);
}
reset_int_vect(pInt);
/* font tables default location (int 1F) */
MEM_WW(pInt, 0x1f << 2, 0xfa6e);
/* int 11 default location (Get Equipment Configuration) */
MEM_WW(pInt, 0x11 << 2, 0xf84d);
/* int 12 default location (Get Conventional Memory Size) */
MEM_WW(pInt, 0x12 << 2, 0xf841);
/* int 15 default location (I/O System Extensions) */
MEM_WW(pInt, 0x15 << 2, 0xf859);
/* int 1A default location (RTC, PCI and others) */
MEM_WW(pInt, 0x1a << 2, 0xff6e);
/* int 05 default location (Bound Exceeded) */
MEM_WW(pInt, 0x05 << 2, 0xff54);
/* int 08 default location (Double Fault) */
MEM_WW(pInt, 0x08 << 2, 0xfea5);
/* int 13 default location (Disk) */
MEM_WW(pInt, 0x13 << 2, 0xec59);
/* int 0E default location (Page Fault) */
MEM_WW(pInt, 0x0e << 2, 0xef57);
/* int 17 default location (Parallel Port) */
MEM_WW(pInt, 0x17 << 2, 0xefd2);
/* fdd table default location (int 1e) */
MEM_WW(pInt, 0x1e << 2, 0xefc7);
/* Set Equipment flag to VGA */
/*
i = MEM_RB(pInt, 0x0410) & 0xCF;
MEM_WB(pInt, 0x0410, i);
*/
MEM_WB(pInt, 0x0410, 0x67);
MEM_WB(pInt, 0x0411, 0x42);
printf("done!");
/* XXX Perhaps setup more of the BDA here. See also int42(0x00). */
}
#endif
int
setup_system_bios(void *base_addr)
int setup_system_bios(void *base_addr)
{
char *base = (char *) base_addr;
/*
* we trap the "industry standard entry points" to the BIOS
* and all other locations by filling them with "hlt"
* TODO: implement hlt-handler for these
*/
memset(base, 0xf4, 0x10000);
/* int11 handler: push ds; push 0040; pop ds; mov ax,[0010]; pop ds; iret16
*/
*(base + 0xf84d + 0) = 0x1e;
*(base + 0xf84d + 1) = 0x68;
*(base + 0xf84d + 2) = 0x40;
*(base + 0xf84d + 3) = 0x00;
*(base + 0xf84d + 4) = 0x1f;
*(base + 0xf84d + 5) = 0xa1;
*(base + 0xf84d + 6) = 0x10;
*(base + 0xf84d + 7) = 0x00;
*(base + 0xf84d + 8) = 0x1f;
*(base + 0xf84d + 9) = 0xcf;
/* set bios date */
strcpy(base + 0x0FFF5, "06/11/99");
/* set up eisa ident string */
strcpy(base + 0x0FFD9, "PCI_ISA");
/* write system model id for IBM-AT */
*((unsigned char *)(base + 0x0FFFE)) = 0xfc;
return 1;
char *base = (char *)base_addr;
/*
* we trap the "industry standard entry points" to the BIOS
* and all other locations by filling them with "hlt"
* TODO: implement hlt-handler for these
*/
memset(base, 0xf4, 0x10000);
/* int11 handler: push ds; push 0040; pop ds; mov ax,[0010]; pop ds; iret16
*/
*(base + 0xf84d + 0) = 0x1e;
*(base + 0xf84d + 1) = 0x68;
*(base + 0xf84d + 2) = 0x40;
*(base + 0xf84d + 3) = 0x00;
*(base + 0xf84d + 4) = 0x1f;
*(base + 0xf84d + 5) = 0xa1;
*(base + 0xf84d + 6) = 0x10;
*(base + 0xf84d + 7) = 0x00;
*(base + 0xf84d + 8) = 0x1f;
*(base + 0xf84d + 9) = 0xcf;
/* set bios date */
strcpy(base + 0x0FFF5, "06/11/99");
/* set up eisa ident string */
strcpy(base + 0x0FFD9, "PCI_ISA");
/* write system model id for IBM-AT */
*((unsigned char *)(base + 0x0FFFE)) = 0xfc;
return 1;
}
void
reset_int_vect(xf86Int10InfoPtr pInt)
void reset_int_vect(xf86Int10InfoPtr pInt)
{
/*
* This table is normally located at 0xF000:0xF0A4. However, int 0x42,
* function 0 (Mode Set) expects it (or a copy) somewhere in the bottom
* 64kB. Note that because this data doesn't survive POST, int 0x42 should
* only be used during EGA/VGA BIOS initialisation.
*/
static const CARD8 VideoParms[] = {
/* Timing for modes 0x00 & 0x01 */
0x38, 0x28, 0x2d, 0x0a, 0x1f, 0x06, 0x19, 0x1c,
0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
/* Timing for modes 0x02 & 0x03 */
0x71, 0x50, 0x5a, 0x0a, 0x1f, 0x06, 0x19, 0x1c,
0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
/* Timing for modes 0x04, 0x05 & 0x06 */
0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70,
0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
/* Timing for mode 0x07 */
0x61, 0x50, 0x52, 0x0f, 0x19, 0x06, 0x19, 0x19,
0x02, 0x0d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
/* Display page lengths in little endian order */
0x00, 0x08, /* Modes 0x00 and 0x01 */
0x00, 0x10, /* Modes 0x02 and 0x03 */
0x00, 0x40, /* Modes 0x04 and 0x05 */
0x00, 0x40, /* Modes 0x06 and 0x07 */
/* Number of columns for each mode */
40, 40, 80, 80, 40, 40, 80, 80,
/* CGA Mode register value for each mode */
0x2c, 0x28, 0x2d, 0x29, 0x2a, 0x2e, 0x1e, 0x29,
/* Padding */
0x00, 0x00, 0x00, 0x00
/*
* This table is normally located at 0xF000:0xF0A4. However, int 0x42,
* function 0 (Mode Set) expects it (or a copy) somewhere in the bottom
* 64kB. Note that because this data doesn't survive POST, int 0x42 should
* only be used during EGA/VGA BIOS initialisation.
*/
static const CARD8 VideoParms[] = {
/* Timing for modes 0x00 & 0x01 */
0x38, 0x28, 0x2d, 0x0a, 0x1f, 0x06, 0x19, 0x1c,
0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
/* Timing for modes 0x02 & 0x03 */
0x71, 0x50, 0x5a, 0x0a, 0x1f, 0x06, 0x19, 0x1c,
0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
/* Timing for modes 0x04, 0x05 & 0x06 */
0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70,
0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
/* Timing for mode 0x07 */
0x61, 0x50, 0x52, 0x0f, 0x19, 0x06, 0x19, 0x19,
0x02, 0x0d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
/* Display page lengths in little endian order */
0x00, 0x08, /* Modes 0x00 and 0x01 */
0x00, 0x10, /* Modes 0x02 and 0x03 */
0x00, 0x40, /* Modes 0x04 and 0x05 */
0x00, 0x40, /* Modes 0x06 and 0x07 */
/* Number of columns for each mode */
40, 40, 80, 80, 40, 40, 80, 80,
/* CGA Mode register value for each mode */
0x2c, 0x28, 0x2d, 0x29, 0x2a, 0x2e, 0x1e, 0x29,
/* Padding */
0x00, 0x00, 0x00, 0x00
};
int i;
for (i = 0; i < sizeof(VideoParms); i++)
MEM_WB(pInt, i + (0x1000 - sizeof(VideoParms)), VideoParms[i]);
MEM_WW(pInt, 0x1d << 2, 0x1000 - sizeof(VideoParms));
MEM_WW(pInt, (0x1d << 2) + 2, 0);
MEM_WW(pInt, 0x10 << 2, 0xf065);
MEM_WW(pInt, (0x10 << 2) + 2, SYS_BIOS >> 4);
MEM_WW(pInt, 0x42 << 2, 0xf065);
MEM_WW(pInt, (0x42 << 2) + 2, SYS_BIOS >> 4);
MEM_WW(pInt, 0x6D << 2, 0xf065);
MEM_WW(pInt, (0x6D << 2) + 2, SYS_BIOS >> 4);
int i;
for (i = 0; i < sizeof(VideoParms); i++)
MEM_WB(pInt, i + (0x1000 - sizeof(VideoParms)), VideoParms[i]);
MEM_WW(pInt, 0x1d << 2, 0x1000 - sizeof(VideoParms));
MEM_WW(pInt, (0x1d << 2) + 2, 0);
MEM_WW(pInt, 0x10 << 2, 0xf065);
MEM_WW(pInt, (0x10 << 2) + 2, SYS_BIOS >> 4);
MEM_WW(pInt, 0x42 << 2, 0xf065);
MEM_WW(pInt, (0x42 << 2) + 2, SYS_BIOS >> 4);
MEM_WW(pInt, 0x6D << 2, 0xf065);
MEM_WW(pInt, (0x6D << 2) + 2, SYS_BIOS >> 4);
}
void
set_return_trap(xf86Int10InfoPtr pInt)
void set_return_trap(xf86Int10InfoPtr pInt)
{
/*
* Here we set the exit condition: We return when we encounter
* 'hlt' (=0xf4), which we locate at address 0x600 in x86 memory.
*/
MEM_WB(pInt, 0x0600, 0xf4);
/*
* Allocate a segment for the stack
*/
pInt->stackseg=0x1000;
/*
* Here we set the exit condition: We return when we encounter
* 'hlt' (=0xf4), which we locate at address 0x600 in x86 memory.
*/
MEM_WB(pInt, 0x0600, 0xf4);
/*
* Allocate a segment for the stack
*/
pInt->stackseg = 0x1000;
}
Bool
initPrimary(void* options)
Bool initPrimary(void *options)
{
Bool initPrimary = FALSE;
Bool initPrimary = FALSE;
if (!options) return FALSE;
return initPrimary;
}
if (!options)
return FALSE;
return initPrimary;
}

3031
x86emu/int10/radeon_init.c

File diff suppressed because it is too large

255
x86emu/int10/radeon_reg.h

@ -70,7 +70,7 @@
#define ATI_DATATYPE_ARGB4444 15
/* Registers for 2D/Video/Overlay */
#define RADEON_ADAPTER_ID 0x0f2c /* PCI */
#define RADEON_ADAPTER_ID 0x0f2c /* PCI */
#define RADEON_AGP_BASE 0x0170
#define RADEON_AGP_CNTL 0x0174
# define RADEON_AGP_APER_SIZE_256MB (0x00 << 0)
@ -83,16 +83,16 @@
# define RADEON_AGP_APER_SIZE_MASK (0x3f << 0)
#define RADEON_STATUS_PCI_CONFIG 0x06
# define RADEON_CAP_LIST 0x100000
#define RADEON_CAPABILITIES_PTR_PCI_CONFIG 0x34 /* offset in PCI config*/
# define RADEON_CAP_PTR_MASK 0xfc /* mask off reserved bits of CAP_PTR */
# define RADEON_CAP_ID_NULL 0x00 /* End of capability list */
# define RADEON_CAP_ID_AGP 0x02 /* AGP capability ID */
# define RADEON_CAP_ID_EXP 0x10 /* PCI Express */
#define RADEON_AGP_COMMAND 0x0f60 /* PCI */
#define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config*/
#define RADEON_CAPABILITIES_PTR_PCI_CONFIG 0x34 /* offset in PCI config */
# define RADEON_CAP_PTR_MASK 0xfc /* mask off reserved bits of CAP_PTR */
# define RADEON_CAP_ID_NULL 0x00 /* End of capability list */
# define RADEON_CAP_ID_AGP 0x02 /* AGP capability ID */
# define RADEON_CAP_ID_EXP 0x10 /* PCI Express */
#define RADEON_AGP_COMMAND 0x0f60 /* PCI */
#define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config */
# define RADEON_AGP_ENABLE (1<<8)
#define RADEON_AGP_PLL_CNTL 0x000b /* PLL */
#define RADEON_AGP_STATUS 0x0f5c /* PCI */
#define RADEON_AGP_PLL_CNTL 0x000b /* PLL */
#define RADEON_AGP_STATUS 0x0f5c /* PCI */
# define RADEON_AGP_1X_MODE 0x01
# define RADEON_AGP_2X_MODE 0x02
# define RADEON_AGP_4X_MODE 0x04
@ -101,9 +101,9 @@
# define RADEON_AGPv3_MODE 0x08
# define RADEON_AGPv3_4X_MODE 0x01
# define RADEON_AGPv3_8X_MODE 0x02
#define RADEON_ATTRDR 0x03c1 /* VGA */
#define RADEON_ATTRDW 0x03c0 /* VGA */
#define RADEON_ATTRX 0x03c0 /* VGA */
#define RADEON_ATTRDR 0x03c1 /* VGA */
#define RADEON_ATTRDW 0x03c0 /* VGA */
#define RADEON_ATTRX 0x03c0 /* VGA */
#define RADEON_AUX_SC_CNTL 0x1660
# define RADEON_AUX1_SC_EN (1 << 0)
# define RADEON_AUX1_SC_MODE_OR (0 << 1)
@ -138,8 +138,8 @@
#define RADEON_BIOS_5_SCRATCH 0x0024
#define RADEON_BIOS_6_SCRATCH 0x0028
#define RADEON_BIOS_7_SCRATCH 0x002c
#define RADEON_BIOS_ROM 0x0f30 /* PCI */
#define RADEON_BIST 0x0f0f /* PCI */
#define RADEON_BIOS_ROM 0x0f30 /* PCI */
#define RADEON_BIST 0x0f0f /* PCI */
#define RADEON_BRUSH_DATA0 0x1480
#define RADEON_BRUSH_DATA1 0x1484
#define RADEON_BRUSH_DATA10 0x14a8
@ -217,10 +217,10 @@
# define RADEON_BUS_WAIT_ON_LOCK_EN (1 << 4)
#define RADEON_CACHE_CNTL 0x1724
#define RADEON_CACHE_LINE 0x0f0c /* PCI */
#define RADEON_CAPABILITIES_ID 0x0f50 /* PCI */
#define RADEON_CAPABILITIES_PTR 0x0f34 /* PCI */
#define RADEON_CLK_PIN_CNTL 0x0001 /* PLL */
#define RADEON_CACHE_LINE 0x0f0c /* PCI */
#define RADEON_CAPABILITIES_ID 0x0f50 /* PCI */
#define RADEON_CAPABILITIES_PTR 0x0f34 /* PCI */
#define RADEON_CLK_PIN_CNTL 0x0001 /* PLL */
# define RADEON_SCLK_DYN_START_CNTL (1 << 15)
#define RADEON_CLOCK_CNTL_DATA 0x000c
#define RADEON_CLOCK_CNTL_INDEX 0x0008
@ -245,7 +245,7 @@
#define RADEON_CLR_CMP_MASK 0x15cc
# define RADEON_CLR_CMP_MSK 0xffffffff
#define RADEON_CLR_CMP_MASK_3D 0x1A28
#define RADEON_COMMAND 0x0f04 /* PCI */
#define RADEON_COMMAND 0x0f04 /* PCI */
#define RADEON_COMPOSITE_SHADOW_ID 0x1a0c
#define RADEON_CONFIG_APER_0_BASE 0x0100
#define RADEON_CONFIG_APER_1_BASE 0x0104
@ -330,8 +330,8 @@
# define RADEON_CRTC2_HSYNC_DIS (1 << 28)
# define RADEON_CRTC2_VSYNC_DIS (1 << 29)
#define RADEON_CRTC_MORE_CNTL 0x27c
# define RADEON_CRTC_H_CUTOFF_ACTIVE_EN (1<<4)
# define RADEON_CRTC_V_CUTOFF_ACTIVE_EN (1<<5)
# define RADEON_CRTC_H_CUTOFF_ACTIVE_EN (1<<4)
# define RADEON_CRTC_V_CUTOFF_ACTIVE_EN (1<<5)
#define RADEON_CRTC_GUI_TRIG_VLINE 0x0218
#define RADEON_CRTC_H_SYNC_STRT_WID 0x0204
# define RADEON_CRTC_H_SYNC_STRT_PIX (0x07 << 0)
@ -432,8 +432,8 @@
#define RADEON_CRTC2_GUI_TRIG_VLINE 0x0318
#define RADEON_CRTC2_STATUS 0x03fc
#define RADEON_CRTC2_VLINE_CRNT_VLINE 0x0310
#define RADEON_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */
#define RADEON_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */
#define RADEON_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */
#define RADEON_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */
#define RADEON_CUR_CLR0 0x026c
#define RADEON_CUR_CLR1 0x0270
#define RADEON_CUR_HORZ_VERT_OFF 0x0268
@ -485,10 +485,10 @@
# define RADEON_DISP_DAC_SOURCE_CRTC2 0x01
# define RADEON_DISP_DAC2_SOURCE_CRTC2 0x04
#define RADEON_DAC_CRC_SIG 0x02cc
#define RADEON_DAC_DATA 0x03c9 /* VGA */
#define RADEON_DAC_MASK 0x03c6 /* VGA */
#define RADEON_DAC_R_INDEX 0x03c7 /* VGA */
#define RADEON_DAC_W_INDEX 0x03c8 /* VGA */
#define RADEON_DAC_DATA 0x03c9 /* VGA */
#define RADEON_DAC_MASK 0x03c6 /* VGA */
#define RADEON_DAC_R_INDEX 0x03c7 /* VGA */
#define RADEON_DAC_W_INDEX 0x03c8 /* VGA */
#define RADEON_DDA_CONFIG 0x02e0
#define RADEON_DDA_ON_OFF 0x02e4
#define RADEON_DEFAULT_OFFSET 0x16e0
@ -498,7 +498,7 @@
# define RADEON_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16)
#define RADEON_DESTINATION_3D_CLR_CMP_VAL 0x1820
#define RADEON_DESTINATION_3D_CLR_CMP_MSK 0x1824
#define RADEON_DEVICE_ID 0x0f02 /* PCI */
#define RADEON_DEVICE_ID 0x0f02 /* PCI */
#define RADEON_DISP_MISC_CNTL 0x0d00
# define RADEON_SOFT_RESET_GRPH_PP (1 << 0)
#define RADEON_DISP_MERGE_CNTL 0x0d60
@ -769,14 +769,14 @@
# define RADEON_VSYNC_INT (1 << 2)
# define RADEON_VSYNC2_INT_AK (1 << 6)
# define RADEON_VSYNC2_INT (1 << 6)
#define RADEON_GENENB 0x03c3 /* VGA */
#define RADEON_GENFC_RD 0x03ca /* VGA */
#define RADEON_GENFC_WT 0x03da /* VGA, 0x03ba */
#define RADEON_GENMO_RD 0x03cc /* VGA */
#define RADEON_GENMO_WT 0x03c2 /* VGA */
#define RADEON_GENS0 0x03c2 /* VGA */
#define RADEON_GENS1 0x03da /* VGA, 0x03ba */
#define RADEON_GPIO_MONID 0x0068 /* DDC interface via I2C */
#define RADEON_GENENB 0x03c3 /* VGA */
#define RADEON_GENFC_RD 0x03ca /* VGA */
#define RADEON_GENFC_WT 0x03da /* VGA, 0x03ba */
#define RADEON_GENMO_RD 0x03cc /* VGA */
#define RADEON_GENMO_WT 0x03c2 /* VGA */
#define RADEON_GENS0 0x03c2 /* VGA */
#define RADEON_GENS1 0x03da /* VGA, 0x03ba */
#define RADEON_GPIO_MONID 0x0068 /* DDC interface via I2C */
#define RADEON_GPIO_MONIDB 0x006c
#define RADEON_GPIO_CRT2_DDC 0x006c
#define RADEON_GPIO_DVI_DDC 0x0064
@ -789,10 +789,10 @@
# define RADEON_GPIO_Y_SHIFT_1 9
# define RADEON_GPIO_EN_0 (1 << 16)
# define RADEON_GPIO_EN_1 (1 << 17)
# define RADEON_GPIO_MASK_0 (1 << 24) /*??*/
# define RADEON_GPIO_MASK_1 (1 << 25) /*??*/
#define RADEON_GRPH8_DATA 0x03cf /* VGA */
#define RADEON_GRPH8_IDX 0x03ce /* VGA */
# define RADEON_GPIO_MASK_0 (1 << 24) /*?? */
# define RADEON_GPIO_MASK_1 (1 << 25) /*?? */
#define RADEON_GRPH8_DATA 0x03cf /* VGA */
#define RADEON_GRPH8_IDX 0x03ce /* VGA */
#define RADEON_GUI_SCRATCH_REG0 0x15e0
#define RADEON_GUI_SCRATCH_REG1 0x15e4
#define RADEON_GUI_SCRATCH_REG2 0x15e8
@ -800,7 +800,7 @@
#define RADEON_GUI_SCRATCH_REG4 0x15f0
#define RADEON_GUI_SCRATCH_REG5 0x15f4
#define RADEON_HEADER 0x0f0e /* PCI */
#define RADEON_HEADER 0x0f0e /* PCI */
#define RADEON_HOST_DATA0 0x17c0
#define RADEON_HOST_DATA1 0x17c4
#define RADEON_HOST_DATA2 0x17c8
@ -812,8 +812,8 @@
#define RADEON_HOST_DATA_LAST 0x17e0
#define RADEON_HOST_PATH_CNTL 0x0130
# define RADEON_HDP_SOFT_RESET (1 << 26)
#define RADEON_HTOTAL_CNTL 0x0009 /* PLL */
#define RADEON_HTOTAL2_CNTL 0x002e /* PLL */
#define RADEON_HTOTAL_CNTL 0x0009 /* PLL */
#define RADEON_HTOTAL2_CNTL 0x002e /* PLL */
/* Multimedia I2C bus */
#define RADEON_I2C_CNTL_0 0x0090
@ -821,14 +821,14 @@
#define RADEON_I2C_DATA 0x0098
#define RADEON_DVI_I2C_CNTL_0 0x02e0
#define RADEON_DVI_I2C_CNTL_1 0x02e4 /* ? */
#define RADEON_DVI_I2C_CNTL_1 0x02e4 /* ? */
#define RADEON_DVI_I2C_DATA 0x02e8
#define RADEON_INTERRUPT_LINE 0x0f3c /* PCI */
#define RADEON_INTERRUPT_PIN 0x0f3d /* PCI */
#define RADEON_IO_BASE 0x0f14 /* PCI */
#define RADEON_INTERRUPT_LINE 0x0f3c /* PCI */
#define RADEON_INTERRUPT_PIN 0x0f3d /* PCI */
#define RADEON_IO_BASE 0x0f14 /* PCI */
#define RADEON_LATENCY 0x0f0d /* PCI */
#define RADEON_LATENCY 0x0f0d /* PCI */
#define RADEON_LEAD_BRES_DEC 0x1608
#define RADEON_LEAD_BRES_LNTH 0x161c
#define RADEON_LEAD_BRES_LNTH_SUB 0x1624
@ -845,7 +845,7 @@
# define RADEON_HSYNC_DELAY_SHIFT 28
# define RADEON_HSYNC_DELAY_MASK (0xf << 28)
#define RADEON_MAX_LATENCY 0x0f3f /* PCI */
#define RADEON_MAX_LATENCY 0x0f3f /* PCI */
#define RADEON_MC_AGP_LOCATION 0x014c
#define RADEON_MC_FB_LOCATION 0x0148
#define RADEON_DISPLAY_BASE_ADDR 0x23c
@ -853,7 +853,7 @@
#define RADEON_OV0_BASE_ADDR 0x43c
#define RADEON_NB_TOM 0x15c
#define R300_MC_INIT_MISC_LAT_TIMER 0x180
#define RADEON_MCLK_CNTL 0x0012 /* PLL */
#define RADEON_MCLK_CNTL 0x0012 /* PLL */
# define RADEON_FORCEON_MCLKA (1 << 16)
# define RADEON_FORCEON_MCLKB (1 << 17)
# define RADEON_FORCEON_YCLKA (1 << 18)
@ -862,7 +862,7 @@
# define RADEON_FORCEON_AIC (1 << 21)
# define R300_DISABLE_MC_MCLKA (1 << 21)
# define R300_DISABLE_MC_MCLKB (1 << 21)
#define RADEON_MCLK_MISC 0x001f /* PLL */
#define RADEON_MCLK_MISC 0x001f /* PLL */
# define RADEON_MC_MCLK_MAX_DYN_STOP_LAT (1<<12)
# define RADEON_IO_MCLK_MAX_DYN_STOP_LAT (1<<13)
# define RADEON_MC_MCLK_DYN_ENABLE (1 << 14)
@ -872,26 +872,26 @@
#define RADEON_MDGPIO_MASK 0x0198
#define RADEON_MDGPIO_Y_REG 0x01b4
#define RADEON_MEM_ADDR_CONFIG 0x0148
#define RADEON_MEM_BASE 0x0f10 /* PCI */
#define RADEON_MEM_BASE 0x0f10 /* PCI */
#define RADEON_MEM_CNTL 0x0140
# define RADEON_MEM_NUM_CHANNELS_MASK 0x01
# define RADEON_MEM_USE_B_CH_ONLY (1<<1)
# define RV100_HALF_MODE (1<<3)
# define R300_MEM_NUM_CHANNELS_MASK 0x03
# define R300_MEM_USE_CD_CH_ONLY (1<<2)
#define RADEON_MEM_TIMING_CNTL 0x0144 /* EXT_MEM_CNTL */
#define RADEON_MEM_TIMING_CNTL 0x0144 /* EXT_MEM_CNTL */
#define RADEON_MEM_INIT_LAT_TIMER 0x0154
#define RADEON_MEM_INTF_CNTL 0x014c
#define RADEON_MEM_SDRAM_MODE_REG 0x0158
#define RADEON_MEM_STR_CNTL 0x0150
#define RADEON_MEM_VGA_RP_SEL 0x003c
#define RADEON_MEM_VGA_WP_SEL 0x0038
#define RADEON_MIN_GRANT 0x0f3e /* PCI */
#define RADEON_MIN_GRANT 0x0f3e /* PCI */
#define RADEON_MM_DATA 0x0004
#define RADEON_MM_INDEX 0x0000
#define RADEON_MPLL_CNTL 0x000e /* PLL */
#define RADEON_MPP_TB_CONFIG 0x01c0 /* ? */
#define RADEON_MPP_GP_CONFIG 0x01c8 /* ? */
#define RADEON_MPLL_CNTL 0x000e /* PLL */
#define RADEON_MPP_TB_CONFIG 0x01c0 /* ? */
#define RADEON_MPP_GP_CONFIG 0x01c8 /* ? */
#define R300_MC_IND_INDEX 0x01f8
# define R300_MC_IND_ADDR_MASK 0x3f
#define R300_MC_IND_DATA 0x01fc
@ -1153,7 +1153,7 @@
#define RADEON_IDCT_AUTH_CONTROL 0x1F88
#define RADEON_IDCT_AUTH 0x1F8C
#define RADEON_P2PLL_CNTL 0x002a /* P2PLL */
#define RADEON_P2PLL_CNTL 0x002a /* P2PLL */
# define RADEON_P2PLL_RESET (1 << 0)
# define RADEON_P2PLL_SLEEP (1 << 1)
# define RADEON_P2PLL_ATOMIC_UPDATE_EN (1 << 16)
@ -1162,10 +1162,10 @@
#define RADEON_P2PLL_DIV_0 0x002c
# define RADEON_P2PLL_FB0_DIV_MASK 0x07ff
# define RADEON_P2PLL_POST0_DIV_MASK 0x00070000
#define RADEON_P2PLL_REF_DIV 0x002B /* PLL */
#define RADEON_P2PLL_REF_DIV 0x002B /* PLL */
# define RADEON_P2PLL_REF_DIV_MASK 0x03ff
# define RADEON_P2PLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
# define RADEON_P2PLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
# define RADEON_P2PLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
# define RADEON_P2PLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
# define R300_PPLL_REF_DIV_ACC_MASK (0x3ff << 18)
# define R300_PPLL_REF_DIV_ACC_SHIFT 18
#define RADEON_PALETTE_DATA 0x00b4
@ -1195,14 +1195,14 @@
# define R300_P2G2CLK_DAC_ALWAYS_ONb (1 << 19)
# define R300_DISP_DAC_PIXCLK_DAC2_BLANK_OFF (1 << 23)
#define RADEON_PLANE_3D_MASK_C 0x1d44
#define RADEON_PLL_TEST_CNTL 0x0013 /* PLL */
#define RADEON_PMI_CAP_ID 0x0f5c /* PCI */
#define RADEON_PMI_DATA 0x0f63 /* PCI */
#define RADEON_PMI_NXT_CAP_PTR 0x0f5d /* PCI */
#define RADEON_PMI_PMC_REG 0x0f5e /* PCI */
#define RADEON_PMI_PMCSR_REG 0x0f60 /* PCI */
#define RADEON_PMI_REGISTER 0x0f5c /* PCI */
#define RADEON_PPLL_CNTL 0x0002 /* PLL */
#define RADEON_PLL_TEST_CNTL 0x0013 /* PLL */
#define RADEON_PMI_CAP_ID 0x0f5c /* PCI */
#define RADEON_PMI_DATA 0x0f63 /* PCI */
#define RADEON_PMI_NXT_CAP_PTR 0x0f5d /* PCI */
#define RADEON_PMI_PMC_REG 0x0f5e /* PCI */
#define RADEON_PMI_PMCSR_REG 0x0f60 /* PCI */
#define RADEON_PMI_REGISTER 0x0f5c /* PCI */
#define RADEON_PPLL_CNTL 0x0002 /* PLL */
# define RADEON_PPLL_RESET (1 << 0)
# define RADEON_PPLL_SLEEP (1 << 1)
# define RADEON_PPLL_ATOMIC_UPDATE_EN (1 << 16)
@ -1210,17 +1210,17 @@
# define RADEON_PPLL_ATOMIC_UPDATE_VSYNC (1 << 18)
# define RADEON_PPLL_PVG_MASK (7 << 11)
# define RADEON_PPLL_PVG_SHIFT 11
#define RADEON_PPLL_DIV_0 0x0004 /* PLL */
#define RADEON_PPLL_DIV_1 0x0005 /* PLL */
#define RADEON_PPLL_DIV_2 0x0006 /* PLL */
#define RADEON_PPLL_DIV_3 0x0007 /* PLL */
#define RADEON_PPLL_DIV_0 0x0004 /* PLL */
#define RADEON_PPLL_DIV_1 0x0005 /* PLL */
#define RADEON_PPLL_DIV_2 0x0006 /* PLL */
#define RADEON_PPLL_DIV_3 0x0007 /* PLL */
# define RADEON_PPLL_FB3_DIV_MASK 0x07ff
# define RADEON_PPLL_POST3_DIV_MASK 0x00070000
#define RADEON_PPLL_REF_DIV 0x0003 /* PLL */
#define RADEON_PPLL_REF_DIV 0x0003 /* PLL */
# define RADEON_PPLL_REF_DIV_MASK 0x03ff
# define RADEON_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
# define RADEON_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
#define RADEON_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */
# define RADEON_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
# define RADEON_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
#define RADEON_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */
#define RADEON_RBBM_GUICNTL 0x172c
# define RADEON_HOST_DATA_SWAP_NONE (0 << 0)
@ -1267,9 +1267,9 @@
# define RADEON_RB3D_DC_FLUSH_ALL 0xf
# define RADEON_RB3D_DC_BUSY (1 << 31)
#define RADEON_REG_BASE 0x0f18 /* PCI */
#define RADEON_REGPROG_INF 0x0f09 /* PCI */
#define RADEON_REVISION_ID 0x0f08 /* PCI */
#define RADEON_REG_BASE 0x0f18 /* PCI */
#define RADEON_REGPROG_INF 0x0f09 /* PCI */
#define RADEON_REVISION_ID 0x0f08 /* PCI */
#define RADEON_SC_BOTTOM 0x164c
#define RADEON_SC_BOTTOM_RIGHT 0x16f0
@ -1281,7 +1281,7 @@
#define RADEON_SC_TOP_LEFT_C 0x1c88
# define RADEON_SC_SIGN_MASK_LO 0x8000
# define RADEON_SC_SIGN_MASK_HI 0x80000000
#define RADEON_SCLK_CNTL 0x000d /* PLL */
#define RADEON_SCLK_CNTL 0x000d /* PLL */
# define RADEON_SCLK_SRC_SEL_MASK 0x0007
# define RADEON_DYN_STOP_LAT_MASK 0x00007ff8
# define RADEON_CP_MAX_DYN_STOP_LAT 0x0008
@ -1309,19 +1309,19 @@
# define R300_SCLK_FORCE_TX (1<<27)
# define R300_SCLK_FORCE_US (1<<28)
# define R300_SCLK_FORCE_SU (1<<30)
#define R300_SCLK_CNTL2 0x1e /* PLL */
#define R300_SCLK_CNTL2 0x1e /* PLL */
# define R300_SCLK_TCL_MAX_DYN_STOP_LAT (1<<10)
# define R300_SCLK_GA_MAX_DYN_STOP_LAT (1<<11)
# define R300_SCLK_CBA_MAX_DYN_STOP_LAT (1<<12)
# define R300_SCLK_FORCE_TCL (1<<13)
# define R300_SCLK_FORCE_CBA (1<<14)
# define R300_SCLK_FORCE_GA (1<<15)
#define RADEON_SCLK_MORE_CNTL 0x0035 /* PLL */
#define RADEON_SCLK_MORE_CNTL 0x0035 /* PLL */
# define RADEON_SCLK_MORE_MAX_DYN_STOP_LAT 0x0007
# define RADEON_SCLK_MORE_FORCEON 0x0700
#define RADEON_SDRAM_MODE_REG 0x0158
#define RADEON_SEQ8_DATA 0x03c5 /* VGA */
#define RADEON_SEQ8_IDX 0x03c4 /* VGA */
#define RADEON_SEQ8_DATA 0x03c5 /* VGA */
#define RADEON_SEQ8_IDX 0x03c4 /* VGA */
#define RADEON_SNAPSHOT_F_COUNT 0x0244
#define RADEON_SNAPSHOT_VH_COUNTS 0x0240
#define RADEON_SNAPSHOT_VIF_COUNT 0x024c
@ -1335,9 +1335,9 @@
#define RADEON_SRC_X_Y 0x1590
#define RADEON_SRC_Y 0x1418
#define RADEON_SRC_Y_X 0x1434
#define RADEON_STATUS 0x0f06 /* PCI */
#define RADEON_SUBPIC_CNTL 0x0540 /* ? */
#define RADEON_SUB_CLASS 0x0f0a /* PCI */
#define RADEON_STATUS 0x0f06 /* PCI */
#define RADEON_SUBPIC_CNTL 0x0540 /* ? */
#define RADEON_SUB_CLASS 0x0f0a /* PCI */
#define RADEON_SURFACE_CNTL 0x0b00
# define RADEON_SURF_TRANSLATION_DIS (1 << 8)
# define RADEON_NONSURF_AP0_SWP_16BPP (1 << 20)
@ -1402,7 +1402,7 @@
#define RADEON_TRAIL_X 0x1618
#define RADEON_TRAIL_X_SUB 0x1620
#define RADEON_VCLK_ECP_CNTL 0x0008 /* PLL */
#define RADEON_VCLK_ECP_CNTL 0x0008 /* PLL */
# define RADEON_VCLK_SRC_SEL_MASK 0x03
# define RADEON_VCLK_SRC_SEL_CPUCLK 0x00
# define RADEON_VCLK_SRC_SEL_PSCANCLK 0x01
@ -1412,13 +1412,13 @@
# define RADEON_PIXCLK_DAC_ALWAYS_ONb (1<<7)
# define R300_DISP_DAC_PIXCLK_DAC_BLANK_OFF (1<<23)
#define RADEON_VENDOR_ID 0x0f00 /* PCI */
#define RADEON_VENDOR_ID 0x0f00 /* PCI */
#define RADEON_VGA_DDA_CONFIG 0x02e8
#define RADEON_VGA_DDA_ON_OFF 0x02ec
#define RADEON_VID_BUFFER_CONTROL 0x0900
#define RADEON_VIDEOMUX_CNTL 0x0190
/* VIP bus */
/* VIP bus */
#define RADEON_VIPH_CH0_DATA 0x0c00
#define RADEON_VIPH_CH1_DATA 0x0c04
#define RADEON_VIPH_CH2_DATA 0x0c08
@ -1447,19 +1447,16 @@
#define RADEON_VIPH_REG_DATA 0x0084
#define RADEON_VIPH_REG_ADDR 0x0080
#define RADEON_WAIT_UNTIL 0x1720
# define RADEON_WAIT_CRTC_PFLIP (1 << 0)
# define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
# define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
# define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
#define RADEON_X_MPLL_REF_FB_DIV 0x000a /* PLL */
#define RADEON_XCLK_CNTL 0x000d /* PLL */
#define RADEON_XDLL_CNTL 0x000c /* PLL */
#define RADEON_XPLL_CNTL 0x000b /* PLL */
#define RADEON_X_MPLL_REF_FB_DIV 0x000a /* PLL */
#define RADEON_XCLK_CNTL 0x000d /* PLL */
#define RADEON_XDLL_CNTL 0x000c /* PLL */
#define RADEON_XPLL_CNTL 0x000b /* PLL */
/* Registers for 3D/TCL */
#define RADEON_PP_BORDER_COLOR_0 0x1d40
@ -1659,7 +1656,7 @@
# define RADEON_TXO_OFFSET_MASK 0xffffffe0
# define RADEON_TXO_OFFSET_SHIFT 5
#define RADEON_PP_CUBIC_OFFSET_T0_0 0x1dd0 /* bits [31:5] */
#define RADEON_PP_CUBIC_OFFSET_T0_0 0x1dd0 /* bits [31:5] */
#define RADEON_PP_CUBIC_OFFSET_T0_1 0x1dd4
#define RADEON_PP_CUBIC_OFFSET_T0_2 0x1dd8
#define RADEON_PP_CUBIC_OFFSET_T0_3 0x1ddc
@ -1675,7 +1672,7 @@
#define RADEON_PP_CUBIC_OFFSET_T2_3 0x1e20
#define RADEON_PP_CUBIC_OFFSET_T2_4 0x1e24
#define RADEON_PP_TEX_SIZE_0 0x1d04 /* NPOT */
#define RADEON_PP_TEX_SIZE_0 0x1d04 /* NPOT */
#define RADEON_PP_TEX_SIZE_1 0x1d0c
#define RADEON_PP_TEX_SIZE_2 0x1d14
# define RADEON_TEX_USIZE_MASK (0x7ff << 0)
@ -1686,9 +1683,9 @@
# define RADEON_SIGNED_RGB_SHIFT 30
# define RADEON_SIGNED_ALPHA_MASK (1 << 31)
# define RADEON_SIGNED_ALPHA_SHIFT 31
#define RADEON_PP_TEX_PITCH_0 0x1d08 /* NPOT */
#define RADEON_PP_TEX_PITCH_1 0x1d10 /* NPOT */
#define RADEON_PP_TEX_PITCH_2 0x1d18 /* NPOT */
#define RADEON_PP_TEX_PITCH_0 0x1d08 /* NPOT */
#define RADEON_PP_TEX_PITCH_1 0x1d10 /* NPOT */
#define RADEON_PP_TEX_PITCH_2 0x1d18 /* NPOT */
/* note: bits 13-5: 32 byte aligned stride of texture map */
#define RADEON_PP_TXCBLEND_0 0x1c60
@ -2034,7 +2031,7 @@
# define RADEON_ROUND_PREC_8TH_PIX (1 << 30)
# define RADEON_ROUND_PREC_4TH_PIX (2 << 30)
# define RADEON_ROUND_PREC_HALF_PIX (3 << 30)
#define R200_RE_CNTL 0x1c50
#define R200_RE_CNTL 0x1c50
# define R200_STIPPLE_ENABLE 0x1
# define R200_SCISSOR_ENABLE 0x2
# define R200_PATTERN_ENABLE 0x4
@ -2122,7 +2119,6 @@
# define RADEON_TEXMAT_2_SHIFT 24
# define RADEON_TEXMAT_3_SHIFT 28
#define RADEON_SE_TCL_OUTPUT_VTX_FMT 0x2254
# define RADEON_TCL_VTX_W0 (1 << 0)
# define RADEON_TCL_VTX_FP_DIFFUSE (1 << 1)
@ -2318,7 +2314,7 @@
# define RADEON_VF_NUM_VERTICES_SHIFT 16
#define RADEON_SE_PORT_DATA0 0x2000
#define R200_SE_VAP_CNTL 0x2080
# define R200_VAP_TCL_ENABLE 0x00000001
# define R200_VAP_SINGLE_BUF_STATE_ENABLE 0x00000010
@ -2345,7 +2341,7 @@
# define R200_VC_NO_SWAP (0 << 0)
# define R200_VC_16BIT_SWAP (1 << 0)
# define R200_VC_32BIT_SWAP (2 << 0)
#define R200_PP_TXFILTER_0 0x2c00
#define R200_PP_TXFILTER_0 0x2c00
#define R200_PP_TXFILTER_1 0x2c20
#define R200_PP_TXFILTER_2 0x2c40
#define R200_PP_TXFILTER_3 0x2c60
@ -2451,19 +2447,19 @@
#define R200_PP_TXFORMAT_X_4 0x2c88
#define R200_PP_TXFORMAT_X_5 0x2ca8
#define R200_PP_TXSIZE_0 0x2c0c /* NPOT only */
#define R200_PP_TXSIZE_1 0x2c2c /* NPOT only */
#define R200_PP_TXSIZE_2 0x2c4c /* NPOT only */
#define R200_PP_TXSIZE_3 0x2c6c /* NPOT only */
#define R200_PP_TXSIZE_4 0x2c8c /* NPOT only */
#define R200_PP_TXSIZE_5 0x2cac /* NPOT only */
#define R200_PP_TXSIZE_0 0x2c0c /* NPOT only */
#define R200_PP_TXSIZE_1 0x2c2c /* NPOT only */
#define R200_PP_TXSIZE_2 0x2c4c /* NPOT only */
#define R200_PP_TXSIZE_3 0x2c6c /* NPOT only */
#define R200_PP_TXSIZE_4 0x2c8c /* NPOT only */
#define R200_PP_TXSIZE_5 0x2cac /* NPOT only */
#define R200_PP_TXPITCH_0 0x2c10 /* NPOT only */
#define R200_PP_TXPITCH_1 0x2c30 /* NPOT only */
#define R200_PP_TXPITCH_2 0x2c50 /* NPOT only */
#define R200_PP_TXPITCH_3 0x2c70 /* NPOT only */
#define R200_PP_TXPITCH_4 0x2c90 /* NPOT only */
#define R200_PP_TXPITCH_5 0x2cb0 /* NPOT only */
#define R200_PP_TXPITCH_0 0x2c10 /* NPOT only */
#define R200_PP_TXPITCH_1 0x2c30 /* NPOT only */
#define R200_PP_TXPITCH_2 0x2c50 /* NPOT only */
#define R200_PP_TXPITCH_3 0x2c70 /* NPOT only */
#define R200_PP_TXPITCH_4 0x2c90 /* NPOT only */
#define R200_PP_TXPITCH_5 0x2cb0 /* NPOT only */
#define R200_PP_TXOFFSET_0 0x2d00
# define R200_TXO_ENDIAN_NO_SWAP (0 << 0)
@ -2636,8 +2632,8 @@
# define R200_TXC_REPL_ARG_C_MASK (3 << 30)
#define R200_PP_TXABLEND_0 0x2f08
# define R200_TXA_ARG_A_ZERO (0)
# define R200_TXA_ARG_A_CURRENT_ALPHA (2) /* guess */
# define R200_TXA_ARG_A_CURRENT_BLUE (3) /* guess */
# define R200_TXA_ARG_A_CURRENT_ALPHA (2) /* guess */
# define R200_TXA_ARG_A_CURRENT_BLUE (3) /* guess */
# define R200_TXA_ARG_A_DIFFUSE_ALPHA (4)
# define R200_TXA_ARG_A_DIFFUSE_BLUE (5)
# define R200_TXA_ARG_A_SPECULAR_ALPHA (6)
@ -2661,8 +2657,8 @@
# define R200_TXA_ARG_A_MASK (31 << 0)
# define R200_TXA_ARG_A_SHIFT 0
# define R200_TXA_ARG_B_ZERO (0 << 5)
# define R200_TXA_ARG_B_CURRENT_ALPHA (2 << 5) /* guess */
# define R200_TXA_ARG_B_CURRENT_BLUE (3 << 5) /* guess */
# define R200_TXA_ARG_B_CURRENT_ALPHA (2 << 5) /* guess */
# define R200_TXA_ARG_B_CURRENT_BLUE (3 << 5) /* guess */
# define R200_TXA_ARG_B_DIFFUSE_ALPHA (4 << 5)
# define R200_TXA_ARG_B_DIFFUSE_BLUE (5 << 5)
# define R200_TXA_ARG_B_SPECULAR_ALPHA (6 << 5)
@ -2686,8 +2682,8 @@
# define R200_TXA_ARG_B_MASK (31 << 5)
# define R200_TXA_ARG_B_SHIFT 5
# define R200_TXA_ARG_C_ZERO (0 << 10)
# define R200_TXA_ARG_C_CURRENT_ALPHA (2 << 10) /* guess */
# define R200_TXA_ARG_C_CURRENT_BLUE (3 << 10) /* guess */
# define R200_TXA_ARG_C_CURRENT_ALPHA (2 << 10) /* guess */
# define R200_TXA_ARG_C_CURRENT_BLUE (3 << 10) /* guess */
# define R200_TXA_ARG_C_DIFFUSE_ALPHA (4 << 10)
# define R200_TXA_ARG_C_DIFFUSE_BLUE (5 << 10)
# define R200_TXA_ARG_C_SPECULAR_ALPHA (6 << 10)
@ -2769,7 +2765,7 @@
# define R200_TXA_REPL_ARG_C_MASK (3 << 30)
#define R200_SE_VTX_FMT_0 0x2088
# define R200_VTX_XY 0 /* always have xy */
# define R200_VTX_XY 0 /* always have xy */
# define R200_VTX_Z0 (1<<0)
# define R200_VTX_W0 (1<<1)
# define R200_VTX_WEIGHT_COUNT_SHIFT (2)
@ -2866,14 +2862,10 @@
# define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
#define RADEON_AIC_LO_ADDR 0x01dc
/* Constants */
#define RADEON_LAST_FRAME_REG RADEON_GUI_SCRATCH_REG0
#define RADEON_LAST_CLEAR_REG RADEON_GUI_SCRATCH_REG2
/* CP packet types */
#define RADEON_CP_PACKET0 0x00000000
#define RADEON_CP_PACKET1 0x40000000
@ -2911,7 +2903,6 @@
#define RADEON_CP_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00
#define RADEON_CP_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00
#define RADEON_CP_VC_FRMT_XY 0x00000000
#define RADEON_CP_VC_FRMT_W0 0x00000001
#define RADEON_CP_VC_FRMT_FPCOLOR 0x00000002

64
x86emu/int10/rs690_struct.c

@ -0,0 +1,64 @@
#include "rs690_struct.h"
/*--------------------------------------------------------------------------------*/
/*
* internal used, most will be filled by vuma init
*/
struct ati_integrated_system_info ati_int_info = {
/* basic */
0, // size of this struct, filled by init
0, // major_ver, filled by init
0, // minor_ver, filled by init
0, // bootup_engine_clock, filled by init, 10KHz unit
0, // bootup_memory_clock, filled by init, 10KHz unit
0, // max_system_memory_clock, filled by init, 10KHz unit
0, // min_system_memory_clock, filled by init, 10KHz unit
0, // num_of_cycle_in_period_hi, filled by init
0, // Reserved1
0, // Reserved2
0, // inter_nb_voltage_low
0, // inter_nb_voltage_high
0, // Reserved3
0, // fsb, MHz unit
0, // cap_flag
/* upstream part */
0, // pcie_nbcfg_reg7, filled by init
0, // k8 memory clock, filled by init
0, // k8 sync start delay, filled by init
0, // k8 data return time, filled by init
0, // max_nb_voltage, filled by init
0, // min_nb_voltage, filled by init
0, // memory_type, filled by init
/* others */
0, // num of cycles in period, filled by init
0, // start_pwm_high_time, filled by init
0, // ht_link_width, filled by init
0, // max_nb_voltage_high, filled by init
0 // min_nb_voltage_high, filled by init
};

39
x86emu/int10/rs690_struct.h

@ -0,0 +1,39 @@
#include <sys/linux/types.h>
struct ati_integrated_system_info {
u16 struct_size; // this struct size
u8 major_ver; // major version
u8 minor_ver; // minor version
u32 bootup_engine_clock; // unit : 10KHz
u32 bootup_memory_clock; // unit : 10KHz
u32 max_system_memory_clock; // unit : 10KHz
u32 min_system_memory_clock; // unit : 10KHz
u8 num_of_cycles_in_period_hi;
u8 reserved1;
u16 reserved2;
u16 inter_nb_voltage_low; // intermidiate PWM value to set the voltage
u16 inter_nb_voltage_high;
u32 reserved3;
u16 fsb; // unit : MHz
#define CAP_FLAG_FAKE_HDMI_SUPPORT 0x01
#define CAP_FLAG_CLOCK_GATING_ENABLE 0x02
#define CAP_FLAG_NO_CARD 0x00
#define CAP_FLAG_AC_CARD 0x04
#define CAP_FLAG_SDVO 0x08
u16 cap_flag;
u16 pcie_nbcfg_reg7; // NBMISC 0x37 value
u16 k8_memory_clock; // k8 memory clock
u16 k8_sync_start_delay;
u16 k8_data_return_time;
u8 max_nb_voltage;
u8 min_nb_voltage;
u8 memory_type; // bits[7:4] = '0001'DDR1 '0010'DDR2 '0011'DDR3
u8 num_of_cycles_in_period;
u8 start_pwm_high_time;
u8 ht_link_width;
u8 max_nb_voltage_high;
u8 min_nb_voltage_high;
};

1474
x86emu/int10/theater_out.c

File diff suppressed because it is too large

96
x86emu/int10/theater_out.h

@ -0,0 +1,96 @@
/*********************************************************************
*
* $Id: theater_out.h,v 1.1.2.2 2004/01/27 22:50:35 fulivi Exp $
*
* Interface file for theater_out module
*
* Copyright (C) 2003 Federico Ulivi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* AUTHORS: F.Ulivi
* NOTES:
* $Log: theater_out.h,v $
* Revision 1.1.2.2 2004/01/27 22:50:35 fulivi
* Support for positioning/sizing of image added
*
* Revision 1.1.2.9 2004/01/18 23:01:12 fede
* Functions for get/setting h/v pos/size replaced by
* theaterOutSetAttr/theaterOutGetAttr/theaterOutGetAttrLimits
* Circular inclusion with radeon.h fixed
*
* Revision 1.1.2.8 2004/01/11 21:43:32 fede
* Fixed problem with definition of TVStd
*
* Revision 1.1.2.7 2004/01/05 00:09:59 fede
* Functions for setting/getting H/V position added
* Functions for setting/getting on/off attribute removed
*
* Revision 1.1.2.1 2003/11/26 19:50:10 fulivi
* Support for ERT added
*
* Revision 1.1.2.6 2003/11/25 20:44:00 fede
* TV_STD_KEEP_OFF added
*
* Revision 1.1.2.5 2003/10/14 18:41:32 fede
* forceERT changed to forceVIP
*
* Revision 1.1.2.4 2003/10/11 12:30:30 fede
* Support for ERT added
*
* Revision 1.1 2003/09/28 21:42:37 fulivi
* Theater_out module added
*
* Revision 1.1.2.3 2003/09/28 15:26:09 fede
* Minor aesthetic changes
*
* Revision 1.1.2.1 2003/08/31 13:36:35 fede
* *** empty log message ***
*
*
*********************************************************************/
#ifndef _THEATER_OUT_H
#define _THEATER_OUT_H
/**********************************************************************
*
* TheaterOutPtr
*
* Pointer to TheaterOut struct. Actual definition is in theater_out.c
*
**********************************************************************/
typedef struct TheaterOut *TheaterOutPtr;
/**********************************************************************
*
* TVStd
*
* Tv standard
*
**********************************************************************/
typedef enum {
TV_STD_NTSC,
TV_STD_PAL,
TV_STD_PAL_M,
TV_STD_PAL_60,
TV_STD_NTSC_J,
TV_STD_PAL_CN,
TV_STD_PAL_N,
TV_STD_KEEP_OFF,
TV_STD_N_STANDARDS /* Must be last */
} TVStd;
#endif /* _THEATER_OUT_H */

64
x86emu/int10/vesa.h

@ -0,0 +1,64 @@
/*
* Modifications to support Loongson Arch:
* Copyright (c) 2008 Lemote. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/*
* VESA framebuffer support. Author: Lj.Peng <penglj@lemote.com>
*/
/* For vesa mode control */
#define GRAPHIC_MODE_100 0x100 /* 640x480 256*/
#define GRAPHIC_MODE_101 0x101 /* 640x480 256*/
#define GRAPHIC_MODE_102 0x102 /* 800x600 16 */
#define GRAPHIC_MODE_103 0x103 /* 800x600 256*/
#define GRAPHIC_MODE_104 0x104 /* 1024x768 16*/
#define GRAPHIC_MODE_105 0x105 /* 1024x768 256*/
#define GRAPHIC_MODE_106 0x106 /* 1280x1024 16*/
#define GRAPHIC_MODE_107 0x107 /* 1280x1024 256*/
#define GRAPHIC_MODE_10d 0x10d /* 320x200 32K(1:5:5:5)*/
#define GRAPHIC_MODE_10e 0x10e /* 320x200 64K(5:6:5)*/
#define GRAPHIC_MODE_10f 0x10f /* 320x200 16.8M(8:8:8)*/
#define GRAPHIC_MODE_110 0x110 /* 640x480 32K*/
#define GRAPHIC_MODE_111 0x111 /* 640x480 64K*/
#define GRAPHIC_MODE_112 0x112 /* 640x480 16.8M*/
#define GRAPHIC_MODE_113 0x113 /* 800x600 32K*/
#define GRAPHIC_MODE_114 0x114 /* 800x600 64K*/
#define GRAPHIC_MODE_115 0x115 /* 800x600 16.8M*/
#define GRAPHIC_MODE_116 0x116 /* 1024x768 32K*/
#define GRAPHIC_MODE_117 0x117 /* 1024x768 64K*/
#define GRAPHIC_MODE_118 0x118 /* 1024x768 16.8M*/
#define GRAPHIC_MODE_119 0x119 /* 1280x1024 32K*/
#define GRAPHIC_MODE_11a 0x11a /* 1280x1024 64K*/
#define GRAPHIC_MODE_11b 0x11b /* 1280x1024 16.8M*/
#define USE_LINEAR_FRAMEBUFFER 0x4000
struct vesamode {
int mode;
int width;
int height;
int bpp;
};

589
x86emu/int10/vesafb.c

@ -0,0 +1,589 @@
/*
* Modifications to support Loongson Arch:
* Copyright (c) 2008 Lemote. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/*
* VESA framebuffer support. Author: Lj.Peng <penglj@lemote.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <dev/pci/pcivar.h>
#include "xf86int10.h"
#include "xf86x86emu.h"
#include "linux/io.h"
#include "mod_framebuffer.h"
#include "vesa.h"
#include <mod_sisfb.h>
//#include "bonito.h"
extern struct pci_device *vga_dev;
int vesa_mode = 1;
/*
* The following macros are especially useful for __asm__
* inline assembler.
*/
#ifndef __STR
#define __STR(x) #x
#endif
#ifndef STR
#define STR(x) __STR(x)
#endif
/*
* Configure language
*/
#ifdef __ASSEMBLY__
#define _ULCAST_
#else
#define _ULCAST_ (unsigned long)
#endif
/*
* Coprocessor 0 register names
*/
#define CP0_INDEX $0
#define CP0_RANDOM $1
#define CP0_ENTRYLO0 $2
#define CP0_ENTRYLO1 $3
#define CP0_CONF $3
#define CP0_CONTEXT $4
#define CP0_PAGEMASK $5
#define CP0_WIRED $6
#define CP0_INFO $7
#define CP0_BADVADDR $8
#define CP0_COUNT $9
#define CP0_ENTRYHI $10
#define CP0_COMPARE $11
#define CP0_STATUS $12
#define CP0_CAUSE $13
#define CP0_EPC $14
#define CP0_PRID $15
#define CP0_CONFIG $16
#define CP0_LLADDR $17
#define CP0_WATCHLO $18
#define CP0_WATCHHI $19
#define CP0_XCONTEXT $20
#define CP0_FRAMEMASK $21
#define CP0_DIAGNOSTIC $22
#define CP0_DEBUG $23
#define CP0_DEPC $24
#define CP0_PERFORMANCE $25
#define CP0_ECC $26
#define CP0_CACHEERR $27
#define CP0_TAGLO $28
#define CP0_TAGHI $29
#define CP0_ERROREPC $30
#define CP0_DESAVE $31
/*
* R4640/R4650 cp0 register names. These registers are listed
* here only for completeness; without MMU these CPUs are not useable
* by Linux. A future ELKS port might take make Linux run on them
* though ...
*/
#define CP0_IBASE $0
#define CP0_IBOUND $1
#define CP0_DBASE $2
#define CP0_DBOUND $3
#define CP0_CALG $17
#define CP0_IWATCH $18
#define CP0_DWATCH $19
/*
* Coprocessor 0 Set 1 register names
*/
#define CP0_S1_DERRADDR0 $26
#define CP0_S1_DERRADDR1 $27
#define CP0_S1_INTCONTROL $20
/*
* TX39 Series
*/
#define CP0_TX39_CACHE $7
/*
* Coprocessor 1 (FPU) register names
*/
#define CP1_REVISION $0
#define CP1_STATUS $31
#define PM_4K 0x00000000
#define PM_16K 0x00006000
#define PM_64K 0x0001e000
#define PM_256K 0x0007e000
#define PM_1M 0x001fe000
#define PM_4M 0x007fe000
#define PM_16M 0x01ffe000
#define PM_64M 0x07ffe000
#define PM_256M 0x1fffe000
/* Page size 64kb */
#define CONFIG_PAGE_SIZE_1M
/*
* Default page size for a given kernel configuration
*/
#ifdef CONFIG_PAGE_SIZE_4KB
#define PM_DEFAULT_MASK PM_4K
#elif defined(CONFIG_PAGE_SIZE_16KB)
#define PM_DEFAULT_MASK PM_16K
#elif defined(CONFIG_PAGE_SIZE_64KB)
#define PM_DEFAULT_MASK PM_64K
#elif defined(CONFIG_PAGE_SIZE_256KB)
#define PM_DEFAULT_MASK PM_256K
#elif defined(CONFIG_PAGE_SIZE_1M)
#define PM_DEFAULT_MASK PM_1M
#elif defined(CONFIG_PAGE_SIZE_4M)
#define PM_DEFAULT_MASK PM_4M
#else
#error Bad page size configuration!
#endif
/*
* Values used for computation of new tlb entries
*/
#define PL_4K 12
#define PL_16K 14
#define PL_64K 16
#define PL_256K 18
#define PL_1M 20
#define PL_4M 22
#define PL_16M 24
#define PL_64M 26
#define PL_256M 28
/*
* Macros to access the system control coprocessor
*/
#define __read_32bit_c0_register(source, sel) \
({ int __res; \
if (sel == 0) \
__asm__ __volatile__( \
"mfc0\t%0, " #source "\n\t" \
: "=r" (__res)); \
else \
__asm__ __volatile__( \
".set\tmips32\n\t" \
"mfc0\t%0, " #source ", " #sel "\n\t" \
".set\tmips0\n\t" \
: "=r" (__res)); \
__res; \
})
#define __read_64bit_c0_register(source, sel) \
({ unsigned long __res; \
if (sel == 0) \
__asm__ __volatile__( \
".set\tmips3\n\t" \
"dmfc0\t%0, " #source "\n\t" \
".set\tmips0" \
: "=r" (__res)); \
else \
__asm__ __volatile__( \
".set\tmips64\n\t" \
"dmfc0\t%0, " #source ", " #sel "\n\t" \
".set\tmips0" \
: "=r" (__res)); \
__res; \
})
#define __write_32bit_c0_register(register, sel, value) \
do { \
if (sel == 0) \
__asm__ __volatile__( \
"mtc0\t%z0, " #register "\n\t" \
: : "Jr" (value)); \
else \
__asm__ __volatile__( \
".set\tmips32\n\t" \
"mtc0\t%z0, " #register ", " #sel "\n\t" \
".set\tmips0" \
: : "Jr" (value)); \
} while (0)
#define __write_64bit_c0_register(register, sel, value) \
do { \
if (sel == 0) \
__asm__ __volatile__( \
".set\tmips3\n\t" \
"dmtc0\t%z0, " #register "\n\t" \
".set\tmips0" \
: : "Jr" (value)); \
else \
__asm__ __volatile__( \
".set\tmips64\n\t" \
"dmtc0\t%z0, " #register ", " #sel "\n\t" \
".set\tmips0" \
: : "Jr" (value)); \
} while (0)
#define __read_ulong_c0_register(reg, sel) \
((sizeof(unsigned long) == 4) ? \
__read_32bit_c0_register(reg, sel) : \
__read_64bit_c0_register(reg, sel))
#define __write_ulong_c0_register(reg, sel, val) \
do { \
if (sizeof(unsigned long) == 4) \
__write_32bit_c0_register(reg, sel, val); \
else \
__write_64bit_c0_register(reg, sel, val); \
} while (0)
#define read_c0_index() __read_32bit_c0_register($0, 0)
#define write_c0_index(val) __write_32bit_c0_register($0, 0, val)
#define read_c0_entrylo0() __read_ulong_c0_register($2, 0)
#define write_c0_entrylo0(val) __write_ulong_c0_register($2, 0, val)
#define read_c0_entrylo1() __read_ulong_c0_register($3, 0)
#define write_c0_entrylo1(val) __write_ulong_c0_register($3, 0, val)
#define read_c0_conf() __read_32bit_c0_register($3, 0)
#define write_c0_conf(val) __write_32bit_c0_register($3, 0, val)
#define read_c0_context() __read_ulong_c0_register($4, 0)
#define write_c0_context(val) __write_ulong_c0_register($4, 0, val)
#define read_c0_pagemask() __read_32bit_c0_register($5, 0)
#define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val)
#define read_c0_wired() __read_32bit_c0_register($6, 0)
#define write_c0_wired(val) __write_32bit_c0_register($6, 0, val)
#define read_c0_info() __read_32bit_c0_register($7, 0)
#define read_c0_cache() __read_32bit_c0_register($7, 0) /* TX39xx */
#define write_c0_cache(val) __write_32bit_c0_register($7, 0, val)
#define read_c0_count() __read_32bit_c0_register($9, 0)
#define write_c0_count(val) __write_32bit_c0_register($9, 0, val)
#define read_c0_entryhi() __read_ulong_c0_register($10, 0)
#define write_c0_entryhi(val) __write_ulong_c0_register($10, 0, val)
#define read_c0_compare() __read_32bit_c0_register($11, 0)
#define write_c0_compare(val) __write_32bit_c0_register($11, 0, val)
#define read_c0_status() __read_32bit_c0_register($12, 0)
#define write_c0_status(val) __write_32bit_c0_register($12, 0, val)
#define read_c0_cause() __read_32bit_c0_register($13, 0)
#define write_c0_cause(val) __write_32bit_c0_register($13, 0, val)
#define read_c0_prid() __read_32bit_c0_register($15, 0)
#define read_c0_config() __read_32bit_c0_register($16, 0)
#define read_c0_config1() __read_32bit_c0_register($16, 1)
#define read_c0_config2() __read_32bit_c0_register($16, 2)
#define read_c0_config3() __read_32bit_c0_register($16, 3)
#define write_c0_config(val) __write_32bit_c0_register($16, 0, val)
#define write_c0_config1(val) __write_32bit_c0_register($16, 1, val)
#define write_c0_config2(val) __write_32bit_c0_register($16, 2, val)
#define write_c0_config3(val) __write_32bit_c0_register($16, 3, val)
#define read_c0_framemask() __read_32bit_c0_register($21, 0)
#define write_c0_framemask(val) __write_32bit_c0_register($21, 0, val)
#define read_c0_debug() __read_32bit_c0_register($23, 0)
#define write_c0_debug(val) __write_32bit_c0_register($23, 0, val)
#define read_c0_depc() __read_ulong_c0_register($24, 0)
#define write_c0_depc(val) __write_ulong_c0_register($24, 0, val)
#define read_c0_ecc() __read_32bit_c0_register($26, 0)
#define write_c0_ecc(val) __write_32bit_c0_register($26, 0, val)
#define read_c0_derraddr0() __read_ulong_c0_register($26, 1)
#define write_c0_derraddr0(val) __write_ulong_c0_register($26, 1, val)
#define read_c0_cacheerr() __read_32bit_c0_register($27, 0)
#define read_c0_derraddr1() __read_ulong_c0_register($27, 1)
#define write_c0_derraddr1(val) __write_ulong_c0_register($27, 1, val)
#define read_c0_taglo() __read_32bit_c0_register($28, 0)
#define write_c0_taglo(val) __write_32bit_c0_register($28, 0, val)
#define read_c0_taghi() __read_32bit_c0_register($29, 0)
#define write_c0_taghi(val) __write_32bit_c0_register($29, 0, val)
#define read_c0_errorepc() __read_ulong_c0_register($30, 0)
#define write_c0_errorepc(val) __write_ulong_c0_register($30, 0, val)
/*
* TLB operations.
*/
static inline void tlb_probe(void)
{
__asm__ __volatile__(
".set noreorder\n\t"
"tlbp\n\t"
".set reorder");
}
static inline void tlb_read(void)
{
__asm__ __volatile__(
".set noreorder\n\t"
"tlbr\n\t"
".set reorder");
}
static inline void tlb_write_indexed(void)
{
__asm__ __volatile__(
".set noreorder\n\t"
"tlbwi\n\t"
".set reorder");
}
static inline void tlb_write_random(void)
{
__asm__ __volatile__(
".set noreorder\n\t"
"tlbwr\n\t"
".set reorder");
}
#define ASID_INC 0x1
#define ASID_MASK 0xff
/*
* PAGE_SHIFT determines the page size
*/
#ifdef CONFIG_PAGE_SIZE_4KB
#define PAGE_SHIFT 12
#endif
#ifdef CONFIG_PAGE_SIZE_16KB
#define PAGE_SHIFT 14
#endif
#ifdef CONFIG_PAGE_SIZE_64KB
#define PAGE_SHIFT 16
#endif
#ifdef CONFIG_PAGE_SIZE_256KB
#define PAGE_SHIFT 18
#endif
#ifdef CONFIG_PAGE_SIZE_1M
#define PAGE_SHIFT 20
#endif
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
/* For vesa mode control */
#define GRAPHIC_MODE_100 0x100 /* 640x400 256*/
#define GRAPHIC_MODE_101 0x101 /* 640x480 256*/
#define GRAPHIC_MODE_102 0x102 /* 800x600 16 */
#define GRAPHIC_MODE_103 0x103 /* 800x600 256*/
#define GRAPHIC_MODE_104 0x104 /* 1024x768 16*/
#define GRAPHIC_MODE_105 0x105 /* 1024x768 256*/
#define GRAPHIC_MODE_106 0x106 /* 1280x1024 16*/
#define GRAPHIC_MODE_107 0x107 /* 1280x1024 256*/
#define GRAPHIC_MODE_10d 0x10d /* 320x200 32K(1:5:5:5)*/
#define GRAPHIC_MODE_10e 0x10e /* 320x200 64K(5:6:5)*/
#define GRAPHIC_MODE_10f 0x10f /* 320x200 16.8M(8:8:8)*/
#define GRAPHIC_MODE_110 0x110 /* 640x480 32K*/
#define GRAPHIC_MODE_111 0x111 /* 640x480 64K*/
#define GRAPHIC_MODE_112 0x112 /* 640x480 16.8M*/
#define GRAPHIC_MODE_113 0x113 /* 800x600 32K*/
#define GRAPHIC_MODE_114 0x114 /* 800x600 64K*/
#define GRAPHIC_MODE_115 0x115 /* 800x600 16.8M*/
#define GRAPHIC_MODE_116 0x116 /* 1024x768 32K*/
#define GRAPHIC_MODE_117 0x117 /* 1024x768 64K*/
#define GRAPHIC_MODE_118 0x118 /* 1024x768 16.8M*/
#define GRAPHIC_MODE_119 0x119 /* 1280x1024 32K*/
#define GRAPHIC_MODE_11a 0x11a /* 1280x1024 64K*/
#define GRAPHIC_MODE_11b 0x11b /* 1280x1024 16.8M*/
#define USE_LINEAR_FRAMEBUFFER 0x4000
struct vesamode vesamode[] = {
{GRAPHIC_MODE_114,800,600,16}, /* default 800x600x16 */
{GRAPHIC_MODE_100,640,400,8},
{GRAPHIC_MODE_101,640,480,8},
{GRAPHIC_MODE_102,800,600,4},
{GRAPHIC_MODE_103,800,600,8},
{GRAPHIC_MODE_104,1024,768,16},
{GRAPHIC_MODE_105,1024,768,8},
{GRAPHIC_MODE_106,1280,1024,16},
{GRAPHIC_MODE_107,1280,1024,8},
{GRAPHIC_MODE_10d,320,200,15},
{GRAPHIC_MODE_10e,320,200,16},
{GRAPHIC_MODE_10f,320,200,24},
{GRAPHIC_MODE_110,640,480,15},
{GRAPHIC_MODE_111,640,480,16},
{GRAPHIC_MODE_112,640,480,24},
{GRAPHIC_MODE_113,800,600,15},
{GRAPHIC_MODE_114,800,600,16},
{GRAPHIC_MODE_115,800,600,24},
{GRAPHIC_MODE_116,1024,768,15},
{GRAPHIC_MODE_117,1024,768,16},
{GRAPHIC_MODE_118,1024,768,24},
{GRAPHIC_MODE_119,1280,1024,15},
{GRAPHIC_MODE_11a,1280,1024,16},
{GRAPHIC_MODE_11b,1280,1024,24},
};
struct vesamode *vesa_mode_head = vesamode;
static u32 io_vaddr;
void tlbmap(u32 viraddr, u32 phyaddr, u32 size)
{
u32 tmp_size;
u32 pid, idx;
write_c0_pagemask(PM_DEFAULT_MASK);
pid = read_c0_entryhi() & ASID_MASK;
printf("tlbmap vaddr %x paddr %x size %x\n", viraddr, phyaddr, size);
for (tmp_size = 0 ;tmp_size < size; tmp_size += (2*PAGE_SIZE)) {
viraddr &= (PAGE_MASK << 1);
write_c0_entryhi(viraddr | (pid));
tlb_probe();
idx = read_c0_index();
printf("viraddr=%08x,phyaddr=%08x,pid=%x,idx=%x\n",viraddr,phyaddr,pid,idx);
/* Uncached accelerate */
write_c0_entrylo0((phyaddr >> 6)|0x3f);
write_c0_entrylo1(((phyaddr+PAGE_SIZE) >> 6)|0x3f);
write_c0_entryhi(viraddr | (pid));
if(idx < 0) {
tlb_write_random();
} else {
tlb_write_indexed();
}
viraddr += (PAGE_SIZE*2);
phyaddr += (PAGE_SIZE*2);
}
write_c0_entryhi(pid);
}
#define BONITO_REGBASE 0x100
#define BONITO_PCIMAP BONITO(BONITO_REGBASE + 0x10)
#define BONITO(x) *(volatile unsigned long *)(0xbfe00000+(x))
#define BONITO_PCIMAP BONITO(BONITO_REGBASE + 0x10)
#define BONITO_PCIMAP_PCIMAP_LO0 0x0000003f
#define BONITO_PCIMAP_WIN(WIN,ADDR) ((((ADDR)>>26) & BONITO_PCIMAP_PCIMAP_LO0) << ((WIN)*6))
int vesafb_init(void)
{
u32 video_mem_size;
u32 fb_address, io_address;
u32 tmp;
fb_address =_pci_conf_read(vga_dev->pa.pa_tag,0x10);
io_address =_pci_conf_read(vga_dev->pa.pa_tag,0x18);
//io_vaddr = io_address | 0xbfd00000;
//io_vaddr = io_address | BONITO_PCIIO_BASE_VA;
io_vaddr = io_address | 0xb8000000;
/* We assume all the framebuffer is required remmapping */
#ifdef USETLB
/* Remap framebuffer address to 0x40000000, which can be accessed by same physical address from cpu */
_pci_conf_write(vga_dev->pa.pa_tag, 0x10, 0x40000000);
/* FIXME: video memory size should be detected by software, but now fixed in 2MB that's enough in PMON */
video_mem_size = 0x200000;
#if 1
/* Map cpu physical address 0x40000000 to BONITO address 0x40000000 -> PCI address 0x40000000.
* Master0 window 3 */
asm (
".set mips3\n"
".set noreorder\n"
"dli $2, 0x900000003ff00000\n"
"dli $3, 0x0000000040000000\n"
"sd $3, 0x18($2)\n"
"dli $3, 0x0000000040000001\n"
"sd $3, 0x58($2)\n"
"dli $3, 0xffffffffc0000000\n"
"sd $3, 0x38($2)\n"
".set reorder\n"
".set mips0\n"
:::"$2","$3","memory"
);
#endif
/* If framebuffer bar is NULL, then it has too large memory to be alloced in kernel mode */
/* TLB map physical address to virtual address in kseg3. Start address is 0xe0000000 */
tlbmap(0xe0000000, 0x40000000, video_mem_size);
#else
#if 0
/* 0x10000000 -> 0x40000000 PCI mapping */
_pci_conf_write(vga_dev->pa.pa_tag, 0x10, 0x40000000);
tmp = BONITO_PCIMAP;
BONITO_PCIMAP =
BONITO_PCIMAP_WIN(0, 0x40000000) |
(tmp & ~BONITO_PCIMAP_PCIMAP_LO0);
#endif
#endif
printf("VESA FB init complete.\n");
return 0;
}
/* dummy implementation */
void video_set_lut2(int index, int rgb)
{
return;
}
int GetXRes(void)
{
return vesamode[vesa_mode].width;
}
int GetYRes(void)
{
return vesamode[vesa_mode].height;
}
int GetBytesPP(void)
{
return (vesamode[vesa_mode].bpp+1)/8;
}
void video_set_lut(int index, int r, int g, int b)
{
linux_outb(index, 0x03C8);
linux_outb(r >> 2, 0x03C9);
linux_outb(g >> 2, 0x03C9);
linux_outb(b >> 2, 0x03C9);
}

4
x86emu/int10/x86emu/src/x86emu/debug.c

@ -167,6 +167,7 @@ void x86emu_inc_decoded_inst_len (int x)
void x86emu_decode_printf (char *x)
{
sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",x);
printf("%s",x);
M.x86.enc_str_pos += strlen(x);
}
@ -175,6 +176,7 @@ void x86emu_decode_printf2 (char *x, int y)
char temp[100];
sprintf(temp,x,y);
sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",temp);
printf("%s",temp);
M.x86.enc_str_pos += strlen(temp);
}
@ -322,7 +324,7 @@ void x86emu_single_step (void)
int X86EMU_trace_on(void)
{
return M.x86.debug |= /*DEBUG_STEP_F |*/ DEBUG_DECODE_F | DEBUG_TRACE_F;
return M.x86.debug |= /*DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F |*/ DEBUG_MEM_TRACE_F | DEBUG_IO_TRACE_F;
}
int X86EMU_trace_off(void)

3
x86emu/int10/x86emu/src/x86emu/decode.c

@ -119,10 +119,9 @@ DB( printf("halted\n");
M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, M.x86.R_DX,M.x86.R_SP);
printf("\tBP=%4X,SI=%4X,DI=%4X,DS=%4X,SS=%4X,ES=%4X\n",M.x86.R_BP,M.x86.R_SI,M.x86.R_DI,
M.x86.R_DS,M.x86.R_SS,M.x86.R_ES);}*/
op1 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
(*x86emu_optab[op1])(op1);
//if (M.x86.R_IP==0x7Ac9) X86EMU_trace_on();
//if (M.x86.R_IP==0x7Acd) X86EMU_trace_on();
}
}

17
x86emu/int10/x86emu/src/x86emu/ops.c

@ -2849,6 +2849,7 @@ void x86emuOp_xor_byte_R_RM(u8 X86EMU_UNUSED(op1))
*destreg = xor_byte(*destreg, *srcreg);
break;
}
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
@ -7949,6 +7950,7 @@ void x86emuOp_mov_word_AX_IMM(u8 X86EMU_UNUSED(op1))
u32 srcval;
START_OF_INSTR();
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
DECODE_PRINTF("MOV\tEAX,");
srcval = fetch_long_imm();
@ -7956,8 +7958,10 @@ void x86emuOp_mov_word_AX_IMM(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("MOV\tAX,");
srcval = fetch_word_imm();
}
DECODE_PRINTF2("%x\n", srcval);
TRACE_AND_STEP();
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
M.x86.R_EAX = srcval;
} else {
@ -9562,10 +9566,18 @@ void x86emuOp_in_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
START_OF_INSTR();
DECODE_PRINTF("IN\t");
if (M.x86.R_AX == 0x4e00)
printf("=====>IN\n");
port = (u8) fetch_byte_imm();
if (M.x86.R_AX == 0x4e00)
printf("=====>IN port = %x\n", port);
DECODE_PRINTF2("%x,AL\n", port);
TRACE_AND_STEP();
if (M.x86.R_AX == 0x4e00)
printf("======> port = %x,value = %x\n", port, (*sys_inb)(port));
M.x86.R_AL = (*sys_inb)(port);
if (M.x86.R_AX == 0x4e00)
printf("======> assign OK \n");
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
@ -9742,6 +9754,11 @@ Handles opcode 0xed
void x86emuOp_in_word_AX_DX(u8 X86EMU_UNUSED(op1))
{
START_OF_INSTR();
if(M.x86.R_AX == 0xf1B8) {
printf("mode = %x\n", M.x86.mode);
printf("value = %x\n", (*sys_inl)(M.x86.R_DX));
printf("value = %x\n", (*sys_inw)(M.x86.R_DX));
}
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
DECODE_PRINTF("IN\tEAX,DX\n");
} else {

15
x86emu/int10/x86emu/src/x86emu/x86emu/debug.h

@ -124,10 +124,25 @@
M.x86.saved_ip = y; \
}
#else
#if 0 // liujl for debug
char temp[100];
# define INC_DECODED_INST_LEN(x)
# define DECODE_PRINTF(x) printf("%s", x)
# define DECODE_PRINTF2(x,y) \
do { \
sprintf(temp, x, y); \
printf("%s", temp); \
}while(0)
# define SAVE_IP_CS(x,y)
#else
# define INC_DECODED_INST_LEN(x)
# define DECODE_PRINTF(x)
# define DECODE_PRINTF2(x,y)
# define SAVE_IP_CS(x,y)
#endif
#endif
#ifdef DEBUG_EMU_VGA

1450
x86emu/int10/xf86int10.c

File diff suppressed because it is too large

93
x86emu/int10/xf86int10.h

@ -18,55 +18,55 @@
/* int10 info structure */
struct pci_dev;
typedef struct {
int entityIndex;
int scrnIndex;
pointer cpuRegs;
CARD16 BIOSseg;
CARD16 inb40time;
pointer private;
struct _int10Mem* mem;
int num;
int ax;
int bx;
int cx;
int dx;
int si;
int di;
int es;
int bp;
int flags;
int stackseg;
struct pci_device *pdev;
int entityIndex;
int scrnIndex;
pointer cpuRegs;
CARD16 BIOSseg;
CARD16 inb40time;
pointer private;
struct _int10Mem *mem;
int num;
int ax;
int bx;
int cx;
int dx;
int si;
int di;
int es;
int bp;
int flags;
int stackseg;
struct pci_device *pdev;
} xf86Int10InfoRec, *xf86Int10InfoPtr;
typedef struct _int10Mem {
CARD8(*rb)(xf86Int10InfoPtr, int);
CARD16(*rw)(xf86Int10InfoPtr, int);
CARD32(*rl)(xf86Int10InfoPtr, int);
void(*wb)(xf86Int10InfoPtr, int, CARD8);
void(*ww)(xf86Int10InfoPtr, int, CARD16);
void(*wl)(xf86Int10InfoPtr, int, CARD32);
CARD8(*rb) (xf86Int10InfoPtr, int);
CARD16(*rw) (xf86Int10InfoPtr, int);
CARD32(*rl) (xf86Int10InfoPtr, int);
void (*wb) (xf86Int10InfoPtr, int, CARD8);
void (*ww) (xf86Int10InfoPtr, int, CARD16);
void (*wl) (xf86Int10InfoPtr, int, CARD32);
} int10MemRec, *int10MemPtr;
typedef struct {
CARD8 save_msr;
CARD8 save_pos102;
CARD8 save_vse;
CARD8 save_46e8;
CARD8 save_msr;
CARD8 save_pos102;
CARD8 save_vse;
CARD8 save_46e8;
} legacyVGARec, *legacyVGAPtr;
typedef struct {
int bus;
union {
struct {
int bus;
int dev;
int func;
} pci;
int legacy;
} location;
int bus;
union {
struct {
int bus;
int dev;
int func;
} pci;
int legacy;
} location;
} xf86int10BiosLocation, *xf86int10BiosLocationPtr;
/* OS dependent functions */
xf86Int10InfoPtr xf86InitInt10(int entityIndex);
void xf86FreeInt10(xf86Int10InfoPtr pInt);
@ -84,7 +84,7 @@ void xf86ExecX86int10(xf86Int10InfoPtr pInt);
#define SYS_BIOS 0xF0000
#if 1
#define BIOS_SIZE 0x10000
#else /* a bug in DGUX requires this - let's try it */
#else /* a bug in DGUX requires this - let's try it */
#define BIOS_SIZE (0x10000 - 1)
#endif
#define LOW_PAGE_SIZE 0x600
@ -133,7 +133,7 @@ void dump_code(xf86Int10InfoPtr pInt);
void dump_registers(xf86Int10InfoPtr pInt);
void stack_trace(xf86Int10InfoPtr pInt);
xf86Int10InfoPtr getInt10Rec(int entityIndex);
CARD8 bios_checksum(CARD8 *start, int size);
CARD8 bios_checksum(CARD8 * start, int size);
void LockLegacyVGA(int screenIndex, legacyVGAPtr vga);
void UnlockLegacyVGA(int screenIndex, legacyVGAPtr vga);
int port_rep_inb(xf86Int10InfoPtr pInt,
@ -168,10 +168,9 @@ void setup_int_vect(xf86Int10InfoPtr pInt);
int setup_system_bios(void *base_addr);
void reset_int_vect(xf86Int10InfoPtr pInt);
void set_return_trap(xf86Int10InfoPtr pInt);
Bool int10_check_bios(int scrnIndex, int codeSeg, unsigned char* vbiosMem);
Bool initPrimary(void* options);
void xf86int10ParseBiosLocation(void* options,
xf86int10BiosLocationPtr bios);
Bool int10_check_bios(int scrnIndex, int codeSeg, unsigned char *vbiosMem);
Bool initPrimary(void *options);
void xf86int10ParseBiosLocation(void *options, xf86int10BiosLocationPtr bios);
#ifdef DEBUG_EMU_VGA
void dprint(unsigned long start, unsigned long size);
#endif
@ -179,5 +178,5 @@ void dprint(unsigned long start, unsigned long size);
/* pci.c */
int mapPciRom(int pciEntity, unsigned char *address);
#endif /* _INT10_PRIVATE */
#endif /* _XF86INT10_H */
#endif /* _INT10_PRIVATE */
#endif /* _XF86INT10_H */

90
x86emu/int10/xf86x86emu.c

@ -15,65 +15,61 @@
#define M _X86EMU_env
static void
x86emu_do_int(int num)
static void x86emu_do_int(int num)
{
Int10Current->num = num;
if (!int_handler(Int10Current)) {
X86EMU_halt_sys();
}
Int10Current->num = num;
printf("int10current->num=0x%x\n",num);
if (!int_handler(Int10Current)) {
printf("int_handler_int10current is error,system halted...\n");
X86EMU_halt_sys();
}
}
void
xf86ExecX86int10(xf86Int10InfoPtr pInt)
void xf86ExecX86int10(xf86Int10InfoPtr pInt)
{
int sig = setup_int(pInt);
int sig = setup_int(pInt);
if (sig < 0)
return;
if (sig < 0)
return;
if (int_handler(pInt)) {
X86EMU_exec();
}
if (int_handler(pInt)) {
X86EMU_exec();
}
finish_int(pInt, sig);
finish_int(pInt, sig);
}
Bool
xf86Int10ExecSetup(xf86Int10InfoPtr pInt)
Bool xf86Int10ExecSetup(xf86Int10InfoPtr pInt)
{
int i;
X86EMU_intrFuncs intFuncs[256];
X86EMU_pioFuncs pioFuncs = {
(u8(*)(u16))x_inb,
(u16(*)(u16))x_inw,
(u32(*)(u16))x_inl,
(void(*)(u16, u8))x_outb,
(void(*)(u16, u16))x_outw,
(void(*)(u16, u32))x_outl
};
int i;
X86EMU_intrFuncs intFuncs[256];
X86EMU_pioFuncs pioFuncs = {
(u8(*)(u16)) x_inb,
(u16(*)(u16)) x_inw,
(u32(*)(u16)) x_inl,
(void (*)(u16, u8))x_outb,
(void (*)(u16, u16))x_outw,
(void (*)(u16, u32))x_outl
};
X86EMU_memFuncs memFuncs = {
(u8(*)(u32))Mem_rb,
(u16(*)(u32))Mem_rw,
(u32(*)(u32))Mem_rl,
(void(*)(u32, u8))Mem_wb,
(void(*)(u32, u16))Mem_ww,
(void(*)(u32, u32))Mem_wl
};
X86EMU_memFuncs memFuncs = {
(u8(*)(u32)) Mem_rb,
(u16(*)(u32)) Mem_rw,
(u32(*)(u32)) Mem_rl,
(void (*)(u32, u8))Mem_wb,
(void (*)(u32, u16))Mem_ww,
(void (*)(u32, u32))Mem_wl
};
X86EMU_setupMemFuncs(&memFuncs);
X86EMU_setupMemFuncs(&memFuncs);
pInt->cpuRegs = &M;
M.mem_base = 0;
M.mem_size = 1024*1024 + 1024;
X86EMU_setupPioFuncs(&pioFuncs);
pInt->cpuRegs = &M;
M.mem_base = 0;
M.mem_size = 1024 * 1024 + 1024;
X86EMU_setupPioFuncs(&pioFuncs);
for (i=0;i<256;i++)
intFuncs[i] = x86emu_do_int;
X86EMU_setupIntrFuncs(intFuncs);
return TRUE;
for (i = 0; i < 256; i++)
intFuncs[i] = x86emu_do_int;
X86EMU_setupIntrFuncs(intFuncs);
return TRUE;
}

Loading…
Cancel
Save