Jump to content

New ATI Framebuffer Xcode project to start from


  • Please log in to reply
124 replies to this topic

#21
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
Hey, can u make a tiny driver which will just initialize a card and quit, without any modes settings and etc, just like what bios/efi does (without settings display mode) ?

it will help us to have multi card ati setups with apple drivers

#22
dong

dong

    InsanelyMac Sage

  • Retired Developers
  • 366 posts
  • Gender:Male
Hi, netkas,

If what you mean is a natit like thing with only the function of injecting required entries (already present in plist file) into IORegistry, it should be easy that anyone can write one.

But it won't be so easy if these entries need to be determined by checking the card at boot time as I'm not very familiar with the meanings of those entries yet. If anyone has a clue of this, we may give it a try.

#23
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
Dong, no, injecting works with natit just fine, vga bios does some initialization of card (using atombios prolly) , so the card can be used by osx drivers, if no initializayion was done - osx drivers will not detect any output on card. so, atm, we cant use dual card solutions using ati.
(dual card - for 4 monitors)

#24
Slice

Slice

    InsanelyMacaholic

  • Local Moderators
  • 3,179 posts
  • Gender:Male
  • Location:Moscow
Yes, I know that some initialization by BIOS did occur. But how can we know what exactly? I know a set of registers "BIOS_..._scratch", "Video_Memory_...". What else?

#25
dong

dong

    InsanelyMac Sage

  • Retired Developers
  • 366 posts
  • Gender:Male

Dong, no, injecting works with natit just fine, vga bios does some initialization of card (using atombios prolly) , so the card can be used by osx drivers, if no initializayion was done - osx drivers will not detect any output on card. so, atm, we cant use dual card solutions using ati.
(dual card - for 4 monitors)


Ok, I now got what you mean.

After reading some posts on the web, I got the information like that there is no such initialization problem for dual NVidia cards, but ATI cards just won't POST if plugged in as secondary card.

It looks to me that the issue here is how to get the secondary ATI card POSTed. I rechecked codes in radeonHD linux driver, they are using int10 in a simulated real mode to boot the BIOS on the secondary card, which is not so easy to port to OSX in my opinion.

And I'm a little confused here about whether just running the card BIOS got it POSTed or you have to additionaly running ATOM init functions to get job done?

Without int10, there is also another problem of accessing the video BIOS as it's not located at 0xC0000 (already used by primary card) and you got no idea where it will be (maybe not in system memory at all). Without access to the BIOS image, there is no way to call ATOM init functions.

Edit: well, I checked ATY_Megalodon and found it did provide a way to read BIOS by interacting with IO registers of the card (0x1600 - 0x1620, 0x1798 - 0x17A0 for setting card to enter/exit BIOS reading state, and 0xA8, 0xAC for actually reading, 4 bytes each time). I will test it to see if this is general for any ATI cards.

Update: I tried these registers on my mobility x1400, but not working. But I saw similar code in radeonHD (RHDReadPCIBios), it does confirm that it depends on the type of card. Some time will be needed to test with it.

Please point out if I got something wrong.

#26
0xdeadbeef

0xdeadbeef

    InsanelyMac Protégé

  • Members
  • PipPip
  • 88 posts
  • Location:Svealand

And I'm a little confused here about whether just running the card BIOS got it POSTed or you have to additionaly running ATOM init functions to get job done?

Without int10, there is also another problem of accessing the video BIOS as it's not located at 0xC0000 (already used by primary card) and you got no idea where it will be (maybe not in system memory at all). Without access to the BIOS image, there is no way to call ATOM init functions.



Maybe you can get all that info by calling IOACPIPlatformDevice methods:

_ROM (Get ROM data)
_GPD (Get POST Device)
_SPD (Set POST Device)

See pages 576..578 of the ACPI Spec

Although if this can be done from a display driver I have no idea. I do know that ATY_* framebuffers call IOACPIPlatformDevice->_DSS (Device Set State)

#27
np_

np_

  • Retired Developers
  • 339 posts
  • Gender:Male
here is more info

http://www.x.org/docs/AMD/
http://www.x.org/wiki/radeonhd

what you need to do is new iokit driver who loads before any ati***.kext ( something like natit )

mapping ATI mem base IO ( check docs for correct registers, they are almost same for any ati card )

and you can read/write anywhere in card mem space , that include to read EDID , card bios ..etc

getting correct info you can push it into ioregs without no problem at all

just note - avoid to hard code EDID info data into ioregs or any data copied from real mac's ioregs, it will cause in most situation black screen or even put video card in funny moods

#28
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
dong, the bios you can always get from ioreg, for r6xx+ cards its there under name ATY,bin_image

and here is what radeonhd x86 does (from rhd_atombios.c)

if (unposted) {
/* run AsicInit */
if (!rhdAtomASICInit(handle))
xf86DrvMsg(scrnIndex, X_WARNING,
"%s: AsicInit failed. Won't be able to obtain in VRAM "
"FB scratch space\n",__func__);


static Bool
rhdAtomASICInit(atomBiosHandlePtr handle)
{
ASIC_INIT_PS_ALLOCATION asicInit;
AtomBiosArgRec data;

RHDFUNC(handle);

RHDAtomBiosFunc(handle->scrnIndex, handle,
GET_DEFAULT_ENGINE_CLOCK,
&data);
asicInit.sASICInitClocks.ulDefaultEngineClock = data.val / 10;/*in 10 Khz*/
RHDAtomBiosFunc(handle->scrnIndex, handle,
GET_DEFAULT_MEMORY_CLOCK,
&data);
asicInit.sASICInitClocks.ulDefaultMemoryClock = data.val / 10;/*in 10 Khz*/
data.exec.dataSpace = NULL;
data.exec.index = GetIndexIntoMasterTable(COMMAND, ASIC_Init);
data.exec.pspace = &asicInit;

xf86DrvMsg(handle->scrnIndex, X_INFO, "Calling ASIC Init\n");
atomDebugPrintPspace(handle, &data, sizeof(asicInit));
if (RHDAtomBiosFunc(handle->scrnIndex, handle,
ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
xf86DrvMsg(handle->scrnIndex, X_INFO, "ASIC_INIT Successful\n");
return TRUE;
}
xf86DrvMsg(handle->scrnIndex, X_INFO, "ASIC_INIT Failed\n");
return FALSE;
}

#29
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
ah well, framebuffer already has _atom_ASIC_Init function, it called on wakeup.

#30
dong

dong

    InsanelyMac Sage

  • Retired Developers
  • 366 posts
  • Gender:Male
netkas, I checked your natit code, you're still getting BIOS ROM from the legacy address 0xC0000 if the ROM is not present in plist file. It won't work for a secondary ATI card.

So, do you want to modify the native driver some way to make it execute atom_ASIC_Init at initialization time?

Or a tiny driver is still needed to do this job?

#31
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
i get it from 0xc0000 only if binimage wasnt found in plist, that;s answer :blink:

well. i modified motmot that way, and it's attitude changed when card run in vga mode, not vesa, but still isnt perfect.

#32
dong

dong

    InsanelyMac Sage

  • Retired Developers
  • 366 posts
  • Gender:Male
Netkas, I put rhdAtomInit related stuff together. It's compiled ok but not tested yet. If it does not do its job or causes KP for some reason, don't blame me. :D

In the probe function, I assume BIOS can be read from IOPCIDevice's "ATY,bin_image". You have to make sure Natit load before this and set that to IOPCIDevice.


Now if BIOS can not be read from "ATY,bin_image", the BIOS at legacy address will be used instead. Adding this is because I don't have a "ATY,bin_image" to debug the code.


Find it in thanoulas's post in this topic if you want to download.

#33
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
seems like you forgot to add some sources to it :P

kld(): Undefined symbols:
_DelayMicroseconds
_DelayMilliseconds
_ReadIndReg32
_ReadPCIReg16
_ReadPCIReg32
_ReadPCIReg8
_ReadReg32
_ReadSysIOReg16
_ReadSysIOReg32
_ReadSysIOReg8
_WriteIndReg32
_WritePCIReg16
_WritePCIReg32
_WritePCIReg8
_WriteReg32
_WriteSysIOReg16
_WriteSysIOReg32
_WriteSysIOReg8




I attached corrected info.plist, the default one doesnt work.



http://rapidshare.de...Info.plist.html

#34
dong

dong

    InsanelyMac Sage

  • Retired Developers
  • 366 posts
  • Gender:Male
My bad, didn't even test it with kextload. The undefined symbols is caused by atombios compiling macros. All the sources are already there. To solve this,

In CD_hw_services.h, add a line at the beginning, i.e., add
#define ENABLE_ALL_SERVICE_FUNCTIONS
right after
#include "CD_Structs.h"

You may also add the line at the beginning of hwserv_drv.c, all the function implementations are there.

The ENABLE_ALL_SERVICE_FUNCTIONS definition will enable them.

The whole project in my last post is also updated.

#35
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
panics in atomSaveRegisters function

#36
dong

dong

    InsanelyMac Sage

  • Retired Developers
  • 366 posts
  • Gender:Male

panics in atomSaveRegisters function


Don't know exactly what caused it, possibly the memory allocation/deallocation stuff. And I do not see how useful can this function be, it seems only backup the registers each time when there is a writing but I do not find out where they are used to restore the values. So a simple suggestion to avoid this panic is to comment out all occasions of atomSaveRegisters in the code.

#37
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
Sorry, i was a bit lazy to analize backtrace last time so made wrong assumption, so getting rid of saveregisters functions made no difference :(

panic was in __RHDRegWrite

│ 1950 ! mov edx, eax
│ 1952 ! mov eax, [ebp+offset_10]
│ 1955 ! mov [edx], eax
│ 1957 ! leave
│ 1958 ! ret

EIP - 1955

edx - a030 , eax - 0x02

#38
dong

dong

    InsanelyMac Sage

  • Retired Developers
  • 366 posts
  • Gender:Male
Just a quick response, I suddenly remember that I forgot to add a "device->setMemoryEnable(true)" in ATY_Init.cpp. I will try to debug further by myself, but you may give another try.

Update: after adding that, it now works for me, though the screen goes into a strange state. Here is the log:
[codebox]dong/project/ATY_Init/build/Debug; USER=root; COMMAND=/sbin/kextload -t ATY_Init.kext
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = 97
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,16)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister© = 1ca
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = 16
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,96)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(c,1ca)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = 96
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,9c)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(c,1a)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = 9c
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,27)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister© = 24a
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = 27
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,a7)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(c,24a)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = a7
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,28)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister© = 28a
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = 28
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,a8)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(c,28a)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL(26) = 17
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL(26,13)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL(1e) = 17
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL(1e,13)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL(1d) = 17
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL(1d,13)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(574,1)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(570) = 0
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(570,0)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(580,c000000)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(4cc,1f000000)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL(:wacko: = 100fac8f
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL(b,100fac8f)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL(:D = 100fac8f
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL(b,100fac13)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = 8b
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,:)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister© = 100fac13
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(8) = b
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(8,8b)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(c,100fac8f)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadPLL(B) = 100fac8f
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWritePLL(b,100fac8f)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReleaseMemory
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReadATIRegister(10) = 40000
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: atomSaveRegisters
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailWriteATIRegister(10,40000)
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: CailReleaseMemory
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: ParseTable said: CD_SUCCESS
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: ASIC_INIT Successful
Mar 23 11:49:49 myLenovo kernel[0]: ATY_Init: Card initialize completed[/codebox]
I do not comment out atomSaveRegisters yet, but it's better to remove them since the memory allocated in it is not freed in the project.

#39
LeoMark

LeoMark

    InsanelyMac Protégé

  • Members
  • Pip
  • 10 posts
Hi, netkas and dong, congratulations for the project! I am a user ati mobility hd2400, I have followed the work of you and I'm anxious for news, some hope for the LVDS connector? sorry for english, I'm Brazilian :(

#40
netkas

netkas

    InsanelyMac Legend

  • Developers
  • 616 posts
  • Gender:Male
latest still panics for me O.o





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy