-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages.go
67 lines (59 loc) · 1.34 KB
/
pages.go
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
// Copyright (c) WithSecure Corporation
//
// Use of this source code is governed by the license
// that can be found in the LICENSE file.
package uefi
// EFI Boot Service offsets
const (
allocatePages = 0x28
freePages = 0x30
)
// EFI_ALLOCATE_TYPE
const (
AllocateAnyPages = iota
AllocateMaxAddress
AllocateAddress
MaxAllocateType
)
// EFI_MEMORY_TYPE
const (
EfiReservedMemoryType = iota
EfiLoaderCode
EfiLoaderData
EfiBootServicesCode
EfiBootServicesData
EfiRuntimeServicesCode
EfiRuntimeServicesData
EfiConventionalMemory
EfiUnusableMemory
EfiACPIReclaimMemory
EfiACPIMemoryNVS
EfiMemoryMappedIO
EfiMemoryMappedIOPortSpace
EfiPalCode
EfiPersistentMemory
EfiUnacceptedMemoryType
EfiMaxMemoryType
)
// AllocatePages calls EFI_BOOT_SERVICES.AllocatePages().
func (s *BootServices) AllocatePages(allocateType int, memoryType int, size int, physicalAddress uint64) error {
status := callService(s.base+allocatePages,
[]uint64{
uint64(allocateType),
uint64(memoryType),
uint64(size) / PageSize,
ptrval(&physicalAddress),
},
)
return parseStatus(status)
}
// FreePages calls EFI_BOOT_SERVICES.FreePages().
func (s *BootServices) FreePages(physicalAddress uint64, size int) error {
status := callService(s.base+freePages,
[]uint64{
physicalAddress,
uint64(size) / PageSize,
},
)
return parseStatus(status)
}