@@ -93,143 +93,6 @@ memory_map(EFI_MEMORY_DESCRIPTOR **map_buf, UINTN *map_size,
93
93
return err ;
94
94
}
95
95
96
- /**
97
- * emalloc - Allocate memory with a strict alignment requirement
98
- * @size: size in bytes of the requested allocation
99
- * @align: the required alignment of the allocation
100
- * @addr: a pointer to the allocated address on success
101
- *
102
- * If we cannot satisfy @align we return 0.
103
- *
104
- * FIXME: This function cannot guarantee to return address under 4G,
105
- * and the hypervisor cannot handle params, which address is above 4G,
106
- * delivered from efi stub.
107
- */
108
- EFI_STATUS emalloc (UINTN size , UINTN align , EFI_PHYSICAL_ADDRESS * addr )
109
- {
110
- UINTN map_size , map_key , desc_size ;
111
- EFI_MEMORY_DESCRIPTOR * map_buf ;
112
- UINTN d , map_end ;
113
- UINT32 desc_version ;
114
- EFI_STATUS err ;
115
- UINTN nr_pages = EFI_SIZE_TO_PAGES (size );
116
-
117
- err = memory_map (& map_buf , & map_size , & map_key ,
118
- & desc_size , & desc_version );
119
- if (err != EFI_SUCCESS )
120
- goto fail ;
121
-
122
- d = (UINTN )map_buf ;
123
- map_end = (UINTN )map_buf + map_size ;
124
-
125
- for (; d < map_end ; d += desc_size ) {
126
- EFI_MEMORY_DESCRIPTOR * desc ;
127
- EFI_PHYSICAL_ADDRESS start , end , aligned ;
128
-
129
- desc = (EFI_MEMORY_DESCRIPTOR * )d ;
130
- if (desc -> Type != EfiConventionalMemory )
131
- continue ;
132
-
133
- if (desc -> NumberOfPages < nr_pages )
134
- continue ;
135
-
136
- start = desc -> PhysicalStart ;
137
- end = start + (desc -> NumberOfPages << EFI_PAGE_SHIFT );
138
-
139
- /* Low-memory is super-precious! */
140
- if (end <= 1 << 20 )
141
- continue ;
142
- if (start < 1 << 20 ) {
143
- size -= (1 << 20 ) - start ;
144
- start = (1 << 20 );
145
- }
146
-
147
- aligned = (start + align - 1 ) & ~(align - 1 );
148
-
149
- if ((aligned + size ) <= end ) {
150
- err = allocate_pages (AllocateAddress , EfiLoaderData ,
151
- nr_pages , & aligned );
152
- if (err == EFI_SUCCESS ) {
153
- * addr = aligned ;
154
- break ;
155
- }
156
- }
157
- }
158
-
159
- if (d == map_end )
160
- err = EFI_OUT_OF_RESOURCES ;
161
-
162
- free_pool (map_buf );
163
- fail :
164
- return err ;
165
- }
166
-
167
-
168
- /**
169
- * efree - Return memory allocated with emalloc
170
- * @memory: the address of the emalloc() allocation
171
- * @size: the size of the allocation
172
- */
173
- void efree (EFI_PHYSICAL_ADDRESS memory , UINTN size )
174
- {
175
- UINTN nr_pages = EFI_SIZE_TO_PAGES (size );
176
-
177
- free_pages (memory , nr_pages );
178
- }
179
-
180
- /**
181
- * malloc - Allocate memory from the EfiLoaderData pool
182
- * @size: size in bytes of the requested allocation
183
- *
184
- * Return a pointer to an allocation of @size bytes of type
185
- * EfiLoaderData.
186
- */
187
- void * malloc (UINTN size )
188
- {
189
- EFI_STATUS err ;
190
- void * buffer ;
191
-
192
- err = allocate_pool (EfiLoaderData , size , & buffer );
193
- if (err != EFI_SUCCESS )
194
- buffer = NULL ;
195
-
196
- return buffer ;
197
- }
198
-
199
- /**
200
- * free - Release memory to the EfiLoaderData pool
201
- * @buffer: pointer to the malloc() allocation to free
202
- */
203
- void free (void * buffer )
204
- {
205
- if (buffer )
206
- free_pool (buffer );
207
- }
208
-
209
- /**
210
- * calloc - Allocate zeroed memory for an array of elements
211
- * @nmemb: number of elements
212
- * @size: size of each element
213
- */
214
- void * calloc (UINTN nmemb , UINTN size )
215
- {
216
- void * buffer ;
217
-
218
- /*
219
- * There's no equivalent of UINTN_MAX, so for safety we refuse to
220
- * allocate anything larger than 32 bits.
221
- */
222
- UINTN bytes = nmemb * size ;
223
- if ((nmemb | size ) > 0xffffU ) {
224
- if (size && bytes / size != nmemb )
225
- return NULL ;
226
- }
227
-
228
- buffer = malloc (bytes );
229
- if (buffer )
230
- (void )memset (buffer , 0 , bytes );
231
- return buffer ;
232
- }
233
96
234
97
EFI_STATUS dump_e820 (void )
235
98
{
0 commit comments