├── .github
├── dependabot.yml
└── workflows
│ ├── linux-gcc-musl.yml
│ ├── linux-gcc.yml
│ ├── linux-llvm.yml
│ ├── linux-mingw.yml
│ ├── macos-gcc.yml
│ ├── windows-mingw.yml
│ └── windows-vs2022.yml
├── .gitignore
├── .vs
├── apps
│ ├── AllocPages.vcxproj
│ ├── AllocPages.vcxproj.filters
│ ├── FreePages.vcxproj
│ ├── FreePages.vcxproj.filters
│ ├── _gen_vcxproj.ps1
│ ├── bltgrid.vcxproj
│ ├── bltgrid.vcxproj.filters
│ ├── common.props
│ ├── debughook.vcxproj
│ ├── debughook.vcxproj.filters
│ ├── drv0.vcxproj
│ ├── drv0.vcxproj.filters
│ ├── drv0_use.vcxproj
│ ├── drv0_use.vcxproj.filters
│ ├── exit.vcxproj
│ ├── exit.vcxproj.filters
│ ├── lfbgrid.vcxproj
│ ├── lfbgrid.vcxproj.filters
│ ├── modelist.vcxproj
│ ├── modelist.vcxproj.filters
│ ├── printenv.vcxproj
│ ├── printenv.vcxproj.filters
│ ├── route80h.vcxproj
│ ├── route80h.vcxproj.filters
│ ├── setdbg.vcxproj
│ ├── setdbg.vcxproj.filters
│ ├── setjmp.vcxproj
│ ├── setjmp.vcxproj.filters
│ ├── t.vcxproj
│ ├── t.vcxproj.filters
│ ├── t2.vcxproj
│ ├── t2.vcxproj.filters
│ ├── t3.vcxproj
│ ├── t3.vcxproj.filters
│ ├── t4.vcxproj
│ ├── t4.vcxproj.filters
│ ├── t5.vcxproj
│ ├── t5.vcxproj.filters
│ ├── t6.vcxproj
│ ├── t6.vcxproj.filters
│ ├── t7.vcxproj
│ ├── t7.vcxproj.filters
│ ├── t8.vcxproj
│ ├── t8.vcxproj.filters
│ ├── tcc.vcxproj
│ ├── tcc.vcxproj.filters
│ ├── unsetdbg.vcxproj
│ └── unsetdbg.vcxproj.filters
├── efilib.vcxproj
└── efilib.vcxproj.filters
├── LICENSE
├── Make.defaults
├── Make.rules
├── Makefile
├── README.md
├── SECURITY.md
├── apps
├── AllocPages.c
├── FreePages.c
├── Makefile
├── bltgrid.c
├── ctors_dtors_priority_test.c
├── ctors_fns.c
├── ctors_test.c
├── debughook.c
├── drv0.c
├── drv0.h
├── drv0_use.c
├── exit.c
├── lfbgrid.c
├── modelist.c
├── old_ABI.c
├── printenv.c
├── route80h.c
├── setdbg.c
├── setjmp.c
├── t.c
├── t2.c
├── t3.c
├── t4.c
├── t5.c
├── t6.c
├── t7.c
├── t8.c
├── tcc.c
└── unsetdbg.c
├── docs
├── README.ABI.md
├── README.elilo.md
├── README.git.md
└── README.packaging.md
├── gnu-efi.sln
├── gnuefi
├── Makefile
├── crt0-efi-aarch64-local.S
├── crt0-efi-aarch64.S
├── crt0-efi-arm.S
├── crt0-efi-ia32-local.S
├── crt0-efi-ia32.S
├── crt0-efi-ia64.S
├── crt0-efi-loongarch64.S
├── crt0-efi-mips64el.S
├── crt0-efi-riscv64-local.S
├── crt0-efi-riscv64.S
├── crt0-efi-x86_64.S
├── elf_aarch64_efi.lds
├── elf_aarch64_efi_local.lds
├── elf_arm_efi.lds
├── elf_ia32_efi.lds
├── elf_ia32_efi_local.lds
├── elf_ia32_fbsd_efi.lds
├── elf_ia64_efi.lds
├── elf_loongarch64_efi.lds
├── elf_mips64el_efi.lds
├── elf_riscv64_efi.lds
├── elf_riscv64_efi_local.lds
├── elf_x86_64_efi.lds
├── elf_x86_64_fbsd_efi.lds
├── gnu-efi.pc.in
├── reloc_aarch64.c
├── reloc_arm.c
├── reloc_ia32.c
├── reloc_ia64.S
├── reloc_loongarch64.c
├── reloc_mips64el.c
├── reloc_riscv64.c
└── reloc_x86_64.c
├── inc
├── Makefile
├── aarch64
│ ├── efibind.h
│ ├── efilibplat.h
│ └── efisetjmp_arch.h
├── arm
│ ├── efibind.h
│ ├── efilibplat.h
│ └── efisetjmp_arch.h
├── efi.h
├── efi_nii.h
├── efi_pxe.h
├── efiapi.h
├── eficompiler.h
├── eficon.h
├── eficonex.h
├── efidebug.h
├── efidef.h
├── efidevp.h
├── efierr.h
├── efifs.h
├── efigpt.h
├── efiip.h
├── efilib.h
├── efilink.h
├── efimp.h
├── efinet.h
├── efipart.h
├── efipciio.h
├── efipoint.h
├── efiprot.h
├── efipxebc.h
├── efirtlib.h
├── efiser.h
├── efisetjmp.h
├── efishell.h
├── efishellintf.h
├── efistdarg.h
├── efitcp.h
├── efiudp.h
├── efiui.h
├── ia32
│ ├── efibind.h
│ ├── efilibplat.h
│ ├── efisetjmp_arch.h
│ └── pe.h
├── ia64
│ ├── efibind.h
│ ├── efilibplat.h
│ ├── efisetjmp_arch.h
│ ├── pe.h
│ └── salproc.h
├── legacy.h
├── lib.h
├── libsmbios.h
├── loongarch64
│ ├── efibind.h
│ ├── efilibplat.h
│ └── efisetjmp_arch.h
├── mips64el
│ ├── efibind.h
│ ├── efilibplat.h
│ └── efisetjmp_arch.h
├── pci22.h
├── protocol
│ ├── adapterdebug.h
│ ├── eficonsplit.h
│ ├── efidbg.h
│ ├── efivar.h
│ ├── ia64
│ │ └── eficontext.h
│ ├── intload.h
│ ├── legacyboot.h
│ ├── make.inf
│ ├── makefile.hdr
│ ├── piflash64.h
│ ├── readme.txt
│ └── vgaclass.h
├── riscv64
│ ├── efibind.h
│ ├── efilibplat.h
│ └── efisetjmp_arch.h
├── romload.h
├── subst
│ └── elf.h
└── x86_64
│ ├── efibind.h
│ ├── efilibplat.h
│ ├── efisetjmp_arch.h
│ └── pe.h
├── lib
├── Makefile
├── aarch64
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
├── arm
│ ├── div.S
│ ├── edk2asm.h
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── ldivmod.S
│ ├── llsl.S
│ ├── llsr.S
│ ├── math.c
│ ├── mullu.S
│ ├── setjmp.S
│ └── uldiv.S
├── boxdraw.c
├── cmdline.c
├── console.c
├── crc.c
├── ctors.S
├── data.c
├── debug.c
├── dpath.c
├── entry.c
├── error.c
├── event.c
├── exit.c
├── guid.c
├── hand.c
├── hw.c
├── ia32
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
├── ia64
│ ├── initplat.c
│ ├── math.c
│ ├── palproc.S
│ ├── palproc.h
│ ├── salpal.c
│ └── setjmp.S
├── init.c
├── lock.c
├── loongarch64
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
├── mips64el
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
├── misc.c
├── pause.c
├── print.c
├── riscv64
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
├── runtime
│ ├── efirtlib.c
│ ├── rtdata.c
│ ├── rtlock.c
│ ├── rtstr.c
│ └── vm.c
├── smbios.c
├── sread.c
├── str.c
└── x86_64
│ ├── callwrap.c
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
├── licenses
├── LICENSE.edk2
└── LICENSE.efilib
└── tests
├── gen_tests.sh
├── run_tests.sh
└── test_list.txt
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5 |
6 | version: 2
7 | updates:
8 | # Maintain dependencies for GitHub Actions
9 | - package-ecosystem: "github-actions"
10 | # Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
11 | directory: "/"
12 | schedule:
13 | interval: "weekly"
14 |
--------------------------------------------------------------------------------
/.github/workflows/linux-llvm.yml:
--------------------------------------------------------------------------------
1 | name: Linux, LLVM
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 |
9 | strategy:
10 | matrix:
11 | arch: [x64]
12 | include:
13 | - arch: x64
14 | dir: x86_64
15 | gcc: multilib
16 | cross_compile:
17 |
18 | steps:
19 | - name: Install toolchain
20 | run: |
21 | sudo apt-get update
22 | sudo apt-get install gcc-${{ matrix.gcc }} clang lld
23 |
24 | - name: Checkout repository
25 | uses: actions/checkout@v4
26 | with:
27 | fetch-depth: 0
28 |
29 | - name: Build
30 | run: make ARCH=${{ matrix.arch }} CROSS_COMPILE=${{ matrix.cross_compile }} CC=clang LD=ld.lld
31 |
32 | - name: Generate binary information
33 | run: readelf -a ./${{ matrix.dir }}/apps/ctors_dtors_priority_test.so > ./${{ matrix.dir }}/apps/readelf.txt
34 |
35 | - name: Upload artifacts
36 | uses: actions/upload-artifact@v4
37 | with:
38 | name: ${{ matrix.arch }}
39 | path: |
40 | ./${{ matrix.dir }}/apps/*
41 | tests:
42 | runs-on: ubuntu-24.04
43 | needs: build
44 |
45 | strategy:
46 | matrix:
47 | arch: [x64]
48 | include:
49 | - arch: x64
50 | pkg: qemu-system-x86
51 | qemu_arch: x86_64
52 | qemu_opts: -M q35
53 | fw_base: OVMF
54 |
55 | steps:
56 | - name: Set up Linux environment
57 | run: |
58 | sudo apt-get update
59 | sudo apt-get -y --no-install-recommends install ${{ matrix.pkg }}
60 |
61 | - name: Checkout repository
62 | uses: actions/checkout@v4
63 | with:
64 | fetch-depth: 0
65 |
66 | - name: Download artifacts
67 | uses: actions/download-artifact@v4
68 | with:
69 | name: ${{ matrix.arch }}
70 |
71 | - name: Download UEFI firmware
72 | run: |
73 | fw_arch=$(echo ${{ matrix.arch }} | tr a-z A-Z)
74 | fw_zip=${{ matrix.fw_base }}-${fw_arch}.zip
75 | curl -O https://efi.akeo.ie/${{ matrix.fw_base }}/${fw_zip}
76 | 7z x ${fw_zip}
77 | rm ${fw_zip}
78 |
79 | - name: Download UEFI Shell
80 | run: |
81 | curl -L -O https://github.com/pbatard/UEFI-Shell/releases/download/23H2/UEFI-Shell-2.2-23H2-RELEASE.iso
82 | mkdir ./image
83 | 7z x -o./image *.iso
84 | rm *.iso
85 |
86 | - name: Run tests
87 | run: |
88 | export UEFI_ARCH=${{ matrix.arch }}
89 | export UEFI_DIR=./image
90 | export QEMU_CMD="qemu-system-${{ matrix.qemu_arch }} ${{ matrix.qemu_opts }} -nodefaults -nographic -serial stdio -net none -L . -drive if=pflash,format=raw,unit=0,file=${{ matrix.fw_base }}.fd,readonly=on -drive format=raw,file=fat:rw:image"
91 | ./tests/gen_tests.sh ./tests/test_list.txt
92 | ./tests/run_tests.sh
93 |
--------------------------------------------------------------------------------
/.github/workflows/linux-mingw.yml:
--------------------------------------------------------------------------------
1 | name: Linux, MinGW
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 |
9 | strategy:
10 | matrix:
11 | arch: [x64, ia32]
12 | include:
13 | - arch: x64
14 | dir: x86_64
15 | pkg: gcc-mingw-w64-x86-64
16 | tuple: x86_64-w64-mingw32-
17 | - arch: ia32
18 | dir: ia32
19 | pkg: gcc-mingw-w64-i686
20 | tuple: i686-w64-mingw32-
21 |
22 | steps:
23 | - name: Checkout repository and submodules
24 | uses: actions/checkout@v4
25 | with:
26 | fetch-depth: 0
27 |
28 | - name: Install gcc toolchain
29 | run: sudo apt install ${{ matrix.pkg }}
30 |
31 | - name: Build
32 | run: make ARCH=${{ matrix.arch }} CROSS_COMPILE=${{ matrix.tuple }}
33 |
34 | - name: Upload artifacts
35 | uses: actions/upload-artifact@v4
36 | with:
37 | name: ${{ matrix.arch }}
38 | path: ./${{ matrix.dir }}/apps/*.efi
39 |
40 | tests:
41 | runs-on: ubuntu-latest
42 | needs: build
43 |
44 | strategy:
45 | matrix:
46 | arch: [x64, ia32]
47 | include:
48 | - arch: x64
49 | pkg: qemu-system-x86
50 | qemu_arch: x86_64
51 | qemu_opts: -M q35
52 | fw_base: OVMF
53 | - arch: ia32
54 | pkg: qemu-system-x86
55 | qemu_arch: i386
56 | qemu_opts: -M pc
57 | fw_base: OVMF
58 |
59 | steps:
60 | - name: Set up Linux environment
61 | run: |
62 | sudo apt-get update
63 | sudo apt-get -y --no-install-recommends install ${{ matrix.pkg }}
64 |
65 | - name: Checkout repository
66 | uses: actions/checkout@v4
67 | with:
68 | fetch-depth: 0
69 |
70 | - name: Download artifacts
71 | uses: actions/download-artifact@v4
72 | with:
73 | name: ${{ matrix.arch }}
74 |
75 | - name: Download UEFI firmware
76 | run: |
77 | fw_arch=$(echo ${{ matrix.arch }} | tr a-z A-Z)
78 | fw_zip=${{ matrix.fw_base }}-${fw_arch}.zip
79 | curl -O https://efi.akeo.ie/${{ matrix.fw_base }}/${fw_zip}
80 | 7z x ${fw_zip}
81 | rm ${fw_zip}
82 |
83 | - name: Download UEFI Shell
84 | run: |
85 | curl -L -O https://github.com/pbatard/UEFI-Shell/releases/download/23H2/UEFI-Shell-2.2-23H2-RELEASE.iso
86 | mkdir ./image
87 | 7z x -o./image *.iso
88 | rm *.iso
89 |
90 | - name: Run tests
91 | run: |
92 | export UEFI_ARCH=${{ matrix.arch }}
93 | export UEFI_DIR=./image
94 | export QEMU_CMD="qemu-system-${{ matrix.qemu_arch }} ${{ matrix.qemu_opts }} -L . -drive if=pflash,format=raw,unit=0,file=${{ matrix.fw_base }}.fd,readonly=on -drive format=raw,file=fat:rw:image -nodefaults -nographic -serial stdio -net none"
95 | ./tests/gen_tests.sh ./tests/test_list.txt
96 | ./tests/run_tests.sh
97 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.efi
2 | *.efi.debug
3 | *.o
4 | *.a
5 | *.so
6 | *.tar.*
7 | *.tar
8 |
--------------------------------------------------------------------------------
/.vs/apps/AllocPages.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {DFA0BA98-D0BA-4176-9A34-B5BA6355B1DE}
6 | AllocPages
7 | 10.0
8 | AllocPages
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.vs/apps/AllocPages.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.vs/apps/FreePages.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {627A0AFB-B9A9-4FC9-9D6B-4D9E227A0666}
6 | FreePages
7 | 10.0
8 | FreePages
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/FreePages.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/_gen_vcxproj.ps1:
--------------------------------------------------------------------------------
1 | $Source = "AllocPages"
2 | $EfiArchName = @{
3 | "x64" = "x64"
4 | "Win32" = "ia32"
5 | "ARM64" = "aa64"
6 | "ARM" = "arm"
7 | }
8 | $i = 0
9 | $sln = (Get-Content ..\..\gnu-efi.sln) -as [collections.arraylist]
10 | Get-ChildItem "..\..\apps" -Filter *.c |
11 | Foreach-Object {
12 | if ($_.BaseName -ne $Source) {
13 | $guid = [guid]::NewGuid().ToString().ToUpper()
14 | Write-Host $guid = $_.BaseName
15 | copy "$Source.vcxproj" "$($_.BaseName).vcxproj"
16 | copy "$Source.vcxproj.filters" "$($_.BaseName).vcxproj.filters"
17 | copy "$Source.vcxproj.user" "$($_.BaseName).vcxproj.user"
18 | (Get-Content "$($_.BaseName).vcxproj").Replace("DFA0BA98-D0BA-4176-9A34-B5BA6355B1DE", $guid).Replace($Source, $_.BaseName) | Set-Content "$($_.BaseName).vcxproj"
19 | (Get-Content "$($_.BaseName).vcxproj.filters").Replace($Source, $_.BaseName) | Set-Content "$($_.BaseName).vcxproj.filters"
20 | $line = 14 + 5 * $i
21 | $sln.insert($line,"Project(""{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"") = ""$($_.BaseName)"", "".vs\apps\$($_.BaseName).vcxproj"", ""{$guid}""")
22 | $line++
23 | $sln.insert($line," ProjectSection(ProjectDependencies) = postProject")
24 | $line++
25 | $sln.insert($line," {3135D563-9596-4584-9ED6-616ADEC52974} = {3135D563-9596-4584-9ED6-616ADEC52974}")
26 | $line++
27 | $sln.insert($line," EndProjectSection")
28 | $line++
29 | $sln.insert($line,"EndProject")
30 | $line++
31 | $line += 44 + 16 * $i
32 | foreach ($Build in @("Debug", "Release")) {
33 | foreach ($Arch in @("ARM64", "ARM", "Win32", "x64")) {
34 | foreach ($Cfg in @("ActiveCfg", "Build.0")) {
35 | $sln.insert($line, " {$guid}.$Build|$($EfiArchName.$Arch).$Cfg = $Build|$Arch")
36 | $line++
37 | }
38 | }
39 | }
40 | $line += 6 + $i
41 | $sln.insert($line, " {$guid} = {DF105116-5A3A-4D48-AB1D-7221690ED545}")
42 | $i++
43 | }
44 | }
45 | $sln | Set-Content ..\..\gnu-efi.sln
--------------------------------------------------------------------------------
/.vs/apps/bltgrid.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {7FD7832D-F7C7-4B3F-9B6D-8A48BDC74E6C}
6 | bltgrid
7 | 10.0
8 | bltgrid
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/bltgrid.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/debughook.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {090590E4-A94D-477A-8512-42522BDDFE0C}
6 | debughook
7 | 10.0
8 | debughook
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/debughook.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/drv0.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {ED1B23FB-FCCA-4ED7-9E99-EEAAD9F2FB7F}
6 | drv0
7 | 10.0
8 | drv0
9 |
10 |
11 |
12 | EFI Boot Service Driver
13 |
14 |
15 |
16 |
17 | EFI Boot Service Driver
18 |
19 |
20 |
21 |
22 | EFI Boot Service Driver
23 |
24 |
25 |
26 |
27 | EFI Boot Service Driver
28 |
29 |
30 |
31 |
32 | EFI Boot Service Driver
33 |
34 |
35 |
36 |
37 | EFI Boot Service Driver
38 |
39 |
40 |
41 |
42 | EFI Boot Service Driver
43 |
44 |
45 |
46 |
47 | EFI Boot Service Driver
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/.vs/apps/drv0.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/drv0_use.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {3947DB96-3A01-4F8C-B7C1-2C4D6C00D640}
6 | drv0_use
7 | 10.0
8 | drv0_use
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/drv0_use.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/exit.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {80BD2830-EF30-4110-97BA-1B9A7B855996}
6 | exit
7 | 10.0
8 | exit
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/exit.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/lfbgrid.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {7C059723-3CD2-484B-8064-238CE7A437BD}
6 | lfbgrid
7 | 10.0
8 | lfbgrid
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/lfbgrid.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/modelist.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {5AD238D9-79AA-4166-BC86-EF759EA45BAB}
6 | modelist
7 | 10.0
8 | modelist
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/modelist.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/printenv.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {731CD95E-7CCD-495F-9456-E2D71357C807}
6 | printenv
7 | 10.0
8 | printenv
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/printenv.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/route80h.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {6F1EB89D-8968-4C3B-9F77-B23788F2D8C1}
6 | route80h
7 | 10.0
8 | route80h
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/route80h.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/setdbg.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {5D8EA8B2-C75F-4E3A-B0BC-E6B77AC77FF5}
6 | setdbg
7 | 10.0
8 | setdbg
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/setdbg.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/setjmp.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {8EC47C20-B7C3-4B82-8B06-967A15C7B323}
6 | setjmp
7 | 10.0
8 | setjmp
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/setjmp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/t.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {9BA1F692-0824-442E-B700-69C3D85D64EE}
6 | t
7 | 10.0
8 | t
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/t.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/t2.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {DCB81D4D-15B8-440D-A757-5B0036C0F4F6}
6 | t2
7 | 10.0
8 | t2
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/t2.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/t3.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {AFF91400-F772-419A-9463-D9900B43C666}
6 | t3
7 | 10.0
8 | t3
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/t3.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/t4.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {3428718B-4B7E-48F5-8D15-B9F3E3CFF38E}
6 | t4
7 | 10.0
8 | t4
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/t4.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/t5.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {7F52AAA4-2071-49D6-A783-529D3CB5AF61}
6 | t5
7 | 10.0
8 | t5
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/t5.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/t6.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {0AE45092-20C3-4999-BFDC-77F2D0FDFF60}
6 | t6
7 | 10.0
8 | t6
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/t6.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/t7.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {04D2685F-8150-47E0-BC10-338D2D6B804C}
6 | t7
7 | 10.0
8 | t7
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/t7.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/t8.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {6C664A44-BC53-4225-A14B-D969D4EED647}
6 | t8
7 | 10.0
8 | t8
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/t8.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/tcc.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {6E45A33B-E4A0-48D4-81AE-ACFD46FDB1CA}
6 | tcc
7 | 10.0
8 | tcc
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/tcc.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.vs/apps/unsetdbg.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {06089797-265A-4FF5-838E-25374C1F0159}
6 | unsetdbg
7 | 10.0
8 | unsetdbg
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.vs/apps/unsetdbg.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | | Version | Supported |
6 | | ------- | ------------------ |
7 | | 4.0.x | :white_check_mark: |
8 | | 3.0.x | :x: |
9 | | 3.0a | :x: |
10 |
11 | ## Reporting a Vulnerability
12 |
13 | Please provide:
14 | 1. Details of how the EFI binary was produced
15 | 2. Where the vulnerability is found in gnu-efi's source code (if known)
16 | 3. Steps to (re-)produce the vulnerability
17 |
18 | [Report here](https://github.com/ncroxon/gnu-efi/security/advisories/new)
19 |
--------------------------------------------------------------------------------
/apps/ctors_dtors_priority_test.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | // 101 in init_array, 65434 in ctors
5 | static void __attribute__((constructor(101))) EFI_NO_TAIL_CALL ctors101() {
6 | Print(u"1) ctor with lower numbered priority \r\n");
7 | }
8 |
9 | // 65434 in init_array, 101 in ctors
10 | static void __attribute__((constructor(65434))) EFI_NO_TAIL_CALL ctors65434() {
11 | Print(u"2) ctor with higher numbered priority \r\n");
12 | }
13 |
14 | // 101 in fini_array, 65434 in dtors
15 | static void __attribute__((destructor(101))) EFI_NO_TAIL_CALL dtors101() {
16 | Print(u"4) dtor with lower numbered priority \r\n");
17 | }
18 |
19 | // 65434 in fini_array, 101 in dtors
20 | static void __attribute__((destructor(65434))) EFI_NO_TAIL_CALL dtors65434() {
21 | Print(u"3) dtor with higher numbered priority \r\n");
22 | }
23 |
24 | EFI_STATUS
25 | efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED)
26 | {
27 | Print(u"Main function \r\n");
28 | return EFI_SUCCESS;
29 | }
30 |
--------------------------------------------------------------------------------
/apps/ctors_fns.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ctors.c
3 | * Copyright 2019 Peter Jones
4 | *
5 | */
6 |
7 | #include
8 | #include
9 |
10 | int constructed_value = 0;
11 |
12 | static void __attribute__((__constructor__)) EFI_NO_TAIL_CALL ctor(void)
13 | {
14 | Print(u"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
15 | constructed_value = 1;
16 | Print(u"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
17 | }
18 |
19 | static void __attribute__((__destructor__)) EFI_NO_TAIL_CALL dtor(void)
20 | {
21 | Print(u"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
22 | constructed_value = 0;
23 | Print(u"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
24 | }
25 |
26 | // vim:fenc=utf-8:tw=75:noet
27 |
--------------------------------------------------------------------------------
/apps/ctors_test.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ctors_test.c
3 | * Copyright 2019 Peter Jones
4 | *
5 | */
6 |
7 | #include
8 | #include
9 |
10 | extern int constructed_value;
11 |
12 | EFI_STATUS
13 | efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED)
14 | {
15 | Print(u"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
16 |
17 | return EFI_SUCCESS;
18 | }
19 |
20 | // vim:fenc=utf-8:tw=75:noet
21 |
--------------------------------------------------------------------------------
/apps/debughook.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | GetVariableAttr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner,
6 | UINT32 *attributes)
7 | {
8 | EFI_STATUS efi_status;
9 |
10 | *len = 0;
11 |
12 | efi_status = uefi_call_wrapper(RT->GetVariable, 5, var, &owner,
13 | NULL, len, NULL);
14 | if (efi_status != EFI_BUFFER_TOO_SMALL)
15 | return efi_status;
16 |
17 | *data = AllocateZeroPool(*len);
18 | if (!*data)
19 | return EFI_OUT_OF_RESOURCES;
20 |
21 | efi_status = uefi_call_wrapper(RT->GetVariable, 5, var, &owner,
22 | attributes, len, *data);
23 |
24 | if (efi_status != EFI_SUCCESS) {
25 | FreePool(*data);
26 | *data = NULL;
27 | }
28 | return efi_status;
29 | }
30 |
31 | EFI_STATUS
32 | GetVariable(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner)
33 | {
34 | return GetVariableAttr(var, data, len, owner, NULL);
35 | }
36 |
37 | EFI_GUID DUMMY_GUID =
38 | {0x55aad538, 0x8f82, 0x4e2a, {0xa4,0xf0,0xbe, 0x59, 0x13, 0xb6, 0x5f, 0x1e}};
39 |
40 | static EFI_OPTNONE void
41 | DebugHook(void)
42 | {
43 | EFI_GUID guid = DUMMY_GUID;
44 | UINT8 *data = NULL;
45 | UINTN dataSize = 0;
46 | EFI_STATUS efi_status;
47 | register volatile unsigned long long x = 0;
48 | extern char _text, _data;
49 |
50 | if (x)
51 | return;
52 |
53 | efi_status = GetVariable(u"DUMMY_DEBUG", &data, &dataSize, guid);
54 | if (EFI_ERROR(efi_status)) {
55 | return;
56 | }
57 |
58 | Print(u"add-symbol-file /usr/lib/debug/boot/efi/debughook.debug "
59 | u"0x%08x -s .data 0x%08x\n", &_text, &_data);
60 |
61 | Print(u"Pausing for debugger attachment.\n");
62 | Print(u"To disable this, remove the EFI variable DUMMY_DEBUG-%g .\n",
63 | &guid);
64 | x = 1;
65 | while (x++) {
66 | /* Make this so it can't /totally/ DoS us. */
67 | #if defined(__x86_64__) || defined(__i386__) || defined(__i686__)
68 | if (x > 4294967294ULL)
69 | break;
70 | __asm__ __volatile__("pause");
71 | #elif defined(__aarch64__)
72 | if (x > 1000)
73 | break;
74 | __asm__ __volatile__("wfi");
75 | #else
76 | if (x > 12000)
77 | break;
78 | uefi_call_wrapper(BS->Stall, 1, 5000);
79 | #endif
80 | }
81 | x = 1;
82 | }
83 |
84 |
85 | EFI_STATUS
86 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
87 | {
88 | InitializeLib(image, systab);
89 | DebugHook();
90 | return EFI_SUCCESS;
91 | }
92 |
--------------------------------------------------------------------------------
/apps/drv0.h:
--------------------------------------------------------------------------------
1 | #ifndef _GNU_EFI_APPS_DRV0_H_
2 | #define _GNU_EFI_APPS_DRV0_H_
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | /* UEFI naming conventions */
9 | #define GNU_EFI_APPS_DRV0_PROTOCOL_GUID \
10 | { 0xe4dcafd0, 0x586c, 0x4b3d, {0x86, 0xe7, 0x28, 0xde, 0x7f, 0xcc, 0x04, 0xb9} }
11 |
12 | INTERFACE_DECL(_GNU_EFI_APPS_DRV0_PROTOCOL);
13 |
14 | typedef
15 | EFI_STATUS
16 | (EFIAPI *GNU_EFI_APPS_DRV0_SAY_HELLO) (
17 | IN const CHAR16 *HelloWho
18 | );
19 |
20 | typedef
21 | EFI_STATUS
22 | (EFIAPI *GNU_EFI_APPS_DRV0_GET_NUMBER_OF_HELLO) (
23 | OUT UINTN *NumberOfHello
24 | );
25 |
26 | typedef struct _GNU_EFI_APPS_DRV0_PROTOCOL {
27 | GNU_EFI_APPS_DRV0_SAY_HELLO SayHello;
28 | GNU_EFI_APPS_DRV0_GET_NUMBER_OF_HELLO GetNumberOfHello;
29 | } GNU_EFI_APPS_DRV0_PROTOCOL;
30 |
31 | #ifdef __cplusplus
32 | }
33 | #endif
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/apps/drv0_use.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 David Decotigny
3 | *
4 | * See drv0.c for an example session.
5 | */
6 |
7 | #include
8 | #include
9 | #include "drv0.h"
10 |
11 |
12 | static EFI_GUID GnuEfiAppsDrv0ProtocolGuid
13 | = GNU_EFI_APPS_DRV0_PROTOCOL_GUID;
14 |
15 |
16 | static
17 | EFI_STATUS
18 | PlayWithGnuEfiAppsDrv0Protocol(IN EFI_HANDLE DrvHandle) {
19 | EFI_STATUS Status;
20 | GNU_EFI_APPS_DRV0_PROTOCOL *drv = NULL;
21 | UINTN NumberOfHello = 0;
22 |
23 | Status = uefi_call_wrapper(BS->OpenProtocol, 6,
24 | DrvHandle,
25 | &GnuEfiAppsDrv0ProtocolGuid,
26 | (void**)&drv,
27 | DrvHandle,
28 | NULL,
29 | EFI_OPEN_PROTOCOL_GET_PROTOCOL);
30 | if (EFI_ERROR(Status)) {
31 | Print(u"Cannot open proto: %d\n", Status);
32 | return Status;
33 | }
34 |
35 | Status = uefi_call_wrapper(drv->SayHello, 2, u"Sample UEFI Driver");
36 | if (EFI_ERROR(Status)) {
37 | Print(u"Cannot call SayHello: %d\n", Status);
38 | }
39 |
40 | Status = uefi_call_wrapper(drv->GetNumberOfHello, 2, &NumberOfHello);
41 | if (EFI_ERROR(Status)) {
42 | Print(u"Cannot call GetNumberOfHello: %d\n", Status);
43 | } else {
44 | Print(u"Hello was called %d time(s).\n", NumberOfHello);
45 | }
46 |
47 | return EFI_SUCCESS;
48 | }
49 |
50 |
51 | EFI_STATUS
52 | efi_main (EFI_HANDLE Image, EFI_SYSTEM_TABLE *SysTab)
53 | {
54 | EFI_STATUS Status;
55 | EFI_HANDLE *Handles = NULL;
56 | UINTN i, NoHandles = 0;
57 |
58 | InitializeLib(Image, SysTab);
59 |
60 | Status = LibLocateHandle(ByProtocol, &GnuEfiAppsDrv0ProtocolGuid,
61 | NULL, &NoHandles, &Handles);
62 | if (EFI_ERROR(Status)) {
63 | Print(u"Error looking up handles for proto: %d\n", Status);
64 | return Status;
65 | }
66 |
67 | for (i = 0 ; i < NoHandles ; ++i)
68 | {
69 | Print(u"Playing with driver instance %d...\n", i);
70 | Status = PlayWithGnuEfiAppsDrv0Protocol(Handles[i]);
71 | if (EFI_ERROR(Status))
72 | Print(u"Error playing with instance %d, skipping\n", i);
73 | }
74 |
75 | if (Handles)
76 | FreePool(Handles);
77 |
78 | return EFI_SUCCESS;
79 | }
80 |
--------------------------------------------------------------------------------
/apps/exit.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
6 | {
7 | InitializeLib(image_handle, systab);
8 |
9 | Exit(EFI_SUCCESS, 0, NULL);
10 |
11 | return EFI_UNSUPPORTED;
12 | }
13 |
--------------------------------------------------------------------------------
/apps/modelist.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | extern EFI_GUID GraphicsOutputProtocol;
5 |
6 | static void
7 | print_modes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
8 | {
9 | int i, imax;
10 | EFI_STATUS rc;
11 |
12 | if (gop->Mode) {
13 | imax = gop->Mode->MaxMode;
14 | Print(u"GOP reports MaxMode %d\n", imax);
15 | } else {
16 | Print(u"gop->Mode is NULL\n");
17 | imax = 1;
18 | }
19 |
20 | for (i = 0; i < imax; i++) {
21 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
22 | UINTN SizeOfInfo;
23 | rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo,
24 | &info);
25 | if (rc == EFI_NOT_STARTED) {
26 | Print(u"gop->QueryMode() returned %r\n", rc);
27 | Print(u"Trying to start GOP with SetMode().\n");
28 | rc = uefi_call_wrapper(gop->SetMode, 2, gop,
29 | gop->Mode ? gop->Mode->Mode : 0);
30 | rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i,
31 | &SizeOfInfo, &info);
32 | }
33 |
34 | if (EFI_ERROR(rc)) {
35 | Print(u"%d: Bad response from QueryMode: %r (%d)\n",
36 | i, rc, rc);
37 | continue;
38 | }
39 | Print(u"%c%d: %dx%d ",
40 | (gop->Mode &&
41 | CompareMem(info,gop->Mode->Info,sizeof(*info)) == 0
42 | ) ? '*' : ' ',
43 | i, info->HorizontalResolution, info->VerticalResolution);
44 | switch(info->PixelFormat) {
45 | case PixelRedGreenBlueReserved8BitPerColor:
46 | Print(u"RGBR");
47 | break;
48 | case PixelBlueGreenRedReserved8BitPerColor:
49 | Print(u"BGRR");
50 | break;
51 | case PixelBitMask:
52 | Print(u"R:%08x G:%08x B:%08x X:%08x",
53 | info->PixelInformation.RedMask,
54 | info->PixelInformation.GreenMask,
55 | info->PixelInformation.BlueMask,
56 | info->PixelInformation.ReservedMask);
57 | break;
58 | case PixelBltOnly:
59 | Print(u"(blt only)");
60 | break;
61 | default:
62 | Print(u"(Invalid pixel format)");
63 | break;
64 | }
65 | Print(u" pitch %d\n", info->PixelsPerScanLine);
66 | }
67 | }
68 |
69 | static EFI_STATUS
70 | SetWatchdog(UINTN seconds)
71 | {
72 | EFI_STATUS rc;
73 | rc = uefi_call_wrapper(BS->SetWatchdogTimer, 4, seconds, 0x1ffff,
74 | 0, NULL);
75 | if (EFI_ERROR(rc)) {
76 | CHAR16 Buffer[64];
77 | StatusToString(Buffer, rc);
78 | Print(u"Bad response from QueryMode: %s (%d)\n", Buffer, rc);
79 | }
80 | return rc;
81 | }
82 |
83 | EFI_STATUS
84 | efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
85 | {
86 | EFI_STATUS rc;
87 | EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;
88 |
89 | InitializeLib(image_handle, systab);
90 |
91 | SetWatchdog(10);
92 |
93 | rc = LibLocateProtocol(&GraphicsOutputProtocol, (void **)&gop);
94 | if (EFI_ERROR(rc)) {
95 | Print(u"Could not locate GOP: %r\n", rc);
96 | return rc;
97 | }
98 |
99 | if (!gop) {
100 | Print(u"LocateProtocol(GOP, &gop) returned %r but GOP is NULL\n", rc);
101 | return EFI_UNSUPPORTED;
102 | }
103 |
104 | print_modes(gop);
105 |
106 | SetWatchdog(0);
107 | return EFI_SUCCESS;
108 | }
109 |
--------------------------------------------------------------------------------
/apps/old_ABI.c:
--------------------------------------------------------------------------------
1 | #define GNU_EFI_3_0_COMPAT
2 |
3 | #include
4 | #include
5 |
6 | /* EFI_TIMESTAMP_PROTOCOL */
7 | #define TEST_GUID { 0xafbfde41, 0x2e6e, 0x4262,\
8 | { 0xba, 0x65, 0x62, 0xb9, 0x23, 0x6e, 0x54, 0x95 }}
9 |
10 | EFI_STATUS
11 | efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED)
12 | {
13 |
14 | CHAR16 *Dest = 0;
15 | EFI_UNUSED CHAR16 *Copy = 0;
16 | UINTN test_str_size = 0;
17 | CONST CHAR16 *test_str = u"Hello World!";
18 |
19 | test_str_size = StrSize(test_str);
20 | Dest = AllocatePool(test_str_size);
21 | CopyMem(Dest, test_str, test_str_size);
22 | Copy = ReallocatePool(Dest, test_str_size, test_str_size+10);
23 | Print(u"Done CopyMem and ReallocatePool!\r\n");
24 |
25 | EFI_GUID a = TEST_GUID;
26 | EFI_GUID b = TEST_GUID;
27 | if (CompareGuid(&a, &b) == 0) {
28 | Print(u"CompareGuid ok!\r\n");
29 | } else {
30 | Print(u"CompareGuid fail!\r\n");
31 | }
32 | return EFI_SUCCESS;
33 | }
34 |
--------------------------------------------------------------------------------
/apps/printenv.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | EFI_STATUS status;
8 | CHAR16 name[256], *val, fmt[20];
9 | EFI_GUID vendor;
10 | UINTN size;
11 |
12 | InitializeLib(image, systab);
13 |
14 | name[0] = 0;
15 | vendor = NullGuid;
16 |
17 | Print(u"GUID Variable Name Value\n");
18 | Print(u"=================================== ==================== ========\n");
19 |
20 | StrCpy(fmt, u"%.-35g %.-20s %s\n");
21 | while (1) {
22 | size = sizeof(name);
23 | status = uefi_call_wrapper(RT->GetNextVariableName, 3, &size, name, &vendor);
24 | if (status != EFI_SUCCESS)
25 | break;
26 |
27 | val = LibGetVariable(name, &vendor);
28 | Print(fmt, &vendor, name, val);
29 | FreePool(val);
30 | }
31 | return EFI_SUCCESS;
32 | }
33 |
--------------------------------------------------------------------------------
/apps/setdbg.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_GUID GRUB_EFI_GRUB_VARIABLE_GUID = {0x91376aff,0xcba6,0x42be,{0x94,0x9d,0x06,0xfd,0xe8,0x11,0x28,0xe8}};
5 | EFI_GUID SHIM_GUID = {0x605dab50,0xe046,0x4300,{0xab,0xb6,0x3d,0xd8,0x10,0xdd,0x8b,0x23}};
6 |
7 | char grubenv[] = "# GRUB Environment Block\n\
8 | debug=tcp,http,net\n\
9 | ####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################";
10 |
11 | EFI_STATUS
12 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
13 | {
14 | EFI_STATUS status;
15 | InitializeLib(image, systab);
16 | #if 0
17 | UINT8 data = 1;
18 |
19 | status = RT->SetVariable(u"SHIM_DEBUG", &SHIM_GUID,
20 | EFI_VARIABLE_NON_VOLATILE |
21 | EFI_VARIABLE_BOOTSERVICE_ACCESS |
22 | EFI_VARIABLE_RUNTIME_ACCESS,
23 | sizeof(data), &data);
24 | if (EFI_ERROR(status))
25 | Print(u"SetVariable failed: %r\n", status);
26 | #endif
27 |
28 | status = RT->SetVariable(u"GRUB_ENV", &SHIM_GUID,
29 | EFI_VARIABLE_NON_VOLATILE |
30 | EFI_VARIABLE_BOOTSERVICE_ACCESS |
31 | EFI_VARIABLE_RUNTIME_ACCESS,
32 | sizeof(grubenv)-1, grubenv);
33 | if (EFI_ERROR(status))
34 | Print(u"SetVariable(GRUB_ENV) failed: %r\n", status);
35 |
36 | return EFI_SUCCESS;
37 | }
38 |
--------------------------------------------------------------------------------
/apps/setjmp.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 |
6 | EFI_STATUS
7 | efi_main(
8 | EFI_HANDLE image_handle,
9 | EFI_SYSTEM_TABLE *systab
10 | )
11 | {
12 | jmp_buf env;
13 | int rc;
14 |
15 | InitializeLib(image_handle, systab);
16 | rc = setjmp(env);
17 | Print(u"setjmp() = %d\n", rc);
18 |
19 | if (rc == 3) {
20 | Print(u"3 worked\n");
21 | longjmp(env, 0);
22 | return 0;
23 | }
24 |
25 | if (rc == 1) {
26 | Print(u"0 got to be one yay\n");
27 | return 0;
28 | }
29 |
30 | longjmp(env, 3);
31 | return 0;
32 | }
33 |
--------------------------------------------------------------------------------
/apps/t.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | static CHAR16 *
5 | a2u (char *str)
6 | {
7 | static CHAR16 mem[2048];
8 | int i;
9 |
10 | for (i = 0; str[i]; ++i)
11 | mem[i] = (CHAR16) str[i];
12 | mem[i] = 0;
13 | return mem;
14 | }
15 |
16 | EFI_STATUS
17 | efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
18 | {
19 | SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
20 |
21 | InitializeLib(image_handle, systab);
22 | conout = systab->ConOut;
23 | uefi_call_wrapper(conout->OutputString, 2, conout, (CHAR16 *)u"Hello World!\r\n");
24 | uefi_call_wrapper(conout->OutputString, 2, conout, a2u("Hello World!\r\n"));
25 |
26 | return EFI_SUCCESS;
27 | }
28 |
--------------------------------------------------------------------------------
/apps/t2.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
8 |
9 | InitializeLib(image, systab);
10 | conout = systab->ConOut;
11 | uefi_call_wrapper(conout->OutputString, 2, conout, u"Hello World!\r\n");
12 |
13 | return EFI_SUCCESS;
14 | }
15 |
--------------------------------------------------------------------------------
/apps/t3.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main(
6 | EFI_HANDLE image_handle,
7 | EFI_SYSTEM_TABLE *systab
8 | )
9 | {
10 | EFI_GUID loaded_image_protocol = LOADED_IMAGE_PROTOCOL;
11 | EFI_STATUS efi_status;
12 | EFI_LOADED_IMAGE *li;
13 | UINTN pat = PoolAllocationType;
14 | VOID *void_li_p;
15 |
16 | InitializeLib(image_handle, systab);
17 | PoolAllocationType = 2; /* klooj */
18 |
19 | Print(u"Hello World! (0xd=0x%x, 13=%d)\n", 13, 13);
20 |
21 | Print(u"before InitializeLib(): PoolAllocationType=%d\n",
22 | pat);
23 |
24 | Print(u" after InitializeLib(): PoolAllocationType=%d\n",
25 | PoolAllocationType);
26 |
27 | /*
28 | * Locate loaded_image_handle instance.
29 | */
30 |
31 | Print(u"BS->HandleProtocol() ");
32 |
33 | efi_status = uefi_call_wrapper(
34 | BS->HandleProtocol,
35 | 3,
36 | image_handle,
37 | &loaded_image_protocol,
38 | &void_li_p);
39 | li = void_li_p;
40 |
41 | Print(u"%xh (%r)\n", efi_status, efi_status);
42 |
43 | if (efi_status != EFI_SUCCESS) {
44 | return efi_status;
45 | }
46 |
47 | Print(u" li: %xh\n", li);
48 |
49 | if (!li) {
50 | return EFI_UNSUPPORTED;
51 | }
52 |
53 | Print(u" li->Revision: %xh\n", li->Revision);
54 | Print(u" li->ParentHandle: %xh\n", li->ParentHandle);
55 | Print(u" li->SystemTable: %xh\n", li->SystemTable);
56 | Print(u" li->DeviceHandle: %xh\n", li->DeviceHandle);
57 | Print(u" li->FilePath: %xh\n", li->FilePath);
58 | Print(u" li->Reserved: %xh\n", li->Reserved);
59 | Print(u" li->LoadOptionsSize: %xh\n", li->LoadOptionsSize);
60 | Print(u" li->LoadOptions: %xh\n", li->LoadOptions);
61 | Print(u" li->ImageBase: %xh\n", li->ImageBase);
62 | Print(u" li->ImageSize: %xh\n", li->ImageSize);
63 | Print(u" li->ImageCodeType: %xh\n", li->ImageCodeType);
64 | Print(u" li->ImageDataType: %xh\n", li->ImageDataType);
65 | Print(u" li->Unload: %xh\n", li->Unload);
66 |
67 | #if 0
68 | typedef struct {
69 | UINT32 Revision;
70 | EFI_HANDLE ParentHandle;
71 | struct _EFI_SYSTEM_TABLE *SystemTable;
72 |
73 | // Source location of image
74 | EFI_HANDLE DeviceHandle;
75 | EFI_DEVICE_PATH *FilePath;
76 | VOID *Reserved;
77 |
78 | // Images load options
79 | UINT32 LoadOptionsSize;
80 | VOID *LoadOptions;
81 |
82 | // Location of where image was loaded
83 | VOID *ImageBase;
84 | UINT64 ImageSize;
85 | EFI_MEMORY_TYPE ImageCodeType;
86 | EFI_MEMORY_TYPE ImageDataType;
87 |
88 | // If the driver image supports a dynamic unload request
89 | EFI_IMAGE_UNLOAD Unload;
90 |
91 | } EFI_LOADED_IMAGE;
92 | #endif
93 |
94 | return EFI_SUCCESS;
95 | }
96 |
--------------------------------------------------------------------------------
/apps/t4.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE *image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | UINTN index;
8 |
9 | InitializeLib(image, systab);
10 | uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut, u"Hello application started\r\n");
11 | uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut, u"\r\n\r\n\r\nHit any key to exit\r\n");
12 | uefi_call_wrapper(systab->BootServices->WaitForEvent, 3, 1, &systab->ConIn->WaitForKey, &index);
13 | return EFI_SUCCESS;
14 | }
15 |
--------------------------------------------------------------------------------
/apps/t5.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | InitializeLib(image, systab);
8 | Print(u"HelloLib application started\n");
9 | Print(u"\n\n\nHit any key to exit this image\n");
10 | WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
11 | uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, u"\n\n");
12 | return EFI_SUCCESS;
13 | }
14 |
--------------------------------------------------------------------------------
/apps/t6.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | typedef EFI_STATUS (*foo_t)(EFI_HANDLE, EFI_GUID *, VOID **);
5 | typedef struct {
6 | unsigned long addr;
7 | unsigned long gp;
8 | } fdesc_t;
9 |
10 | EFI_LOADED_IMAGE my_loaded;
11 |
12 | EFI_STATUS
13 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
14 | {
15 | EFI_LOADED_IMAGE *loaded_image = NULL;
16 | #if 0
17 | EFI_DEVICE_PATH *dev_path;
18 | #endif
19 | EFI_STATUS status;
20 |
21 | InitializeLib(image, systab);
22 | status = uefi_call_wrapper(systab->BootServices->HandleProtocol,
23 | 3,
24 | image,
25 | &LoadedImageProtocol,
26 | (void **) &loaded_image);
27 | if (EFI_ERROR(status)) {
28 | Print(u"handleprotocol: %r\n", status);
29 | }
30 |
31 | #if 0
32 | BS->HandleProtocol(loaded_image->DeviceHandle, &DevicePathProtocol, (void **) &dev_path);
33 |
34 | Print(u"Image device : %s\n", DevicePathToStr(dev_path));
35 | Print(u"Image file : %s\n", DevicePathToStr(loaded_image->FilePath));
36 | #endif
37 | Print(u"Image base : %lx\n", loaded_image->ImageBase);
38 | Print(u"Image size : %lx\n", loaded_image->ImageSize);
39 | Print(u"Load options size : %lx\n", loaded_image->LoadOptionsSize);
40 | Print(u"Load options : %s\n", loaded_image->LoadOptions);
41 |
42 | return EFI_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/apps/t7.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | EFI_INPUT_KEY efi_input_key;
8 | EFI_STATUS efi_status;
9 |
10 | InitializeLib(image, systab);
11 |
12 | Print(u"HelloLib application started\n");
13 |
14 | Print(u"\n\n\nHit any key to exit this image\n");
15 | WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
16 |
17 | uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, u"\n\n");
18 |
19 | efi_status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &efi_input_key);
20 |
21 | Print(u"ScanCode: %xh UnicodeChar: %xh CallRtStatus: %x\n",
22 | efi_input_key.ScanCode, efi_input_key.UnicodeChar, efi_status);
23 |
24 | return EFI_SUCCESS;
25 | }
26 |
--------------------------------------------------------------------------------
/apps/t8.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
6 | {
7 | INTN Argc, i;
8 | CHAR16 **Argv;
9 |
10 | InitializeLib(ImageHandle, SystemTable);
11 | Argc = GetShellArgcArgv(ImageHandle, &Argv);
12 |
13 | Print(u"Hello World, started with Argc=%d\n", Argc);
14 | for (i = 0 ; i < Argc ; ++i)
15 | Print(u" Argv[%d] = '%s'\n", i, Argv[i]);
16 |
17 | Print(u"Bye.\n");
18 | return EFI_SUCCESS;
19 | }
20 |
--------------------------------------------------------------------------------
/apps/unsetdbg.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_GUID GRUB_EFI_GRUB_VARIABLE_GUID = {0x91376aff,0xcba6,0x42be,{0x94,0x9d,0x06,0xfd,0xe8,0x11,0x28,0xe8}};
5 | EFI_GUID SHIM_GUID = {0x605dab50,0xe046,0x4300,{0xab,0xb6,0x3d,0xd8,0x10,0xdd,0x8b,0x23}};
6 |
7 | char grubenv[] = "# GRUB Environment Block\n\
8 | debug=all\n\
9 | #############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################";
10 |
11 | EFI_STATUS
12 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
13 | {
14 | EFI_STATUS status;
15 | UINT8 data = 1;
16 | InitializeLib(image, systab);
17 |
18 | status = RT->SetVariable(u"SHIM_DEBUG", &SHIM_GUID,
19 | EFI_VARIABLE_NON_VOLATILE |
20 | EFI_VARIABLE_BOOTSERVICE_ACCESS |
21 | EFI_VARIABLE_RUNTIME_ACCESS,
22 | 0, &data);
23 | if (EFI_ERROR(status))
24 | Print(u"SetVariable failed: %r\n", status);
25 |
26 | #if 0
27 | status = RT->SetVariable(u"GRUB_ENV", &SHIM_GUID,
28 | EFI_VARIABLE_NON_VOLATILE |
29 | EFI_VARIABLE_BOOTSERVICE_ACCESS |
30 | EFI_VARIABLE_RUNTIME_ACCESS,
31 | sizeof(grubenv)-1, grubenv);
32 | if (EFI_ERROR(status))
33 | Print(u"SetVariable(GRUB_ENV) failed: %r\n", status);
34 | #endif
35 |
36 | return EFI_SUCCESS;
37 | }
38 |
--------------------------------------------------------------------------------
/docs/README.ABI.md:
--------------------------------------------------------------------------------
1 | 1) When using gnu-efi 4.0 with an application which was written
2 | for gnu-efi 3.0, it may be required to set the `GNU_EFI_3_0_COMPAT` compile flag
3 | this changes the default versions of some changed functions back to their prior
4 | versions
5 |
6 | This currently includes the following functions:
7 | - ReallocatePool
8 |
9 | Inputs were re-ordered
10 |
11 | - CopyMem
12 |
13 | Source is no longer marked as constant
14 |
15 | CopyMemC is introduced as a helper function when using a constant source input
16 |
17 | - CompareGuid
18 |
19 | Function now returns BOOLEAN instead of INTN
20 | Return codes are now reversed
21 |
22 | **Will break at runtime - likely causing opposite output to expected**
23 |
24 | 2) Applications which haven't been updated in a while may also be missing the
25 | required `.rodata` section which contains needed read-only data which will prevent
26 | any binary missing this section from running correctly
27 |
--------------------------------------------------------------------------------
/docs/README.elilo.md:
--------------------------------------------------------------------------------
1 |
2 | # IMPORTANT information related to the gnu-efi package
3 | ----------------------------------------------------
4 | June 2001
5 |
6 | As of version 3.0, the gnu-efi package is now split in two different packages:
7 |
8 | - gnu-efi-X.y: contains the EFI library, include files and crt0.
9 |
10 | - elilo-X.y : contains the ELILO bootloader.
11 |
12 | Note that X.y don't need to match for both packages. However elilo-3.x
13 | requires at least gnu-efi-3.0. EFI support for x86_64 is provided in
14 | gnu-efi-3.0d.
15 |
16 | Both packages can be downloaded from:
17 |
18 | - [gnu-efi](https://github.com/ncroxon/gnu-efi)
19 | - [elilo](https://sourceforge.net/projects/elilo/)
20 |
--------------------------------------------------------------------------------
/docs/README.git.md:
--------------------------------------------------------------------------------
1 | # README.git
2 |
3 | Generating releases on GitHub is a very simple process;
4 |
5 | ## Set version in repo
6 | 1) Edit the file "Makefile". Changing the "VERSION" line to the new version.
7 | 2) Do a "git commit" just for the version number change.
8 |
9 | ## Create new release
10 | 1) Go to the [GitHub release page](https://github.com/ncroxon/gnu-efi/releases/new)
11 | 2) Enter the version number in the tag field, selecting "create tag on publish"
12 |
13 | **Ignore GitHub's suggestion of prefixing the version with a "v"**
14 | 3) Set previous tag manually
15 |
16 | - Last stable for stable releases
17 | - Last alpha/beta for alpha/beta releases
18 |
19 | **Ensures GitHub sets the Full Changelog to be between the last release in the cycle**
20 | **and not the start of the repository**
21 | 4) Add a release title - use the version number
22 |
23 | **Otherwise GitHub will add the last commit name as the title**
24 | 5) ***OPTIONAL***
25 | Add a release description *and/or* a list of pull requests and contributors via "Generate release notes"
26 | 6) For alpha/beta versions, set it to be a pre-release
27 | 7) Release the new version
28 | 8) GitHub will automatically generate a GZ compressed TAR file and a ZIP file of the repo
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/docs/README.packaging.md:
--------------------------------------------------------------------------------
1 | # Packaging gnu-efi
2 |
3 | ## Set variables per distro configuration
4 |
5 | make should be called with the following variables:
6 |
7 | - PREFIX (defaults to `/usr/local`)(`%{_prefix}` on RPM distros)
8 | - EXEC_PREFIX (*optional*) (defaults to `$PREFIX`) (`%{_exec_prefix}` on RPM distros)
9 | - LIBDIR (defaults to `$EXEC_PREFIX/lib`) (`%{_libdir}` on RPM distros)
10 | - INCLUDEDIR (*optional*) (defaults to `$PREFIX/include`) (`%{_includedir}` on RPM distros)
11 | - LINUX_HEADERS (*optional*) (**build only**) - location of Linux kernel header files (defaults to `/usr/src/sys/build`)
12 | - DESTDIR (**install only**) - installation output directory (`%{buildroot}` on RPM distros - included in `%make_install`)
13 |
14 | Currently, these variables unless stated will need to be set for both build and installation stages.
15 |
16 | Those without optional markers I heavily suggest you to set them otherwise files may be located in the wrong directory
17 | for the architecture which you are building for
18 |
19 | *The related RPM variables are included here for cross referencing purposes*
--------------------------------------------------------------------------------
/gnuefi/crt0-efi-aarch64.S:
--------------------------------------------------------------------------------
1 | /*
2 | * crt0-efi-aarch64.S - PE/COFF header for AArch64 EFI applications
3 | *
4 | * Copyright (C) 2014 Linaro Ltd.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice and this list of conditions, without modification.
11 | * 2. The name of the author may not be used to endorse or promote products
12 | * derived from this software without specific prior written permission.
13 | *
14 | * Alternatively, this software may be distributed under the terms of the
15 | * GNU General Public License as published by the Free Software Foundation;
16 | * either version 2 of the License, or (at your option) any later version.
17 | */
18 |
19 | .text
20 | .align 12
21 |
22 | .globl _start
23 | .type _start,%function
24 | _start:
25 | stp x29, x30, [sp, #-32]!
26 | mov x29, sp
27 |
28 | stp x0, x1, [sp, #16]
29 | mov x2, x0
30 | mov x3, x1
31 | adr x0, ImageBase
32 | adrp x1, _DYNAMIC
33 | add x1, x1, #:lo12:_DYNAMIC
34 | bl _relocate
35 | cbnz x0, .L_exit
36 |
37 | ldp x0, x1, [sp, #16]
38 | bl _entry
39 |
40 | .L_exit:
41 | ldp x29, x30, [sp], #32
42 | ret
43 |
44 | // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
45 |
46 | .data
47 | dummy0: .4byte 0
48 | dummy1: .4byte 0
49 |
50 | #define IMAGE_REL_ABSOLUTE 0
51 | .section .reloc, "a", %progbits
52 | .4byte dummy1 - dummy0 // Page RVA
53 | .4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
54 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
55 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
56 |
57 | #if defined(__ELF__) && defined(__linux__)
58 | .section .note.GNU-stack,"",%progbits
59 | #endif
60 |
--------------------------------------------------------------------------------
/gnuefi/crt0-efi-ia32.S:
--------------------------------------------------------------------------------
1 | /* crt0-efi-ia32.S - x86 EFI startup code.
2 | Copyright (C) 1999 Hewlett-Packard Co.
3 | Contributed by David Mosberger .
4 |
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following
15 | disclaimer in the documentation and/or other materials
16 | provided with the distribution.
17 | * Neither the name of Hewlett-Packard Co. nor the names of its
18 | contributors may be used to endorse or promote products derived
19 | from this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
26 | BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
32 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 | SUCH DAMAGE.
34 | */
35 |
36 | .text
37 | .align 4
38 |
39 | .globl _start
40 | .type _start,%function
41 | _start:
42 | pushl %ebp
43 | movl %esp,%ebp
44 |
45 | pushl 12(%ebp) # copy "image" argument
46 | pushl 8(%ebp) # copy "systab" argument
47 |
48 | call 0f
49 | 0: popl %eax
50 | movl %eax,%ebx
51 |
52 | addl $ImageBase-0b,%eax # %eax = ldbase
53 | addl $_DYNAMIC-0b,%ebx # %ebx = _DYNAMIC
54 |
55 | pushl %ebx # pass _DYNAMIC as second argument
56 | pushl %eax # pass ldbase as first argument
57 | call _relocate
58 | popl %ebx
59 | popl %ebx
60 | testl %eax,%eax
61 | jne .L_exit
62 |
63 | call _entry # call app with "image" and "systab" argument
64 |
65 | .L_exit:
66 | leave
67 | ret
68 |
69 | // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
70 |
71 | .data
72 | dummy0: .4byte 0
73 | dummy1: .4byte 0
74 |
75 | #define IMAGE_REL_ABSOLUTE 0
76 | .section .reloc
77 | .4byte dummy1 - dummy0 // Page RVA
78 | .4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
79 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
80 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
81 |
82 | #if defined(__ELF__) && defined(__linux__)
83 | .section .note.GNU-stack,"",%progbits
84 | #endif
85 |
--------------------------------------------------------------------------------
/gnuefi/crt0-efi-loongarch64.S:
--------------------------------------------------------------------------------
1 | /*
2 | * crt0-efi-loongarch64.S - PE/COFF header for LoongArch64 EFI applications
3 | *
4 | * Copyright (C) 2021 Loongson Technology Corporation Limited.
5 | * Copyright (C) 2014 Linaro Ltd.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice and this list of conditions, without modification.
12 | * 2. The name of the author may not be used to endorse or promote products
13 | * derived from this software without specific prior written permission.
14 | *
15 | * Alternatively, this software may be distributed under the terms of the
16 | * GNU General Public License as published by the Free Software Foundation;
17 | * either version 2 of the License, or (at your option) any later version.
18 | */
19 |
20 | .text
21 | .align 12
22 | .globl _start
23 | .type _start, @function
24 | _start:
25 | addi.d $sp, $sp, -24
26 | st.d $ra, $sp, 0
27 | st.d $a0, $sp, 8
28 | st.d $a1, $sp, 16
29 |
30 | move $a2, $a0 // a2: ImageHandle
31 | move $a3, $a1 // a3: SystemTable
32 | la.local $a0, ImageBase // a0: ImageBase
33 | la.local $a1, _DYNAMIC // a1: DynamicSection
34 | bl _relocate
35 | bnez $a0, .L_exit
36 |
37 | ld.d $a0, $sp, 8
38 | ld.d $a1, $sp, 16
39 | bl _entry
40 |
41 | .L_exit:
42 | ld.d $ra, $sp, 0
43 | addi.d $sp, $sp, 24
44 | jr $ra
45 |
46 | // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
47 |
48 | .data
49 | dummy0: .4byte 0
50 | dummy1: .4byte 0
51 |
52 | #define IMAGE_REL_ABSOLUTE 0
53 | .section .reloc, "a", %progbits
54 | .4byte dummy1 - dummy0 // Page RVA
55 | .4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
56 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
57 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
58 |
59 | #if defined(__ELF__) && defined(__linux__)
60 | .section .note.GNU-stack,"",%progbits
61 | #endif
62 |
--------------------------------------------------------------------------------
/gnuefi/crt0-efi-riscv64.S:
--------------------------------------------------------------------------------
1 | /* SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause */
2 | /*
3 | * Copyright (C) 2014 Linaro Ltd.
4 | * Copyright (C) 2018 Alexander Graf
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice and this list of conditions, without modification.
11 | * 2. The name of the author may not be used to endorse or promote products
12 | * derived from this software without specific prior written permission.
13 | *
14 | * Alternatively, this software may be distributed under the terms of the
15 | * GNU General Public License as published by the Free Software Foundation;
16 | * either version 2 of the License, or (at your option) any later version.
17 | */
18 |
19 | .text
20 | .globl _start
21 | .type _start,%function
22 | _start:
23 | addi sp, sp, -24
24 | sd a0, 0(sp)
25 | sd a1, 8(sp)
26 | sd ra, 16(sp)
27 | lla a0, ImageBase
28 | lla a1, _DYNAMIC
29 | call _relocate
30 | bne a0, zero, .L_exit
31 | ld a1, 8(sp)
32 | ld a0, 0(sp)
33 | call _entry
34 | ld ra, 16(sp)
35 | .L_exit:
36 | addi sp, sp, 24
37 | ret
38 |
39 | // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
40 |
41 | .data
42 | dummy0: .4byte 0
43 | dummy1: .4byte 0
44 |
45 | #define IMAGE_REL_ABSOLUTE 0
46 | .section .reloc, "a", %progbits
47 | .4byte dummy1 - dummy0 // Page RVA
48 | .4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
49 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
50 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
51 |
52 | #if defined(__ELF__) && defined(__linux__)
53 | .section .note.GNU-stack,"",%progbits
54 | #endif
55 |
--------------------------------------------------------------------------------
/gnuefi/crt0-efi-x86_64.S:
--------------------------------------------------------------------------------
1 | /* crt0-efi-x86_64.S - x86_64 EFI startup code.
2 | Copyright (C) 1999 Hewlett-Packard Co.
3 | Contributed by David Mosberger .
4 | Copyright (C) 2005 Intel Co.
5 | Contributed by Fenghua Yu .
6 |
7 | All rights reserved.
8 |
9 | Redistribution and use in source and binary forms, with or without
10 | modification, are permitted provided that the following conditions
11 | are met:
12 |
13 | * Redistributions of source code must retain the above copyright
14 | notice, this list of conditions and the following disclaimer.
15 | * Redistributions in binary form must reproduce the above
16 | copyright notice, this list of conditions and the following
17 | disclaimer in the documentation and/or other materials
18 | provided with the distribution.
19 | * Neither the name of Hewlett-Packard Co. nor the names of its
20 | contributors may be used to endorse or promote products derived
21 | from this software without specific prior written permission.
22 |
23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
28 | BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
29 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
33 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
34 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 | SUCH DAMAGE.
36 | */
37 | .text
38 | .align 4
39 |
40 | .globl _start
41 | .type _start,%function
42 | _start:
43 | subq $8, %rsp
44 | pushq %rcx
45 | pushq %rdx
46 |
47 | 0:
48 | lea ImageBase(%rip), %rdi
49 | lea _DYNAMIC(%rip), %rsi
50 |
51 | popq %rcx
52 | popq %rdx
53 | pushq %rcx
54 | pushq %rdx
55 | call _relocate
56 |
57 | popq %rdi
58 | popq %rsi
59 |
60 | call _entry
61 | addq $8, %rsp
62 |
63 | .L_exit:
64 | ret
65 |
66 | // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
67 |
68 | .data
69 | dummy0: .4byte 0
70 | dummy1: .4byte 0
71 |
72 | #define IMAGE_REL_ABSOLUTE 0
73 | .section .reloc, "a", %progbits
74 | .4byte dummy1 - dummy0 // Page RVA
75 | .4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
76 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
77 | .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
78 |
79 | #if defined(__ELF__) && defined(__linux__)
80 | .section .note.GNU-stack,"",%progbits
81 | #endif
82 |
--------------------------------------------------------------------------------
/gnuefi/elf_aarch64_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
2 | OUTPUT_ARCH(aarch64)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | . = 0;
7 | ImageBase = .;
8 | /* .hash and/or .gnu.hash MUST come first! */
9 | .hash : { *(.hash) }
10 | .gnu.hash : { *(.gnu.hash) }
11 | . = ALIGN(4096);
12 | .eh_frame : { *(.eh_frame) }
13 | .eh_frame_hdr : { *(.eh_frame_hdr) }
14 | .gcc_except_table : { *(.gcc_except_table*) }
15 | . = ALIGN(4096);
16 | .text : {
17 | _text = .;
18 | *(.text)
19 | *(.text.*)
20 | *(.gnu.linkonce.t.*)
21 | *(.plt)
22 | . = ALIGN(16);
23 | }
24 | _etext = .;
25 | _text_size = _etext - _text;
26 | . = ALIGN(65536);
27 | .data :
28 | {
29 | _data = .;
30 | *(.sdata)
31 | *(.data)
32 | *(.data1)
33 | *(.data.*)
34 | *(.got.plt)
35 | *(.got)
36 |
37 | /*
38 | * Note that these aren't the using the GNU "CONSTRUCTOR" output section
39 | * command, so they don't start with a size. Because of p2align and the
40 | * end/END definitions, and the fact that they're mergeable, they can also
41 | * have NULLs which aren't guaranteed to be at the end.
42 | */
43 | . = ALIGN(16);
44 | __init_array_start = .;
45 | *(SORT(.init_array.*))
46 | *(.init_array)
47 | __init_array_end = .;
48 | . = ALIGN(16);
49 | __CTOR_LIST__ = .;
50 | *(SORT(.ctors.*))
51 | *(.ctors)
52 | __CTOR_END__ = .;
53 | . = ALIGN(16);
54 | __DTOR_LIST__ = .;
55 | *(SORT(.dtors.*))
56 | *(.dtors)
57 | __DTOR_END__ = .;
58 | . = ALIGN(16);
59 | __fini_array_start = .;
60 | *(SORT(.fini_array.*))
61 | *(.fini_array)
62 | __fini_array_end = .;
63 |
64 | /* the EFI loader doesn't seem to like a .bss section, so we stick
65 | it all into .data: */
66 | . = ALIGN(16);
67 | _bss = .;
68 | *(.sbss)
69 | *(.scommon)
70 | *(.dynbss)
71 | *(.bss*)
72 | *(COMMON)
73 | *(.rel.local)
74 | . = ALIGN(16);
75 |
76 | _bss_end = .;
77 | }
78 | . = ALIGN(4096);
79 | .reloc :
80 | {
81 | KEEP (*(.reloc))
82 | }
83 | . = ALIGN(4096);
84 | _DYNAMIC = .;
85 | .dynamic : { *(.dynamic) }
86 | . = ALIGN(4096);
87 | .rela :
88 | {
89 | *(.rela.text*)
90 | *(.rela.data*)
91 | *(.rela.got)
92 | *(.rela.dyn)
93 | *(.rela.stab)
94 | *(.rela.init_array*)
95 | *(.rela.fini_array*)
96 | *(.rela.ctors*)
97 | *(.rela.dtors*)
98 |
99 | }
100 | . = ALIGN(4096);
101 | .rela.plt : { *(.rela.plt) }
102 | . = ALIGN(4096);
103 | .rodata : { *(.rodata*) }
104 | . = ALIGN(512);
105 | _edata = .;
106 | _data_size = _edata - _data;
107 |
108 | . = ALIGN(4096);
109 | .dynsym : { *(.dynsym) }
110 | . = ALIGN(4096);
111 | .dynstr : { *(.dynstr) }
112 | . = ALIGN(4096);
113 | .note.gnu.build-id : { *(.note.gnu.build-id) }
114 | .ignored.reloc :
115 | {
116 | *(.rela.reloc)
117 | *(.note.GNU-stack)
118 | }
119 | .comment 0 : { *(.comment) }
120 | }
121 |
--------------------------------------------------------------------------------
/gnuefi/elf_ia32_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
2 | OUTPUT_ARCH(i386)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | . = 0;
7 | ImageBase = .;
8 | /* .hash and/or .gnu.hash MUST come first! */
9 | .hash : { *(.hash) }
10 | .gnu.hash : { *(.gnu.hash) }
11 | .eh_frame : { *(.eh_frame) }
12 | .eh_frame_hdr : { *(.eh_frame_hdr) }
13 | .gcc_except_table : { *(.gcc_except_table*) }
14 | . = ALIGN(4096);
15 | .text :
16 | {
17 | _text = .;
18 | *(.text)
19 | *(.text.*)
20 | *(.gnu.linkonce.t.*)
21 | *(.plt)
22 | . = ALIGN(16);
23 | }
24 | _etext = .;
25 | _text_size = _etext - _text;
26 | . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
27 | .data :
28 | {
29 | _data = .;
30 | *(.got.plt)
31 | *(.got)
32 | *(.data)
33 | *(.data1)
34 | *(.data.*)
35 |
36 | /*
37 | * Note that these aren't the using the GNU "CONSTRUCTOR" output section
38 | * command, so they don't start with a size. Because of p2align and the
39 | * end/END definitions, and the fact that they're mergeable, they can also
40 | * have NULLs which aren't guaranteed to be at the end.
41 | */
42 | . = ALIGN(16);
43 | __init_array_start = .;
44 | *(SORT(.init_array.*))
45 | *(.init_array)
46 | __init_array_end = .;
47 | . = ALIGN(16);
48 | __CTOR_LIST__ = .;
49 | *(SORT(.ctors.*))
50 | *(.ctors)
51 | __CTOR_END__ = .;
52 | . = ALIGN(16);
53 | __DTOR_LIST__ = .;
54 | *(SORT(.dtors.*))
55 | *(.dtors)
56 | __DTOR_END__ = .;
57 | . = ALIGN(16);
58 | __fini_array_start = .;
59 | *(SORT(.fini_array.*))
60 | *(.fini_array)
61 | __fini_array_end = .;
62 |
63 | /* the EFI loader doesn't seem to like a .bss section, so we stick
64 | it all into .data: */
65 | *(.dynbss)
66 | *(.bss*)
67 | *(COMMON)
68 | }
69 | .note.gnu.build-id : { *(.note.gnu.build-id) }
70 |
71 | . = ALIGN(4096);
72 | _DYNAMIC = .;
73 | .dynamic : { *(.dynamic) }
74 | . = ALIGN(4096);
75 | .rel :
76 | {
77 | *(.rel.text*)
78 | *(.rel.data*)
79 | *(.rel.got)
80 | *(.rel.dyn)
81 | *(.rel.stab)
82 | *(.rel.init_array*)
83 | *(.rel.fini_array*)
84 | *(.rel.ctors*)
85 | *(.rel.dtors*)
86 | *(.data.rel.ro.local)
87 | *(.data.rel.local)
88 | *(.data.rel.ro)
89 | *(.data.rel*)
90 | }
91 | . = ALIGN(4096);
92 | .rel.plt : { *(.rel.plt) }
93 | . = ALIGN(4096);
94 | .rodata : { *(.rodata*) }
95 | _edata = .;
96 | _data_size = _edata - _etext;
97 | . = ALIGN(4096);
98 | .reloc : /* This is the PECOFF .reloc section! */
99 | {
100 | KEEP (*(.reloc))
101 | }
102 | . = ALIGN(4096);
103 | .dynsym : { *(.dynsym) }
104 | . = ALIGN(4096);
105 | .dynstr : { *(.dynstr) }
106 | . = ALIGN(4096);
107 | . = DATA_SEGMENT_END (.);
108 | /DISCARD/ :
109 | {
110 | *(.rel.reloc)
111 | *(.note.GNU-stack)
112 | }
113 | .comment 0 : { *(.comment) }
114 | }
115 |
--------------------------------------------------------------------------------
/gnuefi/elf_ia32_fbsd_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd")
2 | OUTPUT_ARCH(i386)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | . = 0;
7 | ImageBase = .;
8 | /* .hash and/or .gnu.hash MUST come first! */
9 | .hash : { *(.hash) }
10 | .gnu.hash : { *(.gnu.hash) }
11 | .eh_frame : { *(.eh_frame) }
12 | .eh_frame_hdr : { *(.eh_frame_hdr) }
13 | .gcc_except_table : { *(.gcc_except_table*) }
14 | . = ALIGN(4096);
15 | .text :
16 | {
17 | _text = .;
18 | *(.text)
19 | *(.text.*)
20 | *(.gnu.linkonce.t.*)
21 | *(.plt)
22 | . = ALIGN(16);
23 | }
24 | _etext = .;
25 | _text_size = _etext - _text;
26 | . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
27 | .data :
28 | {
29 | _data = .;
30 | *(.got.plt)
31 | *(.got)
32 | *(.data)
33 | *(.data1)
34 | *(.data.*)
35 |
36 | /*
37 | * Note that these aren't the using the GNU "CONSTRUCTOR" output section
38 | * command, so they don't start with a size. Because of p2align and the
39 | * end/END definitions, and the fact that they're mergeable, they can also
40 | * have NULLs which aren't guaranteed to be at the end.
41 | */
42 | . = ALIGN(16);
43 | __init_array_start = .;
44 | *(SORT(.init_array.*))
45 | *(.init_array)
46 | __init_array_end = .;
47 | . = ALIGN(16);
48 | __CTOR_LIST__ = .;
49 | *(SORT(.ctors.*))
50 | *(.ctors)
51 | __CTOR_END__ = .;
52 | . = ALIGN(16);
53 | __DTOR_LIST__ = .;
54 | *(SORT(.dtors.*))
55 | *(.dtors)
56 | __DTOR_END__ = .;
57 | . = ALIGN(16);
58 | __fini_array_start = .;
59 | *(SORT(.fini_array.*))
60 | *(.fini_array)
61 | __fini_array_end = .;
62 |
63 | /* the EFI loader doesn't seem to like a .bss section, so we stick
64 | it all into .data: */
65 | *(.dynbss)
66 | *(.bss*)
67 | *(COMMON)
68 | }
69 | .note.gnu.build-id : { *(.note.gnu.build-id) }
70 |
71 | . = ALIGN(4096);
72 | _DYNAMIC = .;
73 | .dynamic : { *(.dynamic) }
74 | . = ALIGN(4096);
75 | .rel :
76 | {
77 | *(.rel.text*)
78 | *(.rel.data*)
79 | *(.rel.got)
80 | *(.rel.dyn)
81 | *(.rel.stab)
82 | *(.rel.init_array*)
83 | *(.rel.fini_array*)
84 | *(.rel.ctors*)
85 | *(.rel.dtors*)
86 | *(.data.rel.ro.local)
87 | *(.data.rel.local)
88 | *(.data.rel.ro)
89 | *(.data.rel*)
90 | }
91 | . = ALIGN(4096);
92 | .rel.plt : { *(.rel.plt) }
93 | . = ALIGN(4096);
94 | .rodata : { *(.rodata*) }
95 | _edata = .;
96 | _data_size = _edata - _etext;
97 | . = ALIGN(4096);
98 | .reloc : /* This is the PECOFF .reloc section! */
99 | {
100 | KEEP (*(.reloc))
101 | }
102 | . = ALIGN(4096);
103 | .dynsym : { *(.dynsym) }
104 | . = ALIGN(4096);
105 | .dynstr : { *(.dynstr) }
106 | . = ALIGN(4096);
107 | . = DATA_SEGMENT_END (.);
108 | /DISCARD/ :
109 | {
110 | *(.rel.reloc)
111 | *(.note.GNU-stack)
112 | }
113 | .comment 0 : { *(.comment) }
114 | }
115 |
--------------------------------------------------------------------------------
/gnuefi/elf_loongarch64_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf64-loongarch", "elf64-loongarch", "elf64-loongarch")
2 | OUTPUT_ARCH(loongarch)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | . = 0;
7 | ImageBase = .;
8 | /* .hash and/or .gnu.hash MUST come first! */
9 | .hash : { *(.hash) }
10 | .gnu.hash : { *(.gnu.hash) }
11 | . = ALIGN(4096);
12 | .eh_frame : { *(.eh_frame) }
13 | .eh_frame_hdr : { *(.eh_frame_hdr) }
14 | .gcc_except_table : { *(.gcc_except_table*) }
15 | . = ALIGN(4096);
16 | .text : {
17 | _text = .;
18 | *(.text)
19 | *(.text.*)
20 | *(.gnu.linkonce.t.*)
21 | *(.plt)
22 | . = ALIGN(16);
23 | }
24 | _etext = .;
25 | _text_size = _etext - _text;
26 | . = ALIGN(65536);
27 | _DYNAMIC = .;
28 | .dynamic : { *(.dynamic) }
29 | . = ALIGN(4096);
30 | .data :
31 | {
32 | _data = .;
33 | *(.sdata)
34 | *(.data)
35 | *(.data1)
36 | *(.data.*)
37 | *(.got.plt)
38 | *(.got)
39 |
40 | /*
41 | * Note that these aren't the using the GNU "CONSTRUCTOR" output section
42 | * command, so they don't start with a size. Because of p2align and the
43 | * end/END definitions, and the fact that they're mergeable, they can also
44 | * have NULLs which aren't guaranteed to be at the end.
45 | */
46 | . = ALIGN(16);
47 | __init_array_start = .;
48 | *(SORT(.init_array.*))
49 | *(.init_array)
50 | __init_array_end = .;
51 | . = ALIGN(16);
52 | __CTOR_LIST__ = .;
53 | *(SORT(.ctors.*))
54 | *(.ctors)
55 | __CTOR_END__ = .;
56 | . = ALIGN(16);
57 | __DTOR_LIST__ = .;
58 | *(SORT(.dtors.*))
59 | *(.dtors)
60 | __DTOR_END__ = .;
61 | . = ALIGN(16);
62 | __fini_array_start = .;
63 | *(SORT(.fini_array.*))
64 | *(.fini_array)
65 | __fini_array_end = .;
66 |
67 | /* the EFI loader doesn't seem to like a .bss section, so we stick
68 | it all into .data: */
69 | . = ALIGN(16);
70 | _bss = .;
71 | *(.sbss)
72 | *(.scommon)
73 | *(.dynbss)
74 | *(.bss*)
75 | *(COMMON)
76 | *(.rel.local)
77 | . = ALIGN(16);
78 |
79 | _bss_end = .;
80 | }
81 | . = ALIGN(4096);
82 | .reloc :
83 | {
84 | KEEP (*(.reloc))
85 | }
86 |
87 | . = ALIGN(4096);
88 | .rela :
89 | {
90 | *(.rela.text*)
91 | *(.rela.data*)
92 | *(.rela.got)
93 | *(.rela.dyn)
94 | *(.rela.stab)
95 | *(.rela.init_array*)
96 | *(.rela.fini_array*)
97 | *(.rela.ctors*)
98 | *(.rela.dtors*)
99 |
100 | }
101 | . = ALIGN(4096);
102 | .rela.plt : { *(.rela.plt) }
103 | . = ALIGN(4096);
104 | .rodata : { *(.rodata*) }
105 | . = ALIGN(512);
106 | _edata = .;
107 | _data_size = _edata - _data;
108 |
109 | . = ALIGN(4096);
110 | .dynsym : { *(.dynsym) }
111 | . = ALIGN(4096);
112 | .dynstr : { *(.dynstr) }
113 | . = ALIGN(4096);
114 | .note.gnu.build-id : { *(.note.gnu.build-id) }
115 | .ignored.reloc :
116 | {
117 | *(.rela.reloc)
118 | *(.note.GNU-stack)
119 | }
120 | .comment 0 : { *(.comment) }
121 | }
122 |
--------------------------------------------------------------------------------
/gnuefi/elf_mips64el_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips", "elf64-tradlittlemips")
2 | OUTPUT_ARCH(mips)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | .text 0x0 : {
7 | _text = .;
8 | *(.text.head)
9 | *(.text)
10 | *(.text.*)
11 | *(.gnu.linkonce.t.*)
12 | *(.plt)
13 | . = ALIGN(16);
14 | }
15 | _etext = .;
16 | _text_size = _etext - _text;
17 | . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
18 | _DYNAMIC = .;
19 | .dynamic : { *(.dynamic) }
20 | . = ALIGN(4096);
21 | .data :
22 | {
23 | _data = .;
24 | *(.sdata)
25 | *(.data)
26 | *(.data1)
27 | *(.data.*)
28 | *(.got.plt)
29 | HIDDEN (_gp = ALIGN (16) + 0x7ff0);
30 | *(.got)
31 |
32 | /*
33 | * Note that these aren't the using the GNU "CONSTRUCTOR" output section
34 | * command, so they don't start with a size. Because of p2align and the
35 | * end/END definitions, and the fact that they're mergeable, they can also
36 | * have NULLs which aren't guaranteed to be at the end.
37 | */
38 | . = ALIGN(16);
39 | __init_array_start = .;
40 | *(SORT(.init_array.*))
41 | *(.init_array)
42 | __init_array_end = .;
43 | . = ALIGN(16);
44 | __CTOR_LIST__ = .;
45 | *(SORT(.ctors.*))
46 | *(.ctors)
47 | __CTOR_END__ = .;
48 | . = ALIGN(16);
49 | __DTOR_LIST__ = .;
50 | *(SORT(.dtors.*))
51 | *(.dtors)
52 | __DTOR_END__ = .;
53 | . = ALIGN(16);
54 | __fini_array_start = .;
55 | *(SORT(.fini_array.*))
56 | *(.fini_array)
57 | __fini_array_end = .;
58 |
59 | /* the EFI loader doesn't seem to like a .bss section, so we stick
60 | it all into .data: */
61 | . = ALIGN(16);
62 | _bss = .;
63 | *(.sbss)
64 | *(.scommon)
65 | *(.dynbss)
66 | *(.bss*)
67 | *(COMMON)
68 | . = ALIGN(16);
69 | _bss_end = .;
70 | }
71 |
72 | . = ALIGN(4096);
73 | .rel :
74 | {
75 | *(.rel.text*)
76 | *(.rel.data*)
77 | *(.rel.got)
78 | *(.rel.dyn)
79 | *(.rel.stab)
80 | *(.rel.init_array*)
81 | *(.rel.fini_array*)
82 | *(.rel.ctors*)
83 | *(.rel.dtors*)
84 | }
85 | . = ALIGN(4096);
86 | .rel.plt : { *(.rel.plt) }
87 | . = ALIGN(4096);
88 | .rodata : { *(.rodata*) }
89 | _edata = .;
90 | _data_size = _edata - _etext;
91 |
92 | . = ALIGN(4096);
93 | .dynsym : { *(.dynsym) }
94 | . = ALIGN(4096);
95 | .dynstr : { *(.dynstr) }
96 | . = ALIGN(4096);
97 | .note.gnu.build-id : { *(.note.gnu.build-id) }
98 | . = DATA_SEGMENT_END (.);
99 | /DISCARD/ :
100 | {
101 | *(.rel.reloc)
102 | *(.eh_frame)
103 | *(.MIPS.abiflags)
104 | *(.note.GNU-stack)
105 | }
106 | .comment 0 : { *(.comment) }
107 | }
108 |
--------------------------------------------------------------------------------
/gnuefi/elf_x86_64_efi.lds:
--------------------------------------------------------------------------------
1 | /* Same as elf_x86_64_fbsd_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
2 | OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
3 | OUTPUT_ARCH(i386:x86-64)
4 | ENTRY(_start)
5 | SECTIONS
6 | {
7 | . = 0;
8 | ImageBase = .;
9 | /* .hash and/or .gnu.hash MUST come first! */
10 | .hash : { *(.hash) }
11 | .gnu.hash : { *(.gnu.hash) }
12 | . = ALIGN(4096);
13 | .eh_frame : { *(.eh_frame) }
14 | .eh_frame_hdr : { *(.eh_frame_hdr) }
15 | .gcc_except_table : { *(.gcc_except_table*) }
16 | . = ALIGN(4096);
17 | .text :
18 | {
19 | _text = .;
20 | *(.text)
21 | *(.text.*)
22 | *(.gnu.linkonce.t.*)
23 | *(.plt)
24 | . = ALIGN(16);
25 | }
26 | _etext = .;
27 | _text_size = _etext - _text;
28 |
29 | . = ALIGN(4096);
30 | .data :
31 | {
32 | _data = .;
33 | *(.got.plt)
34 | *(.got)
35 | *(.data*)
36 | *(.sdata)
37 |
38 | /*
39 | * Note that these aren't the using the GNU "CONSTRUCTOR" output section
40 | * command, so they don't start with a size. Because of p2align and the
41 | * end/END definitions, and the fact that they're mergeable, they can also
42 | * have NULLs which aren't guaranteed to be at the end.
43 | */
44 | . = ALIGN(16);
45 | __init_array_start = .;
46 | *(SORT(.init_array.*))
47 | *(.init_array)
48 | __init_array_end = .;
49 | . = ALIGN(16);
50 | __CTOR_LIST__ = .;
51 | *(SORT(.ctors.*))
52 | *(.ctors)
53 | __CTOR_END__ = .;
54 | . = ALIGN(16);
55 | __DTOR_LIST__ = .;
56 | *(SORT(.dtors.*))
57 | *(.dtors)
58 | __DTOR_END__ = .;
59 | . = ALIGN(16);
60 | __fini_array_start = .;
61 | *(SORT(.fini_array.*))
62 | *(.fini_array)
63 | __fini_array_end = .;
64 |
65 | /* the EFI loader doesn't seem to like a .bss section, so we stick
66 | it all into .data: */
67 | *(.sbss)
68 | *(.scommon)
69 | *(.dynbss)
70 | *(.bss*)
71 | *(COMMON)
72 | *(.rel.local)
73 | }
74 | .note.gnu.build-id : { *(.note.gnu.build-id) }
75 |
76 | _edata = .;
77 | _data_size = _edata - _etext;
78 | . = ALIGN(4096);
79 | .reloc :
80 | {
81 | KEEP (*(.reloc))
82 | }
83 | . = ALIGN(4096);
84 | _DYNAMIC = .;
85 | .dynamic : { *(.dynamic) }
86 | . = ALIGN(4096);
87 | .rela :
88 | {
89 | *(.rela.text*)
90 | *(.rela.data*)
91 | *(.rela.got)
92 | *(.rela.dyn)
93 | *(.rela.stab)
94 | *(.rela.init_array*)
95 | *(.rela.fini_array*)
96 | *(.rela.ctors*)
97 | *(.rela.dtors*)
98 | }
99 | . = ALIGN(4096);
100 | .rela.plt : { *(.rela.plt) }
101 | . = ALIGN(4096);
102 | .rodata : { *(.rodata*) }
103 | . = ALIGN(4096);
104 | .dynsym : { *(.dynsym) }
105 | . = ALIGN(4096);
106 | .dynstr : { *(.dynstr) }
107 | . = ALIGN(4096);
108 | .ignored.reloc :
109 | {
110 | *(.rela.reloc)
111 | *(.note.GNU-stack)
112 | }
113 | .comment 0 : { *(.comment) }
114 | }
115 |
--------------------------------------------------------------------------------
/gnuefi/elf_x86_64_fbsd_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
2 | OUTPUT_ARCH(i386:x86-64)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | . = 0;
7 | ImageBase = .;
8 | /* .hash and/or .gnu.hash MUST come first! */
9 | .hash : { *(.hash) }
10 | .gnu.hash : { *(.gnu.hash) }
11 | . = ALIGN(4096);
12 | .eh_frame : { *(.eh_frame) }
13 | .eh_frame_hdr : { *(.eh_frame_hdr) }
14 | .gcc_except_table : { *(.gcc_except_table*) }
15 | . = ALIGN(4096);
16 | .text :
17 | {
18 | _text = .;
19 | *(.text)
20 | *(.text.*)
21 | *(.gnu.linkonce.t.*)
22 | *(.plt)
23 | . = ALIGN(16);
24 | }
25 | _etext = .;
26 | _text_size = _etext - _text;
27 |
28 | . = ALIGN(4096);
29 | .data :
30 | {
31 | _data = .;
32 | *(.got.plt)
33 | *(.got)
34 | *(.data*)
35 | *(.sdata)
36 |
37 | /*
38 | * Note that these aren't the using the GNU "CONSTRUCTOR" output section
39 | * command, so they don't start with a size. Because of p2align and the
40 | * end/END definitions, and the fact that they're mergeable, they can also
41 | * have NULLs which aren't guaranteed to be at the end.
42 | */
43 | . = ALIGN(16);
44 | __init_array_start = .;
45 | *(SORT(.init_array.*))
46 | *(.init_array)
47 | __init_array_end = .;
48 | . = ALIGN(16);
49 | __CTOR_LIST__ = .;
50 | *(SORT(.ctors.*))
51 | *(.ctors)
52 | __CTOR_END__ = .;
53 | . = ALIGN(16);
54 | __DTOR_LIST__ = .;
55 | *(SORT(.dtors.*))
56 | *(.dtors)
57 | __DTOR_END__ = .;
58 | . = ALIGN(16);
59 | __fini_array_start = .;
60 | *(SORT(.fini_array.*))
61 | *(.fini_array)
62 | __fini_array_end = .;
63 |
64 | /* the EFI loader doesn't seem to like a .bss section, so we stick
65 | it all into .data: */
66 | *(.sbss)
67 | *(.scommon)
68 | *(.dynbss)
69 | *(.bss*)
70 | *(COMMON)
71 | *(.rel.local)
72 | }
73 | .note.gnu.build-id : { *(.note.gnu.build-id) }
74 |
75 | _edata = .;
76 | _data_size = _edata - _etext;
77 | . = ALIGN(4096);
78 | .reloc :
79 | {
80 | KEEP (*(.reloc))
81 | }
82 | . = ALIGN(4096);
83 | _DYNAMIC = .;
84 | .dynamic : { *(.dynamic) }
85 | . = ALIGN(4096);
86 | .rela :
87 | {
88 | *(.rela.text*)
89 | *(.rela.data*)
90 | *(.rela.got)
91 | *(.rela.dyn)
92 | *(.rela.stab)
93 | *(.rela.init_array*)
94 | *(.rela.fini_array*)
95 | *(.rela.ctors*)
96 | *(.rela.dtors*)
97 | }
98 | . = ALIGN(4096);
99 | .rela.plt : { *(.rela.plt) }
100 | . = ALIGN(4096);
101 | .rodata : { *(.rodata*) }
102 | . = ALIGN(4096);
103 | .dynsym : { *(.dynsym) }
104 | . = ALIGN(4096);
105 | .dynstr : { *(.dynstr) }
106 | . = ALIGN(4096);
107 | .ignored.reloc :
108 | {
109 | *(.rela.reloc)
110 | *(.note.GNU-stack)
111 | }
112 | .comment 0 : { *(.comment) }
113 | }
114 |
--------------------------------------------------------------------------------
/gnuefi/gnu-efi.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@PREFIX@
2 | exec_prefix=@EXEC_PREFIX@
3 | includedir=@INCLUDEDIR@
4 | libdir=@LIBDIR@
5 | efi_machine_type_name=@efi_machine_type_name@
6 | gnu_efi_arch=@gnu_efi_arch@
7 | gnu_efi_default_is_objcopy=@gnu_efi_default_is_objcopy@
8 |
9 | Name: gnu-efi
10 | Description: EFI development toolkit
11 | Version: @VERSION@
12 | Cflags: -I${includedir}/efi
13 | Libs: -lefi
14 |
--------------------------------------------------------------------------------
/inc/Makefile:
--------------------------------------------------------------------------------
1 | SRCDIR = .
2 |
3 | VPATH = $(SRCDIR)
4 | TOPDIR = $(SRCDIR)/..
5 |
6 | include $(SRCDIR)/../Make.defaults
7 |
8 | all:
9 |
10 | clean:
11 |
12 | install:
13 | mkdir -p $(INSTALLROOT)$(INCLUDEDIR)/efi
14 | mkdir -p $(INSTALLROOT)$(INCLUDEDIR)/efi/protocol
15 | mkdir -p $(INSTALLROOT)$(INCLUDEDIR)/efi/$(ARCH)
16 | $(INSTALL) -m 644 $(SRCDIR)/*.h $(INSTALLROOT)$(INCLUDEDIR)/efi
17 | $(INSTALL) -m 644 $(SRCDIR)/protocol/*.h $(INSTALLROOT)$(INCLUDEDIR)/efi/protocol
18 | $(INSTALL) -m 644 $(SRCDIR)/$(ARCH)/*.h $(INSTALLROOT)$(INCLUDEDIR)/efi/$(ARCH)
19 | ifeq ($(ARCH),ia64)
20 | mkdir -p $(INSTALLROOT)$(INCLUDEDIR)/efi/protocol/ia64
21 | $(INSTALL) -m 644 $(SRCDIR)/protocol/ia64/*.h $(INSTALLROOT)$(INCLUDEDIR)/efi/protocol/ia64
22 | endif
23 |
24 | include $(SRCDIR)/../Make.rules
25 |
--------------------------------------------------------------------------------
/inc/aarch64/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
--------------------------------------------------------------------------------
/inc/aarch64/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_AARCH64_SETJMP_H
2 | #define GNU_EFI_AARCH64_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 8
5 |
6 | typedef struct {
7 | /* GP regs */
8 | UINT64 X19;
9 | UINT64 X20;
10 | UINT64 X21;
11 | UINT64 X22;
12 | UINT64 X23;
13 | UINT64 X24;
14 | UINT64 X25;
15 | UINT64 X26;
16 | UINT64 X27;
17 | UINT64 X28;
18 | UINT64 FP;
19 | UINT64 LR;
20 | UINT64 IP0;
21 | UINT64 _pad1;
22 |
23 | /* FP regs */
24 | UINT64 D8;
25 | UINT64 D9;
26 | UINT64 D10;
27 | UINT64 D11;
28 | UINT64 D12;
29 | UINT64 D13;
30 | UINT64 D14;
31 | UINT64 D15;
32 | } EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
33 |
34 | #endif /* GNU_EFI_AARCH64_SETJMP_H */
35 |
--------------------------------------------------------------------------------
/inc/arm/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
--------------------------------------------------------------------------------
/inc/arm/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_ARM_SETJMP_H
2 | #define GNU_EFI_ARM_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 4
5 |
6 | typedef struct {
7 | UINT32 R3; // A copy of R13
8 | UINT32 R4;
9 | UINT32 R5;
10 | UINT32 R6;
11 | UINT32 R7;
12 | UINT32 R8;
13 | UINT32 R9;
14 | UINT32 R10;
15 | UINT32 R11;
16 | UINT32 R12;
17 | UINT32 R13;
18 | UINT32 R14;
19 | } EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
20 |
21 | #endif /* GNU_EFI_ARM_SETJMP_H */
22 |
--------------------------------------------------------------------------------
/inc/efi.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efi.h
8 |
9 | Abstract:
10 |
11 | Public EFI header files
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 |
20 | // Add a predefined macro to detect usage of the library
21 | #ifndef _GNU_EFI
22 | #define _GNU_EFI
23 | #endif
24 |
25 | //
26 | // Build flags on input
27 | // EFI32
28 | // EFI_DEBUG - Enable debugging code
29 | // EFI_NT_EMULATOR - Building for running under NT
30 | //
31 |
32 |
33 | #ifndef _EFI_INCLUDE_
34 | #define _EFI_INCLUDE_
35 |
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | #if defined(__APPLE__)
41 | #error "Mach-O toolchain isn't supported; please compile with an ELF toolchain from Homebrew"
42 | #endif
43 |
44 | #ifndef _GNU_EFI_4_0
45 | #define _GNU_EFI_4_0
46 | #endif
47 |
48 | #define EFI_FIRMWARE_VENDOR L"INTEL"
49 | #define EFI_FIRMWARE_MAJOR_REVISION 12
50 | #define EFI_FIRMWARE_MINOR_REVISION 33
51 | #define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION))
52 |
53 | #if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__)
54 | #include "x86_64/efibind.h"
55 | #elif defined(_M_IX86) || defined(__i386__)
56 | #include "ia32/efibind.h"
57 | #elif defined(_M_IA64) || defined(__ia64__)
58 | #include "ia64/efibind.h"
59 | #elif defined (_M_ARM64) || defined(__aarch64__)
60 | #include "aarch64/efibind.h"
61 | #elif defined (_M_ARM) || defined(__arm__)
62 | #include "arm/efibind.h"
63 | #elif defined (_M_MIPS64) || defined(__mips64__) || defined(__mips64)
64 | #include "mips64el/efibind.h"
65 | #elif defined (__riscv) && __riscv_xlen == 64
66 | #include "riscv64/efibind.h"
67 | #elif defined (__loongarch64)
68 | #include "loongarch64/efibind.h"
69 | #else
70 | #error Usupported architecture
71 | #endif
72 |
73 | #include "eficompiler.h"
74 | #include "efidef.h"
75 | #include "legacy.h"
76 | #include "efidevp.h"
77 | #include "efipciio.h"
78 | #include "efiprot.h"
79 | #include "eficon.h"
80 | #include "eficonex.h"
81 | #include "efiser.h"
82 | #include "efi_nii.h"
83 | #include "efipxebc.h"
84 | #include "efinet.h"
85 | #include "efiapi.h"
86 | #include "efifs.h"
87 | #include "efierr.h"
88 | #include "efiui.h"
89 | #include "efimp.h"
90 | #include "efiip.h"
91 | #include "efiudp.h"
92 | #include "efitcp.h"
93 | #include "efipoint.h"
94 | #include "efishell.h"
95 |
96 | #ifdef __cplusplus
97 | }
98 | #endif
99 |
100 | #endif
101 |
--------------------------------------------------------------------------------
/inc/efi_nii.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_NII_H
2 | #define _EFI_NII_H
3 |
4 | /*++
5 | Copyright (c) 2000 Intel Corporation
6 |
7 | Module name:
8 | efi_nii.h
9 |
10 | Abstract:
11 |
12 | Revision history:
13 | 2000-Feb-18 M(f)J GUID updated.
14 | Structure order changed for machine word alignment.
15 | Added StringId[4] to structure.
16 |
17 | 2000-Feb-14 M(f)J Genesis.
18 | --*/
19 |
20 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \
21 | { 0xE18541CD, 0xF755, 0x4f73, {0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29} }
22 |
23 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 0x00010000
24 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION
25 |
26 | typedef enum {
27 | EfiNetworkInterfaceUndi = 1
28 | } EFI_NETWORK_INTERFACE_TYPE;
29 |
30 | typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL {
31 |
32 | UINT64 Revision;
33 | // Revision of the network interface identifier protocol interface.
34 |
35 | UINT64 ID;
36 | // Address of the first byte of the identifying structure for this
37 | // network interface. This is set to zero if there is no structure.
38 | //
39 | // For PXE/UNDI this is the first byte of the !PXE structure.
40 |
41 | UINT64 ImageAddr;
42 | // Address of the UNrelocated driver/ROM image. This is set
43 | // to zero if there is no driver/ROM image.
44 | //
45 | // For 16-bit UNDI, this is the first byte of the option ROM in
46 | // upper memory.
47 | //
48 | // For 32/64-bit S/W UNDI, this is the first byte of the EFI ROM
49 | // image.
50 | //
51 | // For H/W UNDI, this is set to zero.
52 |
53 | UINT32 ImageSize;
54 | // Size of the UNrelocated driver/ROM image of this network interface.
55 | // This is set to zero if there is no driver/ROM image.
56 |
57 | CHAR8 StringId[4];
58 | // 4 char ASCII string to go in class identifier (option 60) in DHCP
59 | // and Boot Server discover packets.
60 | // For EfiNetworkInterfaceUndi this field is "UNDI".
61 | // For EfiNetworkInterfaceSnp this field is "SNPN".
62 |
63 | UINT8 Type;
64 | UINT8 MajorVer;
65 | UINT8 MinorVer;
66 | // Information to be placed into the PXE DHCP and Discover packets.
67 | // This is the network interface type and version number that will
68 | // be placed into DHCP option 94 (client network interface identifier).
69 | BOOLEAN Ipv6Supported;
70 | UINT8 IfNum; // interface number to be used with pxeid structure
71 | } EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL, EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE;
72 |
73 | // Note: Because it conflicted with the EDK2 struct name, the
74 | // 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL' GUID definition,
75 | // from older versions of gnu-efi, is now obsoleted.
76 | // Use 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID' instead.
77 |
78 | #endif // _EFI_NII_H
79 |
--------------------------------------------------------------------------------
/inc/eficompiler.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 2016-2024 Pete Batard
4 |
5 | Module Name:
6 |
7 | eficompiler.h
8 |
9 | Abstract:
10 |
11 | Compiler specific adjustments
12 |
13 | --*/
14 |
15 | #if defined(__GNUC__)
16 | #define EFI_UNUSED __attribute__((__unused__))
17 | #else
18 | #define EFI_UNUSED
19 | #endif
20 |
21 | #if defined(__clang__)
22 | #define EFI_NO_TAIL_CALL __attribute__((disable_tail_calls))
23 | #elif defined(__GNUC__)
24 | #define EFI_NO_TAIL_CALL __attribute__((optimize("no-optimize-sibling-calls")))
25 | #else
26 | #define EFI_NO_TAIL_CALL
27 | #endif
28 |
29 | #if defined(__clang__)
30 | #define EFI_OPTNONE __attribute__((optnone))
31 | #elif defined(__GNUC__)
32 | #define EFI_OPTNONE __attribute__((__optimize__("0")))
33 | #else
34 | #define EFI_OPTNONE
35 | #endif
36 |
37 | #if defined(__GNUC__)
38 | #define EFI_ALIGN(x) __attribute__((__aligned__(x)))
39 | #elif defined(_MSC_VER)
40 | #define EFI_ALIGN(x) __declspec(align(x))
41 | #else
42 | // Not being able to align is likely to break executables, so report it
43 | #error "No alignement directive is defined for this platform"
44 | #endif
45 |
46 | #if !defined(ALIGN)
47 | #define ALIGN(x) EFI_ALIGN(x)
48 | #endif
49 |
50 | #if defined(__GNUC__)
51 | #define EFI_NORETURN __attribute__((noreturn))
52 | #elif defined(_MSC_VER)
53 | #define EFI_NORETURN __declspec(noreturn)
54 | #else
55 | #define EFI_NORETURN
56 | #endif
57 |
58 | #if defined(__GNUC__)
59 | #define EFI_NOINLINE __attribute__((noinline))
60 | #elif defined(_MSC_VER)
61 | #define EFI_NOINLINE __declspec(noinline)
62 | #else
63 | #define EFI_NOINLINE
64 | #endif
65 |
66 | /* Also add a catch-all on __attribute__() for MS compilers */
67 | #if defined(_MSC_VER)
68 | #define __attribute__(x)
69 | #endif
70 |
--------------------------------------------------------------------------------
/inc/efierr.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_ERR_H
2 | #define _EFI_ERR_H
3 |
4 | /*++
5 |
6 | Copyright (c) 1998 Intel Corporation
7 |
8 | Module Name:
9 |
10 | efierr.h
11 |
12 | Abstract:
13 |
14 | EFI error codes
15 |
16 |
17 |
18 |
19 | Revision History
20 |
21 | --*/
22 |
23 |
24 | #define EFIWARN(a) (a)
25 | #define EFI_ERROR(a) (((INTN) a) < 0)
26 |
27 |
28 | #define EFI_SUCCESS 0
29 | #define EFI_LOAD_ERROR EFIERR(1)
30 | #define EFI_INVALID_PARAMETER EFIERR(2)
31 | #define EFI_UNSUPPORTED EFIERR(3)
32 | #define EFI_BAD_BUFFER_SIZE EFIERR(4)
33 | #define EFI_BUFFER_TOO_SMALL EFIERR(5)
34 | #define EFI_NOT_READY EFIERR(6)
35 | #define EFI_DEVICE_ERROR EFIERR(7)
36 | #define EFI_WRITE_PROTECTED EFIERR(8)
37 | #define EFI_OUT_OF_RESOURCES EFIERR(9)
38 | #define EFI_VOLUME_CORRUPTED EFIERR(10)
39 | #define EFI_VOLUME_FULL EFIERR(11)
40 | #define EFI_NO_MEDIA EFIERR(12)
41 | #define EFI_MEDIA_CHANGED EFIERR(13)
42 | #define EFI_NOT_FOUND EFIERR(14)
43 | #define EFI_ACCESS_DENIED EFIERR(15)
44 | #define EFI_NO_RESPONSE EFIERR(16)
45 | #define EFI_NO_MAPPING EFIERR(17)
46 | #define EFI_TIMEOUT EFIERR(18)
47 | #define EFI_NOT_STARTED EFIERR(19)
48 | #define EFI_ALREADY_STARTED EFIERR(20)
49 | #define EFI_ABORTED EFIERR(21)
50 | #define EFI_ICMP_ERROR EFIERR(22)
51 | #define EFI_TFTP_ERROR EFIERR(23)
52 | #define EFI_PROTOCOL_ERROR EFIERR(24)
53 | #define EFI_INCOMPATIBLE_VERSION EFIERR(25)
54 | #define EFI_SECURITY_VIOLATION EFIERR(26)
55 | #define EFI_CRC_ERROR EFIERR(27)
56 | #define EFI_END_OF_MEDIA EFIERR(28)
57 | #define EFI_END_OF_FILE EFIERR(31)
58 | #define EFI_INVALID_LANGUAGE EFIERR(32)
59 | #define EFI_COMPROMISED_DATA EFIERR(33)
60 | #define EFI_IP_ADDRESS_CONFLICT EFIERR(34)
61 | #define EFI_HTTP_ERROR EFIERR(35)
62 |
63 | #define EFI_WARN_UNKOWN_GLYPH EFIWARN(1)
64 | #define EFI_WARN_UNKNOWN_GLYPH EFIWARN(1)
65 | #define EFI_WARN_DELETE_FAILURE EFIWARN(2)
66 | #define EFI_WARN_WRITE_FAILURE EFIWARN(3)
67 | #define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4)
68 | #define EFI_WARN_STALE_DATA EFIWARN(5)
69 | #define EFI_WARN_FILE_SYSTEM EFIWARN(6)
70 | #define EFI_WARN_RESET_REQUIRED EFIWARN(7)
71 |
72 | #endif
73 |
74 |
--------------------------------------------------------------------------------
/inc/efigpt.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_GPT_H
2 | #define _EFI_GPT_H
3 | /*++
4 |
5 | Copyright (c) 1998 Intel Corporation
6 |
7 | Module Name:
8 |
9 | EfiGpt.h
10 |
11 | Abstract:
12 | Include file for EFI partitioning scheme
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | #define PRIMARY_PART_HEADER_LBA 1
21 |
22 | typedef struct {
23 | EFI_TABLE_HEADER Header;
24 | EFI_LBA MyLBA;
25 | EFI_LBA AlternateLBA;
26 | EFI_LBA FirstUsableLBA;
27 | EFI_LBA LastUsableLBA;
28 | EFI_GUID DiskGUID;
29 | EFI_LBA PartitionEntryLBA;
30 | UINT32 NumberOfPartitionEntries;
31 | UINT32 SizeOfPartitionEntry;
32 | UINT32 PartitionEntryArrayCRC32;
33 | } EFI_PARTITION_TABLE_HEADER;
34 |
35 | #define EFI_PTAB_HEADER_ID "EFI PART"
36 |
37 | typedef struct {
38 | EFI_GUID PartitionTypeGUID;
39 | EFI_GUID UniquePartitionGUID;
40 | EFI_LBA StartingLBA;
41 | EFI_LBA EndingLBA;
42 | UINT64 Attributes;
43 | CHAR16 PartitionName[36];
44 | } EFI_PARTITION_ENTRY;
45 |
46 | //
47 | // EFI Partition Attributes
48 | //
49 | #define EFI_PART_USED_BY_EFI 0x0000000000000001
50 | #define EFI_PART_REQUIRED_TO_FUNCTION 0x0000000000000002
51 | #define EFI_PART_USED_BY_OS 0x0000000000000004
52 | #define EFI_PART_REQUIRED_BY_OS 0x0000000000000008
53 | #define EFI_PART_BACKUP_REQUIRED 0x0000000000000010
54 | #define EFI_PART_USER_DATA 0x0000000000000020
55 | #define EFI_PART_CRITICAL_USER_DATA 0x0000000000000040
56 | #define EFI_PART_REDUNDANT_PARTITION 0x0000000000000080
57 |
58 | #define EFI_PART_TYPE_UNUSED_GUID \
59 | { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }
60 |
61 | #define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \
62 | { 0xc12a7328, 0xf81f, 0x11d2, {0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} }
63 |
64 | #define EFI_PART_TYPE_LEGACY_MBR_GUID \
65 | { 0x024dee41, 0x33e7, 0x11d3, {0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f} }
66 |
67 | #endif
68 |
69 |
--------------------------------------------------------------------------------
/inc/efipart.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_PART_H
2 | #define _EFI_PART_H
3 |
4 | /*++
5 |
6 | Copyright (c) 1998 Intel Corporation
7 |
8 | Module Name:
9 |
10 | efipart.h
11 |
12 | Abstract:
13 | Info about disk partitions and Master Boot Records
14 |
15 |
16 |
17 |
18 | Revision History
19 |
20 | --*/
21 |
22 | //
23 | //
24 | //
25 |
26 | #define EFI_PARTITION 0xef
27 | #define MBR_SIZE 512
28 |
29 | #pragma pack(1)
30 |
31 | typedef struct {
32 | UINT8 BootIndicator;
33 | UINT8 StartHead;
34 | UINT8 StartSector;
35 | UINT8 StartTrack;
36 | UINT8 OSIndicator;
37 | UINT8 EndHead;
38 | UINT8 EndSector;
39 | UINT8 EndTrack;
40 | UINT8 StartingLBA[4];
41 | UINT8 SizeInLBA[4];
42 | } MBR_PARTITION_RECORD;
43 |
44 | #define EXTRACT_UINT32(D) (UINT32)(D[0] | (D[1] << 8) | (D[2] << 16) | (D[3] << 24))
45 |
46 | #define MBR_SIGNATURE 0xaa55
47 | #define MIN_MBR_DEVICE_SIZE 0x80000
48 | #define MBR_ERRATA_PAD 0x40000 // 128 MB
49 |
50 | #define MAX_MBR_PARTITIONS 4
51 | typedef struct {
52 | UINT8 BootStrapCode[440];
53 | UINT8 UniqueMbrSignature[4];
54 | UINT8 Unknown[2];
55 | MBR_PARTITION_RECORD Partition[MAX_MBR_PARTITIONS];
56 | UINT16 Signature;
57 | } MASTER_BOOT_RECORD;
58 | #pragma pack()
59 |
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/inc/efisetjmp.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_SETJMP_H
2 | #define GNU_EFI_SETJMP_H
3 |
4 | #include "eficompiler.h"
5 | #include "efisetjmp_arch.h"
6 |
7 | extern UINTN setjmp(jmp_buf env) __attribute__((returns_twice));
8 | extern VOID longjmp(jmp_buf env, UINTN value) EFI_NORETURN;
9 |
10 | #endif /* GNU_EFI_SETJMP_H */
11 |
--------------------------------------------------------------------------------
/inc/efishellintf.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | SHELL_INTERFACE_PROTOCOL from EDK shell (no spec).
3 |
4 | Shell Interface - additional information (over image_info) provided
5 | to an application started by the shell.
6 |
7 | ConIo provides a file-style interface to the console.
8 |
9 | The shell interface's and data (including ConIo) are only valid during
10 | the applications Entry Point. Once the application returns from it's
11 | entry point the data is freed by the invoking shell.
12 |
13 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
14 | This program and the accompanying materials
15 | are licensed and made available under the terms and conditions of the BSD License
16 | which accompanies this distribution. The full text of the license may be found at
17 | http://opensource.org/licenses/bsd-license.php
18 |
19 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 |
22 | **/
23 | /*
24 | * This is based on ShellPkg/Include/Protocol/EfiShellInterface.h from EDK II.
25 | */
26 |
27 | #ifndef _SHELLINTERFACE_H_
28 | #define _SHELLINTERFACE_H_
29 |
30 |
31 | #define SHELL_INTERFACE_PROTOCOL_GUID \
32 | { \
33 | 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \
34 | }
35 |
36 | ///
37 | /// Bit definitions for EFI_SHELL_ARG_INFO
38 | ///
39 | typedef enum {
40 | ARG_NO_ATTRIB = 0x0,
41 | ARG_IS_QUOTED = 1<<0,
42 | ARG_PARTIALLY_QUOTED = 1<<1,
43 | ARG_FIRST_HALF_QUOTED = 1<<2,
44 | ARG_FIRST_CHAR_IS_ESC = 1<<3
45 | } EFI_SHELL_ARG_INFO_TYPES;
46 |
47 | ///
48 | /// Attributes for an argument.
49 | ///
50 | typedef struct _EFI_SHELL_ARG_INFO {
51 | UINT32 Attributes;
52 | } EFI_SHELL_ARG_INFO;
53 |
54 | ///
55 | /// This protocol provides access to additional information about a shell application.
56 | ///
57 | typedef struct {
58 | ///
59 | /// Handle back to original image handle & image information.
60 | ///
61 | EFI_HANDLE ImageHandle;
62 | EFI_LOADED_IMAGE *Info;
63 |
64 | ///
65 | /// Parsed arg list converted more C-like format.
66 | ///
67 | CHAR16 **Argv;
68 | UINTN Argc;
69 |
70 | ///
71 | /// Storage for file redirection args after parsing.
72 | ///
73 | CHAR16 **RedirArgv;
74 | UINTN RedirArgc;
75 |
76 | ///
77 | /// A file style handle for console io.
78 | ///
79 | EFI_FILE *StdIn;
80 | EFI_FILE *StdOut;
81 | EFI_FILE *StdErr;
82 |
83 | ///
84 | /// List of attributes for each argument.
85 | ///
86 | EFI_SHELL_ARG_INFO *ArgInfo;
87 |
88 | ///
89 | /// Whether we are echoing.
90 | ///
91 | BOOLEAN EchoOn;
92 | } EFI_SHELL_INTERFACE;
93 |
94 | #endif
95 |
--------------------------------------------------------------------------------
/inc/efistdarg.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFISTDARG_H_
2 | #define _EFISTDARG_H_
3 |
4 | /*++
5 |
6 | Copyright (c) 1998 Intel Corporation
7 |
8 | Module Name:
9 |
10 | devpath.h
11 |
12 | Abstract:
13 |
14 | Defines for parsing the EFI Device Path structures
15 |
16 |
17 |
18 | Revision History
19 |
20 | --*/
21 |
22 | #if !defined(GNU_EFI_USE_EXTERNAL_STDARG) && !defined(_MSC_VER)
23 | typedef __builtin_va_list va_list;
24 |
25 | # define va_start(v,l) __builtin_va_start(v,l)
26 | # define va_end(v) __builtin_va_end(v)
27 | # define va_arg(v,l) __builtin_va_arg(v,l)
28 | # define va_copy(d,s) __builtin_va_copy(d,s)
29 | #else
30 | # include
31 | #endif
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/inc/efiui.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_UI_H
2 | #define _EFI_UI_H
3 |
4 | /*++
5 |
6 | Copyright (c) 200 Intel Corporation
7 |
8 | Module Name:
9 |
10 | EfiUi.h
11 |
12 | Abstract:
13 | Protocol used to build User Interface (UI) stuff.
14 |
15 | This protocol is just data. It is a multi dimentional array.
16 | For each string there is an array of UI_STRING_ENTRY. Each string
17 | is for a different language translation of the same string. The list
18 | is terminated by a NULL UiString. There can be any number of
19 | UI_STRING_ENTRY arrays. A NULL array terminates the list. A NULL array
20 | entry contains all zeros.
21 |
22 | Thus the shortest possible EFI_UI_PROTOCOL has three UI_STRING_ENTRY.
23 | The String, it's NULL terminator, and the NULL terminator for the entire
24 | thing.
25 |
26 |
27 | Revision History
28 |
29 | --*/
30 |
31 | #define EFI_UI_INTERFACE_PROTOCOL_GUID \
32 | { 0x32dd7981, 0x2d27, 0x11d4, {0xbc, 0x8b, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
33 | #define EFI_UI_PROTOCOL EFI_UI_INTERFACE_PROTOCOL_GUID
34 |
35 |
36 | typedef enum {
37 | UiDeviceString,
38 | UiVendorString,
39 | UiMaxString
40 | } UI_STRING_TYPE;
41 |
42 | typedef struct {
43 | ISO_639_2 *LangCode;
44 | CHAR16 *UiString;
45 | } UI_STRING_ENTRY;
46 |
47 | #define EFI_UI_INTERFACE_PROTOCOL_VERSION 0x00010000
48 | #define EFI_UI_VERSION EFI_UI_INTERFACE_PROTOCOL_VERSION
49 |
50 | typedef struct _EFI_UI_INTERFACE_PROTOCOL {
51 | UINT32 Version;
52 | UI_STRING_ENTRY *Entry;
53 | } EFI_UI_INTERFACE_PROTOCOL;
54 |
55 | typedef struct _EFI_UI_INTERFACE_PROTOCOL _UI_INTERFACE;
56 | typedef EFI_UI_INTERFACE_PROTOCOL UI_INTERFACE;
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/inc/ia32/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
27 |
--------------------------------------------------------------------------------
/inc/ia32/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_IA32_SETJMP_H
2 | #define GNU_EFI_IA32_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 4
5 |
6 | typedef struct {
7 | UINT32 Ebx;
8 | UINT32 Esi;
9 | UINT32 Edi;
10 | UINT32 Ebp;
11 | UINT32 Esp;
12 | UINT32 Eip;
13 | } EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
14 |
15 | #endif /* GNU_EFI_IA32_SETJMP_H */
16 |
--------------------------------------------------------------------------------
/inc/ia64/efilibplat.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_LIB_PLAT_H
2 | #define _EFI_LIB_PLAT_H
3 | /*++
4 |
5 | Copyright (c) 1998 Intel Corporation
6 |
7 | Module Name:
8 |
9 | efilibplat.h
10 |
11 | Abstract:
12 |
13 | EFI to compile bindings
14 |
15 |
16 |
17 | Revision History
18 |
19 | --*/
20 |
21 | #include "salproc.h"
22 |
23 |
24 | VOID
25 | InitializeLibPlatform (
26 | IN EFI_HANDLE ImageHandle,
27 | IN EFI_SYSTEM_TABLE *SystemTable
28 | );
29 |
30 | VOID
31 | LibInitSalAndPalProc(
32 | OUT PLABEL *SalPlabel,
33 | OUT UINT64 *PalEntry
34 | );
35 |
36 | EFI_STATUS
37 | LibGetSalIoPortMapping (
38 | OUT UINT64 *IoPortMapping
39 | );
40 |
41 | EFI_STATUS
42 | LibGetSalIpiBlock (
43 | OUT UINT64 *IpiBlock
44 | );
45 |
46 | EFI_STATUS
47 | LibGetSalWakeupVector (
48 | OUT UINT64 *WakeVector
49 | );
50 |
51 | VOID *
52 | LibSearchSalSystemTable (
53 | IN UINT8 EntryType
54 | );
55 |
56 |
57 | VOID
58 | LibSalProc (
59 | IN UINT64 Arg1,
60 | IN UINT64 Arg2,
61 | IN UINT64 Arg3,
62 | IN UINT64 Arg4,
63 | IN UINT64 Arg5,
64 | IN UINT64 Arg6,
65 | IN UINT64 Arg7,
66 | IN UINT64 Arg8,
67 | OUT rArg *Results OPTIONAL
68 | );
69 |
70 | VOID
71 | LibPalProc (
72 | IN UINT64 Arg1,
73 | IN UINT64 Arg2,
74 | IN UINT64 Arg3,
75 | IN UINT64 Arg4,
76 | OUT rArg *Results OPTIONAL
77 | );
78 |
79 | #endif
80 |
81 |
--------------------------------------------------------------------------------
/inc/ia64/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_IA64_SETJMP_H
2 | #define GNU_EFI_IA64_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 0x10
5 |
6 | typedef struct {
7 | UINT64 F2[2];
8 | UINT64 F3[2];
9 | UINT64 F4[2];
10 | UINT64 F5[2];
11 | UINT64 F16[2];
12 | UINT64 F17[2];
13 | UINT64 F18[2];
14 | UINT64 F19[2];
15 | UINT64 F20[2];
16 | UINT64 F21[2];
17 | UINT64 F22[2];
18 | UINT64 F23[2];
19 | UINT64 F24[2];
20 | UINT64 F25[2];
21 | UINT64 F26[2];
22 | UINT64 F27[2];
23 | UINT64 F28[2];
24 | UINT64 F29[2];
25 | UINT64 F30[2];
26 | UINT64 F31[2];
27 | UINT64 R4;
28 | UINT64 R5;
29 | UINT64 R6;
30 | UINT64 R7;
31 | UINT64 SP;
32 | UINT64 BR0;
33 | UINT64 BR1;
34 | UINT64 BR2;
35 | UINT64 BR3;
36 | UINT64 BR4;
37 | UINT64 BR5;
38 | UINT64 InitialUNAT;
39 | UINT64 AfterSpillUNAT;
40 | UINT64 PFS;
41 | UINT64 BSP;
42 | UINT64 Predicates;
43 | UINT64 LoopCount;
44 | UINT64 FPSR;
45 | } EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
46 |
47 | #endif /* GNU_EFI_IA64_SETJMP_H */
48 |
--------------------------------------------------------------------------------
/inc/legacy.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_LEGACY_H
2 | #define _EFI_LEGACY_H
3 |
4 | /*
5 | ABIs:
6 | Default ABI will be highest number
7 | Older versions can be selected via compiler defines
8 | */
9 |
10 | /* Option to set all compat to GNU-EFI 3.0
11 | To keep existing apps working without change
12 | Default to current ABI
13 | */
14 | #ifdef GNU_EFI_3_0_COMPAT
15 | #define GNU_EFI_USE_REALLOCATEPOOL_ABI 0
16 | #define GNU_EFI_USE_COPYMEM_ABI 0
17 | #define GNU_EFI_USE_COMPAREGUID_ABI 0
18 | #endif
19 |
20 | /* ReallocatePool */
21 | #ifndef GNU_EFI_USE_REALLOCATEPOOL_ABI
22 | #define GNU_EFI_USE_REALLOCATEPOOL_ABI 1
23 | #endif
24 |
25 | #if GNU_EFI_USE_REALLOCATEPOOL_ABI == 0
26 | #define ReallocatePool ReallocatePool_0
27 | #else
28 | #define ReallocatePool ReallocatePool_1
29 | #endif
30 |
31 | /* prevent circular headers */
32 | VOID *
33 | EFIAPI
34 | ReallocatePool_1 (
35 | IN UINTN OldSize,
36 | IN UINTN NewSize,
37 | IN VOID *OldPool OPTIONAL
38 | );
39 |
40 | STATIC
41 | inline
42 | VOID *
43 | EFIAPI
44 | ReallocatePool_0 (
45 | IN VOID *OldPool,
46 | IN UINTN OldSize,
47 | IN UINTN NewSize
48 | )
49 | {
50 | return ReallocatePool_1(OldSize, NewSize, OldPool);
51 | }
52 |
53 | /* end ReallocatePool */
54 |
55 | /* CopyMem */
56 | /* CopyMemC isn't deprecated - serves different purpose to CopyMem */
57 |
58 | #ifndef GNU_EFI_USE_COPYMEM_ABI
59 | #define GNU_EFI_USE_COPYMEM_ABI 1
60 | #endif
61 |
62 | #if GNU_EFI_USE_COPYMEM_ABI == 0
63 | #define CopyMem CopyMemC
64 | #else
65 | #define CopyMem CopyMem_1
66 | #endif
67 |
68 | /* end CopyMem */
69 |
70 | /* CompareGuid */
71 |
72 | #ifndef GNU_EFI_USE_COMPAREGUID_ABI
73 | #define GNU_EFI_USE_COMPAREGUID_ABI 1
74 | #endif
75 |
76 | #if GNU_EFI_USE_COMPAREGUID_ABI == 0
77 | #define CompareGuid CompareGuid_0
78 | #else
79 | #define CompareGuid CompareGuid_1
80 | #endif
81 |
82 | /* prevent circular headers */
83 | BOOLEAN
84 | EFIAPI
85 | CompareGuid_1 (
86 | IN CONST EFI_GUID *Guid1,
87 | IN CONST EFI_GUID *Guid2
88 | );
89 |
90 | STATIC
91 | inline
92 | INTN
93 | EFIAPI
94 | CompareGuid_0 (
95 | IN EFI_GUID *Guid1,
96 | IN EFI_GUID *Guid2)
97 | {
98 | if (CompareGuid_1(Guid1, Guid2)) {
99 | return 0;
100 | } else {
101 | return 1;
102 | }
103 | }
104 |
105 | #endif
106 |
--------------------------------------------------------------------------------
/inc/lib.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | lib.h
8 |
9 | Abstract:
10 |
11 | EFI library header files
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 | #ifdef __GNUC__
20 | #pragma GCC visibility push(hidden)
21 | #endif
22 |
23 | #include "efi.h"
24 | #include "efilib.h"
25 | #include "efirtlib.h"
26 |
27 | //
28 | // Include non architectural protocols
29 | //
30 | #include "protocol/efivar.h"
31 | #include "protocol/legacyboot.h"
32 | #include "protocol/intload.h"
33 | #include "protocol/vgaclass.h"
34 | #include "protocol/eficonsplit.h"
35 | #include "protocol/adapterdebug.h"
36 | #include "protocol/intload.h"
37 |
38 | #include "efigpt.h"
39 | #include "libsmbios.h"
40 |
41 | //
42 | // Prototypes
43 | //
44 |
45 | VOID
46 | InitializeGuid (
47 | VOID
48 | );
49 |
50 | INTN EFIAPI
51 | LibStubStriCmp (
52 | IN EFI_UNICODE_COLLATION_INTERFACE *This,
53 | IN CHAR16 *S1,
54 | IN CHAR16 *S2
55 | );
56 |
57 | BOOLEAN EFIAPI
58 | LibStubMetaiMatch (
59 | IN EFI_UNICODE_COLLATION_INTERFACE *This,
60 | IN CHAR16 *String,
61 | IN CHAR16 *Pattern
62 | );
63 |
64 | VOID EFIAPI
65 | LibStubStrLwrUpr (
66 | IN EFI_UNICODE_COLLATION_INTERFACE *This,
67 | IN CHAR16 *Str
68 | );
69 |
70 | BOOLEAN
71 | LibMatchDevicePaths (
72 | IN EFI_DEVICE_PATH *Multi,
73 | IN EFI_DEVICE_PATH *Single
74 | );
75 |
76 | EFI_DEVICE_PATH *
77 | LibDuplicateDevicePathInstance (
78 | IN EFI_DEVICE_PATH *DevPath
79 | );
80 |
81 |
82 | //
83 | // Globals
84 | //
85 | extern BOOLEAN LibInitialized;
86 | extern BOOLEAN LibFwInstance;
87 | extern EFI_HANDLE LibImageHandle;
88 | extern SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut;
89 | extern EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface;
90 | extern EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface;
91 | extern EFI_RAISE_TPL LibRuntimeRaiseTPL;
92 | extern EFI_RESTORE_TPL LibRuntimeRestoreTPL;
93 |
--------------------------------------------------------------------------------
/inc/loongarch64/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
--------------------------------------------------------------------------------
/inc/loongarch64/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_LOONGARCH64_SETJMP_H
2 | #define GNU_EFI_LOONGARCH64_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 8
5 |
6 | typedef struct {
7 | /* GP regs */
8 | UINT64 RA;
9 | UINT64 SP;
10 | UINT64 FP;
11 |
12 | UINT64 S0;
13 | UINT64 S1;
14 | UINT64 S2;
15 | UINT64 S3;
16 | UINT64 S4;
17 | UINT64 S5;
18 | UINT64 S6;
19 | UINT64 S7;
20 | UINT64 S8;
21 | } EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
22 |
23 | #endif /* GNU_EFI_LOONGARCH64_SETJMP_H */
24 |
--------------------------------------------------------------------------------
/inc/mips64el/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
--------------------------------------------------------------------------------
/inc/mips64el/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_MIPS64EL_SETJMP_H
2 | #define GNU_EFI_MIPS64EL_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 8
5 |
6 | typedef struct {
7 | /* GP regs */
8 | UINT64 RA;
9 | UINT64 SP;
10 | UINT64 FP;
11 | UINT64 GP;
12 | UINT64 S0;
13 | UINT64 S1;
14 | UINT64 S2;
15 | UINT64 S3;
16 | UINT64 S4;
17 | UINT64 S5;
18 | UINT64 S6;
19 | UINT64 S7;
20 |
21 | #ifdef __mips_hard_float
22 | /* FP regs */
23 | UINT64 F24;
24 | UINT64 F25;
25 | UINT64 F26;
26 | UINT64 F27;
27 | UINT64 F28;
28 | UINT64 F29;
29 | UINT64 F30;
30 | UINT64 F31;
31 | #endif
32 | } EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
33 |
34 | #endif /* GNU_EFI_MIPS64EL_SETJMP_H */
35 |
--------------------------------------------------------------------------------
/inc/protocol/adapterdebug.h:
--------------------------------------------------------------------------------
1 | #ifndef _ADAPTER_DEBUG_H
2 | #define _ADAPTER_DEBUG_H
3 |
4 | /*++
5 |
6 | Copyright (c) 1999 Intel Corporation
7 |
8 | Module Name:
9 |
10 | AdapterDebug.h
11 |
12 | Abstract:
13 |
14 | Protocol to debug the EDD 3.0 enablement of BIOS option ROMs
15 |
16 |
17 |
18 | Revision History
19 |
20 | --*/
21 |
22 | // {82F86881-282B-11d4-BC7D-0080C73C8881}
23 | #define ADAPTER_DEBUG_PROTOCOL \
24 | { 0x82f86881, 0x282b, 0x11d4, {0xbc, 0x7d, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
25 |
26 | //
27 | // This protocol points to the BIOS_LEGACY_DRIVE data structure
28 | // see edd.h for more details
29 | //
30 |
31 | #endif
32 |
33 |
--------------------------------------------------------------------------------
/inc/protocol/eficonsplit.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_CONFORK_H
2 | #define _EFI_CONFORK_H
3 | /*++
4 |
5 | Copyright (c) 1999 Intel Corporation
6 |
7 | Module Name:
8 |
9 | Abstract:
10 |
11 |
12 |
13 | Revision History
14 |
15 | --*/
16 |
17 |
18 |
19 | //
20 | // ConOut Forker Protocol
21 | //
22 |
23 | #define TEXT_OUT_SPLITER_PROTOCOL \
24 | { 0x56d830a0, 0x7e7a, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
25 |
26 | #define ERROR_OUT_SPLITER_PROTOCOL \
27 | { 0xf0ba9039, 0x68f1, 0x425e, {0xaa, 0x7f, 0xd9, 0xaa, 0xf9, 0x1b, 0x82, 0xa1}}
28 |
29 | #define TEXT_IN_SPLITER_PROTOCOL \
30 | { 0xf9a3c550, 0x7fb5, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/inc/protocol/intload.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1999 Intel Corporation
4 |
5 | Module Name:
6 |
7 | intload
8 |
9 | Abstract:
10 |
11 | EFI support for loading internally linked in apps
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 | #ifndef _INTERNAL_LOAD_INCLUDE_
20 | #define _INTERNAL_LOAD_INCLUDE_
21 |
22 | // {D65A6B8C-71E5-4df0-A909-F0D2992B5AA9}
23 | #define INTERNAL_SHELL_GUID \
24 | { 0xd65a6b8c, 0x71e5, 0x4df0, {0xa9, 0x09, 0xf0, 0xd2, 0x99, 0x2b, 0x5a, 0xa9} }
25 |
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/inc/protocol/make.inf:
--------------------------------------------------------------------------------
1 | #
2 | #
3 | #
4 |
5 | [sources]
6 | efivar.h
7 | legacyboot.h
8 | VgaClass.h
9 | intload.h
10 |
11 | [ia32sources]
12 |
13 | [ia64sources]
14 |
--------------------------------------------------------------------------------
/inc/protocol/makefile.hdr:
--------------------------------------------------------------------------------
1 |
2 | #
3 | # This is a machine generated file - DO NOT EDIT
4 | # Generated by genmake.exe
5 | # Generated from make.inf
6 | # Copyright (c) 1998 Intel Corporation
7 | #
8 |
9 | INC_DEPS = $(INC_DEPS) \
10 | $(SDK_INSTALL_DIR)\include\efi\protocol\efivar.h \
11 | $(SDK_INSTALL_DIR)\include\efi\protocol\legacyboot.h \
12 | $(SDK_INSTALL_DIR)\include\efi\protocol\vgaclass.h \
13 | $(SDK_INSTALL_DIR)\include\efi\protocol\efidbg.h \
14 |
15 |
16 | !IF "$(PROCESSOR)" == "Ia32"
17 | INC_DEPS = $(INC_DEPS) \
18 |
19 |
20 | !ENDIF
21 |
22 |
23 | !IF "$(PROCESSOR)" == "Ia64"
24 | INC_DEPS = $(INC_DEPS) \
25 | $(SDK_INSTALL_DIR)\include\efi\protocol\$(PROCESSOR)\eficontext.h \
26 |
27 |
28 | !ENDIF
29 |
30 |
--------------------------------------------------------------------------------
/inc/protocol/readme.txt:
--------------------------------------------------------------------------------
1 | The protocol directory contains non Architectural
2 | Protocols that span the FW, Platform, or application
3 | space.
--------------------------------------------------------------------------------
/inc/protocol/vgaclass.h:
--------------------------------------------------------------------------------
1 | #ifndef _VGA_CLASS_H
2 | #define _VGA_CLASS_H
3 |
4 | /*++
5 |
6 | Copyright (c) 1999 Intel Corporation
7 |
8 | Module Name:
9 |
10 | VgaClass.h
11 |
12 | Abstract:
13 |
14 | Vga Mini port binding to Vga Class protocol
15 |
16 |
17 |
18 | Revision History
19 |
20 | --*/
21 |
22 | //
23 | // VGA Device Structure
24 | //
25 |
26 | // {0E3D6310-6FE4-11d3-BB81-0080C73C8881}
27 | #define VGA_CLASS_DRIVER_PROTOCOL \
28 | { 0xe3d6310, 0x6fe4, 0x11d3, {0xbb, 0x81, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
29 |
30 | typedef
31 | EFI_STATUS
32 | (* INIT_VGA_CARD) (
33 | IN UINTN VgaMode,
34 | IN VOID *Context
35 | );
36 |
37 | typedef struct {
38 | UINTN MaxColumns;
39 | UINTN MaxRows;
40 | } MAX_CONSOLE_GEOMETRY;
41 |
42 | #define VGA_CON_OUT_DEV_SIGNATURE EFI_SIGNATURE_32('c','v','g','a')
43 | typedef struct {
44 | UINTN Signature;
45 |
46 | EFI_HANDLE Handle;
47 | SIMPLE_TEXT_OUTPUT_INTERFACE ConOut;
48 | SIMPLE_TEXT_OUTPUT_MODE ConOutMode;
49 | EFI_DEVICE_PATH *DevicePath;
50 |
51 | UINT8 *Buffer;
52 | EFI_DEVICE_IO_INTERFACE *DeviceIo;
53 |
54 | //
55 | // Video Card Context
56 | //
57 | INIT_VGA_CARD InitVgaCard;
58 | VOID *VgaCardContext;
59 | MAX_CONSOLE_GEOMETRY *Geometry;
60 | //
61 | // Video buffer normally 0xb8000
62 | //
63 | UINT64 VideoBuffer;
64 |
65 | //
66 | // Clear Screen & Default Attribute
67 | //
68 | UINT32 Attribute;
69 |
70 | //
71 | // -1 means search for active VGA device
72 | //
73 | EFI_PCI_ADDRESS_UNION Pci;
74 | } VGA_CON_OUT_DEV;
75 |
76 | #define VGA_CON_OUT_DEV_FROM_THIS(a) CR(a, VGA_CON_OUT_DEV, ConOut, VGA_CON_OUT_DEV_SIGNATURE)
77 |
78 | //
79 | // Vga Class Driver Protocol.
80 | // GUID defined in EFI Lib
81 | //
82 |
83 | typedef
84 | EFI_STATUS
85 | (EFIAPI *INSTALL_VGA_DRIVER) (
86 | IN VGA_CON_OUT_DEV *ConOutDev
87 | );
88 |
89 | typedef struct {
90 | UINT32 Version;
91 | INSTALL_VGA_DRIVER InstallGenericVgaDriver;
92 | } INSTALL_VGA_DRIVER_INTERFACE;
93 |
94 | #endif
95 |
96 |
--------------------------------------------------------------------------------
/inc/riscv64/efilibplat.h:
--------------------------------------------------------------------------------
1 | /* SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause */
2 |
3 | VOID
4 | InitializeLibPlatform (
5 | IN EFI_HANDLE ImageHandle,
6 | IN EFI_SYSTEM_TABLE *SystemTable
7 | );
8 |
--------------------------------------------------------------------------------
/inc/riscv64/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | /* SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause */
2 |
3 | #ifndef GNU_EFI_RISCV64_SETJMP_H
4 | #define GNU_EFI_RISCV64_SETJMP_H
5 |
6 | #define JMPBUF_ALIGN 8
7 |
8 | typedef struct {
9 | /* GP regs */
10 | UINT64 s0;
11 | UINT64 s1;
12 | UINT64 s2;
13 | UINT64 s3;
14 | UINT64 s4;
15 | UINT64 s5;
16 | UINT64 s6;
17 | UINT64 s7;
18 | UINT64 s8;
19 | UINT64 s9;
20 | UINT64 s10;
21 | UINT64 s11;
22 | UINT64 sp;
23 | UINT64 ra;
24 |
25 | /* FP regs */
26 | UINT64 fs0;
27 | UINT64 fs1;
28 | UINT64 fs2;
29 | UINT64 fs3;
30 | UINT64 fs4;
31 | UINT64 fs5;
32 | UINT64 fs6;
33 | UINT64 fs7;
34 | UINT64 fs8;
35 | UINT64 fs9;
36 | UINT64 fs10;
37 | UINT64 fs11;
38 | } EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
39 |
40 | #endif /* GNU_EFI_RISCV64_SETJMP_H */
41 |
--------------------------------------------------------------------------------
/inc/romload.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_ROMLOAD_H
2 | #define _EFI_ROMLOAD_H
3 |
4 | #define ROM_SIGNATURE 0xaa55
5 | #define PCIDS_SIGNATURE "PCIR"
6 | #pragma pack(push)
7 | #pragma pack(1)
8 | typedef struct
9 | {
10 | UINT8 Pcids_Sig[4];
11 | UINT16 VendId;
12 | UINT16 DevId;
13 | UINT16 Vpd_Off;
14 | UINT16 Size;
15 | UINT8 Rev;
16 | UINT8 Class_Code[3];
17 | UINT16 Image_Len;
18 | UINT16 Rev_Lvl;
19 | UINT8 Code_Type;
20 | UINT8 Indi;
21 | UINT16 Rsvd;
22 | }PciDataStructure;
23 | typedef struct
24 | {
25 | UINT16 Size;
26 | UINT32 Header_Sig;
27 | UINT16 SubSystem;
28 | UINT16 MachineType;
29 | UINT8 Resvd[10];
30 | UINT16 EfiOffset;
31 | }ArchData;
32 | typedef struct
33 | {
34 | UINT16 Rom_Sig;
35 | ArchData Arch_Data;
36 | UINT16 Pcids_Off;
37 | UINT8 resvd[38];
38 | }RomHeader;
39 | #pragma pack(pop)
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/inc/subst/elf.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2024 GNU-EFI Contributors
2 |
3 | This library is free software;
4 | you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation;
5 | either version 2.1 of the License, or (at your option) any later version.
6 | This library is distributed in the hope that it will be useful,
7 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 | See the GNU Lesser General Public License for more details.
9 |
10 | You should have received a copy of the GNU Lesser General Public License along with this library;
11 | if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
12 | */
13 |
14 | #if !defined(__GNU_EFI_NO_GLIBC)
15 | #include
16 |
17 | #else
18 |
19 | typedef uint32_t Elf32_Addr;
20 | typedef int32_t Elf32_Sword;
21 | typedef uint32_t Elf32_Word;
22 |
23 | typedef uint64_t Elf64_Addr;
24 | typedef int64_t Elf64_Sxword;
25 | typedef uint64_t Elf64_Xword;
26 |
27 |
28 | typedef struct {
29 | Elf32_Addr r_offset;
30 | Elf32_Word r_info;
31 | } Elf32_Rel;
32 |
33 | typedef struct {
34 | Elf64_Addr r_offset;
35 | Elf64_Xword r_info;
36 | Elf64_Sxword r_addend;
37 | } Elf64_Rela;
38 |
39 | typedef struct {
40 | Elf32_Sword d_tag;
41 | union {
42 | Elf32_Word d_val;
43 | Elf32_Addr d_ptr;
44 | } d_un;
45 | } Elf32_Dyn;
46 |
47 | typedef struct {
48 | Elf64_Sxword d_tag;
49 | union {
50 | Elf64_Xword d_val;
51 | Elf64_Addr d_ptr;
52 | } d_un;
53 | } Elf64_Dyn;
54 |
55 | #define ELF32_R_TYPE(val) ((val) & 0xff)
56 | #define ELF64_R_TYPE(i) ((i) & 0xffffffff)
57 |
58 | #define DT_NULL 0
59 | #define DT_REL 17
60 | #define DT_RELSZ 18
61 | #define DT_RELENT 19
62 | #define DT_RELA 7
63 | #define DT_RELASZ 8
64 | #define DT_RELAENT 9
65 | #define DT_PLTGOT 3
66 |
67 |
68 | #define R_AARCH64_NONE 0
69 | #define R_AARCH64_RELATIVE 1027
70 | #define R_RISCV_RELATIVE 3
71 | #define R_LARCH_NONE 0
72 | #define R_LARCH_RELATIVE 3
73 | #define R_X86_64_NONE 0
74 | #define R_X86_64_RELATIVE 8
75 | #define R_ARM_NONE 0
76 | #define R_ARM_RELATIVE 23
77 | #define R_386_NONE 0
78 | #define R_386_RELATIVE 8
79 | #define R_MIPS_NONE 0
80 | #define R_MIPS_64 18
81 | #define R_MIPS_REL32 3
82 |
83 |
84 | #endif
85 |
--------------------------------------------------------------------------------
/inc/x86_64/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
27 |
--------------------------------------------------------------------------------
/inc/x86_64/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_X86_64_SETJMP_H
2 | #define GNU_EFI_X86_64_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 8
5 |
6 | typedef struct {
7 | UINT64 Rbx;
8 | UINT64 Rsp;
9 | UINT64 Rbp;
10 |
11 | UINT64 Rdi;
12 | UINT64 Rsi;
13 | UINT64 R12;
14 | UINT64 R13;
15 | UINT64 R14;
16 | UINT64 R15;
17 | UINT64 Rip;
18 | UINT64 MxCsr;
19 | UINT8 XmmBuffer[160]; // XMM6 - XMM15
20 | } EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
21 |
22 | #endif /* GNU_EFI_X86_64_SETJMP_H */
23 |
--------------------------------------------------------------------------------
/lib/aarch64/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 |
3 | #if defined(__ELF__) && defined(__linux__)
4 | .section .note.GNU-stack,"",%progbits
5 | #endif
6 |
--------------------------------------------------------------------------------
/lib/aarch64/initplat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
--------------------------------------------------------------------------------
/lib/aarch64/math.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | UINT64
21 | LShiftU64 (
22 | IN UINT64 Operand,
23 | IN UINTN Count
24 | )
25 | // Left shift 64bit by 32bit and get a 64bit result
26 | {
27 | return Operand << Count;
28 | }
29 |
30 | UINT64
31 | RShiftU64 (
32 | IN UINT64 Operand,
33 | IN UINTN Count
34 | )
35 | // Right shift 64bit by 32bit and get a 64bit result
36 | {
37 | return Operand >> Count;
38 | }
39 |
40 |
41 | UINT64
42 | MultU64x32 (
43 | IN UINT64 Multiplicand,
44 | IN UINTN Multiplier
45 | )
46 | // Multiple 64bit by 32bit and get a 64bit result
47 | {
48 | return Multiplicand * Multiplier;
49 | }
50 |
51 | UINT64
52 | DivU64x32 (
53 | IN UINT64 Dividend,
54 | IN UINTN Divisor,
55 | OUT UINTN *Remainder OPTIONAL
56 | )
57 | // divide 64bit by 32bit and get a 64bit result
58 | // N.B. only works for 31bit divisors!!
59 | {
60 | if (Remainder)
61 | *Remainder = Dividend % Divisor;
62 | return Dividend / Divisor;
63 | }
64 |
--------------------------------------------------------------------------------
/lib/aarch64/setjmp.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 | * This program and the accompanying materials are licensed and made
4 | available
5 | * under the terms and conditions of the BSD License which accompanies
6 | this
7 | * distribution. The full text of the license may be found at
8 | * http://opensource.org/licenses/bsd-license.php.
9 | *
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
11 | BASIS,
12 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
13 | * IMPLIED.
14 | */
15 | .text
16 | .p2align 3
17 |
18 | #define GPR_LAYOUT \
19 | REG_PAIR (x19, x20, 0); \
20 | REG_PAIR (x21, x22, 16); \
21 | REG_PAIR (x23, x24, 32); \
22 | REG_PAIR (x25, x26, 48); \
23 | REG_PAIR (x27, x28, 64); \
24 | REG_PAIR (x29, x30, 80); \
25 | REG_ONE (x16, 96)
26 |
27 | #define FPR_LAYOUT \
28 | REG_PAIR(d8, d9, 112); \
29 | REG_PAIR(d10, d11, 128); \
30 | REG_PAIR(d12, d13, 144); \
31 | REG_PAIR(d14, d15, 160);
32 |
33 | #define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]
34 | #define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]
35 |
36 | .globl setjmp
37 | .type setjmp, @function
38 | setjmp:
39 | mov x16, sp
40 | GPR_LAYOUT
41 | FPR_LAYOUT
42 | mov w0, #0
43 | ret
44 |
45 | #undef REG_PAIR
46 | #undef REG_ONE
47 |
48 | #define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]
49 | #define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]
50 |
51 | .globl longjmp
52 | .type longjmp, @function
53 | longjmp:
54 | GPR_LAYOUT
55 | FPR_LAYOUT
56 | mov sp, x16
57 | cmp w1, #0
58 | mov w0, #1
59 | csel w0, w1, w0, ne
60 | br x30
61 |
62 | #if defined(__ELF__) && defined(__linux__)
63 | .section .note.GNU-stack,"",%progbits
64 | #endif
65 |
--------------------------------------------------------------------------------
/lib/arm/edk2asm.h:
--------------------------------------------------------------------------------
1 |
2 | #define ASM_PFX(x) x
3 | #define GCC_ASM_EXPORT(x) \
4 | .globl x ; \
5 | .type x, %function
6 |
7 |
--------------------------------------------------------------------------------
/lib/arm/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 |
3 | #if defined(__ELF__) && defined(__linux__)
4 | .section .note.GNU-stack,"",%progbits
5 | #endif
6 |
--------------------------------------------------------------------------------
/lib/arm/initplat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
28 | #ifdef __GNUC__
29 | void __div0(void)
30 | {
31 | // TODO handle divide by zero fault
32 | while (1);
33 | }
34 | #endif
35 |
--------------------------------------------------------------------------------
/lib/arm/ldivmod.S:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
4 | //
5 | // This program and the accompanying materials
6 | // are licensed and made available under the terms and conditions of the BSD License
7 | // which accompanies this distribution. The full text of the license may be found at
8 | // http://opensource.org/licenses/bsd-license.php
9 | //
10 | // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 | //
13 | //------------------------------------------------------------------------------
14 |
15 |
16 | #include "edk2asm.h"
17 |
18 | .text
19 | .align 2
20 | GCC_ASM_EXPORT(__aeabi_ldivmod)
21 |
22 | //
23 | // A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}},
24 | // the quotient in {r0, r1}, and the remainder in {r2, r3}.
25 | //
26 | //__value_in_regs lldiv_t
27 | //EFIAPI
28 | //__aeabi_ldivmod (
29 | // IN UINT64 Dividen
30 | // IN UINT64 Divisor
31 | // )//
32 | //
33 |
34 | ASM_PFX(__aeabi_ldivmod):
35 | push {r4,lr}
36 | asrs r4,r1,#1
37 | eor r4,r4,r3,LSR #1
38 | bpl L_Test1
39 | rsbs r0,r0,#0
40 | rsc r1,r1,#0
41 | L_Test1:
42 | tst r3,r3
43 | bpl L_Test2
44 | rsbs r2,r2,#0
45 | rsc r3,r3,#0
46 | L_Test2:
47 | bl ASM_PFX(__aeabi_uldivmod)
48 | tst r4,#0x40000000
49 | beq L_Test3
50 | rsbs r0,r0,#0
51 | rsc r1,r1,#0
52 | L_Test3:
53 | tst r4,#0x80000000
54 | beq L_Exit
55 | rsbs r2,r2,#0
56 | rsc r3,r3,#0
57 | L_Exit:
58 | pop {r4,pc}
59 |
60 | #if defined(__ELF__) && defined(__linux__)
61 | .section .note.GNU-stack,"",%progbits
62 | #endif
63 |
--------------------------------------------------------------------------------
/lib/arm/llsl.S:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | #
3 | # Copyright (c) 2013, ARM. All rights reserved.
4 | #
5 | # This program and the accompanying materials
6 | # are licensed and made available under the terms and conditions of the BSD License
7 | # which accompanies this distribution. The full text of the license may be found at
8 | # http://opensource.org/licenses/bsd-license.php
9 | #
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 | #
13 | #------------------------------------------------------------------------------
14 |
15 | #include "edk2asm.h"
16 |
17 | .text
18 | .align 2
19 | GCC_ASM_EXPORT(__aeabi_llsl)
20 |
21 | #
22 | #VOID
23 | #EFIAPI
24 | #__aeabi_llsl (
25 | # IN VOID *Destination,
26 | # IN VOID *Source,
27 | # IN UINT32 Size
28 | # );
29 | #
30 | ASM_PFX(__aeabi_llsl):
31 | subs r3,r2,#0x20
32 | bpl 1f
33 | rsb r3,r2,#0x20
34 | lsl r1,r1,r2
35 | orr r1,r1,r0,lsr r3
36 | lsl r0,r0,r2
37 | bx lr
38 | 1:
39 | lsl r1,r0,r3
40 | mov r0,#0
41 | bx lr
42 |
43 | #if defined(__ELF__) && defined(__linux__)
44 | .section .note.GNU-stack,"",%progbits
45 | #endif
46 |
--------------------------------------------------------------------------------
/lib/arm/llsr.S:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | #
3 | # Copyright (c) 2013, ARM. All rights reserved.
4 | #
5 | # This program and the accompanying materials
6 | # are licensed and made available under the terms and conditions of the BSD License
7 | # which accompanies this distribution. The full text of the license may be found at
8 | # http://opensource.org/licenses/bsd-license.php
9 | #
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 | #
13 | #------------------------------------------------------------------------------
14 |
15 | #include "edk2asm.h"
16 |
17 | .text
18 | .align 2
19 | GCC_ASM_EXPORT(__aeabi_llsr)
20 |
21 | #
22 | #VOID
23 | #EFIAPI
24 | #__aeabi_llsr (
25 | # IN VOID *Destination,
26 | # IN VOID *Source,
27 | # IN UINT32 Size
28 | # );
29 | #
30 | ASM_PFX(__aeabi_llsr):
31 | subs r3,r2,#0x20
32 | bpl 1f
33 | rsb r3,r2,#0x20
34 | lsr r0,r0,r2
35 | orr r0,r0,r1,lsl r3
36 | lsr r1,r1,r2
37 | bx lr
38 | 1:
39 | lsr r0,r1,r3
40 | mov r1,#0
41 | bx lr
42 |
43 | #if defined(__ELF__) && defined(__linux__)
44 | .section .note.GNU-stack,"",%progbits
45 | #endif
46 |
--------------------------------------------------------------------------------
/lib/arm/math.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | UINT64
21 | LShiftU64 (
22 | IN UINT64 Operand,
23 | IN UINTN Count
24 | )
25 | // Left shift 64bit by 32bit and get a 64bit result
26 | {
27 | return Operand << Count;
28 | }
29 |
30 | UINT64
31 | RShiftU64 (
32 | IN UINT64 Operand,
33 | IN UINTN Count
34 | )
35 | // Right shift 64bit by 32bit and get a 64bit result
36 | {
37 | return Operand >> Count;
38 | }
39 |
40 |
41 | UINT64
42 | MultU64x32 (
43 | IN UINT64 Multiplicand,
44 | IN UINTN Multiplier
45 | )
46 | // Multiply 64bit by 32bit and get a 64bit result
47 | {
48 | return Multiplicand * Multiplier;
49 | }
50 |
51 | UINT64
52 | DivU64x32 (
53 | IN UINT64 Dividend,
54 | IN UINTN Divisor,
55 | OUT UINTN *Remainder OPTIONAL
56 | )
57 | {
58 | /*
59 | * GCC turns a division into a multiplication and shift with precalculated
60 | * constants if the divisor is constant and the dividend fits into a 32 bit
61 | * variable. Otherwise, it will turn this into calls into the 32-bit div
62 | * library functions.
63 | */
64 | if (Remainder)
65 | *Remainder = Dividend % Divisor;
66 | return Dividend / Divisor;
67 | }
68 |
--------------------------------------------------------------------------------
/lib/arm/mullu.S:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | #
3 | # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
4 | #
5 | # This program and the accompanying materials
6 | # are licensed and made available under the terms and conditions of the BSD License
7 | # which accompanies this distribution. The full text of the license may be found at
8 | # http://opensource.org/licenses/bsd-license.php
9 | #
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 | #
13 | #------------------------------------------------------------------------------
14 |
15 | #include "edk2asm.h"
16 |
17 | .text
18 | GCC_ASM_EXPORT(__aeabi_lmul)
19 | #
20 | #INT64
21 | #EFIAPI
22 | #__aeabi_lmul (
23 | # IN INT64 Multiplicand
24 | # IN INT64 Multiplier
25 | # );
26 | #
27 | ASM_PFX(__aeabi_lmul):
28 | stmdb sp!, {lr}
29 | mov lr, r0
30 | umull r0, ip, r2, lr
31 | mla r1, r2, r1, ip
32 | mla r1, r3, lr, r1
33 | ldmia sp!, {pc}
34 |
35 | #if defined(__ELF__) && defined(__linux__)
36 | .section .note.GNU-stack,"",%progbits
37 | #endif
38 |
--------------------------------------------------------------------------------
/lib/arm/setjmp.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 | * This program and the accompanying materials are licensed and made
4 | * available under the terms and conditions of the BSD License which
5 | * accompanies this distribution. The full text of the license may
6 | * be found at http://opensource.org/licenses/bsd-license.php.
7 | *
8 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
9 | * BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
10 | * EXPRESS OR IMPLIED.
11 | */
12 | .text
13 | .arm
14 | .globl setjmp
15 | .type setjmp, %function
16 | setjmp:
17 | mov r3, r13
18 | stmia r0, {r3-r12,r14}
19 | eor r0, r0, r0
20 | bx lr
21 |
22 | .globl longjmp
23 | .type longjmp, %function
24 | longjmp:
25 | ldmia r0, {r3-r12,r14}
26 |
27 | #if defined(__ELF__) && defined(__linux__)
28 | .section .note.GNU-stack,"",%progbits
29 | #endif
30 |
--------------------------------------------------------------------------------
/lib/console.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | console.c
8 |
9 | Abstract:
10 |
11 |
12 |
13 |
14 | Revision History
15 |
16 | --*/
17 |
18 | #include "lib.h"
19 |
20 |
21 |
22 | VOID
23 | Output (
24 | IN CHAR16 *Str
25 | )
26 | // Write a string to the console at the current cursor location
27 | {
28 | uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, Str);
29 | }
30 |
31 |
32 | VOID
33 | Input (
34 | IN CHAR16 *Prompt OPTIONAL,
35 | OUT CHAR16 *InStr,
36 | IN UINTN StrLen
37 | )
38 | // Input a string at the current cursor location, for StrLen
39 | {
40 | IInput (
41 | ST->ConOut,
42 | ST->ConIn,
43 | Prompt,
44 | InStr,
45 | StrLen
46 | );
47 | }
48 |
49 | VOID
50 | IInput (
51 | IN SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut,
52 | IN SIMPLE_INPUT_INTERFACE *ConIn,
53 | IN CHAR16 *Prompt OPTIONAL,
54 | OUT CHAR16 *InStr,
55 | IN UINTN StrLen
56 | )
57 | // Input a string at the current cursor location, for StrLen
58 | {
59 | EFI_INPUT_KEY Key;
60 | EFI_STATUS Status;
61 | UINTN Len;
62 |
63 | if (Prompt) {
64 | ConOut->OutputString (ConOut, Prompt);
65 | }
66 |
67 | Len = 0;
68 | for (; ;) {
69 | WaitForSingleEvent (ConIn->WaitForKey, 0);
70 |
71 | Status = uefi_call_wrapper(ConIn->ReadKeyStroke, 2, ConIn, &Key);
72 | if (EFI_ERROR(Status)) {
73 | DEBUG((D_ERROR, "Input: error return from ReadKey %x\n", Status));
74 | break;
75 | }
76 |
77 | if (Key.UnicodeChar == '\n' ||
78 | Key.UnicodeChar == '\r') {
79 | break;
80 | }
81 |
82 | if (Key.UnicodeChar == '\b') {
83 | if (Len) {
84 | uefi_call_wrapper(ConOut->OutputString, 2, ConOut, u"\b \b");
85 | Len -= 1;
86 | }
87 | continue;
88 | }
89 |
90 | if (Key.UnicodeChar >= ' ') {
91 | if (Len < StrLen-1) {
92 | InStr[Len] = Key.UnicodeChar;
93 |
94 | InStr[Len+1] = 0;
95 | uefi_call_wrapper(ConOut->OutputString, 2, ConOut, &InStr[Len]);
96 |
97 | Len += 1;
98 | }
99 | continue;
100 | }
101 | }
102 |
103 | InStr[Len] = 0;
104 | }
105 |
--------------------------------------------------------------------------------
/lib/ctors.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Try to define the minimal empty init/ctor/dtor/fini_arrays so building with
3 | * older or out-of-tree linker scripts will still work.
4 | */
5 | /*
6 | * Note that these aren't using the GNU "CONSTRUCTOR" output section
7 | * command, so they don't start with a size. Because of p2align and the
8 | * end/END definitions, and the fact that they're mergeable, they can also
9 | * have NULLs which aren't guaranteed to be at the end.
10 | */
11 | #if defined(__ELF__)
12 | .section .init_array,"aw",%init_array
13 | #else
14 | .section .init_array,"aw"
15 | #endif
16 | .p2align 4, 0
17 | .globl __init_array_start
18 | __init_array_start:
19 | .globl __init_array_end
20 | __init_array_end:
21 | #if defined(__ELF__)
22 | .section .ctors,"aw",%progbits
23 | #else
24 | .section .ctors,"aw"
25 | #endif
26 | .p2align 4, 0
27 | .globl __CTOR_LIST__
28 | __CTOR_LIST__:
29 | .globl __CTOR_END__
30 | __CTOR_END__:
31 | #if defined(__ELF__)
32 | .section .dtors,"aw",%progbits
33 | #else
34 | .section .dtors,"aw"
35 | #endif
36 | .p2align 4, 0
37 | .globl __DTOR_LIST__
38 | __DTOR_LIST__:
39 | .globl __DTOR_END__
40 | __DTOR_END__:
41 | #if defined(__ELF__)
42 | .section .fini_array,"aw",%fini_array
43 | #else
44 | .section .fini_array,"aw"
45 | #endif
46 | .p2align 4, 0
47 | .globl __fini_array_start
48 | __fini_array_start:
49 | .globl __fini_array_end
50 | __fini_array_end:
51 |
52 | #if defined(__ELF__) && defined(__linux__)
53 | .section .note.GNU-stack,"",%progbits
54 | #endif
55 |
56 |
--------------------------------------------------------------------------------
/lib/debug.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | debug.c
8 |
9 | Abstract:
10 |
11 | Debug library functions
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 | #include "lib.h"
20 |
21 |
22 |
23 | //
24 | // Declare runtime functions
25 | //
26 |
27 | //
28 | //
29 | //
30 |
31 | INTN
32 | DbgAssert (
33 | IN CONST CHAR8 *FileName,
34 | IN INTN LineNo,
35 | IN CONST CHAR8 *Description
36 | )
37 | {
38 | DbgPrint (D_ERROR, (CHAR8 *)"%EASSERT FAILED: %a(%d): %a%N\n", FileName, LineNo, Description);
39 |
40 | BREAKPOINT();
41 | return 0;
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/lib/entry.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ctors.c
3 | * Copyright 2019 Peter Jones
4 | *
5 | */
6 |
7 | #include
8 | #include
9 |
10 | typedef void (*funcp)(void);
11 |
12 | /*
13 | * Note that these aren't the using the GNU "CONSTRUCTOR" output section
14 | * command, so they don't start with a size. Because of p2align and the
15 | * end/END definitions, and the fact that they're mergeable, they can also
16 | * have NULLs which aren't guaranteed to be at the end.
17 | */
18 | extern funcp __init_array_start[], __init_array_end[];
19 | extern funcp __CTOR_LIST__[], __CTOR_END__[];
20 | extern funcp __fini_array_start[], __fini_array_end[];
21 | extern funcp __DTOR_LIST__[], __DTOR_END__[];
22 |
23 | static void ctors(void)
24 | {
25 | size_t __init_array_length = __init_array_end - __init_array_start;
26 | for (size_t i = 0; i < __init_array_length; i++) {
27 | funcp func = __init_array_start[i];
28 | if (func != NULL)
29 | func();
30 | }
31 |
32 | size_t __CTOR_length = __CTOR_END__ - __CTOR_LIST__;
33 | for (size_t i = 0; i < __CTOR_length; i++) {
34 | size_t current = __CTOR_length - i - 1;
35 | funcp func = __CTOR_LIST__[current];
36 | if (func != NULL)
37 | func();
38 | }
39 | }
40 |
41 | static void dtors(void)
42 | {
43 | size_t __DTOR_length = __DTOR_END__ - __DTOR_LIST__;
44 | for (size_t i = 0; i < __DTOR_length; i++) {
45 | funcp func = __DTOR_LIST__[i];
46 | if (func != NULL)
47 | func();
48 | }
49 |
50 | size_t __fini_array_length = __fini_array_end - __fini_array_start;
51 | for (size_t i = 0; i < __fini_array_length; i++) {
52 | size_t current = __fini_array_length - i - 1;
53 | funcp func = __fini_array_start[current];
54 | if (func != NULL)
55 | func();
56 | }
57 | }
58 |
59 | extern EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab);
60 |
61 | EFI_STATUS _entry(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
62 | {
63 | EFI_STATUS status;
64 | InitializeLib(image, systab);
65 |
66 | ctors();
67 | status = efi_main(image, systab);
68 | dtors();
69 |
70 | return status;
71 | }
72 |
73 | // vim:fenc=utf-8:tw=75:noet
74 |
--------------------------------------------------------------------------------
/lib/exit.c:
--------------------------------------------------------------------------------
1 | #include "lib.h"
2 |
3 | VOID
4 | Exit(
5 | IN EFI_STATUS ExitStatus,
6 | IN UINTN ExitDataSize,
7 | IN CHAR16 *ExitData OPTIONAL
8 | )
9 | {
10 | uefi_call_wrapper(BS->Exit,
11 | 4,
12 | LibImageHandle,
13 | ExitStatus,
14 | ExitDataSize,
15 | ExitData);
16 |
17 | // Uh oh, Exit() returned?!
18 | for (;;) { }
19 | }
20 |
--------------------------------------------------------------------------------
/lib/ia32/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 |
3 | #if defined(__ELF__) && defined(__linux__)
4 | .section .note.GNU-stack,"",%progbits
5 | #endif
6 |
--------------------------------------------------------------------------------
/lib/ia32/initplat.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | initplat.c
8 |
9 | Abstract:
10 |
11 |
12 |
13 |
14 | Revision History
15 |
16 | --*/
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/lib/ia32/setjmp.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 | * This program and the accompanying materials are licensed and made
4 | available
5 | * under the terms and conditions of the BSD License which accompanies
6 | this
7 | * distribution. The full text of the license may be found at
8 | * http://opensource.org/licenses/bsd-license.php.
9 | *
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
11 | BASIS,
12 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
13 | * IMPLIED.
14 | */
15 | .text
16 | .globl setjmp
17 | #ifndef __MINGW32__
18 | .type setjmp, @function
19 | #else
20 | .def setjmp; .scl 2; .type 32; .endef
21 | #endif
22 | setjmp:
23 | pop %ecx
24 | movl (%esp), %edx
25 | movl %ebx, (%edx)
26 | movl %esi, 4(%edx)
27 | movl %edi, 8(%edx)
28 | movl %ebp, 12(%edx)
29 | movl %esp, 16(%edx)
30 | xorl %eax, %eax
31 | jmp *%ecx
32 |
33 | .globl longjmp
34 | #ifndef __MINGW32__
35 | .type longjmp, @function
36 | #else
37 | .def longjmp; .scl 2; .type 32; .endef
38 | #endif
39 | longjmp:
40 | pop %eax
41 | pop %edx
42 | pop %eax
43 | movl (%edx), %ebx
44 | movl 4(%edx), %esi
45 | movl 8(%edx), %edi
46 |
47 | #if defined(__ELF__) && defined(__linux__)
48 | .section .note.GNU-stack,"",%progbits
49 | #endif
50 |
--------------------------------------------------------------------------------
/lib/ia64/initplat.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1999 Intel Corporation
4 |
5 | Module Name:
6 |
7 | initplat.c
8 |
9 | Abstract:
10 |
11 | Functions to make SAL and PAL proc calls
12 |
13 | Revision History
14 |
15 | --*/
16 | #include "lib.h"
17 |
18 | //#include "palproc.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | PLABEL SalPlabel;
27 | UINT64 PalEntry;
28 |
29 | LibInitSalAndPalProc (&SalPlabel, &PalEntry);
30 | }
31 |
--------------------------------------------------------------------------------
/lib/ia64/math.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | math.c
8 |
9 | Abstract:
10 |
11 |
12 |
13 |
14 | Revision History
15 |
16 | --*/
17 |
18 | #include "lib.h"
19 |
20 |
21 | //
22 | // Declare runtime functions
23 | //
24 |
25 | #ifdef RUNTIME_CODE
26 | #ifndef __GNUC__
27 | #pragma RUNTIME_CODE(LShiftU64)
28 | #pragma RUNTIME_CODE(RShiftU64)
29 | #pragma RUNTIME_CODE(MultU64x32)
30 | #pragma RUNTIME_CODE(DivU64x32)
31 | #endif
32 | #endif
33 |
34 | //
35 | //
36 | //
37 |
38 |
39 |
40 |
41 | UINT64
42 | LShiftU64 (
43 | IN UINT64 Operand,
44 | IN UINTN Count
45 | )
46 | // Left shift 64bit by 32bit and get a 64bit result
47 | {
48 | return Operand << Count;
49 | }
50 |
51 | UINT64
52 | RShiftU64 (
53 | IN UINT64 Operand,
54 | IN UINTN Count
55 | )
56 | // Right shift 64bit by 32bit and get a 64bit result
57 | {
58 | return Operand >> Count;
59 | }
60 |
61 |
62 | UINT64
63 | MultU64x32 (
64 | IN UINT64 Multiplicand,
65 | IN UINTN Multiplier
66 | )
67 | // Multiple 64bit by 32bit and get a 64bit result
68 | {
69 | return Multiplicand * Multiplier;
70 | }
71 |
72 | UINT64
73 | DivU64x32 (
74 | IN UINT64 Dividend,
75 | IN UINTN Divisor,
76 | OUT UINTN *Remainder OPTIONAL
77 | )
78 | // divide 64bit by 32bit and get a 64bit result
79 | // N.B. only works for 31bit divisors!!
80 | {
81 | ASSERT (Divisor != 0);
82 |
83 | if (Remainder) {
84 | *Remainder = Dividend % Divisor;
85 | }
86 |
87 | return Dividend / Divisor;
88 | }
89 |
--------------------------------------------------------------------------------
/lib/ia64/palproc.h:
--------------------------------------------------------------------------------
1 | //
2 | //
3 | // Copyright (c) 1996-99 Intel Corp.
4 | //
5 | //
6 | //Module Name:
7 | //
8 | // palproc.h
9 | //
10 | //Abstract:
11 | //
12 | // This module contains generic macros for an IA64 assembly writer.
13 | //
14 | //
15 | //Revision History
16 | //
17 |
18 | #ifndef _PALPROC_H
19 | #define _PALPROC_H
20 |
21 | #define PROCEDURE_ENTRY(name) .##text; \
22 | .##type name, @function; \
23 | .##global name; \
24 | .##proc name; \
25 | name:
26 |
27 | #define PROCEDURE_EXIT(name) .##endp name
28 |
29 | // Note: use of NESTED_SETUP requires number of locals (l) >= 3
30 |
31 | #define NESTED_SETUP(i,l,o,r) \
32 | alloc loc1=ar##.##pfs,i,l,o,r ;\
33 | mov loc0=b0
34 |
35 | #define NESTED_RETURN \
36 | mov b0=loc0 ;\
37 | mov ar##.##pfs=loc1 ;;\
38 | br##.##ret##.##dpnt b0;;
39 |
40 |
41 | // defines needed in palproc.s
42 |
43 | #define PAL_MC_CLEAR_LOG 0x0015
44 | #define PAL_MC_DRAIN 0x0016
45 | #define PAL_MC_EXPECTED 0x0017
46 | #define PAL_MC_DYNAMIC_STATE 0x0018
47 | #define PAL_MC_ERROR_INFO 0x0019
48 | #define PAL_MC_RESUME 0x001a
49 | #define PAL_MC_REGISTER_MEM 0x001b
50 |
51 | #endif // _PALPROC_H
52 |
--------------------------------------------------------------------------------
/lib/lock.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | lock.c
8 |
9 | Abstract:
10 |
11 | Implements FLOCK
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 |
20 | #include "lib.h"
21 |
22 |
23 | VOID
24 | InitializeLock (
25 | IN OUT FLOCK *Lock,
26 | IN EFI_TPL Priority
27 | )
28 | /*++
29 |
30 | Routine Description:
31 |
32 | Initialize a basic mutual exclusion lock. Each lock
33 | provides mutual exclusion access at it's task priority
34 | level. Since there is no-premption (at any TPL) or
35 | multiprocessor support, acquiring the lock only consists
36 | of raising to the locks TPL.
37 |
38 | Note on a debug build the lock is acquired and released
39 | to help ensure proper usage.
40 |
41 | Arguments:
42 |
43 | Lock - The FLOCK structure to initialize
44 |
45 | Priority - The task priority level of the lock
46 |
47 |
48 | Returns:
49 |
50 | An initialized F Lock structure.
51 |
52 | --*/
53 | {
54 | Lock->Tpl = Priority;
55 | Lock->OwnerTpl = 0;
56 | Lock->Lock = 0;
57 | }
58 |
59 |
60 | VOID
61 | AcquireLock (
62 | IN FLOCK *Lock
63 | )
64 | /*++
65 |
66 | Routine Description:
67 |
68 | Raising to the task priority level of the mutual exclusion
69 | lock, and then acquires ownership of the lock.
70 |
71 | Arguments:
72 |
73 | Lock - The lock to acquire
74 |
75 | Returns:
76 |
77 | Lock owned
78 |
79 | --*/
80 | {
81 | RtAcquireLock (Lock);
82 | }
83 |
84 |
85 | VOID
86 | ReleaseLock (
87 | IN FLOCK *Lock
88 | )
89 | /*++
90 |
91 | Routine Description:
92 |
93 | Releases ownership of the mutual exclusion lock, and
94 | restores the previous task priority level.
95 |
96 | Arguments:
97 |
98 | Lock - The lock to release
99 |
100 | Returns:
101 |
102 | Lock unowned
103 |
104 | --*/
105 | {
106 | RtReleaseLock (Lock);
107 | }
108 |
--------------------------------------------------------------------------------
/lib/loongarch64/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 | #if defined(__ELF__) && defined(__linux__)
3 | .section .note.GNU-stack,"",%progbits
4 | #endif
5 |
--------------------------------------------------------------------------------
/lib/loongarch64/initplat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
--------------------------------------------------------------------------------
/lib/loongarch64/math.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | UINT64
21 | LShiftU64 (
22 | IN UINT64 Operand,
23 | IN UINTN Count
24 | )
25 | // Left shift 64bit by 32bit and get a 64bit result
26 | {
27 | return Operand << Count;
28 | }
29 |
30 | UINT64
31 | RShiftU64 (
32 | IN UINT64 Operand,
33 | IN UINTN Count
34 | )
35 | // Right shift 64bit by 32bit and get a 64bit result
36 | {
37 | return Operand >> Count;
38 | }
39 |
40 |
41 | UINT64
42 | MultU64x32 (
43 | IN UINT64 Multiplicand,
44 | IN UINTN Multiplier
45 | )
46 | // Multiple 64bit by 32bit and get a 64bit result
47 | {
48 | return Multiplicand * Multiplier;
49 | }
50 |
51 | UINT64
52 | DivU64x32 (
53 | IN UINT64 Dividend,
54 | IN UINTN Divisor,
55 | OUT UINTN *Remainder OPTIONAL
56 | )
57 | // divide 64bit by 32bit and get a 64bit result
58 | // N.B. only works for 31bit divisors!!
59 | {
60 | if (Remainder)
61 | *Remainder = Dividend % Divisor;
62 | return Dividend / Divisor;
63 | }
64 |
--------------------------------------------------------------------------------
/lib/loongarch64/setjmp.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 | * Copyright (c) 2021 Loongson Technology Corporation Limited.All rights
4 | * reserved.
5 | * Author: zhoumingtao
6 | *
7 | * This program and the accompanying materials are licensed and made
8 | * available
9 | * under the terms and conditions of the BSD License which accompanies
10 | * this
11 | * distribution. The full text of the license may be found at
12 | * http://opensource.org/licenses/bsd-license.php.
13 | *
14 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
15 | * BASIS,
16 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
17 | * IMPLIED.
18 | */
19 |
20 | .text
21 | .p2align 3
22 |
23 | /*
24 | int setjmp(jmp_buf env);
25 | */
26 | .globl setjmp
27 | .type setjmp, @function
28 | setjmp:
29 | st.d $ra, $a0, 0x0
30 | st.d $sp, $a0, 0x8
31 | st.d $fp, $a0, 0x10
32 | st.d $s0, $a0, 0x18
33 | st.d $s1, $a0, 0x20
34 | st.d $s2, $a0, 0x28
35 | st.d $s3, $a0, 0x30
36 | st.d $s4, $a0, 0x38
37 | st.d $s5, $a0, 0x40
38 | st.d $s6, $a0, 0x48
39 | st.d $s7, $a0, 0x50
40 | st.d $s8, $a0, 0x58
41 |
42 | move $a0, $zero
43 | jr $ra
44 |
45 | /*
46 | void longjmp(jmp_buf env, int val);
47 | */
48 | .globl longjmp
49 | .type longjmp, @function
50 | longjmp:
51 | ld.d $ra, $a0, 0x0
52 | ld.d $sp, $a0, 0x8
53 | ld.d $fp, $a0, 0x10
54 | ld.d $s0, $a0, 0x18
55 | ld.d $s1, $a0, 0x20
56 | ld.d $s2, $a0, 0x28
57 | ld.d $s3, $a0, 0x30
58 | ld.d $s4, $a0, 0x38
59 | ld.d $s5, $a0, 0x40
60 | ld.d $s6, $a0, 0x48
61 | ld.d $s7, $a0, 0x50
62 | ld.d $s8, $a0, 0x58
63 |
64 | addi.d $a0, $zero, 1 # a0 = 1
65 | beqz $a1, .L0 # if (a1 == 0); goto L0
66 | move $a0, $a1 # a0 = a1
67 | .L0:
68 | jr $ra
69 |
--------------------------------------------------------------------------------
/lib/mips64el/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 |
3 | #if defined(__ELF__) && defined(__linux__)
4 | .section .note.GNU-stack,"",%progbits
5 | #endif
6 |
--------------------------------------------------------------------------------
/lib/mips64el/initplat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
--------------------------------------------------------------------------------
/lib/mips64el/math.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | UINT64
21 | LShiftU64 (
22 | IN UINT64 Operand,
23 | IN UINTN Count
24 | )
25 | // Left shift 64bit by 32bit and get a 64bit result
26 | {
27 | return Operand << Count;
28 | }
29 |
30 | UINT64
31 | RShiftU64 (
32 | IN UINT64 Operand,
33 | IN UINTN Count
34 | )
35 | // Right shift 64bit by 32bit and get a 64bit result
36 | {
37 | return Operand >> Count;
38 | }
39 |
40 |
41 | UINT64
42 | MultU64x32 (
43 | IN UINT64 Multiplicand,
44 | IN UINTN Multiplier
45 | )
46 | // Multiple 64bit by 32bit and get a 64bit result
47 | {
48 | return Multiplicand * Multiplier;
49 | }
50 |
51 | UINT64
52 | DivU64x32 (
53 | IN UINT64 Dividend,
54 | IN UINTN Divisor,
55 | OUT UINTN *Remainder OPTIONAL
56 | )
57 | // divide 64bit by 32bit and get a 64bit result
58 | // N.B. only works for 31bit divisors!!
59 | {
60 | if (Remainder)
61 | *Remainder = Dividend % Divisor;
62 | return Dividend / Divisor;
63 | }
64 |
--------------------------------------------------------------------------------
/lib/mips64el/setjmp.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 | * Copyright (c) 2017 Lemote Co.
4 | * Author: Heiher
5 | *
6 | * This program and the accompanying materials are licensed and made
7 | available
8 | * under the terms and conditions of the BSD License which accompanies
9 | this
10 | * distribution. The full text of the license may be found at
11 | * http://opensource.org/licenses/bsd-license.php.
12 | *
13 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
14 | BASIS,
15 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
16 | * IMPLIED.
17 | */
18 | .text
19 | .p2align 3
20 |
21 | .globl setjmp
22 | .type setjmp, @function
23 | setjmp:
24 | sd $ra, 0x00($a0)
25 | sd $sp, 0x08($a0)
26 | sd $fp, 0x10($a0)
27 | sd $gp, 0x18($a0)
28 |
29 | sd $s0, 0x20($a0)
30 | sd $s1, 0x28($a0)
31 | sd $s2, 0x30($a0)
32 | sd $s3, 0x38($a0)
33 | sd $s4, 0x40($a0)
34 | sd $s5, 0x48($a0)
35 | sd $s6, 0x50($a0)
36 | sd $s7, 0x58($a0)
37 |
38 | #ifdef __mips_hard_float
39 | mfc0 $v0, $12
40 | ext $v0, $v0, 29, 1
41 | beqz $v0, 1f
42 |
43 | s.d $f24, 0x60($a0)
44 | s.d $f25, 0x68($a0)
45 | s.d $f26, 0x70($a0)
46 | s.d $f27, 0x78($a0)
47 | s.d $f28, 0x80($a0)
48 | s.d $f29, 0x88($a0)
49 | s.d $f30, 0x90($a0)
50 | s.d $f31, 0x98($a0)
51 |
52 | 1:
53 | #endif
54 | move $v0, $zero
55 | jr $ra
56 |
57 | .globl longjmp
58 | .type longjmp, @function
59 | longjmp:
60 | ld $ra, 0x00($a0)
61 | ld $sp, 0x08($a0)
62 | ld $fp, 0x10($a0)
63 | ld $gp, 0x18($a0)
64 |
65 | ld $s0, 0x20($a0)
66 | ld $s1, 0x28($a0)
67 | ld $s2, 0x30($a0)
68 | ld $s3, 0x38($a0)
69 | ld $s4, 0x40($a0)
70 | ld $s5, 0x48($a0)
71 | ld $s6, 0x50($a0)
72 | ld $s7, 0x58($a0)
73 |
74 | #ifdef __mips_hard_float
75 | mfc0 $v0, $12
76 | ext $v0, $v0, 29, 1
77 | beqz $v0, 1f
78 |
79 | l.d $f24, 0x60($a0)
80 | l.d $f25, 0x68($a0)
81 | l.d $f26, 0x70($a0)
82 | l.d $f27, 0x78($a0)
83 | l.d $f28, 0x80($a0)
84 | l.d $f29, 0x88($a0)
85 | l.d $f30, 0x90($a0)
86 | l.d $f31, 0x98($a0)
87 |
88 | 1:
89 | #endif
90 | li $v0, 1
91 | movn $v0, $a1, $a1
92 | jr $ra
93 |
94 | #if defined(__ELF__) && defined(__linux__)
95 | .section .note.GNU-stack,"",%progbits
96 | #endif
97 |
--------------------------------------------------------------------------------
/lib/pause.c:
--------------------------------------------------------------------------------
1 | #include "lib.h"
2 |
3 | VOID
4 | Pause(
5 | VOID
6 | )
7 | // Pause until any key is pressed
8 | {
9 | EFI_INPUT_KEY Key;
10 | EFI_STATUS Status EFI_UNUSED;
11 |
12 | WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
13 | Status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &Key);
14 | ASSERT(!EFI_ERROR(Status));
15 | }
16 |
--------------------------------------------------------------------------------
/lib/riscv64/initplat.c:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
2 |
3 | #include "lib.h"
4 |
5 | VOID
6 | InitializeLibPlatform (
7 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
8 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
9 | )
10 | {
11 | }
12 |
--------------------------------------------------------------------------------
/lib/riscv64/math.c:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BSD-2-Clause-Patent
2 | /*
3 | * This code is based on EDK II MdePkg/Library/BaseLib/Math64.c
4 | * Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
5 | */
6 |
7 | #include "lib.h"
8 |
9 | /**
10 | * LShiftU64() - left shift
11 | */
12 | UINT64
13 | LShiftU64 (
14 | IN UINT64 Operand,
15 | IN UINTN Count
16 | )
17 | {
18 | return Operand << Count;
19 | }
20 |
21 | /**
22 | * RShiftU64() - right shift
23 | */
24 | UINT64
25 | RShiftU64 (
26 | IN UINT64 Operand,
27 | IN UINTN Count
28 | )
29 | {
30 | return Operand >> Count;
31 | }
32 |
33 | /**
34 | * MultU64x32() - multiply
35 | */
36 | UINT64
37 | MultU64x32 (
38 | IN UINT64 Multiplicand,
39 | IN UINTN Multiplier
40 | )
41 | {
42 | return Multiplicand * Multiplier;
43 | }
44 |
45 | /**
46 | * DivU64x32() - divide
47 | */
48 | UINT64
49 | DivU64x32 (
50 | IN UINT64 Dividend,
51 | IN UINTN Divisor,
52 | OUT UINTN *Remainder OPTIONAL
53 | )
54 | {
55 | ASSERT(Divisor != 0);
56 |
57 | if (Remainder) {
58 | *Remainder = Dividend % Divisor;
59 | }
60 |
61 | return Dividend / Divisor;
62 | }
63 |
--------------------------------------------------------------------------------
/lib/riscv64/setjmp.S:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
2 | /*
3 | * Copyright Heinrich Schuchardt
4 | */
5 |
6 | .text
7 | .p2align 3
8 |
9 | #define GREG_LIST \
10 | REG_ONE(s0, 0); \
11 | REG_ONE(s1, 8); \
12 | REG_ONE(s2, 16); \
13 | REG_ONE(s3, 24); \
14 | REG_ONE(s4, 32); \
15 | REG_ONE(s5, 40); \
16 | REG_ONE(s6, 48); \
17 | REG_ONE(s7, 56); \
18 | REG_ONE(s8, 64); \
19 | REG_ONE(s9, 72); \
20 | REG_ONE(s10, 80); \
21 | REG_ONE(s11, 88); \
22 | REG_ONE(sp, 96); \
23 | REG_ONE(ra, 104);
24 |
25 | #define FREG_LIST \
26 | FREG_ONE(fs0, 112); \
27 | FREG_ONE(fs1, 120); \
28 | FREG_ONE(fs2, 128); \
29 | FREG_ONE(fs3, 136); \
30 | FREG_ONE(fs4, 144); \
31 | FREG_ONE(fs5, 152); \
32 | FREG_ONE(fs6, 160); \
33 | FREG_ONE(fs7, 168); \
34 | FREG_ONE(fs8, 176); \
35 | FREG_ONE(fs9, 184); \
36 | FREG_ONE(fs10, 192); \
37 | FREG_ONE(fs11, 200);
38 |
39 | #define REG_ONE(R, P) sd R, P(a0)
40 | #define FREG_ONE(R, P) fsd R, P(a0)
41 |
42 | .globl setjmp
43 | .type setjmp, @function
44 |
45 | setjmp:
46 | GREG_LIST
47 | #ifndef __riscv_float_abi_soft
48 | FREG_LIST
49 | #endif
50 | li a0, 0
51 | ret
52 |
53 | #undef REG_ONE
54 | #undef FREG_ONE
55 |
56 | #define REG_ONE(R, P) ld R, P(a0)
57 | #define FREG_ONE(R, P) fld R, P(a0)
58 |
59 | .globl longjmp
60 | .type longjmp, @function
61 |
62 | longjmp:
63 | GREG_LIST
64 | #ifndef __riscv_float_abi_soft
65 | FREG_LIST
66 | #endif
67 | seqz a0, a1
68 | add a0, a0, a1
69 | ret
70 |
71 | #if defined(__ELF__) && defined(__linux__)
72 | .section .note.GNU-stack,"",%progbits
73 | #endif
74 |
--------------------------------------------------------------------------------
/lib/runtime/rtdata.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | data.c
8 |
9 | Abstract:
10 |
11 | EFI library global data
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 | #include "lib.h"
20 |
21 |
22 | //
23 | // These globals are runtime globals
24 | //
25 | // N.B. The Microsoft C compiler will only put the data in the
26 | // right data section if it is explicitly initialized..
27 | //
28 |
29 | #ifndef __GNUC__
30 | #pragma BEGIN_RUNTIME_DATA()
31 | #endif
32 |
33 | //
34 | // RT - pointer to the runtime table
35 | //
36 |
37 | EFI_RUNTIME_SERVICES *RT;
38 |
39 | //
40 | // LibStandalone - TRUE if lib is linked in as part of the firmware.
41 | // N.B. The EFI fw sets this value directly
42 | //
43 |
44 | BOOLEAN LibFwInstance;
45 |
46 | //
47 | // EFIDebug - Debug mask
48 | //
49 |
50 | UINTN EFIDebug = EFI_DBUG_MASK;
51 |
52 | //
53 | // LibRuntimeDebugOut - Runtime Debug Output device
54 | //
55 |
56 | SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut;
57 |
58 | //
59 | // LibRuntimeRaiseTPL, LibRuntimeRestoreTPL - pointers to Runtime functions from the
60 | // Boot Services Table
61 | //
62 |
63 | EFI_RAISE_TPL LibRuntimeRaiseTPL = NULL;
64 | EFI_RESTORE_TPL LibRuntimeRestoreTPL = NULL;
65 |
66 |
--------------------------------------------------------------------------------
/lib/runtime/rtlock.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | lock.c
8 |
9 | Abstract:
10 |
11 | Implements FLOCK
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 |
20 | #include "lib.h"
21 |
22 |
23 |
24 | #ifndef __GNUC__
25 | #pragma RUNTIME_CODE(RtAcquireLock)
26 | #endif
27 | VOID
28 | RtAcquireLock (
29 | IN FLOCK *Lock
30 | )
31 | /*++
32 |
33 | Routine Description:
34 |
35 | Raising to the task priority level of the mutual exclusion
36 | lock, and then acquires ownership of the lock.
37 |
38 | Arguments:
39 |
40 | Lock - The lock to acquire
41 |
42 | Returns:
43 |
44 | Lock owned
45 |
46 | --*/
47 | {
48 | if (BS) {
49 | if (BS->RaiseTPL != NULL) {
50 | Lock->OwnerTpl = uefi_call_wrapper(BS->RaiseTPL, 1, Lock->Tpl);
51 | }
52 | }
53 | else {
54 | if (LibRuntimeRaiseTPL != NULL) {
55 | Lock->OwnerTpl = LibRuntimeRaiseTPL(Lock->Tpl);
56 | }
57 | }
58 | Lock->Lock += 1;
59 | ASSERT (Lock->Lock == 1);
60 | }
61 |
62 |
63 | #ifndef __GNUC__
64 | #pragma RUNTIME_CODE(RtAcquireLock)
65 | #endif
66 | VOID
67 | RtReleaseLock (
68 | IN FLOCK *Lock
69 | )
70 | /*++
71 |
72 | Routine Description:
73 |
74 | Releases ownership of the mutual exclusion lock, and
75 | restores the previous task priority level.
76 |
77 | Arguments:
78 |
79 | Lock - The lock to release
80 |
81 | Returns:
82 |
83 | Lock unowned
84 |
85 | --*/
86 | {
87 | EFI_TPL Tpl;
88 |
89 | Tpl = Lock->OwnerTpl;
90 | ASSERT(Lock->Lock == 1);
91 | Lock->Lock -= 1;
92 | if (BS) {
93 | if (BS->RestoreTPL != NULL) {
94 | uefi_call_wrapper(BS->RestoreTPL, 1, Tpl);
95 | }
96 | }
97 | else {
98 | if (LibRuntimeRestoreTPL != NULL) {
99 | LibRuntimeRestoreTPL(Tpl);
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/lib/runtime/vm.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | vm.c
8 |
9 | Abstract:
10 |
11 | EFI Hell to remap runtime address into the new virual address space
12 | that was registered by the OS for RT calls.
13 |
14 | So the code image needs to be relocated. All pointers need to be
15 | manually fixed up since the address map changes.
16 |
17 | GOOD LUCK NOT HAVING BUGS IN YOUR CODE! PLEASE TEST A LOT. MAKE SURE
18 | EXIT BOOTSERVICES OVER WRITES ALL BOOTSERVICE MEMORY & DATA SPACES WHEN
19 | YOU TEST.
20 |
21 | Revision History
22 |
23 | --*/
24 |
25 | #include "lib.h"
26 |
27 | #ifndef __GNUC__
28 | #pragma RUNTIME_CODE(RtLibEnableVirtualMappings)
29 | #endif
30 | VOID
31 | RUNTIMEFUNCTION
32 | RtLibEnableVirtualMappings (
33 | VOID
34 | )
35 | {
36 | EFI_CONVERT_POINTER ConvertPointer;
37 |
38 | //
39 | // If this copy of the lib is linked into the firmware, then
40 | // do not update the pointers yet.
41 | //
42 |
43 | if (!LibFwInstance) {
44 |
45 | //
46 | // Different components are updating to the new virtual
47 | // mappings at differnt times. The only function that
48 | // is safe to call at this notification is ConvertAddress
49 | //
50 |
51 | ConvertPointer = RT->ConvertPointer;
52 |
53 | //
54 | // Fix any pointers that the lib created, that may be needed
55 | // during runtime.
56 | //
57 |
58 | ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&RT);
59 | ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&LibRuntimeDebugOut);
60 |
61 | ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRaiseTPL);
62 | ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRestoreTPL);
63 |
64 | // that was it :^)
65 | }
66 | }
67 |
68 |
69 | #ifndef __GNUC__
70 | #pragma RUNTIME_CODE(RtConvertList)
71 | #endif
72 | VOID
73 | RUNTIMEFUNCTION
74 | RtConvertList (
75 | IN UINTN DebugDisposition,
76 | IN OUT LIST_ENTRY *ListHead
77 | )
78 | {
79 | LIST_ENTRY *Link;
80 | LIST_ENTRY *NextLink;
81 | EFI_CONVERT_POINTER ConvertPointer;
82 |
83 | ConvertPointer = RT->ConvertPointer;
84 |
85 | //
86 | // Convert all the Flink & Blink pointers in the list
87 | //
88 |
89 | Link = ListHead;
90 | do {
91 | NextLink = Link->Flink;
92 |
93 | ConvertPointer (
94 | Link->Flink == ListHead ? DebugDisposition : 0,
95 | (VOID **)&Link->Flink
96 | );
97 |
98 | ConvertPointer (
99 | Link->Blink == ListHead ? DebugDisposition : 0,
100 | (VOID **)&Link->Blink
101 | );
102 |
103 | Link = NextLink;
104 | } while (Link != ListHead);
105 | }
106 |
--------------------------------------------------------------------------------
/lib/x86_64/callwrap.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Convert SysV calling convention to EFI x86_64 calling convention
3 | *
4 | * Copyright (C) 2007-2010 Intel Corp
5 | * Bibo Mao
6 | * Chandramouli Narayanan
7 | * Huang Ying
8 | *
9 | * All rights reserved.
10 | *
11 | * Redistribution and use in source and binary forms, with or without
12 | * modification, are permitted provided that the following conditions
13 | * are met:
14 | *
15 | * - Redistributions of source code must retain the above copyright
16 | * notice, this list of conditions and the following disclaimer.
17 | * - Redistributions in binary form must reproduce the above
18 | * copyright notice, this list of conditions and the following
19 | * disclaimer in the documentation and/or other materials
20 | * provided with the distribution.
21 | * - Neither the name of Hewlett-Packard Co. nor the names of its
22 | * contributors may be used to endorse or promote products derived
23 | * from this software without specific prior written permission.
24 | *
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
26 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
27 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
30 | * BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
31 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
35 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
36 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 | * SUCH DAMAGE.
38 | */
39 |
40 | /* uefi_call_wrapper() is a macro in efibind.h */
41 |
--------------------------------------------------------------------------------
/lib/x86_64/initplat.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | initplat.c
8 |
9 | Abstract:
10 |
11 |
12 |
13 |
14 | Revision History
15 |
16 | --*/
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/lib/x86_64/setjmp.S:
--------------------------------------------------------------------------------
1 | .text
2 | .globl setjmp
3 | #ifndef __MINGW32__
4 | .type setjmp, @function
5 | #else
6 | .def setjmp; .scl 2; .type 32; .endef
7 | #endif
8 | setjmp:
9 | pop %rsi
10 | movq %rbx,0x00(%rdi)
11 | movq %rsp,0x08(%rdi)
12 | push %rsi
13 | movq %rbp,0x10(%rdi)
14 | movq %r12,0x18(%rdi)
15 | movq %r13,0x20(%rdi)
16 | movq %r14,0x28(%rdi)
17 | movq %r15,0x30(%rdi)
18 | movq %rsi,0x38(%rdi)
19 | xor %rax,%rax
20 | ret
21 |
22 | .globl longjmp
23 | #ifndef __MINGW32__
24 | .type longjmp, @function
25 | #else
26 | .def longjmp; .scl 2; .type 32; .endef
27 | #endif
28 | longjmp:
29 | movl %esi, %eax
30 | movq 0x00(%rdi), %rbx
31 | movq 0x08(%rdi), %rsp
32 | movq 0x10(%rdi), %rbp
33 | movq 0x18(%rdi), %r12
34 | movq 0x20(%rdi), %r13
35 | movq 0x28(%rdi), %r14
36 | movq 0x30(%rdi), %r15
37 | xor %rdx,%rdx
38 | mov $1,%rcx
39 | cmp %rax,%rdx
40 | cmove %rcx,%rax
41 | jmp *0x38(%rdi)
42 |
43 | #if defined(__ELF__) && defined(__linux__)
44 | .section .note.GNU-stack,"",%progbits
45 | #endif
46 |
--------------------------------------------------------------------------------
/licenses/LICENSE.edk2:
--------------------------------------------------------------------------------
1 | Copyright (c) 2019, TianoCore and contributors. All rights reserved.
2 |
3 | SPDX-License-Identifier: BSD-2-Clause-Patent
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice,
9 | this list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | Subject to the terms and conditions of this license, each copyright holder
16 | and contributor hereby grants to those receiving rights under this license
17 | a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
18 | (except for failure to satisfy the conditions of this license) patent
19 | license to make, have made, use, offer to sell, sell, import, and otherwise
20 | transfer this software, where such license applies only to those patent
21 | claims, already acquired or hereafter acquired, licensable by such copyright
22 | holder or contributor that are necessarily infringed by:
23 |
24 | (a) their Contribution(s) (the licensed copyrights of copyright holders and
25 | non-copyrightable additions of contributors, in source or binary form)
26 | alone; or
27 |
28 | (b) combination of their Contribution(s) with the work of authorship to
29 | which such Contribution(s) was added by such copyright holder or
30 | contributor, if, at the time the Contribution is added, such addition
31 | causes such combination to be necessarily infringed. The patent license
32 | shall not apply to any other combinations which include the
33 | Contribution.
34 |
35 | Except as expressly stated above, no rights or licenses from any copyright
36 | holder or contributor is granted under this license, whether expressly, by
37 | implication, estoppel or otherwise.
38 |
39 | DISCLAIMER
40 |
41 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
42 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
45 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
46 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
47 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
48 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
49 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51 | POSSIBILITY OF SUCH DAMAGE.
52 |
--------------------------------------------------------------------------------
/licenses/LICENSE.efilib:
--------------------------------------------------------------------------------
1 |
2 | The files in the "lib" and "inc" subdirectories are using the EFI Application
3 | Toolkit distributed by Intel at http://developer.intel.com/technology/efi
4 |
5 | This code is covered by the following agreement:
6 |
7 | Copyright (c) 1998-2000 Intel Corporation
8 |
9 | Redistribution and use in source and binary forms, with or without modification, are permitted
10 | provided that the following conditions are met:
11 |
12 | Redistributions of source code must retain the above copyright notice, this list of conditions and
13 | the following disclaimer.
14 |
15 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions
16 | and the following disclaimer in the documentation and/or other materials provided with the
17 | distribution.
18 |
19 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL BE
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 | POSSIBILITY OF SUCH DAMAGE. THE EFI SPECIFICATION AND ALL OTHER INFORMATION
29 | ON THIS WEB SITE ARE PROVIDED "AS IS" WITH NO WARRANTIES, AND ARE SUBJECT
30 | TO CHANGE WITHOUT NOTICE.
31 |
--------------------------------------------------------------------------------
/tests/gen_tests.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ## @file
4 | # Test generation script for gnu-efi.
5 | #
6 | # Copyright (c) 2023-2024, Pete Batard
7 | #
8 | # SPDX-License-Identifier: GPL-2.0-or-later
9 | #
10 | ##
11 |
12 | TEST_DIR=./run
13 |
14 | rm -rf $TEST_DIR
15 | mkdir $TEST_DIR
16 |
17 | test_number=0
18 |
19 | while IFS=$'\r\n' read -r line; do
20 | if [[ ${line:0:1} == "#" ]]; then
21 | test_number=$((test_number + 1))
22 | data_file=$(printf "%s/%03d %s.dat" $TEST_DIR $test_number "${line:2}")
23 | setup_file=$(printf "%s/%03d setup.sh" $TEST_DIR $test_number)
24 | teardown_file=$(printf "%s/%03d teardown.sh" $TEST_DIR $test_number)
25 | elif [[ ${line:0:1} == ">" ]]; then
26 | if [[ ! -f "$setup_file" ]]; then
27 | echo "#!/usr/bin/env bash" > "$setup_file"
28 | chmod 755 "$setup_file"
29 | fi
30 | echo "${line:2}" >> "$setup_file"
31 | elif [[ ${line:0:1} == "<" ]]; then
32 | if [[ ! -f "$teardown_file" ]]; then
33 | echo "#!/usr/bin/env bash" > "$teardown_file"
34 | chmod 755 "$teardown_file"
35 | fi
36 | echo "${line:2}" >> "$teardown_file"
37 | elif [[ ! -z "$line" ]]; then
38 | echo "${line}" >> "$data_file"
39 | fi
40 | done < $1
41 |
--------------------------------------------------------------------------------
/tests/test_list.txt:
--------------------------------------------------------------------------------
1 | # ConOut text output
2 | > cp t.efi $UEFI_DIR
3 | > echo "@echo -off" > $UEFI_DIR/startup.nsh
4 | > echo "FS0:\t.efi" >> $UEFI_DIR/startup.nsh
5 | > echo "reset -s" >> $UEFI_DIR/startup.nsh
6 | Hello World!
7 | Hello World!
8 | < rm $UEFI_DIR/*.efi
9 |
10 | # Test args
11 | > cp tcc.efi $UEFI_DIR
12 | > echo "@echo -off" > $UEFI_DIR/startup.nsh
13 | > echo "FS0:\tcc.efi" >> $UEFI_DIR/startup.nsh
14 | > echo "reset -s" >> $UEFI_DIR/startup.nsh
15 | Hello
16 | Returning Failure works
17 | 0 args works just fine here.
18 | 1 arg works just fine here.
19 | 2 args works just fine here.
20 | 3 args works just fine here.
21 | 4 args works just fine here.
22 | 5 args works just fine here.
23 | 6 args works just fine here.
24 | 7 args works just fine here.
25 | 8 args works just fine here.
26 | 9 args works just fine here.
27 | 10 args works just fine here.
28 | < rm $UEFI_DIR/*.efi
29 |
30 | # Print args
31 | > cp t8.efi $UEFI_DIR
32 | > echo "@echo -off" > $UEFI_DIR/startup.nsh
33 | > echo "FS0:\t8.efi Test1 Test2" >> $UEFI_DIR/startup.nsh
34 | > echo "reset -s" >> $UEFI_DIR/startup.nsh
35 | Hello World, started with Argc=3
36 | Argv[0] = 'FS0:\t8.efi'
37 | Argv[1] = 'Test1'
38 | Argv[2] = 'Test2'
39 | Bye.
40 | < rm $UEFI_DIR/*.efi
41 |
42 | # Test driver
43 | > cp drv0.efi drv0_use.efi $UEFI_DIR
44 | > echo "@echo -off" > $UEFI_DIR/startup.nsh
45 | > echo "load FS0:\drv0.efi" >> $UEFI_DIR/startup.nsh
46 | > echo "FS0:\drv0_use.efi" >> $UEFI_DIR/startup.nsh
47 | > echo "reset -s" >> $UEFI_DIR/startup.nsh
48 | Playing with driver instance 0...
49 | Hello Sample UEFI Driver!
50 | Hello was called 1 time(s).
51 | < rm $UEFI_DIR/*.efi
52 |
--------------------------------------------------------------------------------