Make this build and work on amd64 (sledge at least).

This commit is contained in:
Peter Wemm 2003-09-30 04:09:21 +00:00
parent 00f553ed0c
commit 8c489d725d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=120590
2 changed files with 40 additions and 39 deletions

View File

@ -1,5 +1,6 @@
# $FreeBSD$ # $FreeBSD$
PROG= mptable PROG= mptable
WARNS?= 6
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -123,7 +123,7 @@ static busTypeName busTypeTable[] =
{ UNKNOWN_BUSTYPE, "---" } { UNKNOWN_BUSTYPE, "---" }
}; };
char* whereStrings[] = { const char* whereStrings[] = {
"Extended BIOS Data Area", "Extended BIOS Data Area",
"BIOS top of memory", "BIOS top of memory",
"Default top of memory", "Default top of memory",
@ -158,7 +158,7 @@ tableEntry extendedtableEntryTypes[] =
/* MP Floating Pointer Structure */ /* MP Floating Pointer Structure */
typedef struct MPFPS { typedef struct MPFPS {
char signature[ 4 ]; char signature[ 4 ];
void* pap; u_int32_t pap;
u_char length; u_char length;
u_char spec_rev; u_char spec_rev;
u_char checksum; u_char checksum;
@ -177,10 +177,10 @@ typedef struct MPCTH {
u_char checksum; u_char checksum;
u_char oem_id[ 8 ]; u_char oem_id[ 8 ];
u_char product_id[ 12 ]; u_char product_id[ 12 ];
void* oem_table_pointer; u_int32_t oem_table_pointer;
u_short oem_table_size; u_short oem_table_size;
u_short entry_count; u_short entry_count;
void* apic_address; u_int32_t apic_address;
u_short extended_table_length; u_short extended_table_length;
u_char extended_table_checksum; u_char extended_table_checksum;
u_char reserved; u_char reserved;
@ -192,10 +192,10 @@ typedef struct PROCENTRY {
u_char apicID; u_char apicID;
u_char apicVersion; u_char apicVersion;
u_char cpuFlags; u_char cpuFlags;
u_long cpuSignature; u_int32_t cpuSignature;
u_long featureFlags; u_int32_t featureFlags;
u_long reserved1; u_int32_t reserved1;
u_long reserved2; u_int32_t reserved2;
} ProcEntry; } ProcEntry;
typedef struct BUSENTRY { typedef struct BUSENTRY {
@ -209,7 +209,7 @@ typedef struct IOAPICENTRY {
u_char apicID; u_char apicID;
u_char apicVersion; u_char apicVersion;
u_char apicFlags; u_char apicFlags;
void* apicAddress; u_int32_t apicAddress;
} IOApicEntry; } IOApicEntry;
typedef struct INTENTRY { typedef struct INTENTRY {
@ -234,7 +234,7 @@ typedef struct SASENTRY {
u_char addressType; u_char addressType;
u_int64_t addressBase; u_int64_t addressBase;
u_int64_t addressLength; u_int64_t addressLength;
} SasEntry; } __attribute__((__packed__)) SasEntry;
typedef struct BHDENTRY { typedef struct BHDENTRY {
@ -257,15 +257,15 @@ typedef struct CBASMENTRY {
static void apic_probe( vm_offset_t* paddr, int* where ); static void apic_probe( u_int32_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( u_int32_t paddr, int where, mpfps_t* mpfps );
static void MPConfigTableHeader( void* pap ); static void MPConfigTableHeader( u_int32_t pap );
static int readType( void ); static int readType( void );
static void seekEntry( vm_offset_t addr ); static void seekEntry( u_int32_t addr );
static void readEntry( void* entry, int size ); static void readEntry( void* entry, int size );
static void processorEntry( void ); static void processorEntry( void );
@ -308,7 +308,7 @@ usage( void )
int int
main( int argc, char *argv[] ) main( int argc, char *argv[] )
{ {
vm_offset_t paddr; u_int32_t paddr;
int where; int where;
mpfps_t mpfps; mpfps_t mpfps;
int defaultConfig; int defaultConfig;
@ -393,7 +393,7 @@ main( int argc, char *argv[] )
*/ */
#define NEXT(X) ((X) += 4) #define NEXT(X) ((X) += 4)
static void static void
apic_probe( vm_offset_t* paddr, int* where ) apic_probe( u_int32_t* paddr, int* where )
{ {
/* /*
* c rewrite of apic_probe() by Jack F. Vogel * c rewrite of apic_probe() by Jack F. Vogel
@ -401,7 +401,7 @@ apic_probe( vm_offset_t* paddr, int* where )
int x; int x;
u_short segment; u_short segment;
vm_offset_t target; u_int32_t target;
u_int buffer[ BIOS_SIZE / sizeof( int ) ]; u_int buffer[ BIOS_SIZE / sizeof( int ) ];
if ( verbose ) if ( verbose )
@ -410,16 +410,16 @@ apic_probe( vm_offset_t* paddr, int* where )
/* search Extended Bios Data Area, if present */ /* search Extended Bios Data Area, if present */
if ( verbose ) if ( verbose )
printf( " looking for EBDA pointer @ 0x%04x, ", EBDA_POINTER ); printf( " looking for EBDA pointer @ 0x%04x, ", EBDA_POINTER );
seekEntry( (vm_offset_t)EBDA_POINTER ); seekEntry( (u_int32_t)EBDA_POINTER );
readEntry( &segment, 2 ); readEntry( &segment, 2 );
if ( segment ) { /* search EBDA */ if ( segment ) { /* search EBDA */
target = (vm_offset_t)segment << 4; target = (u_int32_t)segment << 4;
if ( verbose ) if ( verbose )
printf( "found, searching EBDA @ 0x%08x\n", target ); printf( "found, searching EBDA @ 0x%08x\n", target );
seekEntry( target ); seekEntry( target );
readEntry( buffer, ONE_KBYTE ); readEntry( buffer, ONE_KBYTE );
for ( x = 0; x < ONE_KBYTE / sizeof ( unsigned int ); NEXT(x) ) { for ( x = 0; x < ONE_KBYTE / (int)sizeof ( unsigned int ); NEXT(x) ) {
if ( buffer[ x ] == MP_SIG ) { if ( buffer[ x ] == MP_SIG ) {
*where = 1; *where = 1;
*paddr = (x * sizeof( unsigned int )) + target; *paddr = (x * sizeof( unsigned int )) + target;
@ -433,7 +433,7 @@ apic_probe( vm_offset_t* paddr, int* where )
} }
/* read CMOS for real top of mem */ /* read CMOS for real top of mem */
seekEntry( (vm_offset_t)TOPOFMEM_POINTER ); seekEntry( (u_int32_t)TOPOFMEM_POINTER );
readEntry( &segment, 2 ); readEntry( &segment, 2 );
--segment; /* less ONE_KBYTE */ --segment; /* less ONE_KBYTE */
target = segment * 1024; target = segment * 1024;
@ -443,7 +443,7 @@ apic_probe( vm_offset_t* paddr, int* where )
seekEntry( target ); seekEntry( target );
readEntry( buffer, ONE_KBYTE ); readEntry( buffer, ONE_KBYTE );
for ( x = 0; x < ONE_KBYTE / sizeof ( unsigned int ); NEXT(x) ) { for ( x = 0; x < ONE_KBYTE / (int)sizeof ( unsigned int ); NEXT(x) ) {
if ( buffer[ x ] == MP_SIG ) { if ( buffer[ x ] == MP_SIG ) {
*where = 2; *where = 2;
*paddr = (x * sizeof( unsigned int )) + target; *paddr = (x * sizeof( unsigned int )) + target;
@ -460,7 +460,7 @@ apic_probe( vm_offset_t* paddr, int* where )
seekEntry( target ); seekEntry( target );
readEntry( buffer, ONE_KBYTE ); readEntry( buffer, ONE_KBYTE );
for ( x = 0; x < ONE_KBYTE / sizeof ( unsigned int ); NEXT(x) ) { for ( x = 0; x < ONE_KBYTE / (int)sizeof ( unsigned int ); NEXT(x) ) {
if ( buffer[ x ] == MP_SIG ) { if ( buffer[ x ] == MP_SIG ) {
*where = 3; *where = 3;
*paddr = (x * sizeof( unsigned int )) + target; *paddr = (x * sizeof( unsigned int )) + target;
@ -475,7 +475,7 @@ apic_probe( vm_offset_t* paddr, int* where )
seekEntry( BIOS_BASE ); seekEntry( BIOS_BASE );
readEntry( buffer, BIOS_SIZE ); readEntry( buffer, BIOS_SIZE );
for ( x = 0; x < BIOS_SIZE / sizeof( unsigned int ); NEXT(x) ) { for ( x = 0; x < BIOS_SIZE / (int)sizeof( unsigned int ); NEXT(x) ) {
if ( buffer[ x ] == MP_SIG ) { if ( buffer[ x ] == MP_SIG ) {
*where = 4; *where = 4;
*paddr = (x * sizeof( unsigned int )) + BIOS_BASE; *paddr = (x * sizeof( unsigned int )) + BIOS_BASE;
@ -489,7 +489,7 @@ apic_probe( vm_offset_t* paddr, int* where )
seekEntry( BIOS_BASE2 ); seekEntry( BIOS_BASE2 );
readEntry( buffer, BIOS_SIZE ); readEntry( buffer, BIOS_SIZE );
for ( x = 0; x < BIOS_SIZE / sizeof( unsigned int ); NEXT(x) ) { for ( x = 0; x < BIOS_SIZE / (int)sizeof( unsigned int ); NEXT(x) ) {
if ( buffer[ x ] == MP_SIG ) { if ( buffer[ x ] == MP_SIG ) {
*where = 5; *where = 5;
*paddr = (x * sizeof( unsigned int )) + BIOS_BASE2; *paddr = (x * sizeof( unsigned int )) + BIOS_BASE2;
@ -505,7 +505,7 @@ apic_probe( vm_offset_t* paddr, int* where )
seekEntry( target ); seekEntry( target );
readEntry( buffer, GROPE_SIZE ); readEntry( buffer, GROPE_SIZE );
for ( x = 0; x < GROPE_SIZE / sizeof( unsigned int ); NEXT(x) ) { for ( x = 0; x < GROPE_SIZE / (int)sizeof( unsigned int ); NEXT(x) ) {
if ( buffer[ x ] == MP_SIG ) { if ( buffer[ x ] == MP_SIG ) {
*where = 6; *where = 6;
*paddr = (x * sizeof( unsigned int )) + GROPE_AREA1; *paddr = (x * sizeof( unsigned int )) + GROPE_AREA1;
@ -519,7 +519,7 @@ apic_probe( vm_offset_t* paddr, int* where )
seekEntry( target ); seekEntry( target );
readEntry( buffer, GROPE_SIZE ); readEntry( buffer, GROPE_SIZE );
for ( x = 0; x < GROPE_SIZE / sizeof( unsigned int ); NEXT(x) ) { for ( x = 0; x < GROPE_SIZE / (int)sizeof( unsigned int ); NEXT(x) ) {
if ( buffer[ x ] == MP_SIG ) { if ( buffer[ x ] == MP_SIG ) {
*where = 7; *where = 7;
*paddr = (x * sizeof( unsigned int )) + GROPE_AREA2; *paddr = (x * sizeof( unsigned int )) + GROPE_AREA2;
@ -529,7 +529,7 @@ apic_probe( vm_offset_t* paddr, int* where )
} }
*where = 0; *where = 0;
*paddr = (vm_offset_t)0; *paddr = (u_int32_t)0;
} }
@ -537,7 +537,7 @@ apic_probe( vm_offset_t* paddr, int* where )
* *
*/ */
static void static void
MPFloatingPointer( vm_offset_t paddr, int where, mpfps_t* mpfps ) MPFloatingPointer( u_int32_t paddr, int where, mpfps_t* mpfps )
{ {
/* read in mpfps structure*/ /* read in mpfps structure*/
@ -663,9 +663,9 @@ MPConfigDefault( int featureByte )
* *
*/ */
static void static void
MPConfigTableHeader( void* pap ) MPConfigTableHeader( u_int32_t pap )
{ {
vm_offset_t paddr; u_int32_t paddr;
mpcth_t cth; mpcth_t cth;
int x; int x;
int totalSize; int totalSize;
@ -679,7 +679,7 @@ MPConfigTableHeader( void* pap )
} }
/* convert physical address to virtual address */ /* convert physical address to virtual address */
paddr = (vm_offset_t)pap; paddr = pap;
/* read in cth structure */ /* read in cth structure */
seekEntry( paddr ); seekEntry( paddr );
@ -817,7 +817,7 @@ MPConfigTableHeader( void* pap )
#if defined( OEM_PROCESSING_READY ) #if defined( OEM_PROCESSING_READY )
# error your on your own here! # error your on your own here!
/* convert OEM table pointer to virtual address */ /* convert OEM table pointer to virtual address */
poemtp = (vm_offset_t)cth.oem_table_pointer; poemtp = (u_int32_t)cth.oem_table_pointer;
/* read in oem table structure */ /* read in oem table structure */
if ( (oemdata = (void*)malloc( cth.oem_table_size )) == NULL ) if ( (oemdata = (void*)malloc( cth.oem_table_size )) == NULL )
@ -873,7 +873,7 @@ readType( void )
* *
*/ */
static void static void
seekEntry( vm_offset_t addr ) seekEntry( u_int32_t addr )
{ {
if ( lseek( pfd, (off_t)addr, SEEK_SET ) < 0 ) if ( lseek( pfd, (off_t)addr, SEEK_SET ) < 0 )
err( 1, "%s seek", _PATH_MEM ); err( 1, "%s seek", _PATH_MEM );
@ -982,14 +982,14 @@ ioApicEntry( void )
} }
char* intTypes[] = { const char* intTypes[] = {
"INT", "NMI", "SMI", "ExtINT" "INT", "NMI", "SMI", "ExtINT"
}; };
char* polarityMode[] = { const char* polarityMode[] = {
"conforms", "active-hi", "reserved", "active-lo" "conforms", "active-hi", "reserved", "active-lo"
}; };
char* triggerMode[] = { const char* triggerMode[] = {
"conforms", "edge", "reserved", "level" "conforms", "edge", "reserved", "level"
}; };
@ -1048,8 +1048,8 @@ sasEntry( void )
break; break;
} }
printf( " address base: 0x%qx\n", entry.addressBase ); printf( " address base: 0x%llx\n", (long long)entry.addressBase );
printf( " address range: 0x%qx\n", entry.addressLength ); printf( " address range: 0x%llx\n", (long long)entry.addressLength );
} }