github.com/oweisse/u-root@v0.0.0-20181109060735-d005ad25fef1/cmds/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  	MAX_SERIALNO_LENGTH              = 32
   130  	LB_TAG_CMOS_OPTION_TABLE         = 200
   131  	LB_TAG_OPTION                    = 201
   132  	CMOS_MAX_NAME_LENGTH             = 32
   133  	LB_TAG_OPTION_ENUM               = 202
   134  	CMOS_MAX_TEXT_LENGTH             = 32
   135  	LB_TAG_OPTION_DEFAULTS           = 203
   136  	CMOS_IMAGE_BUFFER_SIZE           = 256
   137  	LB_TAG_OPTION_CHECKSUM           = 204
   138  	CHECKSUM_NONE                    = 0
   139  	CHECKSUM_PCBIOS                  = 1
   140  
   141  	// Depthcharge entry IDs start at 1000.
   142  	TS_DC_START                     = 1000
   143  	TS_RO_PARAMS_INIT               = 1001
   144  	TS_RO_VB_INIT                   = 1002
   145  	TS_RO_VB_SELECT_FIRMWARE        = 1003
   146  	TS_RO_VB_SELECT_AND_LOAD_KERNEL = 1004
   147  
   148  	TS_RW_VB_SELECT_AND_LOAD_KERNEL = 1010
   149  
   150  	TS_VB_SELECT_AND_LOAD_KERNEL = 1020
   151  
   152  	TS_VB_EC_VBOOT_DONE = 1030
   153  
   154  	TS_CROSSYSTEM_DATA = 1100
   155  	TS_START_KERNEL    = 1101
   156  )
   157  
   158  type Header struct {
   159  	Signature    [4]uint8
   160  	HeaderSz     uint32
   161  	HeaderCSUM   uint32
   162  	TableSz      uint32
   163  	TableCSUM    uint32
   164  	TableEntries uint32
   165  }
   166  type Record struct {
   167  	Tag  uint32
   168  	Size uint32
   169  }
   170  
   171  type memoryRange struct {
   172  	Start uint64
   173  	Size  uint64
   174  	Mtype uint32
   175  }
   176  type memoryEntry struct {
   177  	Record
   178  	Maps []memoryRange
   179  }
   180  type hwrpbEntry struct {
   181  	Record
   182  	HwrPB uint64
   183  }
   184  
   185  type consoleEntry struct {
   186  	Record
   187  	Console uint32
   188  }
   189  
   190  type mainboardEntry struct {
   191  	Record
   192  	Vendor     string
   193  	PartNumber string
   194  }
   195  
   196  type stringEntry struct {
   197  	Record
   198  	String []uint8
   199  }
   200  
   201  type timestampEntry struct {
   202  	Record
   203  	TimeStamp uint32
   204  }
   205  type serialEntry struct {
   206  	Record
   207  	Type     uint32
   208  	BaseAddr uint32
   209  	Baud     uint32
   210  	RegWidth uint32
   211  }
   212  type memconsoleEntry struct {
   213  	Record
   214  	CSize  uint32
   215  	Cursor uint32
   216  	Data   []byte
   217  }
   218  type forwardEntry struct {
   219  	Record
   220  	Forward uint64
   221  }
   222  type framebufferEntry struct {
   223  	Record
   224  	PhysicalAddress  uint64
   225  	XResolution      uint32
   226  	YRresolution     uint32
   227  	BytesPerLine     uint32
   228  	BitsPerPixel     uint8
   229  	RedMaskPos       uint8
   230  	RedMaskSize      uint8
   231  	GreenMaskPos     uint8
   232  	GreenMaskSize    uint8
   233  	BlueMaskPos      uint8
   234  	BlueMaskSize     uint8
   235  	ReservedMaskPos  uint8
   236  	ReservedMaskSize uint8
   237  }
   238  
   239  // GPIO is General Purpose IO
   240  type GPIO struct {
   241  	Port     uint32
   242  	Polarity uint32
   243  	Value    uint32
   244  	Name     []uint8
   245  }
   246  
   247  type gpioEntry struct {
   248  	Record
   249  	Count uint32
   250  	GPIOs []GPIO
   251  }
   252  
   253  type rangeEntry struct {
   254  	Record
   255  	RangeStart uint64
   256  	RangeSize  uint32
   257  }
   258  
   259  type cbmemEntry struct {
   260  	Record
   261  	CbmemAddr uint64
   262  }
   263  
   264  type MTRREntry struct {
   265  	Record
   266  	Index uint32
   267  }
   268  
   269  type BoardIDEntry struct {
   270  	Record
   271  	BoardID uint32
   272  }
   273  type MACEntry struct {
   274  	MACaddr []uint8
   275  	pad     []uint8
   276  }
   277  
   278  type LBEntry struct {
   279  	Record
   280  	Count    uint32
   281  	MACAddrs []MACEntry
   282  }
   283  
   284  type LBRAMEntry struct {
   285  	Record
   286  	RamCode uint32
   287  }
   288  
   289  type SPIFlashEntry struct {
   290  	Record
   291  	FlashSize  uint32
   292  	SectorSize uint32
   293  	EraseCmd   uint32
   294  }
   295  type bootMediaParamsEntry struct {
   296  	Record
   297  	FMAPOffset    uint64
   298  	CBFSOffset    uint64
   299  	CBFSSize      uint64
   300  	BootMediaSize uint64
   301  }
   302  type CBMemEntry struct {
   303  	Record
   304  	Address   uint64
   305  	EntrySize uint32
   306  	ID        uint32
   307  }
   308  type CMOSTable struct {
   309  	Record
   310  	HeaderLength uint32
   311  }
   312  type CMOSEntry struct {
   313  	Record
   314  	Bit      uint32
   315  	Length   uint32
   316  	Config   uint32
   317  	ConfigID uint32
   318  	Name     []uint8
   319  }
   320  type CMOSEnums struct {
   321  	Record
   322  	ConfigID uint32
   323  	Value    uint32
   324  	Text     []uint8
   325  }
   326  type CMOSDefaults struct {
   327  	Record
   328  	NameLength uint32
   329  	Name       []uint8
   330  	DefaultSet []uint8
   331  }
   332  type CMOSChecksum struct {
   333  	Record
   334  	RangeStart uint32
   335  	RangeEnd   uint32
   336  	Location   uint32
   337  	Type       uint32
   338  }
   339  
   340  type CBmem struct {
   341  	Memory           *memoryEntry
   342  	MemConsole       *memconsoleEntry
   343  	Consoles         []string
   344  	TimeStamps       []timestampEntry
   345  	UART             []serialEntry
   346  	MainBoard        mainboardEntry
   347  	Hwrpb            hwrpbEntry
   348  	CBMemory         []cbmemEntry
   349  	BoardID          BoardIDEntry
   350  	StringVars       map[string]string
   351  	BootMediaParams  bootMediaParamsEntry
   352  	VersionTimeStamp uint32
   353  	Unknown          []uint32
   354  	Ignored          []string
   355  }