X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=util%2Fmptable%2Fmptable.c;h=ce775dd71277540bf9f7e7a85d2178d5e45ef7b9;hb=09377b7d3f62fb62a6e7c11aefdde771a774ea05;hp=4355d7116ff0fd75177bb3044ef9bd5249a416bd;hpb=a734f5372156aac1270700421ded7358291c2f4c;p=coreboot.git diff --git a/util/mptable/mptable.c b/util/mptable/mptable.c index 4355d7116..ce775dd71 100644 --- a/util/mptable/mptable.c +++ b/util/mptable/mptable.c @@ -27,11 +27,6 @@ * mptable.c */ -#ifndef lint -static const char rcsid[] = - "$Id$"; -#endif /* not lint */ - #define VMAJOR 2 #define VMINOR 0 #define VDELTA 15 @@ -53,6 +48,7 @@ static const char rcsid[] = #include #include #include +#include #define SEP_LINE \ "\n-------------------------------------------------------------------------------\n" @@ -83,7 +79,7 @@ static const char rcsid[] = #define MAXPNSTR 132 -#define LINUXBIOS_MP_TABLE 0 +#define COREBOOT_MP_TABLE 0 enum busTypes { CBUS = 1, @@ -97,7 +93,7 @@ enum busTypes { }; typedef struct BUSTYPENAME { - u_char type; + uint8_t type; char name[ 7 ]; } busTypeName; @@ -135,8 +131,8 @@ char* whereStrings[] = { }; typedef struct TABLE_ENTRY { - u_char type; - u_char length; + uint8_t type; + uint8_t length; char name[ 32 ]; } tableEntry; @@ -158,69 +154,69 @@ tableEntry extendedtableEntryTypes[] = /* MP Floating Pointer Structure */ typedef struct MPFPS { - char signature[ 4 ]; - void* pap; - u_char length; - u_char spec_rev; - u_char checksum; - u_char mpfb1; - u_char mpfb2; - u_char mpfb3; - u_char mpfb4; - u_char mpfb5; + uint8_t signature[ 4 ]; + uint32_t pap; + uint8_t length; + uint8_t spec_rev; + uint8_t checksum; + uint8_t mpfb1; + uint8_t mpfb2; + uint8_t mpfb3; + uint8_t mpfb4; + uint8_t mpfb5; } mpfps_t; /* MP Configuration Table Header */ typedef struct MPCTH { - char signature[ 4 ]; - u_short base_table_length; - u_char spec_rev; - u_char checksum; - u_char oem_id[ 8 ]; - u_char product_id[ 12 ]; - void* oem_table_pointer; - u_short oem_table_size; - u_short entry_count; - void* apic_address; - u_short extended_table_length; - u_char extended_table_checksum; - u_char reserved; + uint8_t signature[ 4 ]; + uint16_t base_table_length; + uint8_t spec_rev; + uint8_t checksum; + uint8_t oem_id[ 8 ]; + uint8_t product_id[ 12 ]; + uint32_t oem_table_pointer; + uint16_t oem_table_size; + uint16_t entry_count; + uint32_t apic_address; + uint16_t extended_table_length; + uint8_t extended_table_checksum; + uint8_t reserved; } mpcth_t; typedef struct PROCENTRY { - u_char type; - u_char apicID; - u_char apicVersion; - u_char cpuFlags; - u_long cpuSignature; - u_long featureFlags; - u_long reserved1; - u_long reserved2; + uint8_t type; + uint8_t apicID; + uint8_t apicVersion; + uint8_t cpuFlags; + uint32_t cpuSignature; + uint32_t featureFlags; + uint32_t reserved1; + uint32_t reserved2; } ProcEntry; typedef struct BUSENTRY { - u_char type; - u_char busID; - char busType[ 6 ]; + uint8_t type; + uint8_t busID; + uint8_t busType[ 6 ]; } BusEntry; typedef struct IOAPICENTRY { - u_char type; - u_char apicID; - u_char apicVersion; - u_char apicFlags; - void* apicAddress; + uint8_t type; + uint8_t apicID; + uint8_t apicVersion; + uint8_t apicFlags; + uint32_t apicAddress; } IOApicEntry; typedef struct INTENTRY { - u_char type; - u_char intType; - u_short intFlags; - u_char srcBusID; - u_char srcBusIRQ; - u_char dstApicID; - u_char dstApicINT; + uint8_t type; + uint8_t intType; + uint16_t intFlags; + uint8_t srcBusID; + uint8_t srcBusIRQ; + uint8_t dstApicID; + uint8_t dstApicINT; } IntEntry; @@ -229,42 +225,42 @@ typedef struct INTENTRY { */ typedef struct SASENTRY { - u_char type; - u_char length; - u_char busID; - u_char addressType; - u_int64_t addressBase; - u_int64_t addressLength; + uint8_t type; + uint8_t length; + uint8_t busID; + uint8_t addressType; + uint64_t addressBase; + uint64_t addressLength; } SasEntry; typedef struct BHDENTRY { - u_char type; - u_char length; - u_char busID; - u_char busInfo; - u_char busParent; - u_char reserved[ 3 ]; + uint8_t type; + uint8_t length; + uint8_t busID; + uint8_t busInfo; + uint8_t busParent; + uint8_t reserved[ 3 ]; } BhdEntry; typedef struct CBASMENTRY { - u_char type; - u_char length; - u_char busID; - u_char addressMod; - u_int predefinedRange; + uint8_t type; + uint8_t length; + uint8_t busID; + uint8_t addressMod; + uint32_t predefinedRange; } CbasmEntry; -typedef unsigned long vm_offset_t; +typedef uint32_t vm_offset_t; static void apic_probe( vm_offset_t* paddr, int* where ); static void MPConfigDefault( int featureByte ); static void MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps ); -static void MPConfigTableHeader( void* pap ); +static void MPConfigTableHeader( uint32_t pap ); static int readType( void ); static void seekEntry( vm_offset_t addr ); @@ -282,7 +278,7 @@ static void cbasmEntry( void ); static void doOptionList( void ); static void doDmesg( void ); -static void pnstr( char* s, int c ); +static void pnstr( uint8_t* s, int c ); /* global data */ int pfd; /* physical /dev/mem fd */ @@ -299,38 +295,23 @@ int dmesg = 0; int grope = 0; int verbose = 0; int noisy = 0; -/* preamble to the mptable. This is fixed for all linuxbioses */ - +/* preamble to the mptable. This is fixed for all coreboots */ + char *preamble[] = { +"#include ", "#include ", +"#include ", +"#include ", "#include ", -"#include ", -"#include ", "#include ", "", -"void *smp_write_config_table(void *v)", +"static void *smp_write_config_table(void *v)", "{", -" static const char sig[4] = \"PCMP\";", -" static const char oem[8] = \"LNXI \";", -" static const char productid[12] = \"P4DPE \";", " struct mp_config_table *mc;", "", " mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);", -" memset(mc, 0, sizeof(*mc));", "", -" memcpy(mc->mpc_signature, sig, sizeof(sig));", -" mc->mpc_length = sizeof(*mc); /* initially just the header */", -" mc->mpc_spec = 0x04;", -" mc->mpc_checksum = 0; /* not yet computed */", -" memcpy(mc->mpc_oem, oem, sizeof(oem));", -" memcpy(mc->mpc_productid, productid, sizeof(productid));", -" mc->mpc_oemptr = 0;", -" mc->mpc_oemsize = 0;", -" mc->mpc_entry_count = 0; /* No entries yet... */", -" mc->mpc_lapic = LAPIC_ADDR;", -" mc->mpe_length = 0;", -" mc->mpe_checksum = 0;", -" mc->reserved = 0;", +" mptable_init(mc, \"TODO \", LAPIC_ADDR);", "", " smp_write_processors(mc);", "", @@ -339,12 +320,10 @@ char *preamble[] = { }; char *postamble[] = { -" /* There is no extension information... */", -"", -" /* Compute the checksums */", +" /* Compute the checksums. */", " mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);", " mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);", -" printk_debug(\"Wrote the mp table end at: %p - %p\\n\",", +" printk(BIOS_DEBUG, \"Wrote the mp table end at: %p - %p\\n\",", " mc, smp_next_mpe_entry(mc));", " return smp_next_mpe_entry(mc);", "}", @@ -359,35 +338,8 @@ char *postamble[] = { }; char *ioapic_code[] = { -" smp_write_ioapic(mc, 2, 0x20, 0xfec00000);", -" {", -" struct pci_dev *dev;", -" uint32_t base;", -" dev = pci_find_slot(1, PCI_DEVFN(0x1e,0));", -" if (dev) {", -" pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &base);", -" base &= PCI_BASE_ADDRESS_MEM_MASK;", -" smp_write_ioapic(mc, 3, 0x20, base);", -" }", -" dev = pci_find_slot(1, PCI_DEVFN(0x1c,0));", -" if (dev) {", -" pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &base);", -" base &= PCI_BASE_ADDRESS_MEM_MASK;", -" smp_write_ioapic(mc, 4, 0x20, base);", -" }", -" dev = pci_find_slot(4, PCI_DEVFN(0x1e,0));", -" if (dev) {", -" pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &base);", -" base &= PCI_BASE_ADDRESS_MEM_MASK;", -" smp_write_ioapic(mc, 5, 0x20, base);", -" }", -" dev = pci_find_slot(4, PCI_DEVFN(0x1c,0));", -" if (dev) {", -" pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &base);", -" base &= PCI_BASE_ADDRESS_MEM_MASK;", -" smp_write_ioapic(mc, 8, 0x20, base);", -" }", -" }", +" smp_write_ioapic(mc, 2, 0x20, IO_APIC_ADDR);", +" /* TODO: If you have multiple IOAPICs, add them here. */", 0 }; static void @@ -404,7 +356,7 @@ write_code(char **code) printf("%s\n", *code++); } /* - * + * */ int main( int argc, char *argv[] ) @@ -414,33 +366,29 @@ main( int argc, char *argv[] ) mpfps_t mpfps; int defaultConfig; - extern int optreset; - int ch; - /* announce ourselves */ - + if (verbose) puts( SEP_LINE2 ); - printf( "/* generatred by MPTable, version %d.%d.%d*/\n", VMAJOR, VMINOR, VDELTA ); - printf("/* as modified by RGM for LinuxBIOS */\n"); + printf( "/* generated by MPTable, version %d.%d.%d*/\n", VMAJOR, VMINOR, VDELTA ); + printf("/* as modified by RGM for coreboot */\n"); write_code(preamble); /* Ron hates getopt() */ for(argc--, argv++; argc; argc--, argv++){ - char *optarg = argv[0]; - if ( strcmp( optarg, "-dmesg") == 0 ) { + if ( strcmp( argv[0], "-dmesg") == 0 ) { dmesg = 1; - } else - if ( strcmp( optarg, "-help") == 0 ) + } else + if ( strcmp( argv[0], "-help") == 0 ) { usage(); } else - if ( strcmp( optarg, "-grope") == 0 ){ + if ( strcmp( argv[0], "-grope") == 0 ){ grope = 1; - } else if ( strcmp( optarg, "-verbose") == 0 ) + } else if ( strcmp( argv[0], "-verbose") == 0 ) verbose = 1; - else if ( strcmp( optarg, "-noisy") == 0 ) + else if ( strcmp( argv[0], "-noisy") == 0 ) noisy = 1; else usage(); } @@ -536,7 +484,7 @@ apic_probe( vm_offset_t* paddr, int* where ) target = 0; segment = 0; if ( verbose ) - printf( " searching for LinuxBIOS MP table @ 0x%08x (%dK)\n", + printf( " searching for coreboot MP table @ 0x%08x (%dK)\n", target, segment ); seekEntry( target ); readEntry( buffer, ONE_KBYTE ); @@ -652,7 +600,7 @@ apic_probe( vm_offset_t* paddr, int* where ) /* - * + * */ static void MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps ) @@ -723,7 +671,7 @@ MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps ) /* - * + * */ static void MPConfigDefault( int featureByte ) @@ -780,10 +728,10 @@ MPConfigDefault( int featureByte ) /* - * + * */ static void -MPConfigTableHeader( void* pap ) +MPConfigTableHeader( uint32_t pap ) { vm_offset_t paddr; mpcth_t cth; @@ -970,7 +918,7 @@ MPConfigTableHeader( void* pap ) /* - * + * */ static int readType( void ) @@ -988,7 +936,7 @@ readType( void ) /* - * + * */ static void seekEntry( vm_offset_t addr ) @@ -999,7 +947,7 @@ seekEntry( vm_offset_t addr ) /* - * + * */ static void readEntry( void* entry, int size ) @@ -1038,7 +986,7 @@ processorEntry( void ) /* - * + * */ static int lookupBusType( char* name ) @@ -1107,13 +1055,13 @@ ioApicEntry( void ) apics[ entry.apicID ] = entry.apicID; // the numbering and setup of ioapics is so irrational - // that for now we will punt. + // that for now we will punt. #if 0 if (entry.apicFlags & IOAPICENTRY_FLAG_EN) printf("\tsmp_write_ioapic(mc, 0x%x, 0x%x, 0x%x);\n", entry.apicID, entry.apicVersion, entry.apicAddress); #endif - + } @@ -1122,10 +1070,10 @@ char* intTypes[] = { }; char* polarityMode[] = { - "conforms", "MP_IRQ_POLARITY_HIGH", "reserved", "MP_IRQ_POLARITY_LOW" + "MP_IRQ_POLARITY_DEFAULT", "MP_IRQ_POLARITY_HIGH", "reserved", "MP_IRQ_POLARITY_LOW" }; char* triggerMode[] = { - "conforms", "MP_IRQ_TRIGGER_EDGE", "reserved", "MP_IRQ_TRIGGER_LEVEL" + "MP_IRQ_TRIGGER_DEFAULT", "MP_IRQ_TRIGGER_EDGE", "reserved", "MP_IRQ_TRIGGER_LEVEL" }; static void @@ -1148,11 +1096,11 @@ intEntry( void ) printf( "\t %5d", (int)entry.srcBusID ); if ( busses[ (int)entry.srcBusID ] == PCI ) - printf( "\t%2d:%c", + printf( "\t%2d:%c", ((int)entry.srcBusIRQ >> 2) & 0x1f, ((int)entry.srcBusIRQ & 0x03) + 'A' ); else - printf( "\t 0x%x:0x%x(0x%x)", + printf( "\t 0x%x:0x%x(0x%x)", (int)entry.srcBusIRQ>>2, (int)entry.srcBusIRQ & 3, (int)entry.srcBusIRQ ); @@ -1167,7 +1115,7 @@ intEntry( void ) (int)entry.srcBusIRQ, (int)entry.dstApicID , (int)entry.dstApicINT ); - + } static void @@ -1190,7 +1138,7 @@ lintEntry( void ) printf( "\t %5d", (int)entry.srcBusID ); if ( busses[ (int)entry.srcBusID ] == PCI ) - printf( "\t%2d:%c", + printf( "\t%2d:%c", ((int)entry.srcBusIRQ >> 2) & 0x1f, ((int)entry.srcBusIRQ & 0x03) + 'A' ); else @@ -1198,14 +1146,14 @@ lintEntry( void ) printf( "\t %6d", (int)entry.dstApicID ); printf( "\t %3d\n", (int)entry.dstApicINT ); } - printf("\tsmp_write_intsrc(mc, %s, %s|%s, 0x%x, 0x%x, MP_APIC_ALL, 0x%x);\n", + printf("\tsmp_write_lintsrc(mc, %s, %s|%s, 0x%x, 0x%x, MP_APIC_ALL, 0x%x);\n", intTypes[ (int)entry.intType ], triggerMode[ ((int)entry.intFlags >> 2) & 0x03 ] , polarityMode[ (int)entry.intFlags & 0x03 ], (int)entry.srcBusID, (int)entry.srcBusIRQ, (int)entry.dstApicINT ); - + } @@ -1235,8 +1183,8 @@ sasEntry( void ) break; } - printf( " address base: 0x%qx\n", entry.addressBase ); - printf( " address range: 0x%qx\n", entry.addressLength ); + printf( " address base: 0x%lx\n", entry.addressBase ); + printf( " address range: 0x%lx\n", entry.addressLength ); } @@ -1308,16 +1256,16 @@ doOptionList( void ) /* - * + * */ static void -pnstr( char* s, int c ) +pnstr( uint8_t* s, int c ) { - char string[ MAXPNSTR + 1 ]; + uint8_t string[ MAXPNSTR + 1 ]; if ( c > MAXPNSTR ) c = MAXPNSTR; - strncpy( string, s, c ); + strncpy( (char *)string, (char *)s, c ); string[ c ] = '\0'; printf( "%s", string ); }