Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who's Online
28 user(s) are online (22 user(s) are browsing Forum)

Members: 0
Guests: 28

more...

Browsing this Thread:   1 Anonymous Users





Question about pci.hidd

Joined:
2008/2/5 6:58
From Sunny Finland
Group:
Member
Posts: 872
Offline
Hello!

I'm in the process of making some ugly copy/paste coding... but ran into a little problem. In "my" code i'm already in pci enumerator, but i would need to check what my southbridge chip is... so is there in Aros something like pci_get_device as in linux pci. Or do i just modify and paste the enumerator code to my sources?

Just to clarify it a bit more, i don't need to get hold on any structures, just to check if my southbridge chip is any one from some list that i have. Well i could write another enumerator and check it beforehand... or browse through the list myself...

Posted on: 2008/11/5 7:56
Transfer the post to other applications Transfer


Re: Question about pci.hidd

Joined:
2004/3/30 23:19
From Clausthal-Zellerfeld, Germany
Group:
Member
Posts: 386
Offline
Show me the code :)

Posted on: 2008/11/5 9:10
_________________
Click to see original Image in a new window
Transfer the post to other applications Transfer


Re: Question about pci.hidd

Joined:
2008/2/5 6:58
From Sunny Finland
Group:
Member
Posts: 872
Offline
Hello dr.Schulz!

Well there is not much to show. It basicly is our current ata.hidd with my futile attempt to make it work with my chipset...

in via.h i have

static const struct via {
UWORD VendorID, ProductID;
} support[] = {
{ 0x1106, 0x0571, },
{ 0x1106, 0x0581, },
{ 0x1106, 0x1571, },
{ 0x1106, 0x3164, },
{ 0x1106, 0x5324, },
{ 0x0000, 0x0000, }
};

static const struct via_isa_bridge {
const char *name;
UWORD id;
UBYTE rev_min;
UBYTE rev_max;
UWORD flags;
} via_isa_bridges[] = {
{ "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
{ "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
{ "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
{ "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
.
.
.

and of course all needed via definitions

in ata_init.c i've added this in enumerator, doesn't do much more. I understand that in linux they use probes and such things and that their drivers are designed to be patched with what ever and that my code is at best a hack

/*
* obtain more or less useful data
*/
OOP_GetAttr(Device, aHidd_PCIDevice_ProductID, &ProductID);
OOP_GetAttr(Device, aHidd_PCIDevice_VendorID, &VendorID);

bug("[ATAVIA] Enumerator: checking productid %d vendorid %d\n", ProductID, VendorID);

/* And try to match it with supported cards */
while (sup->VendorID){
BOOL foundvia = FALSE;

if ((sup->VendorID == VendorID) && (sup->ProductID == ProductID)){
bug("[ATAVIA] Enumerator: found matching chip... Banging little sense into it...\n");
foundvia = TRUE;

/* To find out how the IDE will behave and what features we
actually have to look at the bridge not the IDE controller */
for (config = via_isa_bridges; config->id; config++){
bug("%s\n",config->name);

// if ((isa = pci_get_device(PCI_VENDOR_ID_VIA +!!(config->flags & VIA_BAD_ID),config->id, NULL))){
// if (isa->revision >= config->rev_min && isa->revision <= config->rev_max)
// break;
// pci_dev_put(isa);
// }
}
}
sup++;
}

OOP_GetAttr(Device, aHidd_PCIDevice_Base4, &DMABase);

Posted on: 2008/11/6 0:50
Transfer the post to other applications Transfer


Re: Question about pci.hidd

Joined:
2008/2/5 6:58
From Sunny Finland
Group:
Member
Posts: 872
Offline
Hello again...

It seems that not even Ubuntu is able to cope with my Via chipset (vt8237), because under heavy disk use it has random freezes. I have now set up ide prefetch to disabled in bios and it seems to cure that... hopefully... I had previously an Intel chipset motherboard, which had only one issue that sound chip had interrupt set on Aros at 255 (bad...), but now i have IDE's interrupt set at 255... I would REALLY, REALLY like if i386 got APIC support. But the second problem is that ata.hidd does not find the second port from any units. It only shows master from either channel (ide1/ide2). It seems that there is cure for that in linux sources and that is what i'm trying to incorporate in ata.hidd, or i might aswell write atavia.hidd (cathchy name i think... but that does not get it any further as I'm a very poor coder...)

Posted on: 2008/11/7 1:10
Transfer the post to other applications Transfer


Re: Question about pci.hidd

Joined:
2007/6/17 16:42
Group:
Member
Posts: 90
Offline
Here is my old RTL8139 that I was writing on my own a few years back. This is different than what is in the source tree as it does not stop at finding the first ethernet card. *gripe* At some point (like making a router), you *WANT* multiple ethernet card supports.

Basically, it goes around enum all PCI devices against the known PCI chip/ID for RTL8139. Very similar to what you are looking for.

#define STANDALONE if you want to run it as a standalone program. It prints out the setting of the Ethernet registers for the cards it can identify.

Sorry AROS ate my files, so I can't find my rtl8139.h
It is not important to show how to use the enum function.

*Edit* guess I cannot attach c source code: :(
Excuse the large wall of text here:


/*
File: rtl8139.c
Description: Card Probing, Init and standalone command line tool
Author: KCL
Date: July 2007

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.
*/

#include "rtl8139.h"

#ifdef DEBUG
char DBGBuf[DBGBUFSIZE];
#endif

struct Library *OOPBase;
OOP_AttrBase __IHidd_PCIDev;
OOP_AttrBase __IHidd_PCIDrv;
OOP_AttrBase HiddAttrBase;

int OpenLibs(void)
{
OOPBase = OpenLibrary("oop.library",0);

if(OOPBase)
{ __IHidd_PCIDev = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);
__IHidd_PCIDrv = OOP_ObtainAttrBase(IID_Hidd_PCIDriver);
HiddAttrBase = OOP_ObtainAttrBase(IID_Hidd);
}
else
{ DBG("Can't open oop.library\n");
}

return(OOPBase!=NULL);
}

int CloseLibs(void)
{ if(OOPBase)
{ if(__IHidd_PCIDev)
OOP_ReleaseAttrBase(IID_Hidd_PCIDevice);
if(__IHidd_PCIDrv)
OOP_ReleaseAttrBase(IID_Hidd_PCIDriver);
if(HiddAttrBase)
OOP_ReleaseAttrBase(IID_Hidd);

CloseLibrary(OOPBase);
OOPBase=NULL;
}
}

struct SupportedCards
{ UWORD VendorID;
UWORD ProductID;
char *CardName;
};

struct SupportedCards rtl8139Cards[]=
{ {0x10ec,0x8139,"RealTek"},
{0x1113,0x1211,"SMC1211/Accton EN-1207D"},
{0x1186,0x1300,"D-Link DFE-538TX"},
{0x1186,0x1340,"D-Link DFE-560txd"},
{0x018a,0x0106,"LevelOne FPC-0106Tx/Compaq HNE-300"}
};

/* PCIEnum_Callback(struct Hook *hook,OOP_Object *PCI_obj,APTR msg)
This hook will be called for every PCI Ethernet device
*/

AROS_UFH3(void,PCIEnum_Callback,
AROS_UFHA(struct Hook *,hook,A0),
AROS_UFHA(OOP_Object *,PCI_obj,A2),
AROS_UFHA(APTR,msg,A1))
{
AROS_USERFUNC_INIT
{ struct CardsRes *Card=hook->h_Data;
struct PerCardRes *EtherRes=&(Card->CardResource[Card->Cards]);
IPTR VendorID, ProductID, RevisionID, IRQ, DirectBus;
int i;

if(Card->Cards {
OOP_GetAttr(PCI_obj,aHidd_PCIDevice_VendorID,&VendorID);
OOP_GetAttr(PCI_obj,aHidd_PCIDevice_ProductID,&ProductID);
OOP_GetAttr(PCI_obj,aHidd_PCIDevice_RevisionID,&RevisionID);

/* Match card against known rtl8139 signatures */

for(i=0;i { if((VendorID==rtl8139Cards[i].VendorID)&&
(ProductID==rtl8139Cards[i].ProductID))
{
OOP_GetAttr(PCI_obj,aHidd_PCIDevice_Base0,&EtherRes->IOBase);
OOP_GetAttr(PCI_obj,aHidd_PCIDevice_INTLine,&IRQ);

OOP_GetAttr(PCI_obj,aHidd_PCIDevice_Driver,(APTR)&EtherRes->PCIDrv_obj);
OOP_GetAttr(EtherRes->PCIDrv_obj,aHidd_PCIDriver_DirectBus,&DirectBus);

EtherRes->CardName= rtl8139Cards[i].CardName;
EtherRes->IRQ=IRQ;
EtherRes->DirectBus=DirectBus;

// Read in Hardware Version ID
EtherRes->ChipRev= (LONGIN(EtherRes->IOBase+RTLr_TCR)>>24)&0x7f;

// Use 8139info tool instead
/*
DBG("Card#%d: Vendor:0x%lX Product:0x%lX Rev:0x%lX ChipRev:%X\n",
Card->Cards,VendorID,ProductID,RevisionID,EtherRes->ChipRev);
DBG("IOBase:0x%lX IRQ:%d\n",EtherRes->IOBase,EtherRes->IRQ);
*/
Card->Cards++;
break;
}
}
}
}

AROS_USERFUNC_EXIT
}

struct CardsRes *Probe(void)
{ OOP_Object *PCI_Obj;

/* Get only Ethernet Cards */
struct TagItem tags[]=
{ {tHidd_PCI_Class,PCI_EthernetClass},
{TAG_DONE, 0UL}
};

struct CardsRes *EtherCards=AllocVec(sizeof(struct CardsRes),MEMF_PUBLIC|MEMF_CLEAR);
struct Hook PCIHook = {h_Entry:(APTR)PCIEnum_Callback,h_Data: (APTR)EtherCards};

if(!EtherCards)
return(NULL);

/* Create instance of pci class */
PCI_Obj = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);

if (PCI_Obj)
{
/* Enumerate through devices who meet the requirements */
HIDD_PCI_EnumDevices(PCI_Obj,&PCIHook,tags);

/* PCI object isn't needed anymore */
OOP_DisposeObject(PCI_Obj);
}

return(EtherCards);
}

void RtlGetMac(IPTR IOBase, ubyte *Mac)
{ ulong MacReg = IOBase+RTLr_MAC0;
int i;

for(i=MAC_SIZE;i;i--)
*Mac++=BYTEIN(MacReg++);
}

// ------------------------------------------------------------------------------------
// Standalone command line for 8319 info
// ------------------------------------------------------------------------------------

#ifdef STANDALONE

struct HWID
{ uword ID;
char *Chip;
};

// RTL8193D Datasheet: Rev. 1.3 29th Dec 2005
// 0x78 from RTL8139C Datasheet: Rev. 1.6 29th Dec 2005

struct HWID hwid[]=
{ {0x60,"RTL8139"},
{0x70,"RTL8139A"},
{0x72,"RTL8139A-G"},
{0x78,"RTL8139B"},
{0x7c,"RTL8130"},
{0x74,"RTL8139C"},
{0x7a,"RTL8100"},
{0x75,"RTL8100B/39D"},
{0x76,"RTL8139C+"},
{0x77,"RTL8101"}
};

int main()
{ struct CardsRes *EtherCards;
int i,j;
ubyte Mac[6],match=0;
uword Status;
ulong DirectBus;

if(OpenLibs())
{ EtherCards=Probe();

if(EtherCards)
{ for(i=0;iCards;i++)
{ printf("\nCard#%d:%s [",i,EtherCards->CardResource[i].CardName);

for(j=0;j if(hwid[j].ID==EtherCards->CardResource[i].ChipRev)
{ printf(hwid[j].Chip);
match=1;
break;
}

if(!match)
printf("VerID:%02x",EtherCards->CardResource[i].ChipRev);

RtlGetMac(EtherCards->CardResource[i].IOBase,Mac);

printf("] IOBase:0x%lX IRQ:%d Direct Bus:%s\n",
EtherCards->CardResource[i].IOBase,EtherCards->CardResource[i].IRQ,
EtherCards->CardResource[i].DirectBus?"Yes":"No");

Status=WORDIN(EtherCards->CardResource[i].IOBase+RTLr_BMSR);

printf("100BaseT:[%s %s] 10BaseT:[%s %s] AutoNegotiate:%s Link:%sMbps %s\n",
(Status&BIT14)?"FD":"--",(Status&BIT13)?"HD":"--",
(Status&BIT12)?"FD":"--",(Status&BIT11)?"HD":"--",
(Status&BIT5)?"Done":(Status&BIT3)?"Pending":"Failed",
WORDIN(EtherCards->CardResource[i].IOBase+RTLr_MSR)&MSR_SPEED_10?"10":"100",
(Status&BIT2)?"Up":"Down");

printf("MAC:%02X:%02X:%02X:%02X:%02X:%02X Jabber:%s Disconnect:%d FalseCarrier:%d\n",
Mac[0],Mac[1],Mac[2],Mac[3],Mac[4],Mac[5],(Status&BIT1)?"Yes":"No",
WORDIN(EtherCards->CardResource[i].IOBase+RTLr_DIS),
WORDIN(EtherCards->CardResource[i].IOBase+RTLr_FCSC));

}
FreeVec(EtherCards);
}
CloseLibs();
}
}
#endif

Posted on: 2008/11/7 17:08
Transfer the post to other applications Transfer


Re: Question about pci.hidd

Joined:
2008/2/5 6:58
From Sunny Finland
Group:
Member
Posts: 872
Offline
Hello!

Thank you for your replie, but that was not exactly what i was after. I already knew in some level how the Enumerator works in pci.hidd, it was clearly documented in source as well as in separate document and for that i'm really grateful, but I was looking for a way to check if my southbridge chip id's could be found, while in the enumerator code that was setup to look for ide capable devices... This could easily be accomplished by separate Enum search for bridges, or by via's prodid's, but i was hoping for a leaner solution, but by now i have given up with that sh*tty excuse for a motherboard and moved back to intel based mobo. I just could not stand for those random freezes. It might be that there was something else wrong with that mb beside the buggy chipset, but i lost interest with it.

Posted on: 2008/11/8 7:31
Transfer the post to other applications Transfer






You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
3656
2 nikolaos
nikolaos
3464
3 phoenixkonsole
phoenixkonsole
3016
4 magorium
magorium
2972
5 deadwood
deadwood
2333
6 mazze
mazze
2068
7 ncafferkey
ncafferkey
2057
8 clusteruk
clusteruk
2050
9 damocles
damocles
1769
10 Kalamatee
Kalamatee
1710
© 2004-2014 AROS Exec