summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Include/Library/LoadLinuxLib.h
blob: 65f5895bfc6ba3acfda3237705754f9c8f15e89b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/** @file
  Load/boot UEFI Linux.

  Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef __LOAD_LINUX_LIB__
#define __LOAD_LINUX_LIB__

/**
  Verifies that the kernel setup image is valid and supported.
  The kernel setup image should be checked before using other library
  routines which take the kernel setup as an input.

  @param[in]     KernelSetup - The kernel setup image
  @param[in]     KernelSetupSize - The kernel setup size

  @retval    EFI_SUCCESS - The Linux kernel setup is valid and supported
  @retval    EFI_INVALID_PARAMETER - KernelSetup was NULL
  @retval    EFI_UNSUPPORTED - The Linux kernel is not supported

**/
EFI_STATUS
EFIAPI
LoadLinuxCheckKernelSetup (
  IN VOID   *KernelSetup,
  IN UINTN  KernelSetupSize
  );

/**
  Gets the initial runtime size of the Linux kernel image by examining
  the kernel setup image.

  @param[in]     KernelSetup - The kernel setup image
  @param[in]     KernelSize - The kernel size on disk.

  @retval    0                An error occurred
  @retval    !0               The initial size required by the kernel to
                              begin execution.

**/
UINTN
EFIAPI
LoadLinuxGetKernelSize (
  IN VOID   *KernelSetup,
  IN UINTN  KernelSize
  );

/**
  Loads and boots UEFI Linux.

  Note: If successful, then this routine will not return

  @param[in]     Kernel - The main kernel image
  @param[in,out] KernelSetup - The kernel setup image

  @retval    EFI_NOT_FOUND - The Linux kernel was not found
  @retval    EFI_INVALID_PARAMETER - Kernel or KernelSetup was NULL
  @retval    EFI_UNSUPPORTED - The Linux kernel version is not supported

**/
EFI_STATUS
EFIAPI
LoadLinux (
  IN VOID      *Kernel,
  IN OUT VOID  *KernelSetup
  );

/**
  Allocates pages for the kernel setup image.

  @param[in]     Pages - The number of pages

  @retval    NULL - Unable to allocate pages
  @retval    !NULL - The address of the pages allocated

**/
VOID *
EFIAPI
LoadLinuxAllocateKernelSetupPages (
  IN UINTN  Pages
  );

/**
  Clears the uninitialised space before and after the struct setup_header
  in the kernel setup image. The kernel requires that these be zeroed
  unless explicitly initialised, so this function should be called after
  the setup_header has been copied in from a bzImage, before setting up
  anything else.

  @param[in]     KernelSetup - The kernel setup image

  @retval    EFI_SUCCESS - The Linux kernel setup was successfully initialized
  @retval    EFI_INVALID_PARAMETER - KernelSetup was NULL
  @retval    EFI_UNSUPPORTED - The Linux kernel is not supported

**/
EFI_STATUS
EFIAPI
LoadLinuxInitializeKernelSetup (
  IN VOID  *KernelSetup
  );

/**
  Allocates pages for the kernel.

  @param[in]     KernelSetup - The kernel setup image
  @param[in]     Pages - The number of pages. (It is recommended to use the
                         size returned from LoadLinuxGetKernelSize.)

  @retval    NULL - Unable to allocate pages
  @retval    !NULL - The address of the pages allocated

**/
VOID *
EFIAPI
LoadLinuxAllocateKernelPages (
  IN VOID   *KernelSetup,
  IN UINTN  Pages
  );

/**
  Allocates pages for the kernel command line.

  @param[in]     Pages - The number of pages.

  @retval    NULL - Unable to allocate pages
  @retval    !NULL - The address of the pages allocated

**/
VOID *
EFIAPI
LoadLinuxAllocateCommandLinePages (
  IN UINTN  Pages
  );

/**
  Allocates pages for the initrd image.

  @param[in,out] KernelSetup - The kernel setup image
  @param[in]     Pages - The number of pages.

  @retval    NULL - Unable to allocate pages
  @retval    !NULL - The address of the pages allocated

**/
VOID *
EFIAPI
LoadLinuxAllocateInitrdPages (
  IN VOID   *KernelSetup,
  IN UINTN  Pages
  );

/**
  Sets the kernel command line parameter within the setup image.

  @param[in,out] KernelSetup - The kernel setup image
  @param[in]     CommandLine - The kernel command line

  @retval    EFI_SUCCESS - The Linux kernel setup is valid and supported
  @retval    EFI_INVALID_PARAMETER - KernelSetup was NULL
  @retval    EFI_UNSUPPORTED - The Linux kernel is not supported

**/
EFI_STATUS
EFIAPI
LoadLinuxSetCommandLine (
  IN OUT VOID  *KernelSetup,
  IN CHAR8     *CommandLine
  );

/**
  Sets the kernel initial ram disk pointer within the setup image.

  @param[in,out] KernelSetup - The kernel setup image
  @param[in]     Initrd - Pointer to the initial ram disk
  @param[in]     InitrdSize - The initial ram disk image size

  @retval    EFI_SUCCESS - The Linux kernel setup is valid and supported
  @retval    EFI_INVALID_PARAMETER - KernelSetup was NULL
  @retval    EFI_UNSUPPORTED - The Linux kernel is not supported

**/
EFI_STATUS
EFIAPI
LoadLinuxSetInitrd (
  IN OUT VOID  *KernelSetup,
  IN VOID      *Initrd,
  IN UINTN     InitrdSize
  );

#endif