Subject: Re: Re: vga initialization

From: Zhang Fuxin <[email-masked]>
Date: Wed, 24 Apr 2002 21:11:20 +0800

hi,
  I don't have that card at hand:(. But if you have tried this emulation
code,please give more detailed message:
  1. what you do
  2. output (dmesg,or captured from your serial console).
  3. your platform,esp. whether it has pc legacy hardware support. 
    For example,a PIIX4 or via686a southbridge will give you 
    functionality of the legacy vga support,8254 timer and standard io ports
    (0x41-0x43 timer,0x61->timer 2 enable,0x3c0-0x3cf ->vga ports etc.)

在 2002-04-24 20:15:00 you wrote：
>would you by any chance try this emulation on AOpen's PT80 card? i failed to
>fire up this card. any clues?
>
>
>----- Original Message -----
>From: "Zhang Fuxin" <[email-masked]>
>To: <[email-masked]>
>Sent: Wednesday, April 24, 2002 10:11 AM
>Subject: vga initialization
>
>
>> hi,
>>   I find most code is already there in scitech's x86emu-0.8.
>> in one day it is adapted into linux kernel.
>>
>>   If anybody is interested,my code can be fetched from
>> ftp://ftp.gnuchina.org/incoming/mips-vga-init/freebiosvga.tar.gz
>>
>> For a short description,the READ in the package is paste here:
>>
>> This is x86/bios emulator adapted for used in 2.4 kernel
>> to do initialize pc VGA cards.
>>
>> Port it to pmon/yamon should be easy,if you want an userland
>> executable,please download the original x86emu-0.8 from SciTech
>> Software, Inc.
>>
>> Usage:
>>  here is my choice:
>>   1.add code in new directory arch/mips/freebiosvga/
>>   2.arch/mips/config.in:
>>      add config option CONFIG_VGA_POST to proper place
>>          bool '  Support for VGA POST' CONFIG_VGA_POST
>>
>>   3.arch/mips/Makefile
>>      add directory and target objects of freevgabios
>>
>>      ifdef CONFIG_VGA_POST
>>      SUBDIRS      += arch/mips/freebiosvga
>>      LIBS         += arch/mips/freebiosvga/vga.o
>>      SUBDIRS      += arch/mips/freebiosvga/x86emu
>>      LIBS         += arch/mips/freebiosvga/x86emu/x86emu.o
>>      endif
>>
>>   4.init/main.c:
>>     add call to vgabios_init (right after pci_init)
>>     #ifdef CONFIG_VGA_POST
>>       vgabios_init();
>>     #endif
>>
>>   5.select 'VGA text console' or proper framebuffer, you may need to
>>   slightly modify the code,because many of them is for x86
>>
>>     for 'VGA text console',the file is drivers/video/vgacon.c,propably
>>   you need to comment out the check for card's presence in vgacon_startup.
>>   Because card initialization is later than console_init,so at that time
>>   pci address 0xa0000-0xc0000 may not response to your requests.
>>
>>
>> Problems & limits:
>>   1.currently the code rely on system's pci resource allocator to assign
>>     a valid address to rom base register(offset 0x30 in pci header).
>>     I have modified the pci_auto.c to handle rom. Patch is here:
>>
>>      diff -r1.2 pci_auto.c
>>      107a108,110
>>      >       u32 bases[7] =
>{PCI_BASE_ADDRESS_0,PCI_BASE_ADDRESS_1,PCI_BASE_ADDRESS_2,
>>      >
>PCI_BASE_ADDRESS_3,PCI_BASE_ADDRESS_4,PCI_BASE_ADDRESS_5,
>>      >                       PCI_ROM_ADDRESS};
>>      110c113,116
>>      <       for (bar = PCI_BASE_ADDRESS_0; bar <= PCI_BASE_ADDRESS_5;
>bar+=4) {
>>      ---
>>      >       for (bar_nr=0; bar_nr<7; bar_nr++) {
>>      >
>>      >               bar = bases[bar_nr];
>>      >
>>      137c143
>>      <               if (bar_response & PCI_BASE_ADDRESS_SPACE) {
>>      ---
>>      >               if (bar_nr != 6 && (bar_response &
>PCI_BASE_ADDRESS_SPACE)) {
>>      209d214
>>      <               bar_nr++;
>>      349,350d353
>>      <
>>      <                       DBG("Skipping legacy mode IDE controller\n");
>>
>>    if you don't use pci_auto,then make sure your pmon/yamon do it.
>>
>>    Of course,you can write an absolute,safe value for your specific
>platform
>>    to see it works:)
>>
>>    If the base address read from your card is invalid,you will get message
>>    like:
>>      "No address assigned to rom" or "No valid bios found"
>>
>>  2. i am assuming ioremap(a_pci_address) will return a valid cpu virtue
>>    address for accessing memory located at 'a_pci_address'.
>>
>>
>>  3. Multiple cards are not supported currently,though it may be a piece of
>>  cake.Complex cards,e.g. those contain bridges,may fail.
>>
>>  4. cards tested here include:
>>    trident 3Dimage9750,S3virge,Riva TNT2
>>
>> DISCLAIMER:
>>   It is provided "as is" without express or implied warranty.
>>
>>   Any problems you can contact [email-masked].
>>
>>
>> Happy hacking and good luck.
>
>
>
>
>_________________________________________________________
>
>Do You Yahoo!?
>
>Get your free @yahoo.com address at http://mail.yahoo.com

Regards
            Zhang Fuxin
            [email-masked]

---

From: "Zhang Fuxin" <[email-masked]>
Date: Thu, 25 Apr 2002 20:29:54 +0800

hi,

 I met the situation you described before.
x86emu0.6 will give such result on many cards.
I believe it's because their bioses access vga
memory between address [0xa0000-0xc0000],while
in x86emu0.6, the mem_read/mem_write doesn't
distinguish they from bios code section.
 
 I guess that your code:
  1. copy bios code to PHYSICAL MEMORY 0xc0000
  2. emulation code,and redirect accesses to
    [0xa0000-0xfffff] to PHYSICAL memory 0xa0000-0xfffff
  3. code ok,vga memory access failed. Because pci addr
    !=physical addr in your platform

x86emu-0.8 solve this.

Another caution please,the original code may define 
 #define char u8
and your compiler might treat 'char' as unsigned!At
least my sde-gcc from algor seems to do this.it will
lead to failure of 'JB' emulation.

======= 2002-04-25 03:14:00 您在来信中写道：=======

>thanks for replying. this card PT80 seems a SPECIAL
>one. perhaps i am the only user for it on non-x86
>platform. 
>
>>   1. what you do
>i borrowed an old MIPS board from my company. from
>home i'm learning MIPS as well as linux. 
>
>i've NOT used your particular code. somebody gave me a
>PMON code which has SciTech's bios emulation code. 
>i've integrated this code as part of bootloader. i
>dont see any dmesg or something.
>
>the board has a custom PCI bridge with 2 PCI slots.
>the PCI slots are 3.3v. i'm trying to port linux 2.4.3
>on this board. so far i'm able to build kernel with
>serial console. in order to support x-windows i need
>VGA monitor. hence i purchased one AOpen's PT80 card
>which supports PCI 3.3v. i was trying to emulate the
>BIOS. since it has only x86 bios. 
>
>in my case, the emulation as such completes. with no
>errors at any time. the monitor switches from power
>down to power on mode & also appears there AOpen's
>splash window. the one comes initially with AOpen's
>icon & some text explaining the card configuration.
>HOWEVER this whole screen is filled with colorful
>vertical lines. that's it & i'm stucked. 
>
>since i dont have any tools like PCI bus analyzer or
>something. so i have no clue to proceed further. i
>have checked the card & also the monitor. it works
>well on a PC running both windows-me & redhat linux
>7.1. 
>
>one thing i checked however is, an user command build
>on linux dumps the register access. the register
>access & the values written there or read from are
>ditto. exact match.
>
>could you make out anything from this?? any clues??
>
>many thanks & best regards,
>girish.
>
><<snip>>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Games - play chess, backgammon, pool and more
>http://games.yahoo.com/

= = = = = = = = = = = = = = = = = = = =

　　　　　　　　致
礼！

　　　　　　　　Zhang Fuxin
　　　　　　　　[email-masked]
　　　　　　　　　　2002-04-25