Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[driver] Add sBFT detection and debug parsing
- Loading branch information
Michael Brown
committed
Oct 23, 2009
1 parent
f8f35a3
commit 8f4e2db
Showing
8 changed files
with
321 additions
and
10 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
* OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include <ntddk.h> | ||
#include <ntstrsafe.h> | ||
#include "sanbootconf.h" | ||
#include "sbft.h" | ||
|
||
/** | ||
* Parse sBFT SCSI subtable | ||
* | ||
* @v sbft sBFT | ||
* @v scsi SCSI subtable | ||
*/ | ||
static VOID parse_sbft_scsi ( PSBFT_TABLE sbft, PSBFT_SCSI_SUBTABLE scsi ) { | ||
|
||
DbgPrint ( "Found sBFT SCSI subtable:\n" ); | ||
DbgPrint ( " LUN = %04x-%04x-%04x-%04x\n", | ||
( ( scsi->lun >> 48 ) & 0xffff ), | ||
( ( scsi->lun >> 32 ) & 0xffff ), | ||
( ( scsi->lun >> 16 ) & 0xffff ), | ||
( ( scsi->lun >> 0 ) & 0xffff ) ); | ||
( VOID ) sbft; | ||
} | ||
|
||
/** | ||
* Parse sBFT SRP subtable | ||
* | ||
* @v sbft sBFT | ||
* @v srp SRP subtable | ||
*/ | ||
static VOID parse_sbft_srp ( PSBFT_TABLE sbft, PSBFT_SRP_SUBTABLE srp ) { | ||
|
||
DbgPrint ( "Found sBFT SRP subtable:\n" ); | ||
DbgPrint ( " Initiator port ID = 0x%08x%08x%08x%08x\n", | ||
RtlUlongByteSwap ( srp->initiator_port_id.u.dwords[0] ), | ||
RtlUlongByteSwap ( srp->initiator_port_id.u.dwords[1] ), | ||
RtlUlongByteSwap ( srp->initiator_port_id.u.dwords[2] ), | ||
RtlUlongByteSwap ( srp->initiator_port_id.u.dwords[3] ) ); | ||
DbgPrint ( " Target port ID = 0x%08x%08x%08x%08x\n", | ||
RtlUlongByteSwap ( srp->target_port_id.u.dwords[0] ), | ||
RtlUlongByteSwap ( srp->target_port_id.u.dwords[1] ), | ||
RtlUlongByteSwap ( srp->target_port_id.u.dwords[2] ), | ||
RtlUlongByteSwap ( srp->target_port_id.u.dwords[3] ) ); | ||
( VOID ) sbft; | ||
} | ||
|
||
/** | ||
* Parse sBFT IB subtable | ||
* | ||
* @v sbft sBFT | ||
* @v ib IB subtable | ||
*/ | ||
static VOID parse_sbft_ib ( PSBFT_TABLE sbft, PSBFT_IB_SUBTABLE ib ) { | ||
|
||
DbgPrint ( "Found sBFT IB subtable:\n" ); | ||
DbgPrint ( " Source GID = 0x%08x%08x%08x%08x\n", | ||
RtlUlongByteSwap ( ib->sgid.u.dwords[0] ), | ||
RtlUlongByteSwap ( ib->sgid.u.dwords[1] ), | ||
RtlUlongByteSwap ( ib->sgid.u.dwords[2] ), | ||
RtlUlongByteSwap ( ib->sgid.u.dwords[3] ) ); | ||
DbgPrint ( " Destination GID = 0x%08x%08x%08x%08x\n", | ||
RtlUlongByteSwap ( ib->dgid.u.dwords[0] ), | ||
RtlUlongByteSwap ( ib->dgid.u.dwords[1] ), | ||
RtlUlongByteSwap ( ib->dgid.u.dwords[2] ), | ||
RtlUlongByteSwap ( ib->dgid.u.dwords[3] ) ); | ||
DbgPrint ( " Service ID = 0x%08x%08x\n", | ||
RtlUlongByteSwap ( ib->service_id.u.dwords[0] ), | ||
RtlUlongByteSwap ( ib->service_id.u.dwords[1] ) ); | ||
DbgPrint ( " Partition key = 0x%04x\n", ib->pkey ); | ||
( VOID ) sbft; | ||
} | ||
|
||
/** | ||
* Parse sBFT | ||
* | ||
* @v sbft sBFT | ||
*/ | ||
VOID parse_sbft ( PSBFT_TABLE sbft ) { | ||
PSBFT_SCSI_SUBTABLE scsi; | ||
PSBFT_SRP_SUBTABLE srp; | ||
PSBFT_IB_SUBTABLE ib; | ||
|
||
if ( sbft->scsi_offset ) { | ||
scsi = ( ( PSBFT_SCSI_SUBTABLE ) | ||
( ( PUCHAR ) sbft + sbft->scsi_offset ) ); | ||
parse_sbft_scsi ( sbft, scsi ); | ||
} | ||
if ( sbft->srp_offset ) { | ||
srp = ( ( PSBFT_SRP_SUBTABLE ) | ||
( ( PUCHAR ) sbft + sbft->srp_offset ) ); | ||
parse_sbft_srp ( sbft, srp ); | ||
} | ||
if ( sbft->ib_offset ) { | ||
ib = ( ( PSBFT_IB_SUBTABLE ) | ||
( ( PUCHAR ) sbft + sbft->ib_offset ) ); | ||
parse_sbft_ib ( sbft, ib ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#ifndef _SBFT_H | ||
#define _SBFT_H | ||
|
||
/* | ||
* Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
* OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
/** @file | ||
* | ||
* SRP boot firmware table | ||
* | ||
* The working draft specification for the SRP boot firmware table can | ||
* be found at | ||
* | ||
* http://etherboot.org/wiki/srp/sbft | ||
* | ||
*/ | ||
|
||
#include "acpi.h" | ||
|
||
/** SRP Boot Firmware Table signature */ | ||
#define SBFT_SIG "sBFT" | ||
|
||
/** | ||
* SRP Boot Firmware Table | ||
*/ | ||
#pragma pack(1) | ||
typedef struct _SBFT_TABLE { | ||
/** ACPI header */ | ||
ACPI_DESCRIPTION_HEADER acpi; | ||
/** Offset to SCSI subtable */ | ||
USHORT scsi_offset; | ||
/** Offset to SRP subtable */ | ||
USHORT srp_offset; | ||
/** Offset to IB subtable, if present */ | ||
USHORT ib_offset; | ||
/** Reserved */ | ||
UCHAR reserved[6]; | ||
} SBFT_TABLE, *PSBFT_TABLE; | ||
#pragma pack() | ||
|
||
/** | ||
* sBFT SCSI subtable | ||
*/ | ||
#pragma pack(1) | ||
typedef struct _SBFT_SCSI_SUBTABLE { | ||
/** LUN */ | ||
ULONGLONG lun; | ||
} SBFT_SCSI_SUBTABLE, *PSBFT_SCSI_SUBTABLE; | ||
#pragma pack() | ||
|
||
/** An SRP port ID */ | ||
#pragma pack(1) | ||
typedef struct _SRP_PORT_ID { | ||
union { | ||
UCHAR bytes[16]; | ||
USHORT words[8]; | ||
ULONG dwords[4]; | ||
} u; | ||
} SRP_PORT_ID, *PSRP_PORT_ID; | ||
#pragma pack() | ||
|
||
/** | ||
* sBFT SRP subtable | ||
*/ | ||
#pragma pack(1) | ||
typedef struct _SBFT_SRP_SUBTABLE { | ||
/** Initiator port identifier */ | ||
SRP_PORT_ID initiator_port_id; | ||
/** Target port identifier */ | ||
SRP_PORT_ID target_port_id; | ||
} SBFT_SRP_SUBTABLE, *PSBFT_SRP_SUBTABLE; | ||
#pragma pack() | ||
|
||
/** An Infiniband GUID */ | ||
#pragma pack(1) | ||
typedef struct _IB_GUID { | ||
union { | ||
UCHAR bytes[8]; | ||
USHORT words[4]; | ||
ULONG dwords[2]; | ||
} u; | ||
} IB_GUID, *PIB_GUID; | ||
#pragma pack() | ||
|
||
/** An Infiniband GID */ | ||
#pragma pack(1) | ||
typedef struct _IB_GID { | ||
union { | ||
UCHAR bytes[16]; | ||
USHORT words[8]; | ||
ULONG dwords[4]; | ||
IB_GUID guid[2]; | ||
} u; | ||
} IB_GID, *PIB_GID; | ||
#pragma pack() | ||
|
||
/** | ||
* sBFT IB subtable | ||
*/ | ||
#pragma pack(1) | ||
typedef struct _SBFT_IB_SUBTABLE { | ||
/** Source GID */ | ||
IB_GID sgid; | ||
/** Destination GID */ | ||
IB_GID dgid; | ||
/** Service ID */ | ||
IB_GUID service_id; | ||
/** Partition key */ | ||
USHORT pkey; | ||
/** Reserved */ | ||
UCHAR reserved[6]; | ||
} SBFT_IB_SUBTABLE, *PSBFT_IB_SUBTABLE; | ||
#pragma pack() | ||
|
||
extern VOID parse_sbft ( PSBFT_TABLE sbft ); | ||
|
||
#endif /* _SBFT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters