Configuring PCI Express
Posted: Tue Jul 16, 2013 10:33 am
Please some one tell me what has to be done after mcfg is located.
The Place to Start for Operating System Developers
http://f.osdev.org/
Actually my original post was this http://forum.osdev.org/viewtopic.php?f=1&t=26887Combuster wrote:Commit your code.
(Fix your question, please.)
Code: Select all
#define _pcie_base_addr_strct_size 16
typedef struct pcie_confaddr_s
{
uint64 *base_addr; //8 bytes base addr
uint16 seg_grp_num; //2 bytes segment group addr
uint8 bus_num_s; //stating bus number
uint8 bus_num_e; //ending bus number
uint32 reserved; //reserved
}__attribute__((packed)) pcie_confaddr_t;
typedef struct sdt_header_s
{
char signature[4];
uint32 len;
uint8 revision;
uint8 checksum;
char OEMID[6];
char OEMtableID[8];
uint32 OEMrevision;
uint32 creatorID;
uint32 creatorRevision;
}__attribute__((packed))sdt_header_t;
sdt_header_t *acpi_getsdt(char *sig)
{
return acpi_findsdt(xsdt,sig);
}
sdt_header_t *acpi_findsdt(xsdt_t *_xsdt, char *signature)
{
int i=0;sdt_header_t *tmp;
for(i=0;i<22;i++)
{
tmp=(sdt_header_t *)_ptr_conv _xsdt->other_tables[i];
if(strncmp(tmp->signature,signature,4)==0)
if(bytesum((phys_addr *)_ptr_conv tmp,tmp->len)==0)
return tmp;
}
return (sdt_header_t *)0;
}
void pcie_init()
{
sdt_header_t *mcfg=acpi_getsdt("MCFG");
printf("\n\t Locating PCI Express Extended configuration space");
if(!mcfg)
{
mcfg=mcfg_pci;
if(!mcfg)
{
mprintf(error_text_colour,"\n\t Unable to locate PCI Express Extended configuration space");
return;
}
}
if(((bytesum((phys_addr *) _ptr_conv mcfg,mcfg->len))&0xff)!=0)
{
mcfg=mcfg_pci;
if(!mcfg || (((bytesum((phys_addr *) _ptr_conv mcfg,mcfg->len))&0xff)!=0))
{
mprintf(error_text_colour,"\n\t Invalid ACPI MCFG Table");
return;
}
}
bus_range[0]=(pcie_confaddr_t *)mcfg+(mcfg->len);
printf("\n\t Found buses from : %d-%d ,",bus_range[0]->bus_num_s,bus_range[0]->bus_num_e);
pcie_find_bus_ranges(mcfg);
}
void pcie_find_bus_ranges(sdt_header_t *mcfg)
{
int i=0;
bus_range[0]=(pcie_confaddr_t *)mcfg+(mcfg->len);
i=0;
while(i<51)
{
++i;
bus_range[i]=bus_range[0]+(_pcie_base_addr_strct_size*i);
printf(" %d-%d ,",bus_range[i]->bus_num_s,bus_range[i]->bus_num_e);
}
}
I hope you know the difference between singular and pluralno replies for weeks