gitlab.com/apertussolutions/u-root@v7.0.0+incompatible/cmds/exp/cbmem/types.go (about)

     1  // Copyright 2016-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  const (
     8  	TableSize = 48
     9  )
    10  
    11  // TODO: we don't have a platform yet that creates these.
    12  type TS struct {
    13  	entry_id    uint32
    14  	entry_stamp uint64
    15  }
    16  
    17  type TSTable struct {
    18  	base_time     uint64
    19  	max_entries   uint16
    20  	tick_freq_mhz uint16
    21  	num_entries   uint32
    22  	entries       []TS
    23  }
    24  
    25  const (
    26  	TS_START_ROMSTAGE            int = 1
    27  	TS_BEFORE_INITRAM            int = 2
    28  	TS_AFTER_INITRAM             int = 3
    29  	TS_END_ROMSTAGE              int = 4
    30  	TS_START_VBOOT               int = 5
    31  	TS_END_VBOOT                 int = 6
    32  	TS_START_COPYRAM             int = 8
    33  	TS_END_COPYRAM               int = 9
    34  	TS_START_RAMSTAGE            int = 10
    35  	TS_START_BOOTBLOCK           int = 11
    36  	TS_END_BOOTBLOCK             int = 12
    37  	TS_START_COPYROM             int = 13
    38  	TS_END_COPYROM               int = 14
    39  	TS_START_ULZMA               int = 15
    40  	TS_END_ULZMA                 int = 16
    41  	TS_DEVICE_ENUMERATE          int = 30
    42  	TS_DEVICE_CONFIGURE          int = 40
    43  	TS_DEVICE_ENABLE             int = 50
    44  	TS_DEVICE_INITIALIZE         int = 60
    45  	TS_DEVICE_DONE               int = 70
    46  	TS_CBMEM_POST                int = 75
    47  	TS_WRITE_TABLES              int = 80
    48  	TS_LOAD_PAYLOAD              int = 90
    49  	TS_ACPI_WAKE_JUMP            int = 98
    50  	TS_SELFBOOT_JUMP             int = 99
    51  	TS_START_COPYVER             int = 501
    52  	TS_END_COPYVER               int = 502
    53  	TS_START_TPMINIT             int = 503
    54  	TS_END_TPMINIT               int = 504
    55  	TS_START_VERIFY_SLOT         int = 505
    56  	TS_END_VERIFY_SLOT           int = 506
    57  	TS_START_HASH_BODY           int = 507
    58  	TS_DONE_LOADING              int = 508
    59  	TS_DONE_HASHING              int = 509
    60  	TS_END_HASH_BODY             int = 510
    61  	TS_FSP_MEMORY_INIT_START     int = 950
    62  	TS_FSP_MEMORY_INIT_END       int = 951
    63  	TS_FSP_TEMP_RAM_EXIT_START   int = 952
    64  	TS_FSP_TEMP_RAM_EXIT_END     int = 953
    65  	TS_FSP_SILICON_INIT_START    int = 954
    66  	TS_FSP_SILICON_INIT_END      int = 955
    67  	TS_FSP_BEFORE_ENUMERATE      int = 956
    68  	TS_FSP_AFTER_ENUMERATE       int = 957
    69  	TS_FSP_BEFORE_FINALIZE       int = 958
    70  	TS_FSP_AFTER_FINALIZE        int = 959
    71  	LB_TAG_UNUSED                    = 0x0000
    72  	LB_TAG_MEMORY                    = 0x0001
    73  	LB_MEM_RAM                       = 1
    74  	LB_MEM_RESERVED                  = 2  // Don't use this memory region
    75  	LB_MEM_ACPI                      = 3  // ACPI Tables
    76  	LB_MEM_NVS                       = 4  // ACPI NVS Memory
    77  	LB_MEM_UNUSABLE                  = 5  // Unusable address space
    78  	LB_MEM_VENDOR_RSVD               = 6  // Vendor Reserved
    79  	LB_MEM_TABLE                     = 16 // Ram configuration tables are kept in
    80  	LB_TAG_HWRPB                     = 0x0002
    81  	LB_TAG_MAINBOARD                 = 0x0003
    82  	LB_TAG_VERSION                   = 0x0004
    83  	LB_TAG_EXTRA_VERSION             = 0x0005
    84  	LB_TAG_BUILD                     = 0x0006
    85  	LB_TAG_COMPILE_TIME              = 0x0007
    86  	LB_TAG_COMPILE_BY                = 0x0008
    87  	LB_TAG_COMPILE_HOST              = 0x0009
    88  	LB_TAG_COMPILE_DOMAIN            = 0x000a
    89  	LB_TAG_COMPILER                  = 0x000b
    90  	LB_TAG_LINKER                    = 0x000c
    91  	LB_TAG_ASSEMBLER                 = 0x000d
    92  	LB_TAG_VERSION_TIMESTAMP         = 0x0026
    93  	LB_TAG_SERIAL                    = 0x000f
    94  	LB_SERIAL_TYPE_IO_MAPPED         = 1
    95  	LB_SERIAL_TYPE_MEMORY_MAPPED     = 2
    96  	LB_TAG_CONSOLE                   = 0x0010
    97  	LB_TAG_CONSOLE_SERIAL8250        = 0
    98  	LB_TAG_CONSOLE_VGA               = 1 // OBSOLETE
    99  	LB_TAG_CONSOLE_BTEXT             = 2 // OBSOLETE
   100  	LB_TAG_CONSOLE_LOGBUF            = 3 // OBSOLETE
   101  	LB_TAG_CONSOLE_SROM              = 4 // OBSOLETE
   102  	LB_TAG_CONSOLE_EHCI              = 5
   103  	LB_TAG_CONSOLE_SERIAL8250MEM     = 6
   104  	LB_TAG_FORWARD                   = 0x0011
   105  	LB_TAG_FRAMEBUFFER               = 0x0012
   106  	LB_TAG_GPIO                      = 0x0013
   107  	ACTIVE_LOW                       = 0
   108  	ACTIVE_HIGH                      = 1
   109  	GPIO_MAX_NAME_LENGTH             = 16
   110  	LB_TAG_VDAT                      = 0x0015
   111  	LB_TAG_VBNV                      = 0x0019
   112  	LB_TAB_VBOOT_HANDOFF             = 0x0020
   113  	LB_TAB_DMA                       = 0x0022
   114  	LB_TAG_RAM_OOPS                  = 0x0023
   115  	LB_TAG_MTC                       = 0x002b
   116  	LB_TAG_TIMESTAMPS                = 0x0016
   117  	LB_TAG_CBMEM_CONSOLE             = 0x0017
   118  	LB_TAG_MRC_CACHE                 = 0x0018
   119  	LB_TAG_ACPI_GNVS                 = 0x0024
   120  	LB_TAG_WIFI_CALIBRATION          = 0x0027
   121  	LB_TAG_X86_ROM_MTRR              = 0x0021
   122  	LB_TAG_BOARD_ID                  = 0x0025
   123  	LB_TAG_RAM_CODE                  = 0x0028
   124  	LB_TAG_SPI_FLASH                 = 0x0029
   125  	LB_TAG_BOOT_MEDIA_PARAMS         = 0x0030
   126  	LB_TAG_CBMEM_ENTRY               = 0x0031
   127  	LB_TAG_SERIALNO                  = 0x002a
   128  	LB_TAG_MAC_ADDRS                 = 0x0033
   129  	LB_TAG_PLATFORM_BLOB_VERSION     = 0x0038
   130  	MAX_SERIALNO_LENGTH              = 32
   131  	LB_TAG_CMOS_OPTION_TABLE         = 200
   132  	LB_TAG_OPTION                    = 201
   133  	CMOS_MAX_NAME_LENGTH             = 32
   134  	LB_TAG_OPTION_ENUM               = 202
   135  	CMOS_MAX_TEXT_LENGTH             = 32
   136  	LB_TAG_OPTION_DEFAULTS           = 203
   137  	CMOS_IMAGE_BUFFER_SIZE           = 256
   138  	LB_TAG_OPTION_CHECKSUM           = 204
   139  	CHECKSUM_NONE                    = 0
   140  	CHECKSUM_PCBIOS                  = 1
   141  
   142  	// Depthcharge entry IDs start at 1000.
   143  	TS_DC_START                     = 1000
   144  	TS_RO_PARAMS_INIT               = 1001
   145  	TS_RO_VB_INIT                   = 1002
   146  	TS_RO_VB_SELECT_FIRMWARE        = 1003
   147  	TS_RO_VB_SELECT_AND_LOAD_KERNEL = 1004
   148  
   149  	TS_RW_VB_SELECT_AND_LOAD_KERNEL = 1010
   150  
   151  	TS_VB_SELECT_AND_LOAD_KERNEL = 1020
   152  
   153  	TS_VB_EC_VBOOT_DONE = 1030
   154  
   155  	TS_CROSSYSTEM_DATA = 1100
   156  	TS_START_KERNEL    = 1101
   157  )
   158  
   159  type Header struct {
   160  	Signature    [4]uint8
   161  	HeaderSz     uint32
   162  	HeaderCSUM   uint32
   163  	TableSz      uint32
   164  	TableCSUM    uint32
   165  	TableEntries uint32
   166  }
   167  type Record struct {
   168  	Tag  uint32
   169  	Size uint32
   170  }
   171  
   172  type memoryRange struct {
   173  	Start uint64
   174  	Size  uint64
   175  	Mtype uint32
   176  }
   177  type memoryEntry struct {
   178  	Record
   179  	Maps []memoryRange
   180  }
   181  type hwrpbEntry struct {
   182  	Record
   183  	HwrPB uint64
   184  }
   185  
   186  type consoleEntry struct {
   187  	Record
   188  	Console uint32
   189  }
   190  
   191  type mainboardEntry struct {
   192  	Record
   193  	Vendor     string
   194  	PartNumber string
   195  }
   196  
   197  type stringEntry struct {
   198  	Record
   199  	String []uint8
   200  }
   201  
   202  type timestampEntry struct {
   203  	Record
   204  	TimeStamp uint32
   205  }
   206  type serialEntry struct {
   207  	Record
   208  	Type     uint32
   209  	BaseAddr uint32
   210  	Baud     uint32
   211  	RegWidth uint32
   212  }
   213  type memconsoleEntry struct {
   214  	Record
   215  	CSize  uint32
   216  	Cursor uint32
   217  	Data   []byte
   218  }
   219  type forwardEntry struct {
   220  	Record
   221  	Forward uint64
   222  }
   223  type framebufferEntry struct {
   224  	Record
   225  	PhysicalAddress  uint64
   226  	XResolution      uint32
   227  	YRresolution     uint32
   228  	BytesPerLine     uint32
   229  	BitsPerPixel     uint8
   230  	RedMaskPos       uint8
   231  	RedMaskSize      uint8
   232  	GreenMaskPos     uint8
   233  	GreenMaskSize    uint8
   234  	BlueMaskPos      uint8
   235  	BlueMaskSize     uint8
   236  	ReservedMaskPos  uint8
   237  	ReservedMaskSize uint8
   238  }
   239  
   240  // GPIO is General Purpose IO
   241  type GPIO struct {
   242  	Port     uint32
   243  	Polarity uint32
   244  	Value    uint32
   245  	Name     []uint8
   246  }
   247  
   248  type gpioEntry struct {
   249  	Record
   250  	Count uint32
   251  	GPIOs []GPIO
   252  }
   253  
   254  type rangeEntry struct {
   255  	Record
   256  	RangeStart uint64
   257  	RangeSize  uint32
   258  }
   259  
   260  type cbmemEntry struct {
   261  	Record
   262  	CbmemAddr uint64
   263  }
   264  
   265  type MTRREntry struct {
   266  	Record
   267  	Index uint32
   268  }
   269  
   270  type BoardIDEntry struct {
   271  	Record
   272  	BoardID uint32
   273  }
   274  type MACEntry struct {
   275  	MACaddr []uint8
   276  	pad     []uint8
   277  }
   278  
   279  type LBEntry struct {
   280  	Record
   281  	Count    uint32
   282  	MACAddrs []MACEntry
   283  }
   284  
   285  type LBRAMEntry struct {
   286  	Record
   287  	RamCode uint32
   288  }
   289  
   290  type SPIFlashEntry struct {
   291  	Record
   292  	FlashSize  uint32
   293  	SectorSize uint32
   294  	EraseCmd   uint32
   295  }
   296  type bootMediaParamsEntry struct {
   297  	Record
   298  	FMAPOffset    uint64
   299  	CBFSOffset    uint64
   300  	CBFSSize      uint64
   301  	BootMediaSize uint64
   302  }
   303  type CBMemEntry struct {
   304  	Record
   305  	Address   uint64
   306  	EntrySize uint32
   307  	ID        uint32
   308  }
   309  type CMOSTable struct {
   310  	Record
   311  	HeaderLength uint32
   312  }
   313  type CMOSEntry struct {
   314  	Record
   315  	Bit      uint32
   316  	Length   uint32
   317  	Config   uint32
   318  	ConfigID uint32
   319  	Name     []uint8
   320  }
   321  type CMOSEnums struct {
   322  	Record
   323  	ConfigID uint32
   324  	Value    uint32
   325  	Text     []uint8
   326  }
   327  type CMOSDefaults struct {
   328  	Record
   329  	NameLength uint32
   330  	Name       []uint8
   331  	DefaultSet []uint8
   332  }
   333  type CMOSChecksum struct {
   334  	Record
   335  	RangeStart uint32
   336  	RangeEnd   uint32
   337  	Location   uint32
   338  	Type       uint32
   339  }
   340  
   341  type CBmem struct {
   342  	Memory           *memoryEntry
   343  	MemConsole       *memconsoleEntry
   344  	Consoles         []string
   345  	TimeStamps       []timestampEntry
   346  	UART             []serialEntry
   347  	MainBoard        mainboardEntry
   348  	Hwrpb            hwrpbEntry
   349  	CBMemory         []cbmemEntry
   350  	BoardID          BoardIDEntry
   351  	StringVars       map[string]string
   352  	BootMediaParams  bootMediaParamsEntry
   353  	VersionTimeStamp uint32
   354  	Unknown          []uint32
   355  	Ignored          []string
   356  }