github.com/icexin/eggos@v0.4.2-0.20220216025428-78b167e4f349/drivers/multiboot/info.go (about)

     1  package multiboot
     2  
     3  import (
     4  	"unsafe"
     5  )
     6  
     7  const (
     8  	bootloaderMagic = 0x2BADB002
     9  )
    10  
    11  const (
    12  	MemoryAvailable = 1 << iota
    13  	MemoryReserved
    14  	MemoryACPIReclaimable
    15  	MemoryNVS
    16  	MemoryBadRAM
    17  )
    18  
    19  type Flag uint32
    20  
    21  const (
    22  	FlagInfoMemory Flag = 1 << iota
    23  	FlagInfoBootDev
    24  	FlagInfoCmdline
    25  	FlagInfoMods
    26  	FlagInfoAoutSyms
    27  	FlagInfoElfSHDR
    28  	FlagInfoMemMap
    29  	FlagInfoDriveInfo
    30  	FlagInfoConfigTable
    31  	FlagInfoBootLoaderName
    32  	FlagInfoAPMTable
    33  	FlagInfoVideoInfo
    34  	FlagInfoFrameBuffer
    35  )
    36  
    37  // Info represents the Multiboot v1 info passed to the loaded kernel.
    38  type Info struct {
    39  	Flags    Flag
    40  	MemLower uint32
    41  	MemUpper uint32
    42  
    43  	BootDevice uint32
    44  
    45  	Cmdline uint32
    46  
    47  	ModsCount uint32
    48  	ModsAddr  uint32
    49  
    50  	Syms [4]uint32
    51  
    52  	MmapLength uint32
    53  	MmapAddr   uint32
    54  
    55  	DriversLength uint32
    56  	DriversAddr   uint32
    57  
    58  	ConfigTable uint32
    59  
    60  	BootLoaderName uint32
    61  
    62  	APMTable uint32
    63  
    64  	VBEControlInfo  uint32
    65  	VBEModeInfo     uint32
    66  	VBEMode         uint16
    67  	VBEInterfaceSeg uint16
    68  	VBEInterfaceOff uint16
    69  	VBEInterfaceLen uint16
    70  
    71  	FramebufferAddr   uint64
    72  	FramebufferPitch  uint32
    73  	FramebufferWidth  uint32
    74  	FramebufferHeight uint32
    75  	FramebufferBPP    byte
    76  	FramebufferType   byte
    77  	ColorInfo         [6]byte
    78  }
    79  
    80  func (i *Info) MmapEntries() []MmapEntry {
    81  	n := i.MmapLength / uint32(unsafe.Sizeof(MmapEntry{}))
    82  	return (*[128]MmapEntry)(unsafe.Pointer(uintptr(i.MmapAddr)))[:n]
    83  }
    84  
    85  type MmapEntry struct {
    86  	Size uint32
    87  	Addr uint64
    88  	Len  uint64
    89  	Type uint32
    90  }