NVIDIA DRIVE OS Linux API Reference

5.1.0.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Kernel Boot Framework

Detailed Description

Declares the APIs and data structures required for kernel booting.

Macros

#define KERNEL_CMDLINE_SIZE   (2 * KB)
 
#define IMAGE_MAGIC   "BOOT_IMAGE!"
 
#define IMAGE_MAGIC_SIZE   12
 
#define CMDLINE_BUF_SIZE   40
 
#define NATIVE_BOOT   1
 
#define VIRTUALIZED_BOOT   2
 
#define RECOVERY_KERNEL_BIT   (1 << 31)
 
#define UPDATE_KERNEL_BIT   (1 << 29)
 

Enumerations

enum  BootImageType {
  BootImageType_Linux = 1,
  BootImageType_Qnx = 2,
  BootImageType_Android = 3,
  BootImageType_Integrity = 4,
  BootImageType_Mods = 5,
  BootImageType_Ramdisk = 6,
  BootImageType_Hypervisor = 7,
  BootImageType_Force = 0x7FFFFFFF
}
 
enum  BootImage_Compression {
  BootImage_CompressionNone = 0,
  BootImage_CompressionLz4 = 3,
  BootImage_Force = 0x7FFFFFFF
}
 
enum  BootImageStreamValidation {
  BootImageStreamValidation_No = 0,
  BootImageStreamValidation_Yes = 1,
  BootImageStreamValidation_Force = 0x7FFFFFFF
}
 
enum  BootImageLoading {
  BootImageLoading_NoCompression_NoStreamValidation,
  BootImageLoading_NoCompression_StreamValidation,
  BootImageLoading_CompressionLz4_NoStreamValidation,
  BootImageLoading_CompressionLz4_StreamValidation,
  BootImageLoading_Force = 0x7FFFFFFF
}
 
enum  BootGuidType {
  BootGuidType_Windows = 0,
  BootGuidType_Linux,
  BootGuidType_Qnx
}
 

Functions

NvError QbLoadAndBootKernel (const NvS8 *pKernelPartName, const NvS8 *pRamdiskPartName, const NvS8 *pDtbPartName)
 (Top-level function) Loads the kernel image from a specific partition. More...
 
NvError QbLoadBootImages (const NvS8 *pKernName, const NvS8 *pRamdiskName, const NvS8 *pDtbPartName, NvUPtr *pBootAddrVirt, NvUPtr *pRamDiskAddrVirt, NvUPtr **pDtAddrVirt, NvU32 *pKernelUnCompressSize, NvU32 *pRamdiskUncompressSize)
 Internal function invoked by QbLoadAndBootKernel to load the images from storage in case of cold boot and from RAM in case of RCM boot. More...
 
void KernelCmdLine (NvU32 RatchetFuseBurnStatus)
 Prepares the kernel command line to be passed to the kernel. More...
 
void KernelDT (void)
 Updates the device tree with architecture-specific and board-specific changes. More...
 
void AppendBoardDT (void)
 Appends the board-specific DT support. More...
 
NvError QbDefaultLoadAndBootKernel (void)
 Adds a default boot policy. More...
 
NvError QbBoardLoadAndBootKernel (void)
 Adds board-specific boot policy. More...
 
NvError QbGetSerialNum (NvU8 **pSerialNum, NvU32 *DataSize)
 Gets the serial number of the board. More...
 
NvBool QbIsHypervisorBoot (void)
 Determines whether hypervisor is to be booted. More...
 
NvBool QbIsAndroidBoot (void)
 Determines whether android is to be booted. More...
 
static void AdjustPointers (NvS32 *pRemains, NvS8 **pPtr, NvS32 len)
 Adjusts pointers in a buffer to process appending new string to the buffer. More...
 
NvError QbQueryMemInfo (NvU8 **pData, NvU32 *pDataSize, NvU64 ReserveMemSize)
 Queries memory info to be passed to kernel. More...
 
void QbPerformHandOff (NvUPtr *pKernelRegs, NvU32 NumKernelRegs, NvUPtr KernelStartAddr)
 Performs any necessary operations before kernel handoff. More...
 

Macro Definition Documentation

#define CMDLINE_BUF_SIZE   40

Definition at line 40 of file bootkernel.h.

#define IMAGE_MAGIC   "BOOT_IMAGE!"

Definition at line 38 of file bootkernel.h.

#define IMAGE_MAGIC_SIZE   12

Definition at line 39 of file bootkernel.h.

#define KERNEL_CMDLINE_SIZE   (2 * KB)

Definition at line 36 of file bootkernel.h.

#define NATIVE_BOOT   1

Definition at line 42 of file bootkernel.h.

#define RECOVERY_KERNEL_BIT   (1 << 31)

Definition at line 86 of file bootkernel.h.

#define UPDATE_KERNEL_BIT   (1 << 29)

Definition at line 87 of file bootkernel.h.

#define VIRTUALIZED_BOOT   2

Definition at line 43 of file bootkernel.h.

Enumeration Type Documentation

Enumerator
BootGuidType_Windows 
BootGuidType_Linux 
BootGuidType_Qnx 

Definition at line 80 of file bootkernel.h.

Enumerator
BootImage_CompressionNone 
BootImage_CompressionLz4 
BootImage_Force 

Definition at line 56 of file bootkernel.h.

Enumerator
BootImageLoading_NoCompression_NoStreamValidation 
BootImageLoading_NoCompression_StreamValidation 
BootImageLoading_CompressionLz4_NoStreamValidation 
BootImageLoading_CompressionLz4_StreamValidation 
BootImageLoading_Force 

Definition at line 68 of file bootkernel.h.

Enumerator
BootImageStreamValidation_No 
BootImageStreamValidation_Yes 
BootImageStreamValidation_Force 

Definition at line 62 of file bootkernel.h.

Enumerator
BootImageType_Linux 
BootImageType_Qnx 
BootImageType_Android 
BootImageType_Integrity 
BootImageType_Mods 
BootImageType_Ramdisk 
BootImageType_Hypervisor 
BootImageType_Force 

Definition at line 45 of file bootkernel.h.

Function Documentation

static void AdjustPointers ( NvS32 *  pRemains,
NvS8 **  pPtr,
NvS32  len 
)
inlinestatic

Adjusts pointers in a buffer to process appending new string to the buffer.

It updates pointer of the string by incrementing by length of string so that it points to next location of buffer where new string can be appended. It also decrements available size by length of the current string.

Parameters
[out]pRemainsPointer to remaining size of the buffer.
[out]pPtrBuffer pointer where current string has been appended.
[in]lenLength of the string being appended.

Definition at line 258 of file bootkernel.h.

References BUG.

void AppendBoardDT ( void  )

Appends the board-specific DT support.

void KernelCmdLine ( NvU32  RatchetFuseBurnStatus)

Prepares the kernel command line to be passed to the kernel.

It first prepares the default kernel command line and then appends the command line that is passed by the user through mkbootimg. Finally, it is added as an ATAG.

Parameters
RatchetFuseBurnStatusprovide the status of burning field ratchet fuse.
Returns
none
void KernelDT ( void  )

Updates the device tree with architecture-specific and board-specific changes.

NvError QbBoardLoadAndBootKernel ( void  )

Adds board-specific boot policy.

Returns
NvSuccess if default behavior is good or NvError_.. in case of boot failures. For other failures, the function does not return.
NvError QbDefaultLoadAndBootKernel ( void  )

Adds a default boot policy.

Return values
NvError_in case of boot failures and does not return otherwise.
NvError QbGetSerialNum ( NvU8 **  pSerialNum,
NvU32 *  DataSize 
)

Gets the serial number of the board.

Parameters
[out]pSerialNumA pointer to a buffer with the serial number.
[out]DataSizeSize A pointer to a field that holds the size of the buffer created by the board file.
Returns
NvSuccess on success, or otherwise an error code. Also returns the serial number through parameters.
NvBool QbIsAndroidBoot ( void  )

Determines whether android is to be booted.

This check is based on Kernel Cmdline.

Returns
NV_TRUE if booting Android, or NV_FALSE otherwise.
NvBool QbIsHypervisorBoot ( void  )

Determines whether hypervisor is to be booted.

This check is based on the Kernel command line.

Returns
NV_TRUE if booting hypervisor, or NV_FALSE otherwise.
NvError QbLoadAndBootKernel ( const NvS8 *  pKernelPartName,
const NvS8 *  pRamdiskPartName,
const NvS8 *  pDtbPartName 
)

(Top-level function) Loads the kernel image from a specific partition.

If the kernel image is stored in a compressed format, it performs streaming decompression of the kernel image in parallel with reading from flash.

If the primary kernel image (application mode kernel) is corrupted, this function automatically loads the secondary image (maintenance mode kernel) from recovery partition and boots it.

It then sets up the ATAGS/DT parameters and other environment variables needed for running the OS kernel. Finally, this function flushes/invalidates and then disables the L1/L2 caches and the MMU before transferring control to the OS kernel.

Parameters
pKernelPartNameKernel partition name.
pRamdiskPartNameRamdisk partition name.
pDtbPartNameDTB partition name.
Returns
Does not return on success, or an appropriate error code otherwise.
NvError QbLoadBootImages ( const NvS8 *  pKernName,
const NvS8 *  pRamdiskName,
const NvS8 *  pDtbPartName,
NvUPtr *  pBootAddrVirt,
NvUPtr *  pRamDiskAddrVirt,
NvUPtr **  pDtAddrVirt,
NvU32 *  pKernelUnCompressSize,
NvU32 *  pRamdiskUncompressSize 
)

Internal function invoked by QbLoadAndBootKernel to load the images from storage in case of cold boot and from RAM in case of RCM boot.

Parameters
pKernNameKernel partition name.
pRamdiskNameRamdisk partition name.
pDtbPartNameDTB partition name.
pBootAddrVirtVirtual address set by function where kernel is loaded.
pRamDiskAddrVirtVirtual address set by function where Ramdisk (if any) is loaded.
pDtAddrVirtVirtual address set by function where DTB (if any) is loaded.
pKernelUnCompressSizeSize of the kernel image. If compressed, the function uncompresses the kernel.
pRamdiskUncompressSizeSize of the ramdisk image. If compressed, the function uncompresses the kernel.
Returns
NvSuccess in case of success, or an appropriate error code otherwise.
void QbPerformHandOff ( NvUPtr *  pKernelRegs,
NvU32  NumKernelRegs,
NvUPtr  KernelStartAddr 
)

Performs any necessary operations before kernel handoff.

Parameters
pKernelRegsA pointer to an array containing the values of the registers.
NumKernelRegsThe number of a register.
KernelStartAddrThe address to which the function must jump after performing its other operations.
Returns
The function jumps to KernelStartAddr; it does not return.
NvError QbQueryMemInfo ( NvU8 **  pData,
NvU32 *  pDataSize,
NvU64  ReserveMemSize 
)

Queries memory info to be passed to kernel.

Parameters
[out]pDataA pointer to a buffer that contains the base and size of each bank.
[out]pDataSizeA pointer to the buffer size.
[in]ReserveMemSizeAmount of memory to be reserved from the primary partition.
Returns
NvSuccess on success, or otherwise an error code. Also returns memory region info through parameters.