Пример #1
0
static bool init_vx86(void) {
    int i;
    
    for (i=0; i<(int)(sizeof(VX86_pciDev)/sizeof(VX86_pciDev[0])); i++) VX86_pciDev[i] = NULL;

    // get North Bridge fun0 & South Bridge fun0 & IDE PCI-CFG
    if ((VX86_pciDev[VX86_NB]  = pci_Alloc(0x00, 0x00, 0x00)) == NULL) goto FAIL_INITVX86;
    if ((VX86_pciDev[VX86_SB]  = pci_Alloc(0x00, 0x07, 0x00)) == NULL) goto FAIL_INITVX86;
    if ((VX86_pciDev[VX86_IDE] = pci_Alloc(0x00, 0x0c, 0x00)) == NULL) goto FAIL_INITVX86;
    
    // now we are allowed to call get_cpuid()
    if ((VX86_cpuID = get_cpuid()) == CPU_UNSUPPORTED) goto FAIL_INITVX86;

    if (vx86_CpuID() != CPU_VORTEX86SX)
    {
        // North Bridge fun1 exists (note NB fun1 isn't a normal PCI device -- its vid & did are 0xffff)
        if ((VX86_pciDev[VX86_NB1]  = pci_Alloc(0x00, 0x00, 0x01)) == NULL) goto FAIL_INITVX86;
    }
    if (vx86_CpuID() == CPU_VORTEX86EX || vx86_CpuID() == CPU_VORTEX86DX2 || vx86_CpuID() == CPU_VORTEX86DX3)
    {
        // South Bridge fun1 exists (note SB fun1 isn't a normal PCI device -- its vid & did are 0xffff)
        if ((VX86_pciDev[VX86_SB1]  = pci_Alloc(0x00, 0x07, 0x01)) == NULL) goto FAIL_INITVX86;
    }
    return true;

FAIL_INITVX86:
    for (i=0; i<(int)(sizeof(VX86_pciDev)/sizeof(VX86_pciDev[0])); i++)
    {
        pci_Free(VX86_pciDev[i]);
        VX86_pciDev[i] = NULL;
    }
    err_print((char*)"%s: fail to setup system PCI devices!\n", __FUNCTION__);
    return false;
}
Пример #2
0
DMPAPI(void*) pci_Find(unsigned short vid, unsigned short did) {  // don't use this function in the init of io system
    unsigned long pciid = ((unsigned long)did << 16) + (unsigned long)vid;
    unsigned long tmpid, pciaddr;
    int bus, dev, fun;

    if (pciid == 0xffffffffUL) return NULL;

    for (bus=0; bus<256; bus++)
    for (dev=0; dev<32;  dev++)
    for (fun=0; fun<8;   fun++)
    {
        pciaddr = PCI_GET_CF8(bus, dev, fun);

        tmpid = pci_indw(pciaddr);
        if (tmpid == pciid) return pci_Alloc((unsigned char)bus, (unsigned char)dev, (unsigned char)fun);
        if (fun == 0)
        {
            if (tmpid == 0xffffffffUL)  // invalid PCI device
            {
                // NOTE: shouldn't do this optimization for Vortex86DX2/DX3/EX's internal PCI devices (where fun0 may be shutdown but fun1 is still enabled)
                if ((vx86_CpuID() == CPU_VORTEX86DX2) || (vx86_CpuID() == CPU_VORTEX86DX3) || (vx86_CpuID() == CPU_VORTEX86EX)) { /* do nothing ... */ } else break;
            }
            if ((pci_inb(pciaddr + 0x0eL) & 0x80) == 0) break;  // single-function PCI device
        }
    } // end for (fun=...

    return NULL;
}
Пример #3
0
static unsigned long get_cpufreq(void) {
    if (vx86_CpuID() == CPU_VORTEX86SX)
    {
        unsigned long strapreg = nb_Read(0x60);
        return VX86_cpuCLK_SX[(int)(strapreg & 0x7L)];
    }
    else
    if ((vx86_CpuID() == CPU_VORTEX86DX_A) || (vx86_CpuID() == CPU_VORTEX86DX_C) || (vx86_CpuID() == CPU_VORTEX86DX_UNKNOWN))
    {
        unsigned long strapreg = nb_Read(0x60);
        if ((strapreg & 0x1fL) == 1L) return VX86_dramCLK_DX[(int)((strapreg >> 8) & 0x07L)];
        return VX86_cpuCLK_DX_A[(int)(strapreg & 0x1fL)];
    }
Пример #4
0
DMPAPI(void) i2c_SetCLKREG(int dev, int mode, unsigned char prescale1, unsigned char prescale2) {
    if ((prescale1 < 10) || (prescale2 > 127))
    {
        errmsg("WARNING: %s() receives wrong clk divisors!\n", __FUNCTION__);
        return;
    }

    if (vx86_CpuID() == CPU_VORTEX86DX_A) prescale1 = prescale1 - 2;

    if (mode == I2CMODE_FAST) prescale2 = prescale2 | 0x80;
    io_outpb(I2C_CLKCTRL1_REG(dev), prescale1);
    io_outpb(I2C_CLKCTRL2_REG(dev), prescale2);
}
Пример #5
0
DMPAPI(void) i2c_DisableStandardHSM(int dev) { //note: this will force SCL pin to be always open drained
    if (vx86_CpuID() == CPU_VORTEX86DX_A) return;
    io_outpb(I2C_EXCTRL_REG(dev), io_inpb(I2C_EXCTRL_REG(dev)) | 0x10);
}
Пример #6
0
DMPAPI(void) i2c_EnableStandardHSM(int dev) { //enable the standard high-speed mode that is compatible with Philips' SPEC.
    if (vx86_CpuID() == CPU_VORTEX86DX_A) return;
    io_outpb(I2C_EXCTRL_REG(dev), io_inpb(I2C_EXCTRL_REG(dev)) & 0xef);
}
Пример #7
0
DMPAPI(void) i2c_DisableNoiseFilter(int dev) {
    if (vx86_CpuID() == CPU_VORTEX86DX_A) return;
    io_outpb(I2C_EXCTRL_REG(dev), io_inpb(I2C_EXCTRL_REG(dev)) | 0x20);
}
Пример #8
0
int main()
{
	char bios_version[16];
	unsigned long mem_size;

	printf("86INFO v1.1, author: PING-HUI WEI, E-mail: [email protected], 2016/03/18\n");

	printf("CPU:\t\t\t ");
	switch(vx86_CpuID())
	{
		case CPU_VORTEX86SX:
			printf("Vortex86SX\n");
			break;
		case CPU_VORTEX86DX_UNKNOWN:
			printf("Vortex86DX_unknown\n");
			break;
		case CPU_VORTEX86DX_A:
			printf("Vortex86DX_A\n");
			break;
		case CPU_VORTEX86DX_C:
			printf("Vortex86DX_C\n");
			break;
		case CPU_VORTEX86DX_D:
			printf("Vortex86DX_D\n");
			break;
		case CPU_VORTEX86MX:
			printf("Vortex86MX\n");
			break;
		case CPU_VORTEX86MX_PLUS:
			printf("Vortex86MX_plus\n");
			break;
		case CPU_VORTEX86DX2:
			printf("Vortex86DX2\n");
			break;
		case CPU_VORTEX86DX3:
			printf("Vortex86DX3\n");
			break;
		case CPU_VORTEX86EX:
			printf("Vortex86EX\n");
			break;
		case CPU_UNSUPPORTED:
		default:
			printf("unsupported\n");
	}

	printf("CPU Frequency:\t\t %ldMHz\n", vx86_CpuCLK());
	printf("CPU Temperature:\t %f °C\n", cpuTemperature());

	printf("Memory Size:\t\t");
	if(get_mem_size(&mem_size) == false)
		printf("get memory size error!\n");
	else
		printf(" %luMB\n", mem_size);

	printf("Memory Frequency:\t %luMHz\n", vx86_DramCLK());

	printf("BIOS Version:\t\t");
	if(get_BIOS_version(bios_version) == false)
		printf("get bios version error!\n");
	else
		printf(" %s\n", bios_version);

	return EXIT_SUCCESS;
}