mptable: reindent code to comply with coreboot coding style

Change-Id: Iee27c535f56ebedaceea542c2919cde68006827c
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-on: http://review.coreboot.org/1111
Tested-by: build bot (Jenkins)
This commit is contained in:
Sven Schnelle 2012-06-20 09:24:45 +02:00
parent 09a180230a
commit b00c9a2257
1 changed files with 852 additions and 878 deletions

View File

@ -97,8 +97,7 @@ typedef struct BUSTYPENAME {
char name[7];
} busTypeName;
static busTypeName busTypeTable[] =
{
static busTypeName busTypeTable[] = {
{CBUS, "CBUS"},
{CBUSII, "CBUSII"},
{EISA, "EISA"},
@ -136,8 +135,7 @@ typedef struct TABLE_ENTRY {
char name[32];
} tableEntry;
tableEntry basetableEntryTypes[] =
{
tableEntry basetableEntryTypes[] = {
{0, 20, "Processor"},
{1, 8, "Bus"},
{2, 8, "I/O APIC"},
@ -145,8 +143,7 @@ tableEntry basetableEntryTypes[] =
{4, 8, "Local INT"}
};
tableEntry extendedtableEntryTypes[] =
{
tableEntry extendedtableEntryTypes[] = {
{128, 20, "System Address Space"},
{129, 8, "Bus Heirarchy"},
{130, 8, "Compatibility Bus Address"}
@ -183,7 +180,6 @@ typedef struct MPCTH {
uint8_t reserved;
} mpcth_t;
typedef struct PROCENTRY {
uint8_t type;
uint8_t apicID;
@ -219,7 +215,6 @@ typedef struct INTENTRY {
uint8_t dstApicINT;
} IntEntry;
/*
* extended entry type structures
*/
@ -233,7 +228,6 @@ typedef struct SASENTRY {
uint64_t addressLength;
} SasEntry;
typedef struct BHDENTRY {
uint8_t type;
uint8_t length;
@ -243,7 +237,6 @@ typedef struct BHDENTRY {
uint8_t reserved[3];
} BhdEntry;
typedef struct CBASMENTRY {
uint8_t type;
uint8_t length;
@ -252,7 +245,6 @@ typedef struct CBASMENTRY {
uint32_t predefinedRange;
} CbasmEntry;
typedef uint32_t vm_offset_t;
static void apic_probe(vm_offset_t * paddr, int *where);
@ -337,24 +329,23 @@ char *postamble[] = {
0
};
static void
usage( void )
static void usage(void)
{
fprintf( stderr, "usage: mptable [-dmesg] [-verbose] [-grope] [-help]\n" );
fprintf(stderr,
"usage: mptable [-dmesg] [-verbose] [-grope] [-help]\n");
exit(0);
}
void
write_code(char **code)
void write_code(char **code)
{
while (*code)
printf("%s\n", *code++);
}
/*
*
*/
int
main( int argc, char *argv[] )
int main(int argc, char *argv[])
{
vm_offset_t paddr;
int where;
@ -363,9 +354,11 @@ main( int argc, char *argv[] )
/* announce ourselves */
if (verbose) puts( SEP_LINE2 );
if (verbose)
puts(SEP_LINE2);
printf( "/* generated by MPTable, version %d.%d.%d*/\n", VMAJOR, VMINOR, VDELTA );
printf("/* generated by MPTable, version %d.%d.%d*/\n", VMAJOR, VMINOR,
VDELTA);
printf("/* as modified by RGM for coreboot */\n");
write_code(preamble);
@ -374,18 +367,16 @@ main( int argc, char *argv[] )
for (argc--, argv++; argc; argc--, argv++) {
if (strcmp(argv[0], "-dmesg") == 0) {
dmesg = 1;
} else
if ( strcmp( argv[0], "-help") == 0 )
{
} else if (strcmp(argv[0], "-help") == 0) {
usage();
} else
if ( strcmp( argv[0], "-grope") == 0 ){
} else if (strcmp(argv[0], "-grope") == 0) {
grope = 1;
} else if (strcmp(argv[0], "-verbose") == 0)
verbose = 1;
else if (strcmp(argv[0], "-noisy") == 0)
noisy = 1;
else usage();
else
usage();
}
/* open physical memory for access to MP structures */
@ -404,12 +395,14 @@ main( int argc, char *argv[] )
printf("\n MP FPS found in %s @ physical addr: 0x%08x\n",
whereStrings[where - 1], paddr);
if (verbose) puts( SEP_LINE );
if (verbose)
puts(SEP_LINE);
/* analyze the MP Floating Pointer Structure */
MPFloatingPointer(paddr, where, &mpfps);
if (verbose) puts( SEP_LINE );
if (verbose)
puts(SEP_LINE);
/* check whether an MP config table exists */
if ((defaultConfig = mpfps.mpfb1))
@ -426,18 +419,17 @@ main( int argc, char *argv[] )
if (dmesg)
doDmesg();
if (verbose) puts( SEP_LINE2 );
if (verbose)
puts(SEP_LINE2);
return 0;
}
/*
* set PHYSICAL address of MP floating pointer structure
*/
#define NEXT(X) ((X) += 4)
static void
apic_probe( vm_offset_t* paddr, int* where )
static void apic_probe(vm_offset_t * paddr, int *where)
{
/*
* c rewrite of apic_probe() by Jack F. Vogel
@ -470,8 +462,7 @@ apic_probe( vm_offset_t* paddr, int* where )
return;
}
}
}
else {
} else {
if (verbose)
printf("NOT found\n");
}
@ -492,7 +483,6 @@ apic_probe( vm_offset_t* paddr, int* where )
}
}
/* read CMOS for real top of mem */
seekEntry((vm_offset_t) TOPOFMEM_POINTER);
readEntry(&segment, 2);
@ -516,7 +506,8 @@ apic_probe( vm_offset_t* paddr, int* where )
if (target != (DEFAULT_TOPOFMEM - 1024)) {
target = (DEFAULT_TOPOFMEM - 1024);
if (verbose)
printf( " searching default 'top of mem' @ 0x%08x (%dK)\n",
printf
(" searching default 'top of mem' @ 0x%08x (%dK)\n",
target, (target / 1024));
seekEntry(target);
readEntry(buffer, ONE_KBYTE);
@ -569,7 +560,8 @@ apic_probe( vm_offset_t* paddr, int* where )
for (x = 0; x < GROPE_SIZE / sizeof(unsigned int); NEXT(x)) {
if (buffer[x] == MP_SIG) {
*where = 6;
*paddr = (x * sizeof( unsigned int )) + GROPE_AREA1;
*paddr =
(x * sizeof(unsigned int)) + GROPE_AREA1;
return;
}
}
@ -583,7 +575,8 @@ apic_probe( vm_offset_t* paddr, int* where )
for (x = 0; x < GROPE_SIZE / sizeof(unsigned int); NEXT(x)) {
if (buffer[x] == MP_SIG) {
*where = 7;
*paddr = (x * sizeof( unsigned int )) + GROPE_AREA2;
*paddr =
(x * sizeof(unsigned int)) + GROPE_AREA2;
return;
}
}
@ -593,12 +586,10 @@ apic_probe( vm_offset_t* paddr, int* where )
*paddr = (vm_offset_t) 0;
}
/*
*
*/
static void
MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps )
static void MPFloatingPointer(vm_offset_t paddr, int where, mpfps_t * mpfps)
{
/* read in mpfps structure */
@ -610,8 +601,7 @@ MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps )
printf("MP Floating Pointer Structure:\n\n");
printf(" location:\t\t\t");
switch ( where )
{
switch (where) {
case 1:
printf("EBDA\n");
break;
@ -647,7 +637,8 @@ MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps )
/* bits 0:6 are RESERVED */
if (mpfps->mpfb2 & 0x7f) {
printf( " warning, MP feature byte 2: 0x%02x\n", mpfps->mpfb2 );
printf(" warning, MP feature byte 2: 0x%02x\n",
mpfps->mpfb2);
}
/* bit 7 is IMCRP */
@ -664,12 +655,10 @@ MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps )
}
}
/*
*
*/
static void
MPConfigDefault( int featureByte )
static void MPConfigDefault(int featureByte)
{
printf(" MP default config type: %d\n\n", featureByte);
switch (featureByte) {
@ -721,12 +710,10 @@ MPConfigDefault( int featureByte )
nintr = 16;
}
/*
*
*/
static void
MPConfigTableHeader( uint32_t pap )
static void MPConfigTableHeader(uint32_t pap)
{
vm_offset_t paddr;
mpcth_t cth;
@ -769,22 +756,26 @@ MPConfigTableHeader( uint32_t pap )
pnstr(cth.product_id, 12);
printf("'\n");
printf( " OEM table pointer:\t\t0x%08x\n", cth.oem_table_pointer );
printf(" OEM table pointer:\t\t0x%08x\n",
cth.oem_table_pointer);
printf(" OEM table size:\t\t%d\n", cth.oem_table_size);
printf(" entry count:\t\t\t%d\n", cth.entry_count);
printf(" local APIC address:\t\t0x%08x\n", cth.apic_address);
printf( " extended table length:\t%d\n", cth.extended_table_length );
printf( " extended table checksum:\t%d\n", cth.extended_table_checksum );
printf(" extended table length:\t%d\n",
cth.extended_table_length);
printf(" extended table checksum:\t%d\n",
cth.extended_table_checksum);
}
totalSize = cth.base_table_length - sizeof(struct MPCTH);
count = cth.entry_count;
if (verbose) {
if (verbose) puts( SEP_LINE );
if (verbose)
puts(SEP_LINE);
printf("MP Config Base Table Entries:\n\n");
}
@ -827,7 +818,8 @@ MPConfigTableHeader( uint32_t pap )
}
/* process all the I/O Ints */
printf( "/*I/O Ints:\tType\tPolarity Trigger\tBus ID\t IRQ\tAPIC ID\tPIN#\n*/" );
printf
("/*I/O Ints:\tType\tPolarity Trigger\tBus ID\t IRQ\tAPIC ID\tPIN#\n*/");
for (c = count; c; c--) {
if (readType() == 3)
intEntry();
@ -835,18 +827,19 @@ MPConfigTableHeader( uint32_t pap )
}
/* process all the Local Ints */
printf( "/*Local Ints:\tType\tPolarity Trigger\tBus ID\t IRQ\tAPIC ID\tPIN#*/\n" );
printf
("/*Local Ints:\tType\tPolarity Trigger\tBus ID\t IRQ\tAPIC ID\tPIN#*/\n");
for (c = count; c; c--) {
if (readType() == 4)
lintEntry();
totalSize -= basetableEntryTypes[4].length;
}
#if defined( EXTENDED_PROCESSING_READY )
/* process any extended data */
if ((totalSize = cth.extended_table_length)) {
if (verbose) puts( SEP_LINE );
if (verbose)
puts(SEP_LINE);
printf("MP Config Extended Table Entries:\n\n");
@ -889,7 +882,8 @@ MPConfigTableHeader( uint32_t pap )
free(oemdata);
#else
printf( "\nyou need to modify the source to handle OEM data!\n\n" );
printf
("\nyou need to modify the source to handle OEM data!\n\n");
#endif /* OEM_PROCESSING_READY */
}
@ -909,12 +903,10 @@ MPConfigTableHeader( uint32_t pap )
#endif /* RAW_DUMP */
}
/*
*
*/
static int
readType( void )
static int readType(void)
{
u_char type;
@ -927,31 +919,25 @@ readType( void )
return (int)type;
}
/*
*
*/
static void
seekEntry( vm_offset_t addr )
static void seekEntry(vm_offset_t addr)
{
if (lseek(pfd, (off_t) addr, SEEK_SET) < 0)
err(1, "/dev/mem seek");
}
/*
*
*/
static void
readEntry( void* entry, int size )
static void readEntry(void *entry, int size)
{
if (read(pfd, entry, size) != size)
err(1, "readEntry");
}
static void
processorEntry( void )
static void processorEntry(void)
{
ProcEntry entry;
@ -966,7 +952,8 @@ processorEntry( void )
printf("\t %s, %s",
(entry.cpuFlags & PROCENTRY_FLAG_BP) ? "BSP" : "AP",
(entry.cpuFlags & PROCENTRY_FLAG_EN) ? "usable" : "unusable" );
(entry.
cpuFlags & PROCENTRY_FLAG_EN) ? "usable" : "unusable");
printf("\t %d\t %d\t %d",
(entry.cpuSignature >> 8) & 0x0f,
@ -977,12 +964,10 @@ processorEntry( void )
}
}
/*
*
*/
static int
lookupBusType( char* name )
static int lookupBusType(char *name)
{
int x;
@ -993,9 +978,7 @@ lookupBusType( char* name )
return UNKNOWN_BUSTYPE;
}
static void
busEntry( void )
static void busEntry(void)
{
char name[8];
BusEntry entry;
@ -1008,7 +991,9 @@ busEntry( void )
if (verbose) {
printf("\t\t%2d", entry.busID);
printf( "\t " ); pnstr( entry.busType, 6 ); printf( "\n" );
printf("\t ");
pnstr(entry.busType, 6);
printf("\n");
}
memset(name, '\0', sizeof(name));
@ -1020,9 +1005,7 @@ busEntry( void )
printf("\");\n");
}
static void
ioApicEntry( void )
static void ioApicEntry(void)
{
IOApicEntry entry;
@ -1036,7 +1019,9 @@ ioApicEntry( void )
printf("\t\t%2d", entry.apicID);
printf("\t 0x%02x", entry.apicVersion);
printf("\t %s",
(entry.apicFlags & IOAPICENTRY_FLAG_EN) ? "usable" : "unusable" );
(entry.
apicFlags & IOAPICENTRY_FLAG_EN) ? "usable" :
"unusable");
printf("\t\t 0x%x\n", entry.apicAddress);
}
@ -1047,20 +1032,21 @@ ioApicEntry( void )
entry.apicID, entry.apicVersion, entry.apicAddress);
}
char *intTypes[] = {
"mp_INT", "mp_NMI", "mp_SMI", "mp_ExtINT"
};
char *polarityMode[] = {
"MP_IRQ_POLARITY_DEFAULT", "MP_IRQ_POLARITY_HIGH", "reserved", "MP_IRQ_POLARITY_LOW"
};
char* triggerMode[] = {
"MP_IRQ_TRIGGER_DEFAULT", "MP_IRQ_TRIGGER_EDGE", "reserved", "MP_IRQ_TRIGGER_LEVEL"
"MP_IRQ_POLARITY_DEFAULT", "MP_IRQ_POLARITY_HIGH", "reserved",
"MP_IRQ_POLARITY_LOW"
};
static void
intEntry( void )
char *triggerMode[] = {
"MP_IRQ_TRIGGER_DEFAULT", "MP_IRQ_TRIGGER_EDGE", "reserved",
"MP_IRQ_TRIGGER_LEVEL"
};
static void intEntry(void)
{
IntEntry entry;
@ -1085,8 +1071,7 @@ intEntry( void )
else
printf("\t 0x%x:0x%x(0x%x)",
(int)entry.srcBusIRQ >> 2,
(int)entry.srcBusIRQ & 3,
(int)entry.srcBusIRQ );
(int)entry.srcBusIRQ & 3, (int)entry.srcBusIRQ);
printf("\t %6d", (int)entry.dstApicID);
printf("\t %3d\n", (int)entry.dstApicINT);
}
@ -1096,13 +1081,11 @@ intEntry( void )
polarityMode[(int)entry.intFlags & 0x03],
(int)entry.srcBusID,
(int)entry.srcBusIRQ,
(int)entry.dstApicID ,
(int)entry.dstApicINT );
(int)entry.dstApicID, (int)entry.dstApicINT);
}
static void
lintEntry( void )
static void lintEntry(void)
{
IntEntry entry;
@ -1129,19 +1112,16 @@ lintEntry( void )
printf("\t %6d", (int)entry.dstApicID);
printf("\t %3d\n", (int)entry.dstApicINT);
}
printf("\tsmp_write_lintsrc(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 );
polarityMode[(int)entry.intFlags & 0x03], (int)entry.srcBusID,
(int)entry.srcBusIRQ, (int)entry.dstApicINT);
}
static void
sasEntry( void )
static void sasEntry(void)
{
SasEntry entry;
@ -1170,9 +1150,7 @@ sasEntry( void )
printf(" address range: 0x%lx\n", entry.addressLength);
}
static void
bhdEntry( void )
static void bhdEntry(void)
{
BhdEntry entry;
@ -1185,9 +1163,7 @@ bhdEntry( void )
printf(" parent bus ID: %d", entry.busParent);
}
static void
cbasmEntry( void )
static void cbasmEntry(void)
{
CbasmEntry entry;
@ -1201,28 +1177,26 @@ cbasmEntry( void )
printf(" predefined range: 0x%08x", entry.predefinedRange);
}
/*
* do a dmesg output
*/
static void
doDmesg( void )
static void doDmesg(void)
{
if (verbose) puts( SEP_LINE );
if (verbose)
puts(SEP_LINE);
printf("dmesg output:\n\n");
fflush(stdout);
system("dmesg");
}
/*
* build "options" entries for the kernel config file
*/
static void
doOptionList( void )
static void doOptionList(void)
{
if (verbose) puts( SEP_LINE );
if (verbose)
puts(SEP_LINE);
printf("# SMP kernel config file options:\n\n");
printf("\n# Required:\n");
@ -1231,18 +1205,18 @@ doOptionList( void )
printf("\n# Optional (built-in defaults will work in most cases):\n");
printf("#options NCPU=%d\t\t\t# number of CPUs\n", ncpu);
printf( "#options NBUS=%d\t\t\t# number of busses\n", nbus );
printf( "#options NAPIC=%d\t\t\t# number of IO APICs\n", napic );
printf("#options NBUS=%d\t\t\t# number of busses\n",
nbus);
printf("#options NAPIC=%d\t\t\t# number of IO APICs\n",
napic);
printf("#options NINTR=%d\t\t# number of INTs\n",
(nintr < 24) ? 24 : nintr);
}
/*
*
*/
static void
pnstr( uint8_t* s, int c )
static void pnstr(uint8_t * s, int c)
{
uint8_t string[MAXPNSTR + 1];