mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
use stdint types for structures, and don't use pointers
for fields defined 32bit in the multi processor specification. Also, fix lots of trivial warnings in the code. If you ever wondered, why you get odd or wrong mp tables on your x64 system: It's not because bios vendors neglected mp tables; it's because we neglected 64bit systems. ;-) Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5056 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
a9796ed362
commit
c6d3ff6cdd
2 changed files with 86 additions and 92 deletions
|
@ -1,6 +1,8 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
|
CFLAGS=-O2 -Wall -Wextra -Wshadow -Wno-sign-compare
|
||||||
|
|
||||||
|
mptable: mptable.c
|
||||||
|
$(CC) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
mptable: mptable.o
|
|
||||||
$(CC) -o mptable mptable.o
|
|
||||||
clean:
|
clean:
|
||||||
\rm *.o mptable
|
rm -f mptable
|
||||||
|
|
|
@ -27,11 +27,6 @@
|
||||||
* mptable.c
|
* mptable.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] =
|
|
||||||
"$Id$";
|
|
||||||
#endif /* not lint */
|
|
||||||
|
|
||||||
#define VMAJOR 2
|
#define VMAJOR 2
|
||||||
#define VMINOR 0
|
#define VMINOR 0
|
||||||
#define VDELTA 15
|
#define VDELTA 15
|
||||||
|
@ -53,6 +48,7 @@ static const char rcsid[] =
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#define SEP_LINE \
|
#define SEP_LINE \
|
||||||
"\n-------------------------------------------------------------------------------\n"
|
"\n-------------------------------------------------------------------------------\n"
|
||||||
|
@ -97,7 +93,7 @@ enum busTypes {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct BUSTYPENAME {
|
typedef struct BUSTYPENAME {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
char name[ 7 ];
|
char name[ 7 ];
|
||||||
} busTypeName;
|
} busTypeName;
|
||||||
|
|
||||||
|
@ -135,8 +131,8 @@ char* whereStrings[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct TABLE_ENTRY {
|
typedef struct TABLE_ENTRY {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
u_char length;
|
uint8_t length;
|
||||||
char name[ 32 ];
|
char name[ 32 ];
|
||||||
} tableEntry;
|
} tableEntry;
|
||||||
|
|
||||||
|
@ -158,69 +154,69 @@ tableEntry extendedtableEntryTypes[] =
|
||||||
|
|
||||||
/* MP Floating Pointer Structure */
|
/* MP Floating Pointer Structure */
|
||||||
typedef struct MPFPS {
|
typedef struct MPFPS {
|
||||||
char signature[ 4 ];
|
uint8_t signature[ 4 ];
|
||||||
void* pap;
|
uint32_t pap;
|
||||||
u_char length;
|
uint8_t length;
|
||||||
u_char spec_rev;
|
uint8_t spec_rev;
|
||||||
u_char checksum;
|
uint8_t checksum;
|
||||||
u_char mpfb1;
|
uint8_t mpfb1;
|
||||||
u_char mpfb2;
|
uint8_t mpfb2;
|
||||||
u_char mpfb3;
|
uint8_t mpfb3;
|
||||||
u_char mpfb4;
|
uint8_t mpfb4;
|
||||||
u_char mpfb5;
|
uint8_t mpfb5;
|
||||||
} mpfps_t;
|
} mpfps_t;
|
||||||
|
|
||||||
/* MP Configuration Table Header */
|
/* MP Configuration Table Header */
|
||||||
typedef struct MPCTH {
|
typedef struct MPCTH {
|
||||||
char signature[ 4 ];
|
uint8_t signature[ 4 ];
|
||||||
u_short base_table_length;
|
uint16_t base_table_length;
|
||||||
u_char spec_rev;
|
uint8_t spec_rev;
|
||||||
u_char checksum;
|
uint8_t checksum;
|
||||||
u_char oem_id[ 8 ];
|
uint8_t oem_id[ 8 ];
|
||||||
u_char product_id[ 12 ];
|
uint8_t product_id[ 12 ];
|
||||||
void* oem_table_pointer;
|
uint32_t oem_table_pointer;
|
||||||
u_short oem_table_size;
|
uint16_t oem_table_size;
|
||||||
u_short entry_count;
|
uint16_t entry_count;
|
||||||
void* apic_address;
|
uint32_t apic_address;
|
||||||
u_short extended_table_length;
|
uint16_t extended_table_length;
|
||||||
u_char extended_table_checksum;
|
uint8_t extended_table_checksum;
|
||||||
u_char reserved;
|
uint8_t reserved;
|
||||||
} mpcth_t;
|
} mpcth_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct PROCENTRY {
|
typedef struct PROCENTRY {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
u_char apicID;
|
uint8_t apicID;
|
||||||
u_char apicVersion;
|
uint8_t apicVersion;
|
||||||
u_char cpuFlags;
|
uint8_t cpuFlags;
|
||||||
u_long cpuSignature;
|
uint32_t cpuSignature;
|
||||||
u_long featureFlags;
|
uint32_t featureFlags;
|
||||||
u_long reserved1;
|
uint32_t reserved1;
|
||||||
u_long reserved2;
|
uint32_t reserved2;
|
||||||
} ProcEntry;
|
} ProcEntry;
|
||||||
|
|
||||||
typedef struct BUSENTRY {
|
typedef struct BUSENTRY {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
u_char busID;
|
uint8_t busID;
|
||||||
char busType[ 6 ];
|
uint8_t busType[ 6 ];
|
||||||
} BusEntry;
|
} BusEntry;
|
||||||
|
|
||||||
typedef struct IOAPICENTRY {
|
typedef struct IOAPICENTRY {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
u_char apicID;
|
uint8_t apicID;
|
||||||
u_char apicVersion;
|
uint8_t apicVersion;
|
||||||
u_char apicFlags;
|
uint8_t apicFlags;
|
||||||
void* apicAddress;
|
uint32_t apicAddress;
|
||||||
} IOApicEntry;
|
} IOApicEntry;
|
||||||
|
|
||||||
typedef struct INTENTRY {
|
typedef struct INTENTRY {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
u_char intType;
|
uint8_t intType;
|
||||||
u_short intFlags;
|
uint16_t intFlags;
|
||||||
u_char srcBusID;
|
uint8_t srcBusID;
|
||||||
u_char srcBusIRQ;
|
uint8_t srcBusIRQ;
|
||||||
u_char dstApicID;
|
uint8_t dstApicID;
|
||||||
u_char dstApicINT;
|
uint8_t dstApicINT;
|
||||||
} IntEntry;
|
} IntEntry;
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,42 +225,42 @@ typedef struct INTENTRY {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct SASENTRY {
|
typedef struct SASENTRY {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
u_char length;
|
uint8_t length;
|
||||||
u_char busID;
|
uint8_t busID;
|
||||||
u_char addressType;
|
uint8_t addressType;
|
||||||
u_int64_t addressBase;
|
uint64_t addressBase;
|
||||||
u_int64_t addressLength;
|
uint64_t addressLength;
|
||||||
} SasEntry;
|
} SasEntry;
|
||||||
|
|
||||||
|
|
||||||
typedef struct BHDENTRY {
|
typedef struct BHDENTRY {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
u_char length;
|
uint8_t length;
|
||||||
u_char busID;
|
uint8_t busID;
|
||||||
u_char busInfo;
|
uint8_t busInfo;
|
||||||
u_char busParent;
|
uint8_t busParent;
|
||||||
u_char reserved[ 3 ];
|
uint8_t reserved[ 3 ];
|
||||||
} BhdEntry;
|
} BhdEntry;
|
||||||
|
|
||||||
|
|
||||||
typedef struct CBASMENTRY {
|
typedef struct CBASMENTRY {
|
||||||
u_char type;
|
uint8_t type;
|
||||||
u_char length;
|
uint8_t length;
|
||||||
u_char busID;
|
uint8_t busID;
|
||||||
u_char addressMod;
|
uint8_t addressMod;
|
||||||
u_int predefinedRange;
|
uint32_t predefinedRange;
|
||||||
} CbasmEntry;
|
} 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 apic_probe( vm_offset_t* paddr, int* where );
|
||||||
|
|
||||||
static void MPConfigDefault( int featureByte );
|
static void MPConfigDefault( int featureByte );
|
||||||
|
|
||||||
static void MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps );
|
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 int readType( void );
|
||||||
static void seekEntry( vm_offset_t addr );
|
static void seekEntry( vm_offset_t addr );
|
||||||
|
@ -282,7 +278,7 @@ static void cbasmEntry( void );
|
||||||
|
|
||||||
static void doOptionList( void );
|
static void doOptionList( void );
|
||||||
static void doDmesg( void );
|
static void doDmesg( void );
|
||||||
static void pnstr( char* s, int c );
|
static void pnstr( uint8_t* s, int c );
|
||||||
|
|
||||||
/* global data */
|
/* global data */
|
||||||
int pfd; /* physical /dev/mem fd */
|
int pfd; /* physical /dev/mem fd */
|
||||||
|
@ -418,9 +414,6 @@ main( int argc, char *argv[] )
|
||||||
mpfps_t mpfps;
|
mpfps_t mpfps;
|
||||||
int defaultConfig;
|
int defaultConfig;
|
||||||
|
|
||||||
extern int optreset;
|
|
||||||
int ch;
|
|
||||||
|
|
||||||
/* announce ourselves */
|
/* announce ourselves */
|
||||||
|
|
||||||
if (verbose) puts( SEP_LINE2 );
|
if (verbose) puts( SEP_LINE2 );
|
||||||
|
@ -432,19 +425,18 @@ main( int argc, char *argv[] )
|
||||||
/* Ron hates getopt() */
|
/* Ron hates getopt() */
|
||||||
|
|
||||||
for(argc--, argv++; argc; argc--, argv++){
|
for(argc--, argv++; argc; argc--, argv++){
|
||||||
char *optarg = argv[0];
|
if ( strcmp( argv[0], "-dmesg") == 0 ) {
|
||||||
if ( strcmp( optarg, "-dmesg") == 0 ) {
|
|
||||||
dmesg = 1;
|
dmesg = 1;
|
||||||
} else
|
} else
|
||||||
if ( strcmp( optarg, "-help") == 0 )
|
if ( strcmp( argv[0], "-help") == 0 )
|
||||||
{
|
{
|
||||||
usage();
|
usage();
|
||||||
} else
|
} else
|
||||||
if ( strcmp( optarg, "-grope") == 0 ){
|
if ( strcmp( argv[0], "-grope") == 0 ){
|
||||||
grope = 1;
|
grope = 1;
|
||||||
} else if ( strcmp( optarg, "-verbose") == 0 )
|
} else if ( strcmp( argv[0], "-verbose") == 0 )
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
else if ( strcmp( optarg, "-noisy") == 0 )
|
else if ( strcmp( argv[0], "-noisy") == 0 )
|
||||||
noisy = 1;
|
noisy = 1;
|
||||||
else usage();
|
else usage();
|
||||||
}
|
}
|
||||||
|
@ -787,7 +779,7 @@ MPConfigDefault( int featureByte )
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
MPConfigTableHeader( void* pap )
|
MPConfigTableHeader( uint32_t pap )
|
||||||
{
|
{
|
||||||
vm_offset_t paddr;
|
vm_offset_t paddr;
|
||||||
mpcth_t cth;
|
mpcth_t cth;
|
||||||
|
@ -1239,8 +1231,8 @@ sasEntry( void )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( " address base: 0x%qx\n", entry.addressBase );
|
printf( " address base: 0x%lx\n", entry.addressBase );
|
||||||
printf( " address range: 0x%qx\n", entry.addressLength );
|
printf( " address range: 0x%lx\n", entry.addressLength );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1315,13 +1307,13 @@ doOptionList( void )
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static 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 )
|
if ( c > MAXPNSTR )
|
||||||
c = MAXPNSTR;
|
c = MAXPNSTR;
|
||||||
strncpy( string, s, c );
|
strncpy( (char *)string, (char *)s, c );
|
||||||
string[ c ] = '\0';
|
string[ c ] = '\0';
|
||||||
printf( "%s", string );
|
printf( "%s", string );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue