diff --git a/.gitignore b/.gitignore index e032565..58d9eb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ .git/ .vscode/ +build/ +.gitignore usb.vmdk +createusbvmdk.sh usbvmdk.sh bochsout.txt +bx_enh_dbg.ini diff --git a/README.md b/README.md index 7315a26..0d6c635 100644 --- a/README.md +++ b/README.md @@ -9,35 +9,16 @@ This project is **not** intended to do some crazy stuff like replacing the giant # Who is involved? * Me, Andrey Antonenko, the creator, maintainer and programmer * Sasha Kulichkov, booted this on his PC several times; created the logo -# What parts does this consist of? -1. First stage loader, called Muon-1 -2. Second stage loader, called Muon-2 -3. The monolithic kernel. So monolithic in fact, that all the system processes, even the graphics, are integrated. It's called Quark. -4. The font converter. Written in C# -5. The custom builder. Written in Python. # Where does it work? In theory, it should work on any modern system. Here are the minimal requirements: * CPU: Pentium 4 or later * RAM: 32 MB -* Buses: PCI, ATA -* An empty internal hard drive to boot from. You will be able to boot from external USB sticks, disk drives, floppies, etc., but -as the kernel only has ATA support right now, it woudn't be able to read any data from any drives except ATA drives or SATA -drives in ATA compatibility mode (can almost certainly be enabled in the BIOS) -* Legacy BIOS system or an UEFI system with legacy emulation mode -* A video card supporting VESA 1.2 standard (integrated CPU graphics should also work)\ +* An UEFI system. Neutron up to version 0.1.11 was a legacy BIOS system, but I had switched over to UEFI for future expanadability. \ Also, there are some detected problems: * Some very modern systems only have UEFI support, totally eliminating the legacy BIOS standard. Neutron can't be booted on those systems. # Show me the screenshots! -Okay, there you go!\ -![boot1](https://github.com/portasynthinca3/neutron/blob/master/screens/boot_1.png "boot1")\ -*Boot screen 1*\ -![boot2](https://github.com/portasynthinca3/neutron/blob/master/screens/boot_2.png "boot2")\ -*Boot screen 2*\ -![desktop](https://github.com/portasynthinca3/neutron/blob/master/screens/desktop.png "desktop")\ -*Desktop* -![shutdown](https://github.com/portasynthinca3/neutron/blob/master/screens/sdown.png "shutdown")\ -*Shutdown prompt* +They are in the `screens` directory # Okay, what do I need to be aware of? Keep in mind that the system is unstable. I am **not** responsible for **any** kind of damage. However, please tell me if you have found a bug, especially if it's dangerous enough to do any damage. That would be very nice! diff --git a/bochsrc.txt b/bochsrc.txt deleted file mode 100644 index 0f28dd8..0000000 --- a/bochsrc.txt +++ /dev/null @@ -1,55 +0,0 @@ -# configuration file generated by Bochs -plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, gameport=1, iodebug=1 -config_interface: textconfig -display_library: x -memory: host=32, guest=32 -romimage: file="/usr/share/bochs/BIOS-bochs-latest", address=0x0, options=none -vgaromimage: file="/usr/share/bochs/VGABIOS-lgpl-latest" -boot: floppy -floppy_bootsig_check: disabled=0 -floppya: type=1_44, 1_44="build/neutron.img", status=inserted, write_protected=0 -# no floppyb -ata0: enabled=0 -ata1: enabled=0 -ata2: enabled=0 -ata3: enabled=0 -optromimage1: file=none -optromimage2: file=none -optromimage3: file=none -optromimage4: file=none -optramimage1: file=none -optramimage2: file=none -optramimage3: file=none -optramimage4: file=none -pci: enabled=1, chipset=i440fx -vga: extension=vbe, update_freq=20, realtime=1 -cpu: count=1:1:1, ips=4000000, quantum=16, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0 -cpuid: level=6, stepping=3, model=3, family=6, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU " -cpuid: mmx=1, apic=xapic, simd=sse2, sse4a=0, misaligned_sse=0, sep=1, movbe=0, adx=0 -cpuid: aes=0, sha=0, xsave=0, xsaveopt=0, avx_f16c=0, avx_fma=0, bmi=0, xop=0, fma4=0 -cpuid: tbm=0, x86_64=1, 1g_pages=0, pcid=0, fsgsbase=0, smep=0, smap=0, mwait=1, vmx=1 -cpuid: svm=0 -print_timestamps: enabled=0 -debugger_log: - -magic_break: enabled=1 -port_e9_hack: enabled=1 -private_colormap: enabled=0 -clock: sync=none, time0=local, rtc_sync=0 -# no cmosimage -# no loader -log: - -logprefix: %t%e%d -debug: action=ignore -info: action=report -error: action=report -panic: action=ask -keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none -mouse: type=ps2, enabled=0, toggle=ctrl+mbutton -sound: waveoutdrv=alsa, waveout=none, waveindrv=alsa, wavein=none, midioutdrv=alsa, midiout=none -speaker: enabled=1, mode=sound -parport1: enabled=1, file=none -parport2: enabled=0 -com1: enabled=0 -com2: enabled=0 -com3: enabled=0 -com4: enabled=0 diff --git a/build/1stg.asm.bin b/build/1stg.asm.bin deleted file mode 100644 index 5efb1c9..0000000 Binary files a/build/1stg.asm.bin and /dev/null differ diff --git a/build/2stg.asm.bin b/build/2stg.asm.bin deleted file mode 100644 index a135829..0000000 Binary files a/build/2stg.asm.bin and /dev/null differ diff --git a/build/lds b/build/lds deleted file mode 100644 index c71673d..0000000 --- a/build/lds +++ /dev/null @@ -1,13 +0,0 @@ -ENTRY(main) -SECTIONS -{ - .text 0x00000F00 : - { - *(.text.main); - *(.text*); - } - .data : - { - *(.data*); - } -} \ No newline at end of file diff --git a/build/neutron.img b/build/neutron.img index e816e9a..8f621d2 100644 Binary files a/build/neutron.img and b/build/neutron.img differ diff --git a/build/obj/a20.s.o b/build/obj/a20.s.o deleted file mode 100644 index dc8ad58..0000000 Binary files a/build/obj/a20.s.o and /dev/null differ diff --git a/build/obj/acpi.c.o b/build/obj/acpi.c.o deleted file mode 100644 index d416b37..0000000 Binary files a/build/obj/acpi.c.o and /dev/null differ diff --git a/build/obj/ata.c.o b/build/obj/ata.c.o deleted file mode 100644 index c81c792..0000000 Binary files a/build/obj/ata.c.o and /dev/null differ diff --git a/build/obj/cbuild.o b/build/obj/cbuild.o deleted file mode 100755 index fe0ec8c..0000000 Binary files a/build/obj/cbuild.o and /dev/null differ diff --git a/build/obj/diskio.c.o b/build/obj/diskio.c.o deleted file mode 100644 index b9da7d6..0000000 Binary files a/build/obj/diskio.c.o and /dev/null differ diff --git a/build/obj/gfx.c.o b/build/obj/gfx.c.o deleted file mode 100644 index e679e8e..0000000 Binary files a/build/obj/gfx.c.o and /dev/null differ diff --git a/build/obj/gui.c.o b/build/obj/gui.c.o deleted file mode 100644 index f5ea808..0000000 Binary files a/build/obj/gui.c.o and /dev/null differ diff --git a/build/obj/isr_wrapper.s.o b/build/obj/isr_wrapper.s.o deleted file mode 100644 index 2360776..0000000 Binary files a/build/obj/isr_wrapper.s.o and /dev/null differ diff --git a/build/obj/pci.c.o b/build/obj/pci.c.o deleted file mode 100644 index 99076e1..0000000 Binary files a/build/obj/pci.c.o and /dev/null differ diff --git a/build/obj/pic.c.o b/build/obj/pic.c.o deleted file mode 100644 index ea14be0..0000000 Binary files a/build/obj/pic.c.o and /dev/null differ diff --git a/build/obj/pit.c.o b/build/obj/pit.c.o deleted file mode 100644 index c2db090..0000000 Binary files a/build/obj/pit.c.o and /dev/null differ diff --git a/build/obj/ps2.c.o b/build/obj/ps2.c.o deleted file mode 100644 index 11e7f1a..0000000 Binary files a/build/obj/ps2.c.o and /dev/null differ diff --git a/build/obj/ps2_kbd.c.o b/build/obj/ps2_kbd.c.o deleted file mode 100644 index 450c0ee..0000000 Binary files a/build/obj/ps2_kbd.c.o and /dev/null differ diff --git a/build/obj/quark.c.o b/build/obj/quark.c.o deleted file mode 100644 index 3dabd40..0000000 Binary files a/build/obj/quark.c.o and /dev/null differ diff --git a/build/obj/stdgui.c.o b/build/obj/stdgui.c.o deleted file mode 100644 index b50caa7..0000000 Binary files a/build/obj/stdgui.c.o and /dev/null differ diff --git a/build/obj/stdlib.c.o b/build/obj/stdlib.c.o deleted file mode 100644 index 55c581c..0000000 Binary files a/build/obj/stdlib.c.o and /dev/null differ diff --git a/build/obj/usb.c.o b/build/obj/usb.c.o deleted file mode 100644 index e375b0b..0000000 Binary files a/build/obj/usb.c.o and /dev/null differ diff --git a/build/quark.bin b/build/quark.bin deleted file mode 100755 index 7fff8bd..0000000 Binary files a/build/quark.bin and /dev/null differ diff --git a/builder.py b/builder.py index 207e14d..c0acb98 100644 --- a/builder.py +++ b/builder.py @@ -1,18 +1,39 @@ import sys, os +def get_object_files(dir_name): + list_of_files = os.listdir(dir_name) + all_files = list() + for entry in list_of_files: + full_path = os.path.join(dir_name, entry) + if os.path.isdir(full_path): + all_files += get_object_files(full_path) + elif full_path.endswith('.o'): + all_files.append(full_path) + + return all_files + +def get_c_files(dir_name): + list_of_files = os.listdir(dir_name) + all_files = list() + for entry in list_of_files: + full_path = os.path.join(dir_name, entry) + if os.path.isdir(full_path): + all_files += get_object_files(full_path) + elif full_path.endswith('.c'): + all_files.append(full_path) + + return all_files + config_file = 'neutron.nbuild' image_file = 'build/neutron.img' -image = bytearray(1440 * 1024) +image_size_sectors = 2880 config_file_obj = open(config_file, 'r') config_contents = config_file_obj.read() config_file_obj.close() -asm_files = list() -asm_stack_files = list() c_files = list() fs_files = list() -crawout = '' config_section = '' config_lines = config_contents.split('\n') @@ -22,139 +43,36 @@ if not line.startswith('#'): if line.startswith('.'): config_section = line[1:] - if not config_section in ['asm', 'c', 'fs', 'crawout']: + if not config_section in ['c', 'fs']: print('Error at ' + config_file + ':' + str(line_no + 1) + ': invalid section "' + config_section + '"') sys.exit() else: - if config_section == 'asm': - if line.endswith(' --no-append'): - asm_files.append(line[:-len(' --no-append')]) - else: - asm_stack_files.append(line) - elif config_section == 'c': + if config_section == 'c': c_files.append(line) elif config_section == 'fs': fs_files.append(line) - elif config_section == 'crawout': - if crawout != '': - print('Error at ' + config_file + ':' + str(line_no + 1) + ': section "' + config_section + '" can only contain one entry') - sys.exit() - else: - crawout = line else: print('Error at ' + config_file + ':' + str(line_no + 1) + ': data in invalid section "' + config_section + '"') sys.exit() -print('Assembling stacking binaries') -stack_pos = 0 -for path in asm_stack_files: - path_bin = 'build/' + os.path.basename(path) + '.bin' - print(' Assembling: ' + path + ' -> ' + path_bin) - os.system('yasm -f bin -o ' + path_bin + ' ' + path) - - print(' Stacking: ' + path_bin) - bin_file = open(path_bin, 'rb') - bin_file_cont = bin_file.read() - bin_file.close() - for byte in bin_file_cont: - image[stack_pos] = byte - stack_pos = stack_pos + 1 - -print('Assembling ordinary binaries') -for path in asm_files: - path_bin = 'build/' + os.path.basename(path) + '.bin' - print(' Assembling: ' + path + ' -> ' + path_bin) - os.system('yasm -f bin -o ' + path_bin + ' ' + path) - c_obj = list() -print('Generating C object files') +c_obj.append('gnu-efi/x86_64/gnuefi/libgnuefi.a') +c_obj.append('gnu-efi/x86_64/lib/libefi.a') +print('Compiling C sources') for path in c_files: - path_obj = 'build/obj/' + os.path.basename(path) + '.o' + path_obj = 'build/' + os.path.basename(path) + '.o' c_obj.append(path_obj) print(' Compiling: ' + path + ' -> ' + path_obj) - #So, hear me out. - #I literally spent more than two days trying to find out why my code doesn't work in VirtualBox - # but does so in Bochs. - #It turned out to be a VirtualBox coding error. A newer ENDBR32 instruction is supposed to enhance the branch - # prediction mechanism preformance on modern CPUs and is placed by GCC at the start of all functions. Older CPUs should - # decode ENDBR32 as REP MULTIBYTE NOP, and that's exactly what Bochs does, so no problems there. But! VirtualBox decodes - # it as a sequence of an illegal opcode and STI. I don't have a proper interrupt servicing mechanism yet, so this - # creates a huge problem. I spent all this time just to find out why Neutron would crash randomly in absolutely - # random places. The -fcf-protection=branch -mmanual-endbr options are here to prevent GCC from placing - # ENDBR32. It could improve performance, in theory, but I disabled this feature solely for the sake of compatibility. - #https://stackoverflow.com/questions/56120231/how-do-old-cpus-execute-the-new-endbr64-and-endbr32-instructions/59219143#59219143 - os.system('cc -o ' + path_obj + ' ' + path + ' -m32 -c -nostdlib -nodefaultlibs -Og -ffunction-sections -fcf-protection=branch -mmanual-endbr') - -print('Linking C object files') -print(' Generating liker script') -ld_script = open('build/lds', 'w') -#ld_script.write('SECTIONS {\n.text 0x00000F00 : {\n' + ' (.text)\n'.join(c_obj) + ' (.text)\n}\n.data : {\n' + ' (.data)\n'.join(c_obj) + ' (.data)\n}\n}') -ld_script.write('ENTRY(main)\nSECTIONS\n{\n\t.text 0x00000F00 :\n\t{\n\t\t*(.text.main);\n\t\t*(.text*);\n\t}\n\t.data :\n\t{\n\t\t*(.data*);\n\t}\n}') -ld_script.close() -print(' Invoking linker') -os.system('ld -o build/obj/cbuild.o ' + ' '.join(c_obj) + ' --entry=main -melf_i386 -nostdlib -n -T build/lds') - -print('Generating raw binary') -os.system('objcopy -O binary build/obj/cbuild.o ' + crawout) - -if len(fs_files) > 0: - print('Building nFS') - print(' Writing signature') - image[4608] = 0x00 - image[4609] = 0xF5 - image[4610] = 0xAD - image[4611] = 0xDE - - print(' Writing partition name') - part_name = 'Neutron Test FS' - for i in range(len(part_name)): - c = part_name[i] - image[4612 + i] = ord(c) - - print(' Writing Master FileTable') - file_sects = list() - next_f_sect = 11 - for path in fs_files: - if path != "": - path_src = path.split('>')[0] - path_dst = path.split('>')[1] - f_size = os.path.getsize(path_src) - f_size_sect = f_size // 512 - if f_size_sect % 512 > 0: - f_size_sect = f_size_sect + 1 - file_sects.append(next_f_sect) - - print(' Writing entry for: ' + path_dst) - for i in range(len(path_dst)): - c = path_dst[i] - image[5120 + (fs_files.index(path) * 32) + i] = ord(c) - - image[5120 + (fs_files.index(path) * 32) + 24] = f_size & 0xFF - image[5120 + (fs_files.index(path) * 32) + 25] = (f_size >> 8) & 0xFF - image[5120 + (fs_files.index(path) * 32) + 26] = (f_size >> 16) & 0xFF - image[5120 + (fs_files.index(path) * 32) + 27] = (f_size >> 24) & 0xFF - image[5120 + (fs_files.index(path) * 32) + 28] = next_f_sect & 0xFF - image[5120 + (fs_files.index(path) * 32) + 29] = (next_f_sect >> 8) & 0xFF - image[5120 + (fs_files.index(path) * 32) + 30] = (next_f_sect >> 16) & 0xFF - image[5120 + (fs_files.index(path) * 32) + 31] = (next_f_sect >> 24) & 0xFF - - next_f_sect = next_f_sect + f_size_sect + os.system('x86_64-w64-mingw32-gcc -ffreestanding -m64 -Ignu-efi/inc -Ignu-efi/lib -Ignu-efi/inc/x86_64 -Ignu-efi/inc/protocol -nostdlib -c -o ' + path_obj + ' ' + path) - print(' Writing files') - for path in fs_files: - if path != "": - path_src = path.split('>')[0] - path_dst = path.split('>')[1] - print(' Writing file: ' + path_dst) - bin_file = open(path_src, 'rb') - bin_file_cont = bin_file.read() - bin_file.close() - stack_pos = 0 - for byte in bin_file_cont: - image[(file_sects[fs_files.index(path)] * 512) + stack_pos] = byte - stack_pos = stack_pos + 1 +print('Linking') +os.system('x86_64-w64-mingw32-gcc -m64 -nostdlib -Wl,-dll -shared -Wl,--subsystem,10 -e efi_main -o build/BOOTX64.EFI ' + ' '.join(c_obj) + ' -lgcc') -print('Writing image to: ' + image_file) -image_file_file = open(image_file, 'wb') -image_file_file.write(image) -image_file_file.close() +print('Bulding system image') +print(' Creating image file') +os.system('dd if=/dev/zero of=build/neutron.img count=' + str(image_size_sectors) + ' > /dev/null') +os.system('mformat -i build/neutron.img -f ' + str(image_size_sectors / 2)) +print(' Creating filesystem') +os.system('mmd -i build/neutron.img ::/EFI') +os.system('mmd -i build/neutron.img ::/EFI/BOOT') +os.system('mcopy -i build/neutron.img build/BOOTX64.EFI ::/EFI/BOOT') \ No newline at end of file diff --git a/bx_enh_dbg.ini b/bx_enh_dbg.ini deleted file mode 100644 index 41ebc33..0000000 --- a/bx_enh_dbg.ini +++ /dev/null @@ -1,26 +0,0 @@ -# bx_enh_dbg_ini -SeeReg[0] = TRUE -SeeReg[1] = TRUE -SeeReg[2] = TRUE -SeeReg[3] = TRUE -SeeReg[4] = FALSE -SeeReg[5] = FALSE -SeeReg[6] = FALSE -SeeReg[7] = FALSE -SingleCPU = FALSE -ShowIOWindows = TRUE -ShowButtons = TRUE -SeeRegColors = TRUE -ignoreNxtT = TRUE -ignSSDisasm = TRUE -UprCase = 0 -DumpInAsciiMode = 3 -isLittleEndian = TRUE -DefaultAsmLines = 512 -DumpWSIndex = 0 -DockOrder = 0x123 -ListWidthPix[0] = 389 -ListWidthPix[1] = 538 -ListWidthPix[2] = 615 -MainWindow = 0, 0, 1054, 500 -FontName = Normal diff --git a/gnu-efi/inc/efi.h b/gnu-efi/inc/efi.h new file mode 100644 index 0000000..2ddd53e --- /dev/null +++ b/gnu-efi/inc/efi.h @@ -0,0 +1,61 @@ +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efi.h + +Abstract: + + Public EFI header files + + + +Revision History + +--*/ + + +// Add a predefined macro to detect usage of the library +#ifndef _GNU_EFI +#define _GNU_EFI +#endif + +// +// Build flags on input +// EFI32 +// EFI_DEBUG - Enable debugging code +// EFI_NT_EMULATOR - Building for running under NT +// + + +#ifndef _EFI_INCLUDE_ +#define _EFI_INCLUDE_ + +#define EFI_FIRMWARE_VENDOR L"INTEL" +#define EFI_FIRMWARE_MAJOR_REVISION 12 +#define EFI_FIRMWARE_MINOR_REVISION 33 +#define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION)) + +#include "efibind.h" +#include "eficompiler.h" +#include "efidef.h" +#include "efidevp.h" +#include "efipciio.h" +#include "efiprot.h" +#include "eficon.h" +#include "efiser.h" +#include "efi_nii.h" +#include "efipxebc.h" +#include "efinet.h" +#include "efiapi.h" +#include "efifs.h" +#include "efierr.h" +#include "efiui.h" +#include "efiip.h" +#include "efiudp.h" +#include "efitcp.h" +#include "efipoint.h" + +#endif diff --git a/gnu-efi/inc/efi_nii.h b/gnu-efi/inc/efi_nii.h new file mode 100644 index 0000000..fdf5cb4 --- /dev/null +++ b/gnu-efi/inc/efi_nii.h @@ -0,0 +1,78 @@ +#ifndef _EFI_NII_H +#define _EFI_NII_H + +/*++ +Copyright (c) 2000 Intel Corporation + +Module name: + efi_nii.h + +Abstract: + +Revision history: + 2000-Feb-18 M(f)J GUID updated. + Structure order changed for machine word alignment. + Added StringId[4] to structure. + + 2000-Feb-14 M(f)J Genesis. +--*/ + +#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \ + { 0xE18541CD, 0xF755, 0x4f73, {0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29} } + +#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 0x00010000 +#define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION + +typedef enum { + EfiNetworkInterfaceUndi = 1 +} EFI_NETWORK_INTERFACE_TYPE; + +typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL { + + UINT64 Revision; + // Revision of the network interface identifier protocol interface. + + UINT64 ID; + // Address of the first byte of the identifying structure for this + // network interface. This is set to zero if there is no structure. + // + // For PXE/UNDI this is the first byte of the !PXE structure. + + UINT64 ImageAddr; + // Address of the UNrelocated driver/ROM image. This is set + // to zero if there is no driver/ROM image. + // + // For 16-bit UNDI, this is the first byte of the option ROM in + // upper memory. + // + // For 32/64-bit S/W UNDI, this is the first byte of the EFI ROM + // image. + // + // For H/W UNDI, this is set to zero. + + UINT32 ImageSize; + // Size of the UNrelocated driver/ROM image of this network interface. + // This is set to zero if there is no driver/ROM image. + + CHAR8 StringId[4]; + // 4 char ASCII string to go in class identifier (option 60) in DHCP + // and Boot Server discover packets. + // For EfiNetworkInterfaceUndi this field is "UNDI". + // For EfiNetworkInterfaceSnp this field is "SNPN". + + UINT8 Type; + UINT8 MajorVer; + UINT8 MinorVer; + // Information to be placed into the PXE DHCP and Discover packets. + // This is the network interface type and version number that will + // be placed into DHCP option 94 (client network interface identifier). + BOOLEAN Ipv6Supported; + UINT8 IfNum; // interface number to be used with pxeid structure +} EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL, EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL' GUID definition, +// from older versions of gnu-efi, is now obsoleted. +// Use 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID' instead. + +#endif // _EFI_NII_H diff --git a/gnu-efi/inc/efi_pxe.h b/gnu-efi/inc/efi_pxe.h new file mode 100644 index 0000000..d24251f --- /dev/null +++ b/gnu-efi/inc/efi_pxe.h @@ -0,0 +1,1743 @@ +#ifndef _EFI_PXE_H +#define _EFI_PXE_H + + +/*++ +Copyright (c) Intel 1999 + +Module name: + efi_pxe.h + +32/64-bit PXE specification: + alpha-4, 99-Dec-17 + +Abstract: + This header file contains all of the PXE type definitions, + structure prototypes, global variables and constants that + are needed for porting PXE to EFI. +--*/ + +#pragma pack(1) + +#define PXE_INTEL_ORDER 1 // Intel order +//#define PXE_NETWORK_ORDER 1 // network order + +#define PXE_UINT64_SUPPORT 1 // UINT64 supported +//#define PXE_NO_UINT64_SUPPORT 1 // UINT64 not supported + +#define PXE_BUSTYPE(a,b,c,d) \ +((((PXE_UINT32)(d) & 0xFF) << 24) | \ +(((PXE_UINT32)(c) & 0xFF) << 16) | \ +(((PXE_UINT32)(b) & 0xFF) << 8) | \ +((PXE_UINT32)(a) & 0xFF)) + +// +// UNDI ROM ID and devive ID signature +// +#define PXE_BUSTYPE_PXE PXE_BUSTYPE('!', 'P', 'X', 'E') + +// +// BUS ROM ID signatures +// +#define PXE_BUSTYPE_PCI PXE_BUSTYPE('P', 'C', 'I', 'R') +#define PXE_BUSTYPE_PC_CARD PXE_BUSTYPE('P', 'C', 'C', 'R') +#define PXE_BUSTYPE_USB PXE_BUSTYPE('U', 'S', 'B', 'R') +#define PXE_BUSTYPE_1394 PXE_BUSTYPE('1', '3', '9', '4') + +#define PXE_SWAP_UINT16(n) \ +((((PXE_UINT16)(n) & 0x00FF) << 8) | \ +(((PXE_UINT16)(n) & 0xFF00) >> 8)) + +#define PXE_SWAP_UINT32(n) \ +((((PXE_UINT32)(n) & 0x000000FF) << 24) | \ +(((PXE_UINT32)(n) & 0x0000FF00) << 8) | \ +(((PXE_UINT32)(n) & 0x00FF0000) >> 8) | \ +(((PXE_UINT32)(n) & 0xFF000000) >> 24)) + +#if PXE_UINT64_SUPPORT != 0 +#define PXE_SWAP_UINT64(n) \ +((((PXE_UINT64)(n) & 0x00000000000000FF) << 56) | \ +(((PXE_UINT64)(n) & 0x000000000000FF00) << 40) | \ +(((PXE_UINT64)(n) & 0x0000000000FF0000) << 24) | \ +(((PXE_UINT64)(n) & 0x00000000FF000000) << 8) | \ +(((PXE_UINT64)(n) & 0x000000FF00000000) >> 8) | \ +(((PXE_UINT64)(n) & 0x0000FF0000000000) >> 24) | \ +(((PXE_UINT64)(n) & 0x00FF000000000000) >> 40) | \ +(((PXE_UINT64)(n) & 0xFF00000000000000) >> 56)) +#endif // PXE_UINT64_SUPPORT + +#if PXE_NO_UINT64_SUPPORT != 0 +#define PXE_SWAP_UINT64(n) \ +{ \ +PXE_UINT32 tmp = (PXE_UINT64)(n)[1]; \ +(PXE_UINT64)(n)[1] = PXE_SWAP_UINT32((PXE_UINT64)(n)[0]); \ +(PXE_UINT64)(n)[0] = tmp; \ +} +#endif // PXE_NO_UINT64_SUPPORT + +#define PXE_CPBSIZE_NOT_USED 0 // zero +#define PXE_DBSIZE_NOT_USED 0 // zero +#define PXE_CPBADDR_NOT_USED (PXE_UINT64)0 // zero +#define PXE_DBADDR_NOT_USED (PXE_UINT64)0 // zero + +#define PXE_CONST const + +#define PXE_VOLATILE volatile + +typedef void PXE_VOID; + +typedef unsigned char PXE_UINT8; + +typedef unsigned short PXE_UINT16; + +typedef unsigned PXE_UINT32; + +#if PXE_UINT64_SUPPORT != 0 +// typedef unsigned long PXE_UINT64; +typedef UINT64 PXE_UINT64; +#endif // PXE_UINT64_SUPPORT + +#if PXE_NO_UINT64_SUPPORT != 0 +typedef PXE_UINT32 PXE_UINT64[2]; +#endif // PXE_NO_UINT64_SUPPORT + +typedef unsigned PXE_UINTN; + +typedef PXE_UINT8 PXE_BOOL; + +#define PXE_FALSE 0 // zero +#define PXE_TRUE (!PXE_FALSE) + +typedef PXE_UINT16 PXE_OPCODE; + +// +// Return UNDI operational state. +// +#define PXE_OPCODE_GET_STATE 0x0000 + +// +// Change UNDI operational state from Stopped to Started. +// +#define PXE_OPCODE_START 0x0001 + +// +// Change UNDI operational state from Started to Stopped. +// +#define PXE_OPCODE_STOP 0x0002 + +// +// Get UNDI initialization information. +// +#define PXE_OPCODE_GET_INIT_INFO 0x0003 + +// +// Get NIC configuration information. +// +#define PXE_OPCODE_GET_CONFIG_INFO 0x0004 + +// +// Changed UNDI operational state from Started to Initialized. +// +#define PXE_OPCODE_INITIALIZE 0x0005 + +// +// Re-initialize the NIC H/W. +// +#define PXE_OPCODE_RESET 0x0006 + +// +// Change the UNDI operational state from Initialized to Started. +// +#define PXE_OPCODE_SHUTDOWN 0x0007 + +// +// Read & change state of external interrupt enables. +// +#define PXE_OPCODE_INTERRUPT_ENABLES 0x0008 + +// +// Read & change state of packet receive filters. +// +#define PXE_OPCODE_RECEIVE_FILTERS 0x0009 + +// +// Read & change station MAC address. +// +#define PXE_OPCODE_STATION_ADDRESS 0x000A + +// +// Read traffic statistics. +// +#define PXE_OPCODE_STATISTICS 0x000B + +// +// Convert multicast IP address to multicast MAC address. +// +#define PXE_OPCODE_MCAST_IP_TO_MAC 0x000C + +// +// Read or change non-volatile storage on the NIC. +// +#define PXE_OPCODE_NVDATA 0x000D + +// +// Get & clear interrupt status. +// +#define PXE_OPCODE_GET_STATUS 0x000E + +// +// Fill media header in packet for transmit. +// +#define PXE_OPCODE_FILL_HEADER 0x000F + +// +// Transmit packet(s). +// +#define PXE_OPCODE_TRANSMIT 0x0010 + +// +// Receive packet. +// +#define PXE_OPCODE_RECEIVE 0x0011 + +// last valid opcode: +#define PXE_OPCODE_VALID_MAX 0x0011 + +// +// Last valid PXE UNDI OpCode number. +// +#define PXE_OPCODE_LAST_VALID 0x0011 + +typedef PXE_UINT16 PXE_OPFLAGS; + +#define PXE_OPFLAGS_NOT_USED 0x0000 + +//////////////////////////////////////// +// UNDI Get State +// + +// No OpFlags + +//////////////////////////////////////// +// UNDI Start +// + +// No OpFlags + +//////////////////////////////////////// +// UNDI Stop +// + +// No OpFlags + +//////////////////////////////////////// +// UNDI Get Init Info +// + +// No Opflags + +//////////////////////////////////////// +// UNDI Get Config Info +// + +// No Opflags + +//////////////////////////////////////// +// UNDI Initialize +// + +#define PXE_OPFLAGS_INITIALIZE_CABLE_DETECT_MASK 0x0001 +#define PXE_OPFLAGS_INITIALIZE_DETECT_CABLE 0x0000 +#define PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE 0x0001 + +//////////////////////////////////////// +// UNDI Reset +// + +#define PXE_OPFLAGS_RESET_DISABLE_INTERRUPTS 0x0001 +#define PXE_OPFLAGS_RESET_DISABLE_FILTERS 0x0002 + +//////////////////////////////////////// +// UNDI Shutdown +// + +// No OpFlags + +//////////////////////////////////////// +// UNDI Interrupt Enables +// + +// +// Select whether to enable or disable external interrupt signals. +// Setting both enable and disable will return PXE_STATCODE_INVALID_OPFLAGS. +// +#define PXE_OPFLAGS_INTERRUPT_OPMASK 0xC000 +#define PXE_OPFLAGS_INTERRUPT_ENABLE 0x8000 +#define PXE_OPFLAGS_INTERRUPT_DISABLE 0x4000 +#define PXE_OPFLAGS_INTERRUPT_READ 0x0000 + +// +// Enable receive interrupts. An external interrupt will be generated +// after a complete non-error packet has been received. +// +#define PXE_OPFLAGS_INTERRUPT_RECEIVE 0x0001 + +// +// Enable transmit interrupts. An external interrupt will be generated +// after a complete non-error packet has been transmitted. +// +#define PXE_OPFLAGS_INTERRUPT_TRANSMIT 0x0002 + +// +// Enable command interrupts. An external interrupt will be generated +// when command execution stops. +// +#define PXE_OPFLAGS_INTERRUPT_COMMAND 0x0004 + +// +// Generate software interrupt. Setting this bit generates an external +// interrupt, if it is supported by the hardware. +// +#define PXE_OPFLAGS_INTERRUPT_SOFTWARE 0x0008 + +//////////////////////////////////////// +// UNDI Receive Filters +// + +// +// Select whether to enable or disable receive filters. +// Setting both enable and disable will return PXE_STATCODE_INVALID_OPCODE. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_OPMASK 0xC000 +#define PXE_OPFLAGS_RECEIVE_FILTER_ENABLE 0x8000 +#define PXE_OPFLAGS_RECEIVE_FILTER_DISABLE 0x4000 +#define PXE_OPFLAGS_RECEIVE_FILTER_READ 0x0000 + +// +// To reset the contents of the multicast MAC address filter list, +// set this OpFlag: +// +#define PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST 0x2000 + +// +// Enable unicast packet receiving. Packets sent to the current station +// MAC address will be received. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_UNICAST 0x0001 + +// +// Enable broadcast packet receiving. Packets sent to the broadcast +// MAC address will be received. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST 0x0002 + +// +// Enable filtered multicast packet receiving. Packets sent to any +// of the multicast MAC addresses in the multicast MAC address filter +// list will be received. If the filter list is empty, no multicast +// +#define PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST 0x0004 + +// +// Enable promiscuous packet receiving. All packets will be received. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS 0x0008 + +// +// Enable promiscuous multicast packet receiving. All multicast +// packets will be received. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST 0x0010 + +//////////////////////////////////////// +// UNDI Station Address +// + +#define PXE_OPFLAGS_STATION_ADDRESS_READ 0x0000 +#define PXE_OPFLAGS_STATION_ADDRESS_RESET 0x0001 + +//////////////////////////////////////// +// UNDI Statistics +// + +#define PXE_OPFLAGS_STATISTICS_READ 0x0000 +#define PXE_OPFLAGS_STATISTICS_RESET 0x0001 + +//////////////////////////////////////// +// UNDI MCast IP to MAC +// + +// +// Identify the type of IP address in the CPB. +// +#define PXE_OPFLAGS_MCAST_IP_TO_MAC_OPMASK 0x0003 +#define PXE_OPFLAGS_MCAST_IPV4_TO_MAC 0x0000 +#define PXE_OPFLAGS_MCAST_IPV6_TO_MAC 0x0001 + +//////////////////////////////////////// +// UNDI NvData +// + +// +// Select the type of non-volatile data operation. +// +#define PXE_OPFLAGS_NVDATA_OPMASK 0x0001 +#define PXE_OPFLAGS_NVDATA_READ 0x0000 +#define PXE_OPFLAGS_NVDATA_WRITE 0x0001 + +//////////////////////////////////////// +// UNDI Get Status +// + +// +// Return current interrupt status. This will also clear any interrupts +// that are currently set. This can be used in a polling routine. The +// interrupt flags are still set and cleared even when the interrupts +// are disabled. +// +#define PXE_OPFLAGS_GET_INTERRUPT_STATUS 0x0001 + +// +// Return list of transmitted buffers for recycling. Transmit buffers +// must not be changed or unallocated until they have recycled. After +// issuing a transmit command, wait for a transmit complete interrupt. +// When a transmit complete interrupt is received, read the transmitted +// buffers. Do not plan on getting one buffer per interrupt. Some +// NICs and UNDIs may transmit multiple buffers per interrupt. +// +#define PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS 0x0002 + +//////////////////////////////////////// +// UNDI Fill Header +// + +#define PXE_OPFLAGS_FILL_HEADER_OPMASK 0x0001 +#define PXE_OPFLAGS_FILL_HEADER_FRAGMENTED 0x0001 +#define PXE_OPFLAGS_FILL_HEADER_WHOLE 0x0000 + +//////////////////////////////////////// +// UNDI Transmit +// + +// +// S/W UNDI only. Return after the packet has been transmitted. A +// transmit complete interrupt will still be generated and the transmit +// buffer will have to be recycled. +// +#define PXE_OPFLAGS_SWUNDI_TRANSMIT_OPMASK 0x0001 +#define PXE_OPFLAGS_TRANSMIT_BLOCK 0x0001 +#define PXE_OPFLAGS_TRANSMIT_DONT_BLOCK 0x0000 + +// +// +// +#define PXE_OPFLAGS_TRANSMIT_OPMASK 0x0002 +#define PXE_OPFLAGS_TRANSMIT_FRAGMENTED 0x0002 +#define PXE_OPFLAGS_TRANSMIT_WHOLE 0x0000 + +//////////////////////////////////////// +// UNDI Receive +// + +// No OpFlags + +typedef PXE_UINT16 PXE_STATFLAGS; + +#define PXE_STATFLAGS_INITIALIZE 0x0000 + +//////////////////////////////////////// +// Common StatFlags that can be returned by all commands. +// + +// +// The COMMAND_COMPLETE and COMMAND_FAILED status flags must be +// implemented by all UNDIs. COMMAND_QUEUED is only needed by UNDIs +// that support command queuing. +// +#define PXE_STATFLAGS_STATUS_MASK 0xC000 +#define PXE_STATFLAGS_COMMAND_COMPLETE 0xC000 +#define PXE_STATFLAGS_COMMAND_FAILED 0x8000 +#define PXE_STATFLAGS_COMMAND_QUEUED 0x4000 +//#define PXE_STATFLAGS_INITIALIZE 0x0000 + +#define PXE_STATFLAGS_DB_WRITE_TRUNCATED 0x2000 + +//////////////////////////////////////// +// UNDI Get State +// + +#define PXE_STATFLAGS_GET_STATE_MASK 0x0003 +#define PXE_STATFLAGS_GET_STATE_INITIALIZED 0x0002 +#define PXE_STATFLAGS_GET_STATE_STARTED 0x0001 +#define PXE_STATFLAGS_GET_STATE_STOPPED 0x0000 + +//////////////////////////////////////// +// UNDI Start +// + +// No additional StatFlags + +//////////////////////////////////////// +// UNDI Get Init Info +// + +#define PXE_STATFLAGS_CABLE_DETECT_MASK 0x0001 +#define PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED 0x0000 +#define PXE_STATFLAGS_CABLE_DETECT_SUPPORTED 0x0001 + + +//////////////////////////////////////// +// UNDI Initialize +// + +#define PXE_STATFLAGS_INITIALIZED_NO_MEDIA 0x0001 + +//////////////////////////////////////// +// UNDI Reset +// + +#define PXE_STATFLAGS_RESET_NO_MEDIA 0x0001 + +//////////////////////////////////////// +// UNDI Shutdown +// + +// No additional StatFlags + +//////////////////////////////////////// +// UNDI Interrupt Enables +// + +// +// If set, receive interrupts are enabled. +// +#define PXE_STATFLAGS_INTERRUPT_RECEIVE 0x0001 + +// +// If set, transmit interrupts are enabled. +// +#define PXE_STATFLAGS_INTERRUPT_TRANSMIT 0x0002 + +// +// If set, command interrupts are enabled. +// +#define PXE_STATFLAGS_INTERRUPT_COMMAND 0x0004 + + +//////////////////////////////////////// +// UNDI Receive Filters +// + +// +// If set, unicast packets will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_UNICAST 0x0001 + +// +// If set, broadcast packets will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_BROADCAST 0x0002 + +// +// If set, multicast packets that match up with the multicast address +// filter list will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST 0x0004 + +// +// If set, all packets will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS 0x0008 + +// +// If set, all multicast packets will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST 0x0010 + +//////////////////////////////////////// +// UNDI Station Address +// + +// No additional StatFlags + +//////////////////////////////////////// +// UNDI Statistics +// + +// No additional StatFlags + +//////////////////////////////////////// +// UNDI MCast IP to MAC +// + +// No additional StatFlags + +//////////////////////////////////////// +// UNDI NvData +// + +// No additional StatFlags + + +//////////////////////////////////////// +// UNDI Get Status +// + +// +// Use to determine if an interrupt has occurred. +// +#define PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK 0x000F +#define PXE_STATFLAGS_GET_STATUS_NO_INTERRUPTS 0x0000 + +// +// If set, at least one receive interrupt occurred. +// +#define PXE_STATFLAGS_GET_STATUS_RECEIVE 0x0001 + +// +// If set, at least one transmit interrupt occurred. +// +#define PXE_STATFLAGS_GET_STATUS_TRANSMIT 0x0002 + +// +// If set, at least one command interrupt occurred. +// +#define PXE_STATFLAGS_GET_STATUS_COMMAND 0x0004 + +// +// If set, at least one software interrupt occurred. +// +#define PXE_STATFLAGS_GET_STATUS_SOFTWARE 0x0008 + +// +// This flag is set if the transmitted buffer queue is empty. This flag +// will be set if all transmitted buffer addresses get written into the DB. +// +#define PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY 0x0010 + +// +// This flag is set if no transmitted buffer addresses were written +// into the DB. (This could be because DBsize was too small.) +// +#define PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN 0x0020 + +//////////////////////////////////////// +// UNDI Fill Header +// + +// No additional StatFlags + +//////////////////////////////////////// +// UNDI Transmit +// + +// No additional StatFlags. + +//////////////////////////////////////// +// UNDI Receive +// + +// No additional StatFlags. + +typedef PXE_UINT16 PXE_STATCODE; + +#define PXE_STATCODE_INITIALIZE 0x0000 + +//////////////////////////////////////// +// Common StatCodes returned by all UNDI commands, UNDI protocol functions +// and BC protocol functions. +// + +#define PXE_STATCODE_SUCCESS 0x0000 + +#define PXE_STATCODE_INVALID_CDB 0x0001 +#define PXE_STATCODE_INVALID_CPB 0x0002 +#define PXE_STATCODE_BUSY 0x0003 +#define PXE_STATCODE_QUEUE_FULL 0x0004 +#define PXE_STATCODE_ALREADY_STARTED 0x0005 +#define PXE_STATCODE_NOT_STARTED 0x0006 +#define PXE_STATCODE_NOT_SHUTDOWN 0x0007 +#define PXE_STATCODE_ALREADY_INITIALIZED 0x0008 +#define PXE_STATCODE_NOT_INITIALIZED 0x0009 +#define PXE_STATCODE_DEVICE_FAILURE 0x000A +#define PXE_STATCODE_NVDATA_FAILURE 0x000B +#define PXE_STATCODE_UNSUPPORTED 0x000C +#define PXE_STATCODE_BUFFER_FULL 0x000D +#define PXE_STATCODE_INVALID_PARAMETER 0x000E +#define PXE_STATCODE_INVALID_UNDI 0x000F +#define PXE_STATCODE_IPV4_NOT_SUPPORTED 0x0010 +#define PXE_STATCODE_IPV6_NOT_SUPPORTED 0x0011 +#define PXE_STATCODE_NOT_ENOUGH_MEMORY 0x0012 +#define PXE_STATCODE_NO_DATA 0x0013 + + +typedef PXE_UINT16 PXE_IFNUM; + +// +// This interface number must be passed to the S/W UNDI Start command. +// +#define PXE_IFNUM_START 0x0000 + +// +// This interface number is returned by the S/W UNDI Get State and +// Start commands if information in the CDB, CPB or DB is invalid. +// +#define PXE_IFNUM_INVALID 0x0000 + +typedef PXE_UINT16 PXE_CONTROL; + +// +// Setting this flag directs the UNDI to queue this command for later +// execution if the UNDI is busy and it supports command queuing. +// If queuing is not supported, a PXE_STATCODE_INVALID_CONTROL error +// is returned. If the queue is full, a PXE_STATCODE_CDB_QUEUE_FULL +// error is returned. +// +#define PXE_CONTROL_QUEUE_IF_BUSY 0x0002 + +// +// These two bit values are used to determine if there are more UNDI +// CDB structures following this one. If the link bit is set, there +// must be a CDB structure following this one. Execution will start +// on the next CDB structure as soon as this one completes successfully. +// If an error is generated by this command, execution will stop. +// +#define PXE_CONTROL_LINK 0x0001 +#define PXE_CONTROL_LAST_CDB_IN_LIST 0x0000 + +typedef PXE_UINT8 PXE_FRAME_TYPE; + +#define PXE_FRAME_TYPE_NONE 0x00 +#define PXE_FRAME_TYPE_UNICAST 0x01 +#define PXE_FRAME_TYPE_BROADCAST 0x02 +#define PXE_FRAME_TYPE_MULTICAST 0x03 +#define PXE_FRAME_TYPE_PROMISCUOUS 0x04 + +typedef PXE_UINT32 PXE_IPV4; + +typedef PXE_UINT32 PXE_IPV6[4]; +#define PXE_MAC_LENGTH 32 + +typedef PXE_UINT8 PXE_MAC_ADDR[PXE_MAC_LENGTH]; + +typedef PXE_UINT8 PXE_IFTYPE; +typedef PXE_UINT16 PXE_MEDIA_PROTOCOL; + +// +// This information is from the ARP section of RFC 1700. +// +// 1 Ethernet (10Mb) [JBP] +// 2 Experimental Ethernet (3Mb) [JBP] +// 3 Amateur Radio AX.25 [PXK] +// 4 Proteon ProNET Token Ring [JBP] +// 5 Chaos [GXP] +// 6 IEEE 802 Networks [JBP] +// 7 ARCNET [JBP] +// 8 Hyperchannel [JBP] +// 9 Lanstar [TU] +// 10 Autonet Short Address [MXB1] +// 11 LocalTalk [JKR1] +// 12 LocalNet (IBM PCNet or SYTEK LocalNET) [JXM] +// 13 Ultra link [RXD2] +// 14 SMDS [GXC1] +// 15 Frame Relay [AGM] +// 16 Asynchronous Transmission Mode (ATM) [JXB2] +// 17 HDLC [JBP] +// 18 Fibre Channel [Yakov Rekhter] +// 19 Asynchronous Transmission Mode (ATM) [Mark Laubach] +// 20 Serial Line [JBP] +// 21 Asynchronous Transmission Mode (ATM) [MXB1] +// + +#define PXE_IFTYPE_ETHERNET 0x01 +#define PXE_IFTYPE_TOKENRING 0x04 +#define PXE_IFTYPE_FIBRE_CHANNEL 0x12 + +typedef struct s_pxe_hw_undi { +PXE_UINT32 Signature; // PXE_ROMID_SIGNATURE +PXE_UINT8 Len; // sizeof(PXE_HW_UNDI) +PXE_UINT8 Fudge; // makes 8-bit cksum equal zero +PXE_UINT8 Rev; // PXE_ROMID_REV +PXE_UINT8 IFcnt; // physical connector count +PXE_UINT8 MajorVer; // PXE_ROMID_MAJORVER +PXE_UINT8 MinorVer; // PXE_ROMID_MINORVER +PXE_UINT16 reserved; // zero, not used +PXE_UINT32 Implementation; // implementation flags +// reserved // vendor use +// PXE_UINT32 Status; // status port +// PXE_UINT32 Command; // command port +// PXE_UINT64 CDBaddr; // CDB address port +} PXE_HW_UNDI; + +// +// Status port bit definitions +// + +// +// UNDI operation state +// +#define PXE_HWSTAT_STATE_MASK 0xC0000000 +#define PXE_HWSTAT_BUSY 0xC0000000 +#define PXE_HWSTAT_INITIALIZED 0x80000000 +#define PXE_HWSTAT_STARTED 0x40000000 +#define PXE_HWSTAT_STOPPED 0x00000000 + +// +// If set, last command failed +// +#define PXE_HWSTAT_COMMAND_FAILED 0x20000000 + +// +// If set, identifies enabled receive filters +// +#define PXE_HWSTAT_PROMISCUOUS_MULTICAST_RX_ENABLED 0x00001000 +#define PXE_HWSTAT_PROMISCUOUS_RX_ENABLED 0x00000800 +#define PXE_HWSTAT_BROADCAST_RX_ENABLED 0x00000400 +#define PXE_HWSTAT_MULTICAST_RX_ENABLED 0x00000200 +#define PXE_HWSTAT_UNICAST_RX_ENABLED 0x00000100 + +// +// If set, identifies enabled external interrupts +// +#define PXE_HWSTAT_SOFTWARE_INT_ENABLED 0x00000080 +#define PXE_HWSTAT_TX_COMPLETE_INT_ENABLED 0x00000040 +#define PXE_HWSTAT_PACKET_RX_INT_ENABLED 0x00000020 +#define PXE_HWSTAT_CMD_COMPLETE_INT_ENABLED 0x00000010 + +// +// If set, identifies pending interrupts +// +#define PXE_HWSTAT_SOFTWARE_INT_PENDING 0x00000008 +#define PXE_HWSTAT_TX_COMPLETE_INT_PENDING 0x00000004 +#define PXE_HWSTAT_PACKET_RX_INT_PENDING 0x00000002 +#define PXE_HWSTAT_CMD_COMPLETE_INT_PENDING 0x00000001 + +// +// Command port definitions +// + +// +// If set, CDB identified in CDBaddr port is given to UNDI. +// If not set, other bits in this word will be processed. +// +#define PXE_HWCMD_ISSUE_COMMAND 0x80000000 +#define PXE_HWCMD_INTS_AND_FILTS 0x00000000 + +// +// Use these to enable/disable receive filters. +// +#define PXE_HWCMD_PROMISCUOUS_MULTICAST_RX_ENABLE 0x00001000 +#define PXE_HWCMD_PROMISCUOUS_RX_ENABLE 0x00000800 +#define PXE_HWCMD_BROADCAST_RX_ENABLE 0x00000400 +#define PXE_HWCMD_MULTICAST_RX_ENABLE 0x00000200 +#define PXE_HWCMD_UNICAST_RX_ENABLE 0x00000100 + +// +// Use these to enable/disable external interrupts +// +#define PXE_HWCMD_SOFTWARE_INT_ENABLE 0x00000080 +#define PXE_HWCMD_TX_COMPLETE_INT_ENABLE 0x00000040 +#define PXE_HWCMD_PACKET_RX_INT_ENABLE 0x00000020 +#define PXE_HWCMD_CMD_COMPLETE_INT_ENABLE 0x00000010 + +// +// Use these to clear pending external interrupts +// +#define PXE_HWCMD_CLEAR_SOFTWARE_INT 0x00000008 +#define PXE_HWCMD_CLEAR_TX_COMPLETE_INT 0x00000004 +#define PXE_HWCMD_CLEAR_PACKET_RX_INT 0x00000002 +#define PXE_HWCMD_CLEAR_CMD_COMPLETE_INT 0x00000001 + +typedef struct s_pxe_sw_undi { +PXE_UINT32 Signature; // PXE_ROMID_SIGNATURE +PXE_UINT8 Len; // sizeof(PXE_SW_UNDI) +PXE_UINT8 Fudge; // makes 8-bit cksum zero +PXE_UINT8 Rev; // PXE_ROMID_REV +PXE_UINT8 IFcnt; // physical connector count +PXE_UINT8 MajorVer; // PXE_ROMID_MAJORVER +PXE_UINT8 MinorVer; // PXE_ROMID_MINORVER +PXE_UINT16 reserved1; // zero, not used +PXE_UINT32 Implementation; // Implementation flags +PXE_UINT64 EntryPoint; // API entry point +PXE_UINT8 reserved2[3]; // zero, not used +PXE_UINT8 BusCnt; // number of bustypes supported +PXE_UINT32 BusType[1]; // list of supported bustypes +} PXE_SW_UNDI; + +typedef union u_pxe_undi { +PXE_HW_UNDI hw; +PXE_SW_UNDI sw; +} PXE_UNDI; + +// +// Signature of !PXE structure +// +#define PXE_ROMID_SIGNATURE PXE_BUSTYPE('!', 'P', 'X', 'E') + +// +// !PXE structure format revision +// +#define PXE_ROMID_REV 0x02 + +// +// UNDI command interface revision. These are the values that get sent +// in option 94 (Client Network Interface Identifier) in the DHCP Discover +// and PXE Boot Server Request packets. +// +#define PXE_ROMID_MAJORVER 0x03 +#define PXE_ROMID_MINORVER 0x00 + +// +// Implementation flags +// +#define PXE_ROMID_IMP_HW_UNDI 0x80000000 +#define PXE_ROMID_IMP_SW_VIRT_ADDR 0x40000000 +#define PXE_ROMID_IMP_64BIT_DEVICE 0x00010000 +#define PXE_ROMID_IMP_FRAG_SUPPORTED 0x00008000 +#define PXE_ROMID_IMP_CMD_LINK_SUPPORTED 0x00004000 +#define PXE_ROMID_IMP_CMD_QUEUE_SUPPORTED 0x00002000 +#define PXE_ROMID_IMP_MULTI_FRAME_SUPPORTED 0x00001000 +#define PXE_ROMID_IMP_NVDATA_SUPPORT_MASK 0x00000C00 +#define PXE_ROMID_IMP_NVDATA_BULK_WRITABLE 0x00000C00 +#define PXE_ROMID_IMP_NVDATA_SPARSE_WRITABLE 0x00000800 +#define PXE_ROMID_IMP_NVDATA_READ_ONLY 0x00000400 +#define PXE_ROMID_IMP_NVDATA_NOT_AVAILABLE 0x00000000 +#define PXE_ROMID_IMP_STATISTICS_SUPPORTED 0x00000200 +#define PXE_ROMID_IMP_STATION_ADDR_SETTABLE 0x00000100 +#define PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED 0x00000080 +#define PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED 0x00000040 +#define PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED 0x00000020 +#define PXE_ROMID_IMP_FILTERED_MULTICAST_RX_SUPPORTED 0x00000010 +#define PXE_ROMID_IMP_SOFTWARE_INT_SUPPORTED 0x00000008 +#define PXE_ROMID_IMP_TX_COMPLETE_INT_SUPPORTED 0x00000004 +#define PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED 0x00000002 +#define PXE_ROMID_IMP_CMD_COMPLETE_INT_SUPPORTED 0x00000001 + + +typedef struct s_pxe_cdb { +PXE_OPCODE OpCode; +PXE_OPFLAGS OpFlags; +PXE_UINT16 CPBsize; +PXE_UINT16 DBsize; +UINT64 CPBaddr; +UINT64 DBaddr; +PXE_STATCODE StatCode; +PXE_STATFLAGS StatFlags; +PXE_UINT16 IFnum; +PXE_CONTROL Control; +} PXE_CDB; + + +typedef union u_pxe_ip_addr { +PXE_IPV6 IPv6; +PXE_IPV4 IPv4; +} PXE_IP_ADDR; + +typedef union pxe_device { +// +// PCI and PC Card NICs are both identified using bus, device +// and function numbers. For PC Card, this may require PC +// Card services to be loaded in the BIOS or preboot +// environment. +// +struct { +// +// See S/W UNDI ROMID structure definition for PCI and +// PCC BusType definitions. +// +PXE_UINT32 BusType; + +// +// Bus, device & function numbers that locate this device. +// +PXE_UINT16 Bus; +PXE_UINT8 Device; +PXE_UINT8 Function; +} PCI, PCC; + +// +// %%TBD - More information is needed about enumerating +// USB and 1394 devices. +// +struct { +PXE_UINT32 BusType; +PXE_UINT32 tdb; +} USB, _1394; +} PXE_DEVICE; + +// cpb and db definitions + +#define MAX_PCI_CONFIG_LEN 64 // # of dwords +#define MAX_EEPROM_LEN 128 // #of dwords +#define MAX_XMIT_BUFFERS 32 // recycling Q length for xmit_done +#define MAX_MCAST_ADDRESS_CNT 8 + +typedef struct s_pxe_cpb_start { + // + // PXE_VOID Delay(PXE_UINT64 microseconds); + // + // UNDI will never request a delay smaller than 10 microseconds + // and will always request delays in increments of 10 microseconds. + // The Delay() CallBack routine must delay between n and n + 10 + // microseconds before returning control to the UNDI. + // + // This field cannot be set to zero. + // + PXE_UINT64 Delay; + + // + // PXE_VOID Block(PXE_UINT32 enable); + // + // UNDI may need to block multi-threaded/multi-processor access to + // critical code sections when programming or accessing the network + // device. To this end, a blocking service is needed by the UNDI. + // When UNDI needs a block, it will call Block() passing a non-zero + // value. When UNDI no longer needs a block, it will call Block() + // with a zero value. When called, if the Block() is already enabled, + // do not return control to the UNDI until the previous Block() is + // disabled. + // + // This field cannot be set to zero. + // + PXE_UINT64 Block; + + // + // PXE_VOID Virt2Phys(PXE_UINT64 virtual, PXE_UINT64 physical_ptr); + // + // UNDI will pass the virtual address of a buffer and the virtual + // address of a 64-bit physical buffer. Convert the virtual address + // to a physical address and write the result to the physical address + // buffer. If virtual and physical addresses are the same, just + // copy the virtual address to the physical address buffer. + // + // This field can be set to zero if virtual and physical addresses + // are equal. + // + PXE_UINT64 Virt2Phys; + // + // PXE_VOID Mem_IO(PXE_UINT8 read_write, PXE_UINT8 len, PXE_UINT64 port, + // PXE_UINT64 buf_addr); + // + // UNDI will read or write the device io space using this call back + // function. It passes the number of bytes as the len parameter and it + // will be either 1,2,4 or 8. + // + // This field can not be set to zero. + // + PXE_UINT64 Mem_IO; +} PXE_CPB_START; + +#define PXE_DELAY_MILLISECOND 1000 +#define PXE_DELAY_SECOND 1000000 +#define PXE_IO_READ 0 +#define PXE_IO_WRITE 1 +#define PXE_MEM_READ 2 +#define PXE_MEM_WRITE 4 + + +typedef struct s_pxe_db_get_init_info { + // + // Minimum length of locked memory buffer that must be given to + // the Initialize command. Giving UNDI more memory will generally + // give better performance. + // + // If MemoryRequired is zero, the UNDI does not need and will not + // use system memory to receive and transmit packets. + // + PXE_UINT32 MemoryRequired; + + // + // Maximum frame data length for Tx/Rx excluding the media header. + // + PXE_UINT32 FrameDataLen; + + // + // Supported link speeds are in units of mega bits. Common ethernet + // values are 10, 100 and 1000. Unused LinkSpeeds[] entries are zero + // filled. + // + PXE_UINT32 LinkSpeeds[4]; + + // + // Number of non-volatile storage items. + // + PXE_UINT32 NvCount; + + // + // Width of non-volatile storage item in bytes. 0, 1, 2 or 4 + // + PXE_UINT16 NvWidth; + + // + // Media header length. This is the typical media header length for + // this UNDI. This information is needed when allocating receive + // and transmit buffers. + // + PXE_UINT16 MediaHeaderLen; + + // + // Number of bytes in the NIC hardware (MAC) address. + // + PXE_UINT16 HWaddrLen; + + // + // Maximum number of multicast MAC addresses in the multicast + // MAC address filter list. + // + PXE_UINT16 MCastFilterCnt; + + // + // Default number and size of transmit and receive buffers that will + // be allocated by the UNDI. If MemoryRequired is non-zero, this + // allocation will come out of the memory buffer given to the Initialize + // command. If MemoryRequired is zero, this allocation will come out of + // memory on the NIC. + // + PXE_UINT16 TxBufCnt; + PXE_UINT16 TxBufSize; + PXE_UINT16 RxBufCnt; + PXE_UINT16 RxBufSize; + + // + // Hardware interface types defined in the Assigned Numbers RFC + // and used in DHCP and ARP packets. + // See the PXE_IFTYPE typedef and PXE_IFTYPE_xxx macros. + // + PXE_UINT8 IFtype; + + // + // Supported duplex. See PXE_DUPLEX_xxxxx #defines below. + // + PXE_UINT8 Duplex; + + // + // Supported loopback options. See PXE_LOOPBACK_xxxxx #defines below. + // + PXE_UINT8 LoopBack; +} PXE_DB_GET_INIT_INFO; + +#define PXE_MAX_TXRX_UNIT_ETHER 1500 + +#define PXE_HWADDR_LEN_ETHER 0x0006 +#define PXE_MAC_HEADER_LEN_ETHER 0x000E + +#define PXE_DUPLEX_ENABLE_FULL_SUPPORTED 1 +#define PXE_DUPLEX_FORCE_FULL_SUPPORTED 2 + +#define PXE_LOOPBACK_INTERNAL_SUPPORTED 1 +#define PXE_LOOPBACK_EXTERNAL_SUPPORTED 2 + + +typedef struct s_pxe_pci_config_info { + // + // This is the flag field for the PXE_DB_GET_CONFIG_INFO union. + // For PCI bus devices, this field is set to PXE_BUSTYPE_PCI. + // + PXE_UINT32 BusType; + + // + // This identifies the PCI network device that this UNDI interface + // is bound to. + // + PXE_UINT16 Bus; + PXE_UINT8 Device; + PXE_UINT8 Function; + + // + // This is a copy of the PCI configuration space for this + // network device. + // + union { + PXE_UINT8 Byte[256]; + PXE_UINT16 Word[128]; + PXE_UINT32 Dword[64]; + } Config; +} PXE_PCI_CONFIG_INFO; + + +typedef struct s_pxe_pcc_config_info { + // + // This is the flag field for the PXE_DB_GET_CONFIG_INFO union. + // For PCC bus devices, this field is set to PXE_BUSTYPE_PCC. + // + PXE_UINT32 BusType; + + // + // This identifies the PCC network device that this UNDI interface + // is bound to. + // + PXE_UINT16 Bus; + PXE_UINT8 Device; + PXE_UINT8 Function; + + // + // This is a copy of the PCC configuration space for this + // network device. + // + union { + PXE_UINT8 Byte[256]; + PXE_UINT16 Word[128]; + PXE_UINT32 Dword[64]; + } Config; +} PXE_PCC_CONFIG_INFO; + + +typedef struct s_pxe_usb_config_info { + PXE_UINT32 BusType; + // %%TBD What should we return here... +} PXE_USB_CONFIG_INFO; + + +typedef struct s_pxe_1394_config_info { + PXE_UINT32 BusType; + // %%TBD What should we return here... +} PXE_1394_CONFIG_INFO; + + +typedef union u_pxe_db_get_config_info { + PXE_PCI_CONFIG_INFO pci; + PXE_PCC_CONFIG_INFO pcc; + PXE_USB_CONFIG_INFO usb; + PXE_1394_CONFIG_INFO _1394; +} PXE_DB_GET_CONFIG_INFO; + + +typedef struct s_pxe_cpb_initialize { + // + // Address of first (lowest) byte of the memory buffer. This buffer must + // be in contiguous physical memory and cannot be swapped out. The UNDI + // will be using this for transmit and receive buffering. + // + PXE_UINT64 MemoryAddr; + + // + // MemoryLength must be greater than or equal to MemoryRequired + // returned by the Get Init Info command. + // + PXE_UINT32 MemoryLength; + + // + // Desired link speed in Mbit/sec. Common ethernet values are 10, 100 + // and 1000. Setting a value of zero will auto-detect and/or use the + // default link speed (operation depends on UNDI/NIC functionality). + // + PXE_UINT32 LinkSpeed; + + // + // Suggested number and size of receive and transmit buffers to + // allocate. If MemoryAddr and MemoryLength are non-zero, this + // allocation comes out of the supplied memory buffer. If MemoryAddr + // and MemoryLength are zero, this allocation comes out of memory + // on the NIC. + // + // If these fields are set to zero, the UNDI will allocate buffer + // counts and sizes as it sees fit. + // + PXE_UINT16 TxBufCnt; + PXE_UINT16 TxBufSize; + PXE_UINT16 RxBufCnt; + PXE_UINT16 RxBufSize; + + // + // The following configuration parameters are optional and must be zero + // to use the default values. + // + PXE_UINT8 Duplex; + + PXE_UINT8 LoopBack; +} PXE_CPB_INITIALIZE; + + +#define PXE_DUPLEX_DEFAULT 0x00 +#define PXE_FORCE_FULL_DUPLEX 0x01 +#define PXE_ENABLE_FULL_DUPLEX 0x02 + +#define LOOPBACK_NORMAL 0 +#define LOOPBACK_INTERNAL 1 +#define LOOPBACK_EXTERNAL 2 + + +typedef struct s_pxe_db_initialize { + // + // Actual amount of memory used from the supplied memory buffer. This + // may be less that the amount of memory suppllied and may be zero if + // the UNDI and network device do not use external memory buffers. + // + // Memory used by the UNDI and network device is allocated from the + // lowest memory buffer address. + // + PXE_UINT32 MemoryUsed; + + // + // Actual number and size of receive and transmit buffers that were + // allocated. + // + PXE_UINT16 TxBufCnt; + PXE_UINT16 TxBufSize; + PXE_UINT16 RxBufCnt; + PXE_UINT16 RxBufSize; +} PXE_DB_INITIALIZE; + + +typedef struct s_pxe_cpb_receive_filters { + // + // List of multicast MAC addresses. This list, if present, will + // replace the existing multicast MAC address filter list. + // + PXE_MAC_ADDR MCastList[MAX_MCAST_ADDRESS_CNT]; +} PXE_CPB_RECEIVE_FILTERS; + + +typedef struct s_pxe_db_receive_filters { + // + // Filtered multicast MAC address list. + // + PXE_MAC_ADDR MCastList[MAX_MCAST_ADDRESS_CNT]; +} PXE_DB_RECEIVE_FILTERS; + + +typedef struct s_pxe_cpb_station_address { + // + // If supplied and supported, the current station MAC address + // will be changed. + // + PXE_MAC_ADDR StationAddr; +} PXE_CPB_STATION_ADDRESS; + + +typedef struct s_pxe_dpb_station_address { + // + // Current station MAC address. + // + PXE_MAC_ADDR StationAddr; + + // + // Station broadcast MAC address. + // + PXE_MAC_ADDR BroadcastAddr; + + // + // Permanent station MAC address. + // + PXE_MAC_ADDR PermanentAddr; +} PXE_DB_STATION_ADDRESS; + + +typedef struct s_pxe_db_statistics { + // + // Bit field identifying what statistic data is collected by the + // UNDI/NIC. + // If bit 0x00 is set, Data[0x00] is collected. + // If bit 0x01 is set, Data[0x01] is collected. + // If bit 0x20 is set, Data[0x20] is collected. + // If bit 0x21 is set, Data[0x21] is collected. + // Etc. + // + PXE_UINT64 Supported; + + // + // Statistic data. + // + PXE_UINT64 Data[64]; +} PXE_DB_STATISTICS; + +// +// Total number of frames received. Includes frames with errors and +// dropped frames. +// +#define PXE_STATISTICS_RX_TOTAL_FRAMES 0x00 + +// +// Number of valid frames received and copied into receive buffers. +// +#define PXE_STATISTICS_RX_GOOD_FRAMES 0x01 + +// +// Number of frames below the minimum length for the media. +// This would be <64 for ethernet. +// +#define PXE_STATISTICS_RX_UNDERSIZE_FRAMES 0x02 + +// +// Number of frames longer than the maxminum length for the +// media. This would be >1500 for ethernet. +// +#define PXE_STATISTICS_RX_OVERSIZE_FRAMES 0x03 + +// +// Valid frames that were dropped because receive buffers were full. +// +#define PXE_STATISTICS_RX_DROPPED_FRAMES 0x04 + +// +// Number of valid unicast frames received and not dropped. +// +#define PXE_STATISTICS_RX_UNICAST_FRAMES 0x05 + +// +// Number of valid broadcast frames received and not dropped. +// +#define PXE_STATISTICS_RX_BROADCAST_FRAMES 0x06 + +// +// Number of valid mutlicast frames received and not dropped. +// +#define PXE_STATISTICS_RX_MULTICAST_FRAMES 0x07 + +// +// Number of frames w/ CRC or alignment errors. +// +#define PXE_STATISTICS_RX_CRC_ERROR_FRAMES 0x08 + +// +// Total number of bytes received. Includes frames with errors +// and dropped frames. +// +#define PXE_STATISTICS_RX_TOTAL_BYTES 0x09 + +// +// Transmit statistics. +// +#define PXE_STATISTICS_TX_TOTAL_FRAMES 0x0A +#define PXE_STATISTICS_TX_GOOD_FRAMES 0x0B +#define PXE_STATISTICS_TX_UNDERSIZE_FRAMES 0x0C +#define PXE_STATISTICS_TX_OVERSIZE_FRAMES 0x0D +#define PXE_STATISTICS_TX_DROPPED_FRAMES 0x0E +#define PXE_STATISTICS_TX_UNICAST_FRAMES 0x0F +#define PXE_STATISTICS_TX_BROADCAST_FRAMES 0x10 +#define PXE_STATISTICS_TX_MULTICAST_FRAMES 0x11 +#define PXE_STATISTICS_TX_CRC_ERROR_FRAMES 0x12 +#define PXE_STATISTICS_TX_TOTAL_BYTES 0x13 + +// +// Number of collisions detection on this subnet. +// +#define PXE_STATISTICS_COLLISIONS 0x14 + +// +// Number of frames destined for unsupported protocol. +// +#define PXE_STATISTICS_UNSUPPORTED_PROTOCOL 0x15 + + +typedef struct s_pxe_cpb_mcast_ip_to_mac { + // + // Multicast IP address to be converted to multicast MAC address. + // + PXE_IP_ADDR IP; +} PXE_CPB_MCAST_IP_TO_MAC; + + +typedef struct s_pxe_db_mcast_ip_to_mac { + // + // Multicast MAC address. + // + PXE_MAC_ADDR MAC; +} PXE_DB_MCAST_IP_TO_MAC; + + +typedef struct s_pxe_cpb_nvdata_sparse { + // + // NvData item list. Only items in this list will be updated. + // + struct { + // Non-volatile storage address to be changed. + PXE_UINT32 Addr; + + // Data item to write into above storage address. + + union { + PXE_UINT8 Byte; + PXE_UINT16 Word; + PXE_UINT32 Dword; + } Data; + } Item[MAX_EEPROM_LEN]; +} PXE_CPB_NVDATA_SPARSE; + + +// +// When using bulk update, the size of the CPB structure must be +// the same size as the non-volatile NIC storage. +// +typedef union u_pxe_cpb_nvdata_bulk { + // + // Array of byte-wide data items. + // + PXE_UINT8 Byte[MAX_EEPROM_LEN << 2]; + + // + // Array of word-wide data items. + // + PXE_UINT16 Word[MAX_EEPROM_LEN << 1]; + + // + // Array of dword-wide data items. + // + PXE_UINT32 Dword[MAX_EEPROM_LEN]; +} PXE_CPB_NVDATA_BULK; + +typedef struct s_pxe_db_nvdata { + + // Arrays of data items from non-volatile storage. + + union { + // + // Array of byte-wide data items. + // + PXE_UINT8 Byte[MAX_EEPROM_LEN << 2]; + + // + // Array of word-wide data items. + // + PXE_UINT16 Word[MAX_EEPROM_LEN << 1]; + + // Array of dword-wide data items. + + PXE_UINT32 Dword[MAX_EEPROM_LEN]; + } Data; +} PXE_DB_NVDATA; + + +typedef struct s_pxe_db_get_status { + // + // Length of next receive frame (header + data). If this is zero, + // there is no next receive frame available. + // + PXE_UINT32 RxFrameLen; + + // + // Reserved, set to zero. + // + PXE_UINT32 reserved; + + // + // Addresses of transmitted buffers that need to be recycled. + // + PXE_UINT64 TxBuffer[MAX_XMIT_BUFFERS]; +} PXE_DB_GET_STATUS; + + + +typedef struct s_pxe_cpb_fill_header { + // + // Source and destination MAC addresses. These will be copied into + // the media header without doing byte swapping. + // + PXE_MAC_ADDR SrcAddr; + PXE_MAC_ADDR DestAddr; + + // + // Address of first byte of media header. The first byte of packet data + // follows the last byte of the media header. + // + PXE_UINT64 MediaHeader; + + // + // Length of packet data in bytes (not including the media header). + // + PXE_UINT32 PacketLen; + + // + // Protocol type. This will be copied into the media header without + // doing byte swapping. Protocol type numbers can be obtained from + // the Assigned Numbers RFC 1700. + // + PXE_UINT16 Protocol; + + // + // Length of the media header in bytes. + // + PXE_UINT16 MediaHeaderLen; +} PXE_CPB_FILL_HEADER; + + +#define PXE_PROTOCOL_ETHERNET_IP 0x0800 +#define PXE_PROTOCOL_ETHERNET_ARP 0x0806 +#define MAX_XMIT_FRAGMENTS 16 + +typedef struct s_pxe_cpb_fill_header_fragmented { + // + // Source and destination MAC addresses. These will be copied into + // the media header without doing byte swapping. + // + PXE_MAC_ADDR SrcAddr; + PXE_MAC_ADDR DestAddr; + + // + // Length of packet data in bytes (not including the media header). + // + PXE_UINT32 PacketLen; + + // + // Protocol type. This will be copied into the media header without + // doing byte swapping. Protocol type numbers can be obtained from + // the Assigned Numbers RFC 1700. + // + PXE_MEDIA_PROTOCOL Protocol; + + // + // Length of the media header in bytes. + // + PXE_UINT16 MediaHeaderLen; + + // + // Number of packet fragment descriptors. + // + PXE_UINT16 FragCnt; + + // + // Reserved, must be set to zero. + // + PXE_UINT16 reserved; + + // + // Array of packet fragment descriptors. The first byte of the media + // header is the first byte of the first fragment. + // + struct { + // + // Address of this packet fragment. + // + PXE_UINT64 FragAddr; + + // + // Length of this packet fragment. + // + PXE_UINT32 FragLen; + + // + // Reserved, must be set to zero. + // + PXE_UINT32 reserved; + } FragDesc[MAX_XMIT_FRAGMENTS]; +} PXE_CPB_FILL_HEADER_FRAGMENTED; + + + +typedef struct s_pxe_cpb_transmit { + // + // Address of first byte of frame buffer. This is also the first byte + // of the media header. + // + PXE_UINT64 FrameAddr; + + // + // Length of the data portion of the frame buffer in bytes. Do not + // include the length of the media header. + // + PXE_UINT32 DataLen; + + // + // Length of the media header in bytes. + // + PXE_UINT16 MediaheaderLen; + + // + // Reserved, must be zero. + // + PXE_UINT16 reserved; +} PXE_CPB_TRANSMIT; + + + +typedef struct s_pxe_cpb_transmit_fragments { + // + // Length of packet data in bytes (not including the media header). + // + PXE_UINT32 FrameLen; + + // + // Length of the media header in bytes. + // + PXE_UINT16 MediaheaderLen; + + // + // Number of packet fragment descriptors. + // + PXE_UINT16 FragCnt; + + // + // Array of frame fragment descriptors. The first byte of the first + // fragment is also the first byte of the media header. + // + struct { + // + // Address of this frame fragment. + // + PXE_UINT64 FragAddr; + + // + // Length of this frame fragment. + // + PXE_UINT32 FragLen; + + // + // Reserved, must be set to zero. + // + PXE_UINT32 reserved; + } FragDesc[MAX_XMIT_FRAGMENTS]; +} PXE_CPB_TRANSMIT_FRAGMENTS; + + +typedef struct s_pxe_cpb_receive { + // + // Address of first byte of receive buffer. This is also the first byte + // of the frame header. + // + PXE_UINT64 BufferAddr; + + // + // Length of receive buffer. This must be large enough to hold the + // received frame (media header + data). If the length of smaller than + // the received frame, data will be lost. + // + PXE_UINT32 BufferLen; + + // + // Reserved, must be set to zero. + // + PXE_UINT32 reserved; +} PXE_CPB_RECEIVE; + + +typedef struct s_pxe_db_receive { + // + // Source and destination MAC addresses from media header. + // + PXE_MAC_ADDR SrcAddr; + PXE_MAC_ADDR DestAddr; + + // + // Length of received frame. May be larger than receive buffer size. + // The receive buffer will not be overwritten. This is how to tell + // if data was lost because the receive buffer was too small. + // + PXE_UINT32 FrameLen; + + // + // Protocol type from media header. + // + PXE_MEDIA_PROTOCOL Protocol; + + // + // Length of media header in received frame. + // + PXE_UINT16 MediaHeaderLen; + + // + // Type of receive frame. + // + PXE_FRAME_TYPE Type; + + // + // Reserved, must be zero. + // + PXE_UINT8 reserved[7]; + +} PXE_DB_RECEIVE; + +#pragma pack() + +/* EOF - efi_pxe.h */ +#endif /* _EFI_PXE_H */ + diff --git a/gnu-efi/inc/efiapi.h b/gnu-efi/inc/efiapi.h new file mode 100644 index 0000000..bdf5de2 --- /dev/null +++ b/gnu-efi/inc/efiapi.h @@ -0,0 +1,967 @@ +#ifndef _EFI_API_H +#define _EFI_API_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efiapi.h + +Abstract: + + Global EFI runtime & boot service interfaces + + + + +Revision History + +--*/ + +// +// EFI Specification Revision +// + +#define EFI_SPECIFICATION_MAJOR_REVISION 1 +#define EFI_SPECIFICATION_MINOR_REVISION 02 + +// +// Declare forward referenced data structures +// + +INTERFACE_DECL(_EFI_SYSTEM_TABLE); + +// +// EFI Memory +// + +typedef +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_PAGES) ( + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN NoPages, + OUT EFI_PHYSICAL_ADDRESS *Memory + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FREE_PAGES) ( + IN EFI_PHYSICAL_ADDRESS Memory, + IN UINTN NoPages + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_MEMORY_MAP) ( + IN OUT UINTN *MemoryMapSize, + IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, + OUT UINTN *MapKey, + OUT UINTN *DescriptorSize, + OUT UINT32 *DescriptorVersion + ); + +#define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size)) + + +typedef +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_POOL) ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN Size, + OUT VOID **Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FREE_POOL) ( + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) ( + IN UINTN MemoryMapSize, + IN UINTN DescriptorSize, + IN UINT32 DescriptorVersion, + IN EFI_MEMORY_DESCRIPTOR *VirtualMap + ); + + +#define EFI_OPTIONAL_PTR 0x00000001 +#define EFI_INTERNAL_FNC 0x00000002 // Pointer to internal runtime fnc +#define EFI_INTERNAL_PTR 0x00000004 // Pointer to internal runtime data + + +typedef +EFI_STATUS +(EFIAPI *EFI_CONVERT_POINTER) ( + IN UINTN DebugDisposition, + IN OUT VOID **Address + ); + + +// +// EFI Events +// + +#define EVT_TIMER 0x80000000 +#define EVT_RUNTIME 0x40000000 +#define EVT_RUNTIME_CONTEXT 0x20000000 + +#define EVT_NOTIFY_WAIT 0x00000100 +#define EVT_NOTIFY_SIGNAL 0x00000200 + +#define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201 +#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 + +#define EVT_EFI_SIGNAL_MASK 0x000000FF +#define EVT_EFI_SIGNAL_MAX 4 + +#define EFI_EVENT_TIMER EVT_TIMER +#define EFI_EVENT_RUNTIME EVT_RUNTIME +#define EFI_EVENT_RUNTIME_CONTEXT EVT_RUNTIME_CONTEXT +#define EFI_EVENT_NOTIFY_WAIT EVT_NOTIFY_WAIT +#define EFI_EVENT_NOTIFY_SIGNAL EVT_NOTIFY_SIGNAL +#define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES EVT_SIGNAL_EXIT_BOOT_SERVICES +#define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE +#define EFI_EVENT_EFI_SIGNAL_MASK EVT_EFI_SIGNAL_MASK +#define EFI_EVENT_EFI_SIGNAL_MAX EVT_EFI_SIGNAL_MAX + + +typedef +VOID +(EFIAPI *EFI_EVENT_NOTIFY) ( + IN EFI_EVENT Event, + IN VOID *Context + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CREATE_EVENT) ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *Event + ); + +typedef enum { + TimerCancel, + TimerPeriodic, + TimerRelative, + TimerTypeMax +} EFI_TIMER_DELAY; + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_TIMER) ( + IN EFI_EVENT Event, + IN EFI_TIMER_DELAY Type, + IN UINT64 TriggerTime + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SIGNAL_EVENT) ( + IN EFI_EVENT Event + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_WAIT_FOR_EVENT) ( + IN UINTN NumberOfEvents, + IN EFI_EVENT *Event, + OUT UINTN *Index + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CLOSE_EVENT) ( + IN EFI_EVENT Event + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CHECK_EVENT) ( + IN EFI_EVENT Event + ); + +// +// Task priority level +// + +#define TPL_APPLICATION 4 +#define TPL_CALLBACK 8 +#define TPL_NOTIFY 16 +#define TPL_HIGH_LEVEL 31 +#define EFI_TPL_APPLICATION TPL_APPLICATION +#define EFI_TPL_CALLBACK TPL_CALLBACK +#define EFI_TPL_NOTIFY TPL_NOTIFY +#define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL +typedef +EFI_TPL +(EFIAPI *EFI_RAISE_TPL) ( + IN EFI_TPL NewTpl + ); + +typedef +VOID +(EFIAPI *EFI_RESTORE_TPL) ( + IN EFI_TPL OldTpl + ); + + +// +// EFI platform varibles +// + +#define EFI_GLOBAL_VARIABLE \ + { 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} } + +// Variable attributes +#define EFI_VARIABLE_NON_VOLATILE 0x00000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 +#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 +#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020 +#define EFI_VARIABLE_APPEND_WRITE 0x00000040 + +// Variable size limitation +#define EFI_MAXIMUM_VARIABLE_SIZE 1024 + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_VARIABLE) ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_VARIABLE) ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ); + + +// +// EFI Time +// + +typedef struct { + UINT32 Resolution; // 1e-6 parts per million + UINT32 Accuracy; // hertz + BOOLEAN SetsToZero; // Set clears sub-second time +} EFI_TIME_CAPABILITIES; + + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_TIME) ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_TIME) ( + IN EFI_TIME *Time + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_WAKEUP_TIME) ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_WAKEUP_TIME) ( + IN BOOLEAN Enable, + IN EFI_TIME *Time OPTIONAL + ); + + +// +// Image functions +// + + +// PE32+ Subsystem type for EFI images + +#if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION) +#define IMAGE_SUBSYSTEM_EFI_APPLICATION 10 +#define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 +#define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 +#endif + +// PE32+ Machine type for EFI images + +#if !defined(EFI_IMAGE_MACHINE_IA32) +#define EFI_IMAGE_MACHINE_IA32 0x014c +#endif + +#if !defined(EFI_IMAGE_MACHINE_IA64) +#define EFI_IMAGE_MACHINE_IA64 0x0200 +#endif + +#if !defined(EFI_IMAGE_MACHINE_EBC) +#define EFI_IMAGE_MACHINE_EBC 0x0EBC +#endif + +#if !defined(EFI_IMAGE_MACHINE_X64) +#define EFI_IMAGE_MACHINE_X64 0x8664 +#endif + +#if !defined(EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) +#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2 +#endif + +#if !defined(EFI_IMAGE_MACHINE_AARCH64) +#define EFI_IMAGE_MACHINE_AARCH64 0xAA64 +#endif + +// Image Entry prototype + +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_ENTRY_POINT) ( + IN EFI_HANDLE ImageHandle, + IN struct _EFI_SYSTEM_TABLE *SystemTable + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_LOAD) ( + IN BOOLEAN BootPolicy, + IN EFI_HANDLE ParentImageHandle, + IN EFI_DEVICE_PATH *FilePath, + IN VOID *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + OUT EFI_HANDLE *ImageHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_START) ( + IN EFI_HANDLE ImageHandle, + OUT UINTN *ExitDataSize, + OUT CHAR16 **ExitData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_EXIT) ( + IN EFI_HANDLE ImageHandle, + IN EFI_STATUS ExitStatus, + IN UINTN ExitDataSize, + IN CHAR16 *ExitData OPTIONAL + ); + + +// Image handle +/*#define LOADED_IMAGE_PROTOCOL \ + { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } + +#define EFI_IMAGE_INFORMATION_REVISION 0x1000 +typedef struct { + UINT32 Revision; + EFI_HANDLE ParentHandle; + struct _EFI_SYSTEM_TABLE *SystemTable; + + // Source location of image + EFI_HANDLE DeviceHandle; + EFI_DEVICE_PATH *FilePath; + VOID *Reserved; + + // Images load options + UINT32 LoadOptionsSize; + VOID *LoadOptions; + + // Location of where image was loaded + VOID *ImageBase; + UINT64 ImageSize; + EFI_MEMORY_TYPE ImageCodeType; + EFI_MEMORY_TYPE ImageDataType; + + // If the driver image supports a dynamic unload request + EFI_IMAGE_UNLOAD Unload; + +} EFI_LOADED_IMAGE;*/ + + +typedef +EFI_STATUS +(EFIAPI *EFI_EXIT_BOOT_SERVICES) ( + IN EFI_HANDLE ImageHandle, + IN UINTN MapKey + ); + +// +// Misc +// + + +typedef +EFI_STATUS +(EFIAPI *EFI_STALL) ( + IN UINTN Microseconds + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_WATCHDOG_TIMER) ( + IN UINTN Timeout, + IN UINT64 WatchdogCode, + IN UINTN DataSize, + IN CHAR16 *WatchdogData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CONNECT_CONTROLLER) ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE *DriverImageHandle OPTIONAL, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL, + IN BOOLEAN Recursive + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISCONNECT_CONTROLLER) ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE DriverImageHandle OPTIONAL, + IN EFI_HANDLE ChildHandle OPTIONAL + ); + +#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 +#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 +#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 +#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 +#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 +#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 + +typedef +EFI_STATUS +(EFIAPI *EFI_OPEN_PROTOCOL) ( + IN EFI_HANDLE Handle, + IN EFI_GUID *Protocol, + OUT VOID **Interface OPTIONAL, + IN EFI_HANDLE AgentHandle, + IN EFI_HANDLE ControllerHandle, + IN UINT32 Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CLOSE_PROTOCOL) ( + IN EFI_HANDLE Handle, + IN EFI_GUID *Protocol, + IN EFI_HANDLE AgentHandle, + IN EFI_HANDLE ControllerHandle + ); + +typedef struct { + EFI_HANDLE AgentHandle; + EFI_HANDLE ControllerHandle; + UINT32 Attributes; + UINT32 OpenCount; +} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY; + +typedef +EFI_STATUS +(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) ( + IN EFI_HANDLE Handle, + IN EFI_GUID *Protocol, + OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, + OUT UINTN *EntryCount + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PROTOCOLS_PER_HANDLE) ( + IN EFI_HANDLE Handle, + OUT EFI_GUID ***ProtocolBuffer, + OUT UINTN *ProtocolBufferCount + ); + +typedef enum { + AllHandles, + ByRegisterNotify, + ByProtocol +} EFI_LOCATE_SEARCH_TYPE; + +typedef +EFI_STATUS +(EFIAPI *EFI_LOCATE_HANDLE_BUFFER) ( + IN EFI_LOCATE_SEARCH_TYPE SearchType, + IN EFI_GUID *Protocol OPTIONAL, + IN VOID *SearchKey OPTIONAL, + IN OUT UINTN *NoHandles, + OUT EFI_HANDLE **Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_LOCATE_PROTOCOL) ( + IN EFI_GUID *Protocol, + IN VOID *Registration OPTIONAL, + OUT VOID **Interface + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( + IN OUT EFI_HANDLE *Handle, + ... + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( + IN OUT EFI_HANDLE Handle, + ... + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CALCULATE_CRC32) ( + IN VOID *Data, + IN UINTN DataSize, + OUT UINT32 *Crc32 + ); + +typedef +VOID +(EFIAPI *EFI_COPY_MEM) ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ); + +typedef +VOID +(EFIAPI *EFI_SET_MEM) ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_CREATE_EVENT_EX) ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, + IN const VOID *NotifyContext OPTIONAL, + IN const EFI_GUID *EventGroup OPTIONAL, + OUT EFI_EVENT *Event + ); + +typedef enum { + EfiResetCold, + EfiResetWarm, + EfiResetShutdown +} EFI_RESET_TYPE; + +typedef +EFI_STATUS +(EFIAPI *EFI_RESET_SYSTEM) ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) ( + OUT UINT64 *Count + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) ( + OUT UINT32 *HighCount + ); + +typedef struct { + UINT64 Length; + union { + EFI_PHYSICAL_ADDRESS DataBlock; + EFI_PHYSICAL_ADDRESS ContinuationPointer; + } Union; +} EFI_CAPSULE_BLOCK_DESCRIPTOR; + +typedef struct { + EFI_GUID CapsuleGuid; + UINT32 HeaderSize; + UINT32 Flags; + UINT32 CapsuleImageSize; +} EFI_CAPSULE_HEADER; + +#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 +#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 +#define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 + +typedef +EFI_STATUS +(EFIAPI *EFI_UPDATE_CAPSULE) ( + IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) ( + IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + OUT UINT64 *MaximumCapsuleSize, + OUT EFI_RESET_TYPE *ResetType + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_QUERY_VARIABLE_INFO) ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ); + +// +// Protocol handler functions +// + +typedef enum { + EFI_NATIVE_INTERFACE, + EFI_PCODE_INTERFACE +} EFI_INTERFACE_TYPE; + +typedef +EFI_STATUS +(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) ( + IN OUT EFI_HANDLE *Handle, + IN EFI_GUID *Protocol, + IN EFI_INTERFACE_TYPE InterfaceType, + IN VOID *Interface + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) ( + IN EFI_HANDLE Handle, + IN EFI_GUID *Protocol, + IN VOID *OldInterface, + IN VOID *NewInterface + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) ( + IN EFI_HANDLE Handle, + IN EFI_GUID *Protocol, + IN VOID *Interface + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HANDLE_PROTOCOL) ( + IN EFI_HANDLE Handle, + IN EFI_GUID *Protocol, + OUT VOID **Interface + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) ( + IN EFI_GUID *Protocol, + IN EFI_EVENT Event, + OUT VOID **Registration + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_LOCATE_HANDLE) ( + IN EFI_LOCATE_SEARCH_TYPE SearchType, + IN EFI_GUID *Protocol OPTIONAL, + IN VOID *SearchKey OPTIONAL, + IN OUT UINTN *BufferSize, + OUT EFI_HANDLE *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_LOCATE_DEVICE_PATH) ( + IN EFI_GUID *Protocol, + IN OUT EFI_DEVICE_PATH **DevicePath, + OUT EFI_HANDLE *Device + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) ( + IN EFI_GUID *Guid, + IN VOID *Table + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_RESERVED_SERVICE) ( + ); + +// +// Standard EFI table header +// + +typedef struct _EFI_TABLE_HEADER { + UINT64 Signature; + UINT32 Revision; + UINT32 HeaderSize; + UINT32 CRC32; + UINT32 Reserved; +} EFI_TABLE_HEADER; + + +// +// EFI Runtime Serivces Table +// + +#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 +#define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) + +typedef struct { + EFI_TABLE_HEADER Hdr; + + // + // Time services + // + + EFI_GET_TIME GetTime; + EFI_SET_TIME SetTime; + EFI_GET_WAKEUP_TIME GetWakeupTime; + EFI_SET_WAKEUP_TIME SetWakeupTime; + + // + // Virtual memory services + // + + EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; + EFI_CONVERT_POINTER ConvertPointer; + + // + // Variable serviers + // + + EFI_GET_VARIABLE GetVariable; + EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; + EFI_SET_VARIABLE SetVariable; + + // + // Misc + // + + EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; + EFI_RESET_SYSTEM ResetSystem; + + EFI_UPDATE_CAPSULE UpdateCapsule; + EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities; + EFI_QUERY_VARIABLE_INFO QueryVariableInfo; +} EFI_RUNTIME_SERVICES; + + +// +// EFI Boot Services Table +// + +#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 +#define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) + +typedef struct _EFI_BOOT_SERVICES { + + EFI_TABLE_HEADER Hdr; + + // + // Task priority functions + // + + EFI_RAISE_TPL RaiseTPL; + EFI_RESTORE_TPL RestoreTPL; + + // + // Memory functions + // + + EFI_ALLOCATE_PAGES AllocatePages; + EFI_FREE_PAGES FreePages; + EFI_GET_MEMORY_MAP GetMemoryMap; + EFI_ALLOCATE_POOL AllocatePool; + EFI_FREE_POOL FreePool; + + // + // Event & timer functions + // + + EFI_CREATE_EVENT CreateEvent; + EFI_SET_TIMER SetTimer; + EFI_WAIT_FOR_EVENT WaitForEvent; + EFI_SIGNAL_EVENT SignalEvent; + EFI_CLOSE_EVENT CloseEvent; + EFI_CHECK_EVENT CheckEvent; + + // + // Protocol handler functions + // + + EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface; + EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface; + EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface; + EFI_HANDLE_PROTOCOL HandleProtocol; + EFI_HANDLE_PROTOCOL PCHandleProtocol; + EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify; + EFI_LOCATE_HANDLE LocateHandle; + EFI_LOCATE_DEVICE_PATH LocateDevicePath; + EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable; + + // + // Image functions + // + + EFI_IMAGE_LOAD LoadImage; + EFI_IMAGE_START StartImage; + EFI_EXIT Exit; + EFI_IMAGE_UNLOAD UnloadImage; + EFI_EXIT_BOOT_SERVICES ExitBootServices; + + // + // Misc functions + // + + EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; + EFI_STALL Stall; + EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; + + // + // DriverSupport Services + // + + EFI_CONNECT_CONTROLLER ConnectController; + EFI_DISCONNECT_CONTROLLER DisconnectController; + + // + // Open and Close Protocol Services + // + EFI_OPEN_PROTOCOL OpenProtocol; + EFI_CLOSE_PROTOCOL CloseProtocol; + EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation; + + // + // Library Services + // + EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle; + EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer; + EFI_LOCATE_PROTOCOL LocateProtocol; + EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces; + EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces; + + // + // 32-bit CRC Services + // + EFI_CALCULATE_CRC32 CalculateCrc32; + + // + // Misc Services + // + EFI_COPY_MEM CopyMem; + EFI_SET_MEM SetMem; + EFI_CREATE_EVENT_EX CreateEventEx; +} EFI_BOOT_SERVICES; + + +// +// EFI Configuration Table and GUID definitions +// + +#define MPS_TABLE_GUID \ + { 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define ACPI_TABLE_GUID \ + { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define ACPI_20_TABLE_GUID \ + { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } + +#define SMBIOS_TABLE_GUID \ + { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define SMBIOS3_TABLE_GUID \ + { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94} } + +#define SAL_SYSTEM_TABLE_GUID \ + { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + + +typedef struct _EFI_CONFIGURATION_TABLE { + EFI_GUID VendorGuid; + VOID *VendorTable; +} EFI_CONFIGURATION_TABLE; + + +// +// EFI System Table +// + + + + +#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 +#define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) + +typedef struct _EFI_SYSTEM_TABLE { + EFI_TABLE_HEADER Hdr; + + CHAR16 *FirmwareVendor; + UINT32 FirmwareRevision; + + EFI_HANDLE ConsoleInHandle; + SIMPLE_INPUT_INTERFACE *ConIn; + + EFI_HANDLE ConsoleOutHandle; + SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut; + + EFI_HANDLE StandardErrorHandle; + SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr; + + EFI_RUNTIME_SERVICES *RuntimeServices; + EFI_BOOT_SERVICES *BootServices; + + UINTN NumberOfTableEntries; + EFI_CONFIGURATION_TABLE *ConfigurationTable; + +} EFI_SYSTEM_TABLE; + +#endif + diff --git a/gnu-efi/inc/eficompiler.h b/gnu-efi/inc/eficompiler.h new file mode 100644 index 0000000..26636c7 --- /dev/null +++ b/gnu-efi/inc/eficompiler.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2016 Pete Batard + +Module Name: + + eficompiler.h + +Abstract: + + Compiler specific adjustments + +--*/ + +#ifdef _MSC_EXTENSIONS +#define EFI_UNUSED +#else +#define EFI_UNUSED __attribute__((__unused__)) +#endif + +#ifdef _MSC_EXTENSIONS +#define ALIGN(x) __declspec(align(x)) +#else +#define ALIGN(x) __attribute__((__aligned__(x))) +#endif + +/* Also add a catch-all on __attribute__() for MS compilers */ +#ifdef _MSC_EXTENSIONS +#define __attribute__(x) +#endif diff --git a/gnu-efi/inc/eficon.h b/gnu-efi/inc/eficon.h new file mode 100644 index 0000000..5d17e04 --- /dev/null +++ b/gnu-efi/inc/eficon.h @@ -0,0 +1,306 @@ +#ifndef _EFI_CON_H +#define _EFI_CON_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + eficon.h + +Abstract: + + EFI console protocols + + + +Revision History + +--*/ + +// +// Text output protocol +// + +#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \ + { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID + +INTERFACE_DECL(_SIMPLE_TEXT_OUTPUT_INTERFACE); + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_RESET) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + IN BOOLEAN ExtendedVerification + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_OUTPUT_STRING) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + IN CHAR16 *String + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_TEST_STRING) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + IN CHAR16 *String + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_QUERY_MODE) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + IN UINTN ModeNumber, + OUT UINTN *Columns, + OUT UINTN *Rows + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_MODE) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + IN UINTN ModeNumber + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + IN UINTN Attribute + ); + +#define EFI_BLACK 0x00 +#define EFI_BLUE 0x01 +#define EFI_GREEN 0x02 +#define EFI_CYAN (EFI_BLUE | EFI_GREEN) +#define EFI_RED 0x04 +#define EFI_MAGENTA (EFI_BLUE | EFI_RED) +#define EFI_BROWN (EFI_GREEN | EFI_RED) +#define EFI_LIGHTGRAY (EFI_BLUE | EFI_GREEN | EFI_RED) +#define EFI_BRIGHT 0x08 +#define EFI_DARKGRAY (EFI_BRIGHT) +#define EFI_LIGHTBLUE (EFI_BLUE | EFI_BRIGHT) +#define EFI_LIGHTGREEN (EFI_GREEN | EFI_BRIGHT) +#define EFI_LIGHTCYAN (EFI_CYAN | EFI_BRIGHT) +#define EFI_LIGHTRED (EFI_RED | EFI_BRIGHT) +#define EFI_LIGHTMAGENTA (EFI_MAGENTA | EFI_BRIGHT) +#define EFI_YELLOW (EFI_BROWN | EFI_BRIGHT) +#define EFI_WHITE (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT) + +#define EFI_TEXT_ATTR(f,b) ((f) | ((b) << 4)) + +#define EFI_BACKGROUND_BLACK 0x00 +#define EFI_BACKGROUND_BLUE 0x10 +#define EFI_BACKGROUND_GREEN 0x20 +#define EFI_BACKGROUND_CYAN (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN) +#define EFI_BACKGROUND_RED 0x40 +#define EFI_BACKGROUND_MAGENTA (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED) +#define EFI_BACKGROUND_BROWN (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED) +#define EFI_BACKGROUND_LIGHTGRAY (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED) + + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_CLEAR_SCREEN) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + IN UINTN Column, + IN UINTN Row + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_ENABLE_CURSOR) ( + IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + IN BOOLEAN Enable + ); + +typedef struct { + INT32 MaxMode; + // current settings + INT32 Mode; + INT32 Attribute; + INT32 CursorColumn; + INT32 CursorRow; + BOOLEAN CursorVisible; +} SIMPLE_TEXT_OUTPUT_MODE; + +typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE { + EFI_TEXT_RESET Reset; + + EFI_TEXT_OUTPUT_STRING OutputString; + EFI_TEXT_TEST_STRING TestString; + + EFI_TEXT_QUERY_MODE QueryMode; + EFI_TEXT_SET_MODE SetMode; + EFI_TEXT_SET_ATTRIBUTE SetAttribute; + + EFI_TEXT_CLEAR_SCREEN ClearScreen; + EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition; + EFI_TEXT_ENABLE_CURSOR EnableCursor; + + // Current mode + SIMPLE_TEXT_OUTPUT_MODE *Mode; +} SIMPLE_TEXT_OUTPUT_INTERFACE, EFI_SIMPLE_TEXT_OUT_PROTOCOL; + +// +// Define's for required EFI Unicode Box Draw character +// + +#define BOXDRAW_HORIZONTAL 0x2500 +#define BOXDRAW_VERTICAL 0x2502 +#define BOXDRAW_DOWN_RIGHT 0x250c +#define BOXDRAW_DOWN_LEFT 0x2510 +#define BOXDRAW_UP_RIGHT 0x2514 +#define BOXDRAW_UP_LEFT 0x2518 +#define BOXDRAW_VERTICAL_RIGHT 0x251c +#define BOXDRAW_VERTICAL_LEFT 0x2524 +#define BOXDRAW_DOWN_HORIZONTAL 0x252c +#define BOXDRAW_UP_HORIZONTAL 0x2534 +#define BOXDRAW_VERTICAL_HORIZONTAL 0x253c + +#define BOXDRAW_DOUBLE_HORIZONTAL 0x2550 +#define BOXDRAW_DOUBLE_VERTICAL 0x2551 +#define BOXDRAW_DOWN_RIGHT_DOUBLE 0x2552 +#define BOXDRAW_DOWN_DOUBLE_RIGHT 0x2553 +#define BOXDRAW_DOUBLE_DOWN_RIGHT 0x2554 + +#define BOXDRAW_DOWN_LEFT_DOUBLE 0x2555 +#define BOXDRAW_DOWN_DOUBLE_LEFT 0x2556 +#define BOXDRAW_DOUBLE_DOWN_LEFT 0x2557 + +#define BOXDRAW_UP_RIGHT_DOUBLE 0x2558 +#define BOXDRAW_UP_DOUBLE_RIGHT 0x2559 +#define BOXDRAW_DOUBLE_UP_RIGHT 0x255a + +#define BOXDRAW_UP_LEFT_DOUBLE 0x255b +#define BOXDRAW_UP_DOUBLE_LEFT 0x255c +#define BOXDRAW_DOUBLE_UP_LEFT 0x255d + +#define BOXDRAW_VERTICAL_RIGHT_DOUBLE 0x255e +#define BOXDRAW_VERTICAL_DOUBLE_RIGHT 0x255f +#define BOXDRAW_DOUBLE_VERTICAL_RIGHT 0x2560 + +#define BOXDRAW_VERTICAL_LEFT_DOUBLE 0x2561 +#define BOXDRAW_VERTICAL_DOUBLE_LEFT 0x2562 +#define BOXDRAW_DOUBLE_VERTICAL_LEFT 0x2563 + +#define BOXDRAW_DOWN_HORIZONTAL_DOUBLE 0x2564 +#define BOXDRAW_DOWN_DOUBLE_HORIZONTAL 0x2565 +#define BOXDRAW_DOUBLE_DOWN_HORIZONTAL 0x2566 + +#define BOXDRAW_UP_HORIZONTAL_DOUBLE 0x2567 +#define BOXDRAW_UP_DOUBLE_HORIZONTAL 0x2568 +#define BOXDRAW_DOUBLE_UP_HORIZONTAL 0x2569 + +#define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE 0x256a +#define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL 0x256b +#define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL 0x256c + +// +// EFI Required Block Elements Code Chart +// + +#define BLOCKELEMENT_FULL_BLOCK 0x2588 +#define BLOCKELEMENT_LIGHT_SHADE 0x2591 +// +// EFI Required Geometric Shapes Code Chart +// + +#define GEOMETRICSHAPE_UP_TRIANGLE 0x25b2 +#define GEOMETRICSHAPE_RIGHT_TRIANGLE 0x25ba +#define GEOMETRICSHAPE_DOWN_TRIANGLE 0x25bc +#define GEOMETRICSHAPE_LEFT_TRIANGLE 0x25c4 + +// +// EFI Required Arrow shapes +// + +#define ARROW_UP 0x2191 +#define ARROW_DOWN 0x2193 + +// +// Text input protocol +// + +#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \ + { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID + +INTERFACE_DECL(_SIMPLE_INPUT_INTERFACE); + +typedef struct { + UINT16 ScanCode; + CHAR16 UnicodeChar; +} EFI_INPUT_KEY; + +// +// Baseline unicode control chars +// + +#define CHAR_NULL 0x0000 +#define CHAR_BACKSPACE 0x0008 +#define CHAR_TAB 0x0009 +#define CHAR_LINEFEED 0x000A +#define CHAR_CARRIAGE_RETURN 0x000D + +// +// Scan codes for base line keys +// + +#define SCAN_NULL 0x0000 +#define SCAN_UP 0x0001 +#define SCAN_DOWN 0x0002 +#define SCAN_RIGHT 0x0003 +#define SCAN_LEFT 0x0004 +#define SCAN_HOME 0x0005 +#define SCAN_END 0x0006 +#define SCAN_INSERT 0x0007 +#define SCAN_DELETE 0x0008 +#define SCAN_PAGE_UP 0x0009 +#define SCAN_PAGE_DOWN 0x000A +#define SCAN_F1 0x000B +#define SCAN_F2 0x000C +#define SCAN_F3 0x000D +#define SCAN_F4 0x000E +#define SCAN_F5 0x000F +#define SCAN_F6 0x0010 +#define SCAN_F7 0x0011 +#define SCAN_F8 0x0012 +#define SCAN_F9 0x0013 +#define SCAN_F10 0x0014 +#define SCAN_F11 0x0015 +#define SCAN_F12 0x0016 +#define SCAN_ESC 0x0017 + +typedef +EFI_STATUS +(EFIAPI *EFI_INPUT_RESET) ( + IN struct _SIMPLE_INPUT_INTERFACE *This, + IN BOOLEAN ExtendedVerification + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_INPUT_READ_KEY) ( + IN struct _SIMPLE_INPUT_INTERFACE *This, + OUT EFI_INPUT_KEY *Key + ); + +typedef struct _SIMPLE_INPUT_INTERFACE { + EFI_INPUT_RESET Reset; + EFI_INPUT_READ_KEY ReadKeyStroke; + EFI_EVENT WaitForKey; +} SIMPLE_INPUT_INTERFACE, EFI_SIMPLE_TEXT_IN_PROTOCOL; + +#endif + diff --git a/gnu-efi/inc/efidebug.h b/gnu-efi/inc/efidebug.h new file mode 100644 index 0000000..8e54dcd --- /dev/null +++ b/gnu-efi/inc/efidebug.h @@ -0,0 +1,620 @@ +#ifndef _EFI_DEBUG_H +#define _EFI_DEBUG_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efidebug.h + +Abstract: + + EFI library debug functions + + + +Revision History + +--*/ + +extern UINTN EFIDebug; + +#if EFI_DEBUG + + #define DBGASSERT(a) DbgAssert(__FILE__, __LINE__, #a) + #define DEBUG(a) DbgPrint a + +#else + + #define DBGASSERT(a) + #define DEBUG(a) + +#endif + +#if EFI_DEBUG_CLEAR_MEMORY + + #define DBGSETMEM(a,l) SetMem(a,l,(CHAR8)BAD_POINTER) + +#else + + #define DBGSETMEM(a,l) + +#endif + +#define D_INIT 0x00000001 // Initialization style messages +#define D_WARN 0x00000002 // Warnings +#define D_LOAD 0x00000004 // Load events +#define D_FS 0x00000008 // EFI File system +#define D_POOL 0x00000010 // Alloc & Free's +#define D_PAGE 0x00000020 // Alloc & Free's +#define D_INFO 0x00000040 // Verbose +#define D_VAR 0x00000100 // Variable +#define D_PARSE 0x00000200 // Command parsing +#define D_BM 0x00000400 // Boot manager +#define D_BLKIO 0x00001000 // BlkIo Driver +#define D_BLKIO_ULTRA 0x00002000 // BlkIo Driver +#define D_NET 0x00004000 // SNI Driver +#define D_NET_ULTRA 0x00008000 // SNI Driver +#define D_TXTIN 0x00010000 // Simple Input Driver +#define D_TXTOUT 0x00020000 // Simple Text Output Driver +#define D_ERROR_ATA 0x00040000 // ATA error messages +#define D_ERROR 0x80000000 // Error + +#define D_RESERVED 0x7fffC880 // Bits not reserved above + +// +// Current Debug level of the system, value of EFIDebug +// +//#define EFI_DBUG_MASK (D_ERROR | D_WARN | D_LOAD | D_BLKIO | D_INIT) +#define EFI_DBUG_MASK (D_ERROR) + +// +// +// + +#if EFI_DEBUG + + #define ASSERT(a) if(!(a)) DBGASSERT(a) + #define ASSERT_LOCKED(l) if(!(l)->Lock) DBGASSERT(l not locked) + #define ASSERT_STRUCT(p,t) DBGASSERT(t not structure), p + +#else + + #define ASSERT(a) + #define ASSERT_LOCKED(l) + #define ASSERT_STRUCT(p,t) + +#endif + +// +// Prototypes +// + +INTN +DbgAssert ( + CONST CHAR8 *file, + INTN lineno, + CONST CHAR8 *string + ); + +INTN +DbgPrint ( + INTN mask, + CONST CHAR8 *format, + ... + ); + +// +// Instruction Set Architectures definitions for debuggers +// + +typedef INTN EFI_EXCEPTION_TYPE; + +// IA32 +#define EXCEPT_IA32_DIVIDE_ERROR 0 +#define EXCEPT_IA32_DEBUG 1 +#define EXCEPT_IA32_NMI 2 +#define EXCEPT_IA32_BREAKPOINT 3 +#define EXCEPT_IA32_OVERFLOW 4 +#define EXCEPT_IA32_BOUND 5 +#define EXCEPT_IA32_INVALID_OPCODE 6 +#define EXCEPT_IA32_DOUBLE_FAULT 8 +#define EXCEPT_IA32_INVALID_TSS 10 +#define EXCEPT_IA32_SEG_NOT_PRESENT 11 +#define EXCEPT_IA32_STACK_FAULT 12 +#define EXCEPT_IA32_GP_FAULT 13 +#define EXCEPT_IA32_PAGE_FAULT 14 +#define EXCEPT_IA32_FP_ERROR 16 +#define EXCEPT_IA32_ALIGNMENT_CHECK 17 +#define EXCEPT_IA32_MACHINE_CHECK 18 +#define EXCEPT_IA32_SIMD 19 + +typedef struct { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT32 Eip; + UINT16 Cs; + UINT16 Reserved1; + UINT32 DataOffset; + UINT16 Ds; + UINT8 Reserved2[10]; + UINT8 St0Mm0[10], Reserved3[6]; + UINT8 St1Mm1[10], Reserved4[6]; + UINT8 St2Mm2[10], Reserved5[6]; + UINT8 St3Mm3[10], Reserved6[6]; + UINT8 St4Mm4[10], Reserved7[6]; + UINT8 St5Mm5[10], Reserved8[6]; + UINT8 St6Mm6[10], Reserved9[6]; + UINT8 St7Mm7[10], Reserved10[6]; + UINT8 Xmm0[16]; + UINT8 Xmm1[16]; + UINT8 Xmm2[16]; + UINT8 Xmm3[16]; + UINT8 Xmm4[16]; + UINT8 Xmm5[16]; + UINT8 Xmm6[16]; + UINT8 Xmm7[16]; + UINT8 Reserved11[14 * 16]; +} EFI_FX_SAVE_STATE_IA32; + +typedef struct { + UINT32 ExceptionData; + EFI_FX_SAVE_STATE_IA32 FxSaveState; + UINT32 Dr0; + UINT32 Dr1; + UINT32 Dr2; + UINT32 Dr3; + UINT32 Dr6; + UINT32 Dr7; + UINT32 Cr0; + UINT32 Cr1; + UINT32 Cr2; + UINT32 Cr3; + UINT32 Cr4; + UINT32 Eflags; + UINT32 Ldtr; + UINT32 Tr; + UINT32 Gdtr[2]; + UINT32 Idtr[2]; + UINT32 Eip; + UINT32 Gs; + UINT32 Fs; + UINT32 Es; + UINT32 Ds; + UINT32 Cs; + UINT32 Ss; + UINT32 Edi; + UINT32 Esi; + UINT32 Ebp; + UINT32 Esp; + UINT32 Ebx; + UINT32 Edx; + UINT32 Ecx; + UINT32 Eax; +} EFI_SYSTEM_CONTEXT_IA32; + +// X64 +#define EXCEPT_X64_DIVIDE_ERROR 0 +#define EXCEPT_X64_DEBUG 1 +#define EXCEPT_X64_NMI 2 +#define EXCEPT_X64_BREAKPOINT 3 +#define EXCEPT_X64_OVERFLOW 4 +#define EXCEPT_X64_BOUND 5 +#define EXCEPT_X64_INVALID_OPCODE 6 +#define EXCEPT_X64_DOUBLE_FAULT 8 +#define EXCEPT_X64_INVALID_TSS 10 +#define EXCEPT_X64_SEG_NOT_PRESENT 11 +#define EXCEPT_X64_STACK_FAULT 12 +#define EXCEPT_X64_GP_FAULT 13 +#define EXCEPT_X64_PAGE_FAULT 14 +#define EXCEPT_X64_FP_ERROR 16 +#define EXCEPT_X64_ALIGNMENT_CHECK 17 +#define EXCEPT_X64_MACHINE_CHECK 18 +#define EXCEPT_X64_SIMD 19 + +typedef struct { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT64 Rip; + UINT64 DataOffset; + UINT8 Reserved1[8]; + UINT8 St0Mm0[10], Reserved2[6]; + UINT8 St1Mm1[10], Reserved3[6]; + UINT8 St2Mm2[10], Reserved4[6]; + UINT8 St3Mm3[10], Reserved5[6]; + UINT8 St4Mm4[10], Reserved6[6]; + UINT8 St5Mm5[10], Reserved7[6]; + UINT8 St6Mm6[10], Reserved8[6]; + UINT8 St7Mm7[10], Reserved9[6]; + UINT8 Xmm0[16]; + UINT8 Xmm1[16]; + UINT8 Xmm2[16]; + UINT8 Xmm3[16]; + UINT8 Xmm4[16]; + UINT8 Xmm5[16]; + UINT8 Xmm6[16]; + UINT8 Xmm7[16]; + UINT8 Reserved11[14 * 16]; +} EFI_FX_SAVE_STATE_X64; + +typedef struct { + UINT64 ExceptionData; + EFI_FX_SAVE_STATE_X64 FxSaveState; + UINT64 Dr0; + UINT64 Dr1; + UINT64 Dr2; + UINT64 Dr3; + UINT64 Dr6; + UINT64 Dr7; + UINT64 Cr0; + UINT64 Cr1; + UINT64 Cr2; + UINT64 Cr3; + UINT64 Cr4; + UINT64 Cr8; + UINT64 Rflags; + UINT64 Ldtr; + UINT64 Tr; + UINT64 Gdtr[2]; + UINT64 Idtr[2]; + UINT64 Rip; + UINT64 Gs; + UINT64 Fs; + UINT64 Es; + UINT64 Ds; + UINT64 Cs; + UINT64 Ss; + UINT64 Rdi; + UINT64 Rsi; + UINT64 Rbp; + UINT64 Rsp; + UINT64 Rbx; + UINT64 Rdx; + UINT64 Rcx; + UINT64 Rax; + UINT64 R8; + UINT64 R9; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; +} EFI_SYSTEM_CONTEXT_X64; + +/// IA64 +#define EXCEPT_IPF_VHTP_TRANSLATION 0 +#define EXCEPT_IPF_INSTRUCTION_TLB 1 +#define EXCEPT_IPF_DATA_TLB 2 +#define EXCEPT_IPF_ALT_INSTRUCTION_TLB 3 +#define EXCEPT_IPF_ALT_DATA_TLB 4 +#define EXCEPT_IPF_DATA_NESTED_TLB 5 +#define EXCEPT_IPF_INSTRUCTION_KEY_MISSED 6 +#define EXCEPT_IPF_DATA_KEY_MISSED 7 +#define EXCEPT_IPF_DIRTY_BIT 8 +#define EXCEPT_IPF_INSTRUCTION_ACCESS_BIT 9 +#define EXCEPT_IPF_DATA_ACCESS_BIT 10 +#define EXCEPT_IPF_BREAKPOINT 11 +#define EXCEPT_IPF_EXTERNAL_INTERRUPT 12 +#define EXCEPT_IPF_PAGE_NOT_PRESENT 20 +#define EXCEPT_IPF_KEY_PERMISSION 21 +#define EXCEPT_IPF_INSTRUCTION_ACCESS_RIGHTS 22 +#define EXCEPT_IPF_DATA_ACCESS_RIGHTS 23 +#define EXCEPT_IPF_GENERAL_EXCEPTION 24 +#define EXCEPT_IPF_DISABLED_FP_REGISTER 25 +#define EXCEPT_IPF_NAT_CONSUMPTION 26 +#define EXCEPT_IPF_SPECULATION 27 +#define EXCEPT_IPF_DEBUG 29 +#define EXCEPT_IPF_UNALIGNED_REFERENCE 30 +#define EXCEPT_IPF_UNSUPPORTED_DATA_REFERENCE 31 +#define EXCEPT_IPF_FP_FAULT 32 +#define EXCEPT_IPF_FP_TRAP 33 +#define EXCEPT_IPF_LOWER_PRIVILEGE_TRANSFER_TRAP 34 +#define EXCEPT_IPF_TAKEN_BRANCH 35 +#define EXCEPT_IPF_SINGLE_STEP 36 +#define EXCEPT_IPF_IA32_EXCEPTION 45 +#define EXCEPT_IPF_IA32_INTERCEPT 46 +#define EXCEPT_IPF_IA32_INTERRUPT 47 + +typedef struct { + UINT64 Reserved; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 R8; + UINT64 R9; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; + UINT64 R16; + UINT64 R17; + UINT64 R18; + UINT64 R19; + UINT64 R20; + UINT64 R21; + UINT64 R22; + UINT64 R23; + UINT64 R24; + UINT64 R25; + UINT64 R26; + UINT64 R27; + UINT64 R28; + UINT64 R29; + UINT64 R30; + UINT64 R31; + UINT64 F2[2]; + UINT64 F3[2]; + UINT64 F4[2]; + UINT64 F5[2]; + UINT64 F6[2]; + UINT64 F7[2]; + UINT64 F8[2]; + UINT64 F9[2]; + UINT64 F10[2]; + UINT64 F11[2]; + UINT64 F12[2]; + UINT64 F13[2]; + UINT64 F14[2]; + UINT64 F15[2]; + UINT64 F16[2]; + UINT64 F17[2]; + UINT64 F18[2]; + UINT64 F19[2]; + UINT64 F20[2]; + UINT64 F21[2]; + UINT64 F22[2]; + UINT64 F23[2]; + UINT64 F24[2]; + UINT64 F25[2]; + UINT64 F26[2]; + UINT64 F27[2]; + UINT64 F28[2]; + UINT64 F29[2]; + UINT64 F30[2]; + UINT64 F31[2]; + UINT64 Pr; + UINT64 B0; + UINT64 B1; + UINT64 B2; + UINT64 B3; + UINT64 B4; + UINT64 B5; + UINT64 B6; + UINT64 B7; + UINT64 ArRsc; + UINT64 ArBsp; + UINT64 ArBspstore; + UINT64 ArRnat; + UINT64 ArFcr; + UINT64 ArEflag; + UINT64 ArCsd; + UINT64 ArSsd; + UINT64 ArCflg; + UINT64 ArFsr; + UINT64 ArFir; + UINT64 ArFdr; + UINT64 ArCcv; + UINT64 ArUnat; + UINT64 ArFpsr; + UINT64 ArPfs; + UINT64 ArLc; + UINT64 ArEc; + UINT64 CrDcr; + UINT64 CrItm; + UINT64 CrIva; + UINT64 CrPta; + UINT64 CrIpsr; + UINT64 CrIsr; + UINT64 CrIip; + UINT64 CrIfa; + UINT64 CrItir; + UINT64 CrIipa; + UINT64 CrIfs; + UINT64 CrIim; + UINT64 CrIha; + UINT64 Dbr0; + UINT64 Dbr1; + UINT64 Dbr2; + UINT64 Dbr3; + UINT64 Dbr4; + UINT64 Dbr5; + UINT64 Dbr6; + UINT64 Dbr7; + UINT64 Ibr0; + UINT64 Ibr1; + UINT64 Ibr2; + UINT64 Ibr3; + UINT64 Ibr4; + UINT64 Ibr5; + UINT64 Ibr6; + UINT64 Ibr7; + UINT64 IntNat; +} EFI_SYSTEM_CONTEXT_IPF; + +// EBC +#define EXCEPT_EBC_UNDEFINED 0 +#define EXCEPT_EBC_DIVIDE_ERROR 1 +#define EXCEPT_EBC_DEBUG 2 +#define EXCEPT_EBC_BREAKPOINT 3 +#define EXCEPT_EBC_OVERFLOW 4 +#define EXCEPT_EBC_INVALID_OPCODE 5 +#define EXCEPT_EBC_STACK_FAULT 6 +#define EXCEPT_EBC_ALIGNMENT_CHECK 7 +#define EXCEPT_EBC_INSTRUCTION_ENCODING 8 +#define EXCEPT_EBC_BAD_BREAK 9 +#define EXCEPT_EBC_STEP 10 +#define MAX_EBC_EXCEPTION EXCEPT_EBC_STEP + +typedef struct { + UINT64 R0; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 Flags; + UINT64 ControlFlags; + UINT64 Ip; +} EFI_SYSTEM_CONTEXT_EBC; + +// ARM +#define EXCEPT_ARM_RESET 0 +#define EXCEPT_ARM_UNDEFINED_INSTRUCTION 1 +#define EXCEPT_ARM_SOFTWARE_INTERRUPT 2 +#define EXCEPT_ARM_PREFETCH_ABORT 3 +#define EXCEPT_ARM_DATA_ABORT 4 +#define EXCEPT_ARM_RESERVED 5 +#define EXCEPT_ARM_IRQ 6 +#define EXCEPT_ARM_FIQ 7 +#define MAX_ARM_EXCEPTION EXCEPT_ARM_FIQ + +typedef struct { + UINT32 R0; + UINT32 R1; + UINT32 R2; + UINT32 R3; + UINT32 R4; + UINT32 R5; + UINT32 R6; + UINT32 R7; + UINT32 R8; + UINT32 R9; + UINT32 R10; + UINT32 R11; + UINT32 R12; + UINT32 SP; + UINT32 LR; + UINT32 PC; + UINT32 CPSR; + UINT32 DFSR; + UINT32 DFAR; + UINT32 IFSR; + UINT32 IFAR; +} EFI_SYSTEM_CONTEXT_ARM; + + +typedef union { + EFI_SYSTEM_CONTEXT_EBC *SystemContextEbc; + EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32; + EFI_SYSTEM_CONTEXT_X64 *SystemContextX64; + EFI_SYSTEM_CONTEXT_IPF *SystemContextIpf; + EFI_SYSTEM_CONTEXT_ARM *SystemContextArm; +} EFI_SYSTEM_CONTEXT; + +typedef +VOID +(EFIAPI *EFI_EXCEPTION_CALLBACK)( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN OUT EFI_SYSTEM_CONTEXT SystemContext); + +typedef +VOID +(EFIAPI *EFI_PERIODIC_CALLBACK)( + IN OUT EFI_SYSTEM_CONTEXT SystemContext); + +typedef enum { + IsaIa32 = EFI_IMAGE_MACHINE_IA32, + IsaX64 = EFI_IMAGE_MACHINE_X64, + IsaIpf = EFI_IMAGE_MACHINE_IA64, + IsaEbc = EFI_IMAGE_MACHINE_EBC, + IsaArm = EFI_IMAGE_MACHINE_ARMTHUMB_MIXED, +// IsaArm64 = EFI_IMAGE_MACHINE_AARCH64 +} EFI_INSTRUCTION_SET_ARCHITECTURE; + +// +// DEBUG_IMAGE_INFO +// + +#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \ + { 0x49152e77, 0x1ada, 0x4764, {0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b} } + +#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01 +#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02 +#define EFI_DEBUG_IMAGE_INFO_INITIAL_SIZE (EFI_PAGE_SIZE / sizeof (UINTN)) +#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01 + +typedef struct { +UINT64 Signature; +EFI_PHYSICAL_ADDRESS EfiSystemTableBase; +UINT32 Crc32; +} EFI_SYSTEM_TABLE_POINTER; + +typedef struct { +UINT32 ImageInfoType; +EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolInstance; +EFI_HANDLE *ImageHandle; +} EFI_DEBUG_IMAGE_INFO_NORMAL; + +typedef union { +UINT32 *ImageInfoType; +EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; +} EFI_DEBUG_IMAGE_INFO; + +typedef struct { +volatile UINT32 UpdateStatus; +UINT32 TableSize; +EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable; +} EFI_DEBUG_IMAGE_INFO_TABLE_HEADER; + +// +// EFI_DEBUGGER_PROTOCOL +// + +#define EFI_DEBUG_SUPPORT_PROTOCOL_GUID \ + { 0x2755590c, 0x6f3c, 0x42fa, {0x9e, 0xa4, 0xa3, 0xba, 0x54, 0x3c, 0xda, 0x25} } + +INTERFACE_DECL(_EFI_DEBUG_SUPPORT_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_MAXIMUM_PROCESSOR_INDEX)( + IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This, + OUT UINTN *MaxProcessorIndex); + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_PERIODIC_CALLBACK)( + IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This, + IN UINTN ProcessorIndex, + IN EFI_PERIODIC_CALLBACK PeriodicCallback); + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_EXCEPTION_CALLBACK)( + IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This, + IN UINTN ProcessorIndex, + IN EFI_EXCEPTION_CALLBACK ExceptionCallback, + IN EFI_EXCEPTION_TYPE ExceptionType); + +typedef +EFI_STATUS +(EFIAPI *EFI_INVALIDATE_INSTRUCTION_CACHE)( + IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This, + IN UINTN ProcessorIndex, + IN VOID *Start, + IN UINT64 Length); + +typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL { + EFI_INSTRUCTION_SET_ARCHITECTURE Isa; + EFI_GET_MAXIMUM_PROCESSOR_INDEX GetMaximumProcessorIndex; + EFI_REGISTER_PERIODIC_CALLBACK RegisterPeriodicCallback; + EFI_REGISTER_EXCEPTION_CALLBACK RegisterExceptionCallback; + EFI_INVALIDATE_INSTRUCTION_CACHE InvalidateInstructionCache; +} EFI_DEBUG_SUPPORT_PROTOCOL; + +#endif diff --git a/gnu-efi/inc/efidef.h b/gnu-efi/inc/efidef.h new file mode 100644 index 0000000..8b70051 --- /dev/null +++ b/gnu-efi/inc/efidef.h @@ -0,0 +1,220 @@ +#ifndef _EFI_DEF_H +#define _EFI_DEF_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efidef.h + +Abstract: + + EFI definitions + + + + +Revision History + +--*/ + +typedef UINT16 CHAR16; +typedef UINT8 CHAR8; +typedef UINT8 BOOLEAN; +#ifndef CONST + #define CONST const +#endif +#ifndef TRUE + #define TRUE ((BOOLEAN) 1) + #define FALSE ((BOOLEAN) 0) +#endif + +#ifndef NULL + #define NULL ((VOID *) 0) +#endif + +typedef UINTN EFI_STATUS; +typedef UINT64 EFI_LBA; +typedef UINTN EFI_TPL; +typedef VOID *EFI_HANDLE; +typedef VOID *EFI_EVENT; + + +// +// Prototype argument decoration for EFI parameters to indicate +// their direction +// +// IN - argument is passed into the function +// OUT - argument (pointer) is returned from the function +// OPTIONAL - argument is optional +// + +#ifndef IN + #define IN + #define OUT + #define OPTIONAL +#endif + + +// +// A GUID +// + +typedef struct { + UINT32 Data1; + UINT16 Data2; + UINT16 Data3; + UINT8 Data4[8]; +} EFI_GUID; + + +// +// Time +// + +typedef struct { + UINT16 Year; // 1998 - 20XX + UINT8 Month; // 1 - 12 + UINT8 Day; // 1 - 31 + UINT8 Hour; // 0 - 23 + UINT8 Minute; // 0 - 59 + UINT8 Second; // 0 - 59 + UINT8 Pad1; + UINT32 Nanosecond; // 0 - 999,999,999 + INT16 TimeZone; // -1440 to 1440 or 2047 + UINT8 Daylight; + UINT8 Pad2; +} EFI_TIME; + +// Bit definitions for EFI_TIME.Daylight +#define EFI_TIME_ADJUST_DAYLIGHT 0x01 +#define EFI_TIME_IN_DAYLIGHT 0x02 + +// Value definition for EFI_TIME.TimeZone +#define EFI_UNSPECIFIED_TIMEZONE 0x07FF + + + +// +// Networking +// + +typedef struct { + UINT8 Addr[4]; +} EFI_IPv4_ADDRESS; + +typedef struct { + UINT8 Addr[16]; +} EFI_IPv6_ADDRESS; + +typedef struct { + UINT8 Addr[32]; +} EFI_MAC_ADDRESS; + +typedef struct { + UINT32 ReceivedQueueTimeoutValue; + UINT32 TransmitQueueTimeoutValue; + UINT16 ProtocolTypeFilter; + BOOLEAN EnableUnicastReceive; + BOOLEAN EnableMulticastReceive; + BOOLEAN EnableBroadcastReceive; + BOOLEAN EnablePromiscuousReceive; + BOOLEAN FlushQueuesOnReset; + BOOLEAN EnableReceiveTimestamps; + BOOLEAN DisableBackgroundPolling; +} EFI_MANAGED_NETWORK_CONFIG_DATA; + +// +// Memory +// + +typedef UINT64 EFI_PHYSICAL_ADDRESS; +typedef UINT64 EFI_VIRTUAL_ADDRESS; + +typedef enum { + AllocateAnyPages, + AllocateMaxAddress, + AllocateAddress, + MaxAllocateType +} EFI_ALLOCATE_TYPE; + +//Preseve the attr on any range supplied. +//ConventialMemory must have WB,SR,SW when supplied. +//When allocating from ConventialMemory always make it WB,SR,SW +//When returning to ConventialMemory always make it WB,SR,SW +//When getting the memory map, or on RT for runtime types + + +typedef enum { + EfiReservedMemoryType, + EfiLoaderCode, + EfiLoaderData, + EfiBootServicesCode, + EfiBootServicesData, + EfiRuntimeServicesCode, + EfiRuntimeServicesData, + EfiConventionalMemory, + EfiUnusableMemory, + EfiACPIReclaimMemory, + EfiACPIMemoryNVS, + EfiMemoryMappedIO, + EfiMemoryMappedIOPortSpace, + EfiPalCode, + EfiMaxMemoryType +} EFI_MEMORY_TYPE; + +// possible caching types for the memory range +#define EFI_MEMORY_UC 0x0000000000000001 +#define EFI_MEMORY_WC 0x0000000000000002 +#define EFI_MEMORY_WT 0x0000000000000004 +#define EFI_MEMORY_WB 0x0000000000000008 +#define EFI_MEMORY_UCE 0x0000000000000010 + +// physical memory protection on range +#define EFI_MEMORY_WP 0x0000000000001000 +#define EFI_MEMORY_RP 0x0000000000002000 +#define EFI_MEMORY_XP 0x0000000000004000 + +// range requires a runtime mapping +#define EFI_MEMORY_RUNTIME 0x8000000000000000 + +#define EFI_MEMORY_DESCRIPTOR_VERSION 1 +typedef struct { + UINT32 Type; // Field size is 32 bits followed by 32 bit pad + UINT32 Pad; + EFI_PHYSICAL_ADDRESS PhysicalStart; // Field size is 64 bits + EFI_VIRTUAL_ADDRESS VirtualStart; // Field size is 64 bits + UINT64 NumberOfPages; // Field size is 64 bits + UINT64 Attribute; // Field size is 64 bits +} EFI_MEMORY_DESCRIPTOR; + +// +// International Language +// + +typedef UINT8 ISO_639_2; +#define ISO_639_2_ENTRY_SIZE 3 + +// +// +// + +#define EFI_PAGE_SIZE 4096 +#define EFI_PAGE_MASK 0xFFF +#define EFI_PAGE_SHIFT 12 + +#define EFI_SIZE_TO_PAGES(a) \ + ( ((a) >> EFI_PAGE_SHIFT) + ((a) & EFI_PAGE_MASK ? 1 : 0) ) + +#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001 +#define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002 +#define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED \ + 0x0000000000000004 +#define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED \ + 0x0000000000000008 +#define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED \ + 0x0000000000000010 + +#endif diff --git a/gnu-efi/inc/efidevp.h b/gnu-efi/inc/efidevp.h new file mode 100644 index 0000000..fa1a235 --- /dev/null +++ b/gnu-efi/inc/efidevp.h @@ -0,0 +1,582 @@ +#ifndef _DEVPATH_H +#define _DEVPATH_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + devpath.h + +Abstract: + + Defines for parsing the EFI Device Path structures + + + +Revision History + +--*/ + +// +// Device Path structures - Section C +// + +typedef struct _EFI_DEVICE_PATH_PROTOCOL { + UINT8 Type; + UINT8 SubType; + UINT8 Length[2]; +} EFI_DEVICE_PATH_PROTOCOL; + +typedef struct _EFI_DEVICE_PATH_PROTOCOL _EFI_DEVICE_PATH; +typedef EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH; + +#define EFI_DP_TYPE_MASK 0x7F +#define EFI_DP_TYPE_UNPACKED 0x80 + +//#define END_DEVICE_PATH_TYPE 0xff +#define END_DEVICE_PATH_TYPE 0x7f +//#define END_DEVICE_PATH_TYPE_UNPACKED 0x7f + +#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff +#define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01 +#define END_DEVICE_PATH_LENGTH (sizeof(EFI_DEVICE_PATH_PROTOCOL)) + + +#define DP_IS_END_TYPE(a) +#define DP_IS_END_SUBTYPE(a) ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) + +#define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK ) +#define DevicePathSubType(a) ( (a)->SubType ) +#define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) ) +#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a))) +//#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE_UNPACKED ) +#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE ) +#define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) +#define IsDevicePathEnd(a) ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) ) +#define IsDevicePathUnpacked(a) ( (a)->Type & EFI_DP_TYPE_UNPACKED ) + + +#define SetDevicePathNodeLength(a,l) { \ + (a)->Length[0] = (UINT8) (l); \ + (a)->Length[1] = (UINT8) ((l) >> 8); \ + } + +#define SetDevicePathEndNode(a) { \ + (a)->Type = END_DEVICE_PATH_TYPE; \ + (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \ + (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \ + (a)->Length[1] = 0; \ + } + + +/* + * Hardware Device Path (UEFI 2.4 specification, version 2.4 § 9.3.2.) + */ + +#define HARDWARE_DEVICE_PATH 0x01 + +#define HW_PCI_DP 0x01 +typedef struct _PCI_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 Function; + UINT8 Device; +} PCI_DEVICE_PATH; + +#define HW_PCCARD_DP 0x02 +typedef struct _PCCARD_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 FunctionNumber ; +} PCCARD_DEVICE_PATH; + +#define HW_MEMMAP_DP 0x03 +typedef struct _MEMMAP_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 MemoryType; + EFI_PHYSICAL_ADDRESS StartingAddress; + EFI_PHYSICAL_ADDRESS EndingAddress; +} MEMMAP_DEVICE_PATH; + +#define HW_VENDOR_DP 0x04 +typedef struct _VENDOR_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID Guid; +} VENDOR_DEVICE_PATH; + +#define UNKNOWN_DEVICE_GUID \ + { 0xcf31fac5, 0xc24e, 0x11d2, {0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} } + +typedef struct _UKNOWN_DEVICE_VENDOR_DP { + VENDOR_DEVICE_PATH DevicePath; + UINT8 LegacyDriveLetter; +} UNKNOWN_DEVICE_VENDOR_DEVICE_PATH; + +#define HW_CONTROLLER_DP 0x05 +typedef struct _CONTROLLER_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Controller; +} CONTROLLER_DEVICE_PATH; + + +/* + * ACPI Device Path (UEFI 2.4 specification, version 2.4 § 9.3.3 and 9.3.4.) + */ +#define ACPI_DEVICE_PATH 0x02 + +#define ACPI_DP 0x01 +typedef struct _ACPI_HID_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 HID; + UINT32 UID; +} ACPI_HID_DEVICE_PATH; + +#define EXPANDED_ACPI_DP 0x02 +typedef struct _EXPANDED_ACPI_HID_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 HID; + UINT32 UID; + UINT32 CID; + UINT8 HidStr[1]; +} EXPANDED_ACPI_HID_DEVICE_PATH; + +#define ACPI_ADR_DP 3 +typedef struct _ACPI_ADR_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + UINT32 ADR ; +} ACPI_ADR_DEVICE_PATH ; + +// +// EISA ID Macro +// EISA ID Definition 32-bits +// bits[15:0] - three character compressed ASCII EISA ID. +// bits[31:16] - binary number +// Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z' +// +#define PNP_EISA_ID_CONST 0x41d0 +#define EISA_ID(_Name, _Num) ((UINT32) ((_Name) | (_Num) << 16)) +#define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId))) + +#define PNP_EISA_ID_MASK 0xffff +#define EISA_ID_TO_NUM(_Id) ((_Id) >> 16) + + +/* + * Messaging Device Path (UEFI 2.4 specification, version 2.4 § 9.3.5.) + */ +#define MESSAGING_DEVICE_PATH 0x03 + +#define MSG_ATAPI_DP 0x01 +typedef struct _ATAPI_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 PrimarySecondary; + UINT8 SlaveMaster; + UINT16 Lun; +} ATAPI_DEVICE_PATH; + +#define MSG_SCSI_DP 0x02 +typedef struct _SCSI_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 Pun; + UINT16 Lun; +} SCSI_DEVICE_PATH; + +#define MSG_FIBRECHANNEL_DP 0x03 +typedef struct _FIBRECHANNEL_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Reserved; + UINT64 WWN; + UINT64 Lun; +} FIBRECHANNEL_DEVICE_PATH; + +/** + * Fibre Channel Ex SubType. + * UEFI 2.0 specification version 2.4 § 9.3.5.6. + */ +#define MSG_FIBRECHANNELEX_DP 21 +typedef struct _FIBRECHANNELEX_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + UINT32 Reserved ; + UINT8 WWN[ 8 ] ; /* World Wide Name */ + UINT8 Lun[ 8 ] ; /* Logical unit, T-10 SCSI Architecture Model 4 specification */ +} FIBRECHANNELEX_DEVICE_PATH ; + +#define MSG_1394_DP 0x04 +typedef struct _F1394_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Reserved; + UINT64 Guid; +} F1394_DEVICE_PATH; + +#define MSG_USB_DP 0x05 +typedef struct _USB_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 Port; + UINT8 Endpoint; +} USB_DEVICE_PATH; + +/** + * SATA Device Path SubType. + * UEFI 2.0 specification version 2.4 § 9.3.5.6. + */ +#define MSG_SATA_DP 18 +typedef struct _SATA_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + UINT16 HBAPortNumber ; + UINT16 PortMultiplierPortNumber ; + UINT16 Lun ; /* Logical Unit Number */ +} SATA_DEVICE_PATH ; + +/** + * USB WWID Device Path SubType. + * UEFI 2.0 specification version 2.4 § 9.3.5.7. + */ +#define MSG_USB_WWID_DP 16 +typedef struct _USB_WWID_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + UINT16 InterfaceNumber ; + UINT16 VendorId ; + UINT16 ProductId ; + CHAR16 SerialNumber[ 1 ] ; /* UTF-16 characters of the USB serial number */ +} USB_WWID_DEVICE_PATH ; + +/** + * Device Logical Unit SubType. + * UEFI 2.0 specification version 2.4 § 9.3.5.8. + */ +#define MSG_DEVICE_LOGICAL_UNIT_DP 17 +typedef struct _DEVICE_LOGICAL_UNIT_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + UINT8 Lun ; /* Logical Unit Number */ +} DEVICE_LOGICAL_UNIT_DEVICE_PATH ; + +#define MSG_USB_CLASS_DP 0x0F +typedef struct _USB_CLASS_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 VendorId; + UINT16 ProductId; + UINT8 DeviceClass; + UINT8 DeviceSubclass; + UINT8 DeviceProtocol; +} USB_CLASS_DEVICE_PATH; + +#define MSG_I2O_DP 0x06 +typedef struct _I2O_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Tid; +} I2O_DEVICE_PATH; + +#define MSG_MAC_ADDR_DP 0x0b +typedef struct _MAC_ADDR_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_MAC_ADDRESS MacAddress; + UINT8 IfType; +} MAC_ADDR_DEVICE_PATH; + +#define MSG_IPv4_DP 0x0c +typedef struct _IPv4_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_IPv4_ADDRESS LocalIpAddress; + EFI_IPv4_ADDRESS RemoteIpAddress; + UINT16 LocalPort; + UINT16 RemotePort; + UINT16 Protocol; + BOOLEAN StaticIpAddress; + /* new from UEFI version 2, code must check Length field in Header */ + EFI_IPv4_ADDRESS GatewayIpAddress ; + EFI_IPv4_ADDRESS SubnetMask ; +} IPv4_DEVICE_PATH; + +#define MSG_IPv6_DP 0x0d +typedef struct _IPv6_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_IPv6_ADDRESS LocalIpAddress; + EFI_IPv6_ADDRESS RemoteIpAddress; + UINT16 LocalPort; + UINT16 RemotePort; + UINT16 Protocol; + BOOLEAN IPAddressOrigin ; + /* new from UEFI version 2, code must check Length field in Header */ + UINT8 PrefixLength ; + EFI_IPv6_ADDRESS GatewayIpAddress ; +} IPv6_DEVICE_PATH; + + +/** + * Uniform Resource Identifiers SubType. + * UEFI 2.0 specification version 2.4C § 9.3.5.23. + */ +#define MSG_URI_DP 24 +typedef struct _URI_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + CHAR8 Uri[1]; +} URI_DEVICE_PATH; + +/** + * Device Logical Unit SubType. + * UEFI 2.0 specification version 2.4 § 9.3.5.8. + */ +#define MSG_VLAN_DP 20 +typedef struct _VLAN_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + UINT16 VlanId ; +} VLAN_DEVICE_PATH; + +#define MSG_INFINIBAND_DP 0x09 +typedef struct _INFINIBAND_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 ResourceFlags; + UINT8 PortGid[16]; + UINT64 ServiceId; + UINT64 TargetPortId; + UINT64 DeviceId; +} INFINIBAND_DEVICE_PATH; + +#define MSG_UART_DP 0x0e +typedef struct _UART_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Reserved; + UINT64 BaudRate; + UINT8 DataBits; + UINT8 Parity; + UINT8 StopBits; +} UART_DEVICE_PATH; + +#define MSG_VENDOR_DP 0x0A +/* Use VENDOR_DEVICE_PATH struct */ + +#define EFI_PC_ANSI_GUID \ + { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define DEVICE_PATH_MESSAGING_PC_ANSI EFI_PC_ANSI_GUID + +#define EFI_VT_100_GUID \ + { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define DEVICE_PATH_MESSAGING_VT_100 EFI_VT_100_GUID + +#define EFI_VT_100_PLUS_GUID \ + { 0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43} } +#define DEVICE_PATH_MESSAGING_VT_100_PLUS EFI_VT_100_PLUS_GUID + +#define EFI_VT_UTF8_GUID \ + { 0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88} } +#define DEVICE_PATH_MESSAGING_VT_UTF8 EFI_VT_UTF8_GUID + + +/* + * Media Device Path (UEFI 2.4 specification, version 2.4 § 9.3.6.) + */ +#define MEDIA_DEVICE_PATH 0x04 + +#define MEDIA_HARDDRIVE_DP 0x01 +typedef struct _HARDDRIVE_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 PartitionNumber; + UINT64 PartitionStart; + UINT64 PartitionSize; + UINT8 Signature[16]; + UINT8 MBRType; + UINT8 SignatureType; +} HARDDRIVE_DEVICE_PATH; + +#define MBR_TYPE_PCAT 0x01 +#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02 + +#define SIGNATURE_TYPE_MBR 0x01 +#define SIGNATURE_TYPE_GUID 0x02 + +#define MEDIA_CDROM_DP 0x02 +typedef struct _CDROM_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 BootEntry; + UINT64 PartitionStart; + UINT64 PartitionSize; +} CDROM_DEVICE_PATH; + +#define MEDIA_VENDOR_DP 0x03 +/* Use VENDOR_DEVICE_PATH struct */ + +#define MEDIA_FILEPATH_DP 0x04 +typedef struct _FILEPATH_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + CHAR16 PathName[1]; +} FILEPATH_DEVICE_PATH; + +#define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName) + +#define MEDIA_PROTOCOL_DP 0x05 +typedef struct _MEDIA_PROTOCOL_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID Protocol; +} MEDIA_PROTOCOL_DEVICE_PATH; + +/** + * PIWG Firmware File SubType. + * UEFI 2.0 specification version 2.4 § 9.3.6.6. + */ +#define MEDIA_PIWG_FW_FILE_DP 6 +typedef struct _MEDIA_FW_VOL_FILEPATH_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + EFI_GUID FvFileName ; +} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ; + +/** + * PIWG Firmware Volume Device Path SubType. + * UEFI 2.0 specification version 2.4 § 9.3.6.7. + */ +#define MEDIA_PIWG_FW_VOL_DP 7 +typedef struct _MEDIA_FW_VOL_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + EFI_GUID FvName ; +} MEDIA_FW_VOL_DEVICE_PATH ; + +/** + * Media relative offset range device path. + * UEFI 2.0 specification version 2.4 § 9.3.6.8. + */ +#define MEDIA_RELATIVE_OFFSET_RANGE_DP 8 +typedef struct _MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header ; + UINT32 Reserved ; + UINT64 StartingOffset ; + UINT64 EndingOffset ; +} MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH ; + + +/* + * BIOS Boot Specification Device Path (UEFI 2.4 specification, version 2.4 § 9.3.7.) + */ +#define BBS_DEVICE_PATH 0x05 + +#define BBS_BBS_DP 0x01 +typedef struct _BBS_BBS_DEVICE_PATH { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 DeviceType; + UINT16 StatusFlag; + CHAR8 String[1]; +} BBS_BBS_DEVICE_PATH; + +/* DeviceType definitions - from BBS specification */ +#define BBS_TYPE_FLOPPY 0x01 +#define BBS_TYPE_HARDDRIVE 0x02 +#define BBS_TYPE_CDROM 0x03 +#define BBS_TYPE_PCMCIA 0x04 +#define BBS_TYPE_USB 0x05 +#define BBS_TYPE_EMBEDDED_NETWORK 0x06 +#define BBS_TYPE_DEV 0x80 +#define BBS_TYPE_UNKNOWN 0xFF + +typedef union { + EFI_DEVICE_PATH_PROTOCOL DevPath; + PCI_DEVICE_PATH Pci; + PCCARD_DEVICE_PATH PcCard; + MEMMAP_DEVICE_PATH MemMap; + VENDOR_DEVICE_PATH Vendor; + UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor; + CONTROLLER_DEVICE_PATH Controller; + ACPI_HID_DEVICE_PATH Acpi; + + ATAPI_DEVICE_PATH Atapi; + SCSI_DEVICE_PATH Scsi; + FIBRECHANNEL_DEVICE_PATH FibreChannel; + + F1394_DEVICE_PATH F1394; + USB_DEVICE_PATH Usb; + USB_CLASS_DEVICE_PATH UsbClass; + I2O_DEVICE_PATH I2O; + MAC_ADDR_DEVICE_PATH MacAddr; + IPv4_DEVICE_PATH Ipv4; + IPv6_DEVICE_PATH Ipv6; + URI_DEVICE_PATH Uri; + INFINIBAND_DEVICE_PATH InfiniBand; + UART_DEVICE_PATH Uart; + + HARDDRIVE_DEVICE_PATH HardDrive; + CDROM_DEVICE_PATH CD; + + FILEPATH_DEVICE_PATH FilePath; + MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol; + + BBS_BBS_DEVICE_PATH Bbs; + +} EFI_DEV_PATH; + +typedef union { + EFI_DEVICE_PATH_PROTOCOL *DevPath; + PCI_DEVICE_PATH *Pci; + PCCARD_DEVICE_PATH *PcCard; + MEMMAP_DEVICE_PATH *MemMap; + VENDOR_DEVICE_PATH *Vendor; + UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor; + CONTROLLER_DEVICE_PATH *Controller; + ACPI_HID_DEVICE_PATH *Acpi; + + ATAPI_DEVICE_PATH *Atapi; + SCSI_DEVICE_PATH *Scsi; + FIBRECHANNEL_DEVICE_PATH *FibreChannel; + + F1394_DEVICE_PATH *F1394; + USB_DEVICE_PATH *Usb; + USB_CLASS_DEVICE_PATH *UsbClass; + I2O_DEVICE_PATH *I2O; + MAC_ADDR_DEVICE_PATH *MacAddr; + IPv4_DEVICE_PATH *Ipv4; + IPv6_DEVICE_PATH *Ipv6; + URI_DEVICE_PATH *Uri; + INFINIBAND_DEVICE_PATH *InfiniBand; + UART_DEVICE_PATH *Uart; + + HARDDRIVE_DEVICE_PATH *HardDrive; + + FILEPATH_DEVICE_PATH *FilePath; + MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol; + + CDROM_DEVICE_PATH *CD; + BBS_BBS_DEVICE_PATH *Bbs; + +} EFI_DEV_PATH_PTR; + +#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ + { 0x8b843e20, 0x8132, 0x4852, {0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c} } + +typedef +CHAR16* +(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ); + +typedef +CHAR16* +(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ); + +typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL { + EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText; + EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText; +} EFI_DEVICE_PATH_TO_TEXT_PROTOCOL; + +#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \ + { 0x5c99a21, 0xc70f, 0x4ad2, {0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e} } + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) ( + IN CONST CHAR16 *TextDeviceNode + ); + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) ( + IN CONST CHAR16 *TextDevicePath + ); + +typedef struct { + EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode; + EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath; +} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL; + +#endif diff --git a/gnu-efi/inc/efierr.h b/gnu-efi/inc/efierr.h new file mode 100644 index 0000000..d351c1c --- /dev/null +++ b/gnu-efi/inc/efierr.h @@ -0,0 +1,67 @@ +#ifndef _EFI_ERR_H +#define _EFI_ERR_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efierr.h + +Abstract: + + EFI error codes + + + + +Revision History + +--*/ + + +#define EFIWARN(a) (a) +#define EFI_ERROR(a) (((INTN) a) < 0) + + +#define EFI_SUCCESS 0 +#define EFI_LOAD_ERROR EFIERR(1) +#define EFI_INVALID_PARAMETER EFIERR(2) +#define EFI_UNSUPPORTED EFIERR(3) +#define EFI_BAD_BUFFER_SIZE EFIERR(4) +#define EFI_BUFFER_TOO_SMALL EFIERR(5) +#define EFI_NOT_READY EFIERR(6) +#define EFI_DEVICE_ERROR EFIERR(7) +#define EFI_WRITE_PROTECTED EFIERR(8) +#define EFI_OUT_OF_RESOURCES EFIERR(9) +#define EFI_VOLUME_CORRUPTED EFIERR(10) +#define EFI_VOLUME_FULL EFIERR(11) +#define EFI_NO_MEDIA EFIERR(12) +#define EFI_MEDIA_CHANGED EFIERR(13) +#define EFI_NOT_FOUND EFIERR(14) +#define EFI_ACCESS_DENIED EFIERR(15) +#define EFI_NO_RESPONSE EFIERR(16) +#define EFI_NO_MAPPING EFIERR(17) +#define EFI_TIMEOUT EFIERR(18) +#define EFI_NOT_STARTED EFIERR(19) +#define EFI_ALREADY_STARTED EFIERR(20) +#define EFI_ABORTED EFIERR(21) +#define EFI_ICMP_ERROR EFIERR(22) +#define EFI_TFTP_ERROR EFIERR(23) +#define EFI_PROTOCOL_ERROR EFIERR(24) +#define EFI_INCOMPATIBLE_VERSION EFIERR(25) +#define EFI_SECURITY_VIOLATION EFIERR(26) +#define EFI_CRC_ERROR EFIERR(27) +#define EFI_END_OF_MEDIA EFIERR(28) +#define EFI_END_OF_FILE EFIERR(31) +#define EFI_INVALID_LANGUAGE EFIERR(32) +#define EFI_COMPROMISED_DATA EFIERR(33) + +#define EFI_WARN_UNKNOWN_GLYPH EFIWARN(1) +#define EFI_WARN_DELETE_FAILURE EFIWARN(2) +#define EFI_WARN_WRITE_FAILURE EFIWARN(3) +#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4) + +#endif + diff --git a/gnu-efi/inc/efifs.h b/gnu-efi/inc/efifs.h new file mode 100644 index 0000000..fc595d1 --- /dev/null +++ b/gnu-efi/inc/efifs.h @@ -0,0 +1,116 @@ +#ifndef _EFI_FS_H +#define _EFI_FS_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efifs.h + +Abstract: + + EFI File System structures + + + +Revision History + +--*/ + + +// +// EFI Partition header (normaly starts in LBA 1) +// + +#define EFI_PARTITION_SIGNATURE 0x5053595320494249 +#define EFI_PARTITION_REVISION 0x00010001 +#define MIN_EFI_PARTITION_BLOCK_SIZE 512 +#define EFI_PARTITION_LBA 1 + +typedef struct _EFI_PARTITION_HEADER { + EFI_TABLE_HEADER Hdr; + UINT32 DirectoryAllocationNumber; + UINT32 BlockSize; + EFI_LBA FirstUsableLba; + EFI_LBA LastUsableLba; + EFI_LBA UnusableSpace; + EFI_LBA FreeSpace; + EFI_LBA RootFile; + EFI_LBA SecutiryFile; +} EFI_PARTITION_HEADER; + + +// +// File header +// + +#define EFI_FILE_HEADER_SIGNATURE 0x454c494620494249 +#define EFI_FILE_HEADER_REVISION 0x00010000 +#define EFI_FILE_STRING_SIZE 260 + +typedef struct _EFI_FILE_HEADER { + EFI_TABLE_HEADER Hdr; + UINT32 Class; + UINT32 LBALOffset; + EFI_LBA Parent; + UINT64 FileSize; + UINT64 FileAttributes; + EFI_TIME FileCreateTime; + EFI_TIME FileModificationTime; + EFI_GUID VendorGuid; + CHAR16 FileString[EFI_FILE_STRING_SIZE]; +} EFI_FILE_HEADER; + + +// +// Return the file's first LBAL which is in the same +// logical block as the file header +// + +#define EFI_FILE_LBAL(a) ((EFI_LBAL *) (((CHAR8 *) (a)) + (a)->LBALOffset)) + +#define EFI_FILE_CLASS_FREE_SPACE 1 +#define EFI_FILE_CLASS_EMPTY 2 +#define EFI_FILE_CLASS_NORMAL 3 + + +// +// Logical Block Address List - the fundemental block +// description structure +// + +#define EFI_LBAL_SIGNATURE 0x4c41424c20494249 +#define EFI_LBAL_REVISION 0x00010000 + +typedef struct _EFI_LBAL { + EFI_TABLE_HEADER Hdr; + UINT32 Class; + EFI_LBA Parent; + EFI_LBA Next; + UINT32 ArraySize; + UINT32 ArrayCount; +} EFI_LBAL; + +// Array size +#define EFI_LBAL_ARRAY_SIZE(lbal,offs,blks) \ + (((blks) - (offs) - (lbal)->Hdr.HeaderSize) / sizeof(EFI_RL)) + +// +// Logical Block run-length +// + +typedef struct { + EFI_LBA Start; + UINT64 Length; +} EFI_RL; + +// +// Return the run-length structure from an LBAL header +// + +#define EFI_LBAL_RL(a) ((EFI_RL*) (((CHAR8 *) (a)) + (a)->Hdr.HeaderSize)) + +#endif + diff --git a/gnu-efi/inc/efigpt.h b/gnu-efi/inc/efigpt.h new file mode 100644 index 0000000..d1694ae --- /dev/null +++ b/gnu-efi/inc/efigpt.h @@ -0,0 +1,68 @@ +#ifndef _EFI_GPT_H +#define _EFI_GPT_H +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + EfiGpt.h + +Abstract: + Include file for EFI partitioning scheme + + + +Revision History + +--*/ + +#define PRIMARY_PART_HEADER_LBA 1 + +typedef struct { + EFI_TABLE_HEADER Header; + EFI_LBA MyLBA; + EFI_LBA AlternateLBA; + EFI_LBA FirstUsableLBA; + EFI_LBA LastUsableLBA; + EFI_GUID DiskGUID; + EFI_LBA PartitionEntryLBA; + UINT32 NumberOfPartitionEntries; + UINT32 SizeOfPartitionEntry; + UINT32 PartitionEntryArrayCRC32; +} EFI_PARTITION_TABLE_HEADER; + +#define EFI_PTAB_HEADER_ID "EFI PART" + +typedef struct { + EFI_GUID PartitionTypeGUID; + EFI_GUID UniquePartitionGUID; + EFI_LBA StartingLBA; + EFI_LBA EndingLBA; + UINT64 Attributes; + CHAR16 PartitionName[36]; +} EFI_PARTITION_ENTRY; + +// +// EFI Partition Attributes +// +#define EFI_PART_USED_BY_EFI 0x0000000000000001 +#define EFI_PART_REQUIRED_TO_FUNCTION 0x0000000000000002 +#define EFI_PART_USED_BY_OS 0x0000000000000004 +#define EFI_PART_REQUIRED_BY_OS 0x0000000000000008 +#define EFI_PART_BACKUP_REQUIRED 0x0000000000000010 +#define EFI_PART_USER_DATA 0x0000000000000020 +#define EFI_PART_CRITICAL_USER_DATA 0x0000000000000040 +#define EFI_PART_REDUNDANT_PARTITION 0x0000000000000080 + +#define EFI_PART_TYPE_UNUSED_GUID \ + { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} } + +#define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \ + { 0xc12a7328, 0xf81f, 0x11d2, {0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} } + +#define EFI_PART_TYPE_LEGACY_MBR_GUID \ + { 0x024dee41, 0x33e7, 0x11d3, {0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f} } + +#endif + diff --git a/gnu-efi/inc/efiip.h b/gnu-efi/inc/efiip.h new file mode 100644 index 0000000..8395079 --- /dev/null +++ b/gnu-efi/inc/efiip.h @@ -0,0 +1,459 @@ +#ifndef _EFI_IP_H +#define _EFI_IP_H + +/*++ +Copyright (c) 2013 Intel Corporation + +--*/ + +#define EFI_IP4_SERVICE_BINDING_PROTOCOL \ + {0xc51711e7,0xb4bf,0x404a,{0xbf,0xb8,0x0a,0x04, 0x8e,0xf1,0xff,0xe4}} + +#define EFI_IP4_PROTOCOL \ + {0x41d94cd2,0x35b6,0x455a,{0x82,0x58,0xd4,0xe5,0x13,0x34,0xaa,0xdd}} + +#define EFI_IP6_SERVICE_BINDING_PROTOCOL \ + {0xec835dd3,0xfe0f,0x617b,{0xa6,0x21,0xb3,0x50,0xc3,0xe1,0x33,0x88}} + +#define EFI_IP6_PROTOCOL \ + {0x2c8759d5,0x5c2d,0x66ef,{0x92,0x5f,0xb6,0x6c,0x10,0x19,0x57,0xe2}} + +INTERFACE_DECL(_EFI_IP4); +INTERFACE_DECL(_EFI_IP6); + +typedef struct { + EFI_HANDLE InstanceHandle; + EFI_IPv4_ADDRESS Ip4Address; + EFI_IPv4_ADDRESS SubnetMask; +} EFI_IP4_ADDRESS_PAIR; + +typedef struct { + EFI_HANDLE DriverHandle; + UINT32 AddressCount; + EFI_IP4_ADDRESS_PAIR AddressPairs[1]; +} EFI_IP4_VARIABLE_DATA; + +typedef struct { + UINT8 DefaultProtocol; + BOOLEAN AcceptAnyProtocol; + BOOLEAN AcceptIcmpErrors; + BOOLEAN AcceptBroadcast; + BOOLEAN AcceptPromiscuous; + BOOLEAN UseDefaultAddress; + EFI_IPv4_ADDRESS StationAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT8 TypeOfService; + UINT8 TimeToLive; + BOOLEAN DoNotFragment; + BOOLEAN RawData; + UINT32 ReceiveTimeout; + UINT32 TransmitTimeout; +} EFI_IP4_CONFIG_DATA; + +typedef struct { + EFI_IPv4_ADDRESS SubnetAddress; + EFI_IPv4_ADDRESS SubnetMask; + EFI_IPv4_ADDRESS GatewayAddress; +} EFI_IP4_ROUTE_TABLE; + +typedef struct { + UINT8 Type; + UINT8 Code; +} EFI_IP4_ICMP_TYPE; + +typedef struct { + BOOLEAN IsStarted; + UINT32 MaxPacketSize; + EFI_IP4_CONFIG_DATA ConfigData; + BOOLEAN IsConfigured; + UINT32 GroupCount; + EFI_IPv4_ADDRESS *GroupTable; + UINT32 RouteCount; + EFI_IP4_ROUTE_TABLE *RouteTable; + UINT32 IcmpTypeCount; + EFI_IP4_ICMP_TYPE *IcmpTypeList; +} EFI_IP4_MODE_DATA; + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_GET_MODE_DATA) ( + IN struct _EFI_IP4 *This, + OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIGURE) ( + IN struct _EFI_IP4 *This, + IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_GROUPS) ( + IN struct _EFI_IP4 *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_ROUTES) ( + IN struct _EFI_IP4 *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv4_ADDRESS *SubnetAddress, + IN EFI_IPv4_ADDRESS *SubnetMask, + IN EFI_IPv4_ADDRESS *GatewayAddress + ); + +#pragma pack(1) +typedef struct { + UINT8 HeaderLength:4; + UINT8 Version:4; + UINT8 TypeOfService; + UINT16 TotalLength; + UINT16 Identification; + UINT16 Fragmentation; + UINT8 TimeToLive; + UINT8 Protocol; + UINT16 Checksum; + EFI_IPv4_ADDRESS SourceAddress; + EFI_IPv4_ADDRESS DestinationAddress; +} EFI_IP4_HEADER; +#pragma pack() + +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_IP4_FRAGMENT_DATA; + +typedef struct { + EFI_TIME TimeStamp; + EFI_EVENT RecycleSignal; + UINT32 HeaderLength; + EFI_IP4_HEADER *Header; + UINT32 OptionsLength; + VOID *Options; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_IP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP4_RECEIVE_DATA; + +typedef struct { + EFI_IPv4_ADDRESS SourceAddress; + EFI_IPv4_ADDRESS GatewayAddress; + UINT8 Protocol; + UINT8 TypeOfService; + UINT8 TimeToLive; + BOOLEAN DoNotFragment; +} EFI_IP4_OVERRIDE_DATA; + +typedef struct { + EFI_IPv4_ADDRESS DestinationAddress; + EFI_IP4_OVERRIDE_DATA *OverrideData; + UINT32 OptionsLength; + VOID *OptionsBuffer; + UINT32 TotalDataLength; + UINT32 FragmentCount; + EFI_IP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP4_TRANSMIT_DATA; + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + union { + EFI_IP4_RECEIVE_DATA *RxData; + EFI_IP4_TRANSMIT_DATA *TxData; + } Packet; +} EFI_IP4_COMPLETION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_TRANSMIT) ( + IN struct _EFI_IP4 *This, + IN EFI_IP4_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_RECEIVE) ( + IN struct _EFI_IP4 *This, + IN EFI_IP4_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CANCEL)( + IN struct _EFI_IP4 *This, + IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_POLL) ( + IN struct _EFI_IP4 *This + ); + +typedef struct _EFI_IP4 { + EFI_IP4_GET_MODE_DATA GetModeData; + EFI_IP4_CONFIGURE Configure; + EFI_IP4_GROUPS Groups; + EFI_IP4_ROUTES Routes; + EFI_IP4_TRANSMIT Transmit; + EFI_IP4_RECEIVE Receive; + EFI_IP4_CANCEL Cancel; + EFI_IP4_POLL Poll; +} EFI_IP4; + +typedef struct { + UINT8 DefaultProtocol; + BOOLEAN AcceptAnyProtocol; + BOOLEAN AcceptIcmpErrors; + BOOLEAN AcceptPromiscuous; + EFI_IPv6_ADDRESS DestinationAddress; + EFI_IPv6_ADDRESS StationAddress; + UINT8 TrafficClass; + UINT8 HopLimit; + UINT32 FlowLabel; + UINT32 ReceiveTimeout; + UINT32 TransmitTimeout; +} EFI_IP6_CONFIG_DATA; + +typedef struct { + EFI_IPv6_ADDRESS Address; + UINT8 PrefixLength; +} EFI_IP6_ADDRESS_INFO; + +typedef struct { + EFI_IPv6_ADDRESS Gateway; + EFI_IPv6_ADDRESS Destination; + UINT8 PrefixLength; +} EFI_IP6_ROUTE_TABLE; + +typedef enum { + EfiNeighborInComplete, + EfiNeighborReachable, + EfiNeighborStale, + EfiNeighborDelay, + EfiNeighborProbe +} EFI_IP6_NEIGHBOR_STATE; + +typedef struct { + EFI_IPv6_ADDRESS Neighbor; + EFI_MAC_ADDRESS LinkAddress; + EFI_IP6_NEIGHBOR_STATE State; +} EFI_IP6_NEIGHBOR_CACHE; + +typedef struct { + UINT8 Type; + UINT8 Code; +} EFI_IP6_ICMP_TYPE; + +//*********************************************************** +// ICMPv6 type definitions for error messages +//*********************************************************** +#define ICMP_V6_DEST_UNREACHABLE 0x1 +#define ICMP_V6_PACKET_TOO_BIG 0x2 +#define ICMP_V6_TIME_EXCEEDED 0x3 +#define ICMP_V6_PARAMETER_PROBLEM 0x4 + +//*********************************************************** +// ICMPv6 type definition for informational messages +//*********************************************************** +#define ICMP_V6_ECHO_REQUEST 0x80 +#define ICMP_V6_ECHO_REPLY 0x81 +#define ICMP_V6_LISTENER_QUERY 0x82 +#define ICMP_V6_LISTENER_REPORT 0x83 +#define ICMP_V6_LISTENER_DONE 0x84 +#define ICMP_V6_ROUTER_SOLICIT 0x85 +#define ICMP_V6_ROUTER_ADVERTISE 0x86 +#define ICMP_V6_NEIGHBOR_SOLICIT 0x87 +#define ICMP_V6_NEIGHBOR_ADVERTISE 0x88 +#define ICMP_V6_REDIRECT 0x89 +#define ICMP_V6_LISTENER_REPORT_2 0x8F + +//*********************************************************** +// ICMPv6 code definitions for ICMP_V6_DEST_UNREACHABLE +//*********************************************************** +#define ICMP_V6_NO_ROUTE_TO_DEST 0x0 +#define ICMP_V6_COMM_PROHIBITED 0x1 +#define ICMP_V6_BEYOND_SCOPE 0x2 +#define ICMP_V6_ADDR_UNREACHABLE 0x3 +#define ICMP_V6_PORT_UNREACHABLE 0x4 +#define ICMP_V6_SOURCE_ADDR_FAILED 0x5 +#define ICMP_V6_ROUTE_REJECTED 0x6 + +//*********************************************************** +// ICMPv6 code definitions for ICMP_V6_TIME_EXCEEDED +//*********************************************************** +#define ICMP_V6_TIMEOUT_HOP_LIMIT 0x0 +#define ICMP_V6_TIMEOUT_REASSEMBLE 0x1 + +//*********************************************************** +// ICMPv6 code definitions for ICMP_V6_PARAMETER_PROBLEM +//*********************************************************** +#define ICMP_V6_ERRONEOUS_HEADER 0x0 +#define ICMP_V6_UNRECOGNIZE_NEXT_HDR 0x1 +#define ICMP_V6_UNRECOGNIZE_OPTION 0x2 + +typedef struct { + BOOLEAN IsStarted; + UINT32 MaxPacketSize; + EFI_IP6_CONFIG_DATA ConfigData; + BOOLEAN IsConfigured; + UINT32 AddressCount; + EFI_IP6_ADDRESS_INFO *AddressList; + UINT32 GroupCount; + EFI_IPv6_ADDRESS *GroupTable; + UINT32 RouteCount; + EFI_IP6_ROUTE_TABLE *RouteTable; + UINT32 NeighborCount; + EFI_IP6_NEIGHBOR_CACHE *NeighborCache; + UINT32 PrefixCount; + EFI_IP6_ADDRESS_INFO *PrefixTable; + UINT32 IcmpTypeCount; + EFI_IP6_ICMP_TYPE *IcmpTypeList; +} EFI_IP6_MODE_DATA; + +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_GET_MODE_DATA) ( + IN struct _EFI_IP6 *This, + OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIGURE) ( + IN struct _EFI_IP6 *This, + IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL + ); +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_GROUPS) ( + IN struct _EFI_IP6 *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_ROUTES) ( + IN struct _EFI_IP6 *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv6_ADDRESS *Destination OPTIONAL, + IN UINT8 PrefixLength, + IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_NEIGHBORS) ( + IN struct _EFI_IP6 *This, + IN BOOLEAN DeleteFlag, + IN EFI_IPv6_ADDRESS *TargetIp6Address, + IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, + IN UINT32 Timeout, + IN BOOLEAN Override + ); + +typedef struct _EFI_IP6_FRAGMENT_DATA { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_IP6_FRAGMENT_DATA; + +typedef struct _EFI_IP6_OVERRIDE_DATA { + UINT8 Protocol; + UINT8 HopLimit; + UINT32 FlowLabel; +} EFI_IP6_OVERRIDE_DATA; + +typedef struct _EFI_IP6_TRANSMIT_DATA { + EFI_IPv6_ADDRESS DestinationAddress; + EFI_IP6_OVERRIDE_DATA *OverrideData; + UINT32 ExtHdrsLength; + VOID *ExtHdrs; + UINT8 NextHeader; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_IP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP6_TRANSMIT_DATA; + +#pragma pack(1) +typedef struct _EFI_IP6_HEADER { + UINT8 TrafficClassH:4; + UINT8 Version:4; + UINT8 FlowLabelH:4; + UINT8 TrafficClassL:4; + UINT16 FlowLabelL; + UINT16 PayloadLength; + UINT8 NextHeader; + UINT8 HopLimit; + EFI_IPv6_ADDRESS SourceAddress; + EFI_IPv6_ADDRESS DestinationAddress; +} EFI_IP6_HEADER; +#pragma pack() + +typedef struct _EFI_IP6_RECEIVE_DATA { + EFI_TIME TimeStamp; + EFI_EVENT RecycleSignal; + UINT32 HeaderLength; + EFI_IP6_HEADER *Header; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_IP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP6_RECEIVE_DATA; + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + union { + EFI_IP6_RECEIVE_DATA *RxData; + EFI_IP6_TRANSMIT_DATA *TxData; + } Packet; +} EFI_IP6_COMPLETION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_TRANSMIT) ( + IN struct _EFI_IP6 *This, + IN EFI_IP6_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_RECEIVE) ( + IN struct _EFI_IP6 *This, + IN EFI_IP6_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CANCEL)( + IN struct _EFI_IP6 *This, + IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_POLL) ( + IN struct _EFI_IP6 *This + ); + +typedef struct _EFI_IP6 { + EFI_IP6_GET_MODE_DATA GetModeData; + EFI_IP6_CONFIGURE Configure; + EFI_IP6_GROUPS Groups; + EFI_IP6_ROUTES Routes; + EFI_IP6_NEIGHBORS Neighbors; + EFI_IP6_TRANSMIT Transmit; + EFI_IP6_RECEIVE Receive; + EFI_IP6_CANCEL Cancel; + EFI_IP6_POLL Poll; +} EFI_IP6; + +#endif /* _EFI_IP_H */ diff --git a/gnu-efi/inc/efilib.h b/gnu-efi/inc/efilib.h new file mode 100644 index 0000000..8a507af --- /dev/null +++ b/gnu-efi/inc/efilib.h @@ -0,0 +1,1036 @@ +#ifndef _EFILIB_INCLUDE_ +#define _EFILIB_INCLUDE_ + +/*++ + +Copyright (c) 2000 Intel Corporation + +Module Name: + + efilib.h + +Abstract: + + EFI library functions + + + +Revision History + +--*/ + +#include "efidebug.h" +#include "efipart.h" +#include "efilibplat.h" +#include "efilink.h" +#include "efirtlib.h" +#include "efistdarg.h" +#include "pci22.h" +#include "libsmbios.h" + +// +// Public read-only data in the EFI library +// + +extern EFI_SYSTEM_TABLE *ST; +#define gST ST +extern EFI_BOOT_SERVICES *BS; +#define gBS BS +extern EFI_RUNTIME_SERVICES *RT; +#define gRT RT + +extern EFI_GUID gEfiDevicePathProtocolGuid; +#define DevicePathProtocol gEfiDevicePathProtocolGuid +extern EFI_GUID gEfiDevicePathToTextProtocolGuid; +#define DevicePathToTextProtocol gEfiDevicePathToTextProtocolGuid +extern EFI_GUID gEfiDevicePathFromTextProtocolGuid; +#define DevicePathFromTextProtocol gEfiDevicePathFromTextProtocolGuid +extern EFI_GUID gEfiLoadedImageProtocolGuid; +#define LoadedImageProtocol gEfiLoadedImageProtocolGuid +extern EFI_GUID gEfiSimpleTextInProtocolGuid; +#define TextInProtocol gEfiSimpleTextInProtocolGuid +extern EFI_GUID gEfiSimpleTextOutProtocolGuid; +#define TextOutProtocol gEfiSimpleTextOutProtocolGuid +extern EFI_GUID gEfiGraphicsOutputProtocolGuid; +#define GraphicsOutputProtocol gEfiGraphicsOutputProtocolGuid +extern EFI_GUID gEfiEdidDiscoveredProtocolGuid; +#define EdidDiscoveredProtocol gEfiEdidDiscoveredProtocolGuid +extern EFI_GUID gEfiEdidActiveProtocolGuid; +#define EdidActiveProtocol gEfiEdidActiveProtocolGuid +extern EFI_GUID gEfiEdidOverrideProtocolGuid; +#define EdidOverrideProtocol gEfiEdidOverrideProtocolGuid +extern EFI_GUID gEfiBlockIoProtocolGuid; +#define BlockIoProtocol gEfiBlockIoProtocolGuid +extern EFI_GUID gEfiBlockIo2ProtocolGuid; +#define BlockIo2Protocol gEfiBlockIo2ProtocolGuid +extern EFI_GUID gEfiDiskIoProtocolGuid; +#define DiskIoProtocol gEfiDiskIoProtocolGuid +extern EFI_GUID gEfiDiskIo2ProtocolGuid; +#define DiskIo2Protocol gEfiDiskIo2ProtocolGuid +extern EFI_GUID gEfiSimpleFileSystemProtocolGuid; +#define FileSystemProtocol gEfiSimpleFileSystemProtocolGuid +extern EFI_GUID gEfiLoadFileProtocolGuid; +#define LoadFileProtocol gEfiLoadFileProtocolGuid +extern EFI_GUID gEfiDeviceIoProtocolGuid; +#define DeviceIoProtocol gEfiDeviceIoProtocolGuid +extern EFI_GUID VariableStoreProtocol; +extern EFI_GUID LegacyBootProtocol; +extern EFI_GUID gEfiUnicodeCollationProtocolGuid; +#define UnicodeCollationProtocol gEfiUnicodeCollationProtocolGuid +extern EFI_GUID gEfiSerialIoProtocolGuid; +#define SerialIoProtocol gEfiSerialIoProtocolGuid +extern EFI_GUID VgaClassProtocol; +extern EFI_GUID TextOutSpliterProtocol; +extern EFI_GUID ErrorOutSpliterProtocol; +extern EFI_GUID TextInSpliterProtocol; +extern EFI_GUID gEfiSimpleNetworkProtocolGuid; +#define SimpleNetworkProtocol gEfiSimpleNetworkProtocolGuid +extern EFI_GUID gEfiPxeBaseCodeProtocolGuid; +#define PxeBaseCodeProtocol gEfiPxeBaseCodeProtocolGuid +extern EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid; +#define PxeCallbackProtocol gEfiPxeBaseCodeCallbackProtocolGuid +extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid; +#define NetworkInterfaceIdentifierProtocol gEfiNetworkInterfaceIdentifierProtocolGuid +extern EFI_GUID gEFiUiInterfaceProtocolGuid; +#define UiProtocol gEFiUiInterfaceProtocolGuid +extern EFI_GUID InternalShellProtocol; +extern EFI_GUID gEfiPciIoProtocolGuid; +#define PciIoProtocol gEfiPciIoProtocolGuid +extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid; +extern EFI_GUID gEfiDriverBindingProtocolGuid; +#define DriverBindingProtocol gEfiDriverBindingProtocolGuid +extern EFI_GUID gEfiComponentNameProtocolGuid; +#define ComponentNameProtocol gEfiComponentNameProtocolGuid +extern EFI_GUID gEfiComponentName2ProtocolGuid; +#define ComponentName2Protocol gEfiComponentName2ProtocolGuid +extern EFI_GUID gEfiHashProtocolGuid; +#define HashProtocol gEfiHashProtocolGuid +extern EFI_GUID gEfiPlatformDriverOverrideProtocolGuid; +#define PlatformDriverOverrideProtocol gEfiPlatformDriverOverrideProtocolGuid +extern EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid; +#define BusSpecificDriverOverrideProtocol gEfiBusSpecificDriverOverrideProtocolGuid +extern EFI_GUID gEfiDriverFamilyOverrideProtocolGuid; +#define DriverFamilyOverrideProtocol gEfiDriverFamilyOverrideProtocolGuid +extern EFI_GUID gEfiEbcProtocolGuid; + +extern EFI_GUID gEfiGlobalVariableGuid; +#define EfiGlobalVariable gEfiGlobalVariableGuid +extern EFI_GUID gEfiFileInfoGuid; +#define GenericFileInfo gEfiFileInfoGuid +extern EFI_GUID gEfiFileSystemInfoGuid; +#define FileSystemInfo gEfiFileSystemInfoGuid +extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid; +#define FileSystemVolumeLabelInfo gEfiFileSystemVolumeLabelInfoIdGuid +extern EFI_GUID gEfiPcAnsiGuid; +#define PcAnsiProtocol gEfiPcAnsiGuid +extern EFI_GUID gEfiVT100Guid; +#define Vt100Protocol gEfiVT100Guid +extern EFI_GUID gEfiVT100PlusGuid; +extern EFI_GUID gEfiVTUTF8Guid; + +extern EFI_GUID NullGuid; +extern EFI_GUID UnknownDevice; + +extern EFI_GUID EfiPartTypeSystemPartitionGuid; +extern EFI_GUID EfiPartTypeLegacyMbrGuid; + +extern EFI_GUID MpsTableGuid; +extern EFI_GUID AcpiTableGuid; +extern EFI_GUID SMBIOSTableGuid; +extern EFI_GUID SalSystemTableGuid; + +extern EFI_GUID SimplePointerProtocol; +extern EFI_GUID AbsolutePointerProtocol; + +extern EFI_GUID gEfiDebugImageInfoTableGuid; +extern EFI_GUID gEfiDebugSupportProtocolGuid; + +// +// EFI Variable strings +// +#define LOAD_OPTION_ACTIVE 0x00000001 + +#define VarLanguageCodes L"LangCodes" +#define VarLanguage L"Lang" +#define VarTimeout L"Timeout" +#define VarConsoleInp L"ConIn" +#define VarConsoleOut L"ConOut" +#define VarErrorOut L"ErrOut" +#define VarBootOption L"Boot%04x" +#define VarBootOrder L"BootOrder" +#define VarBootNext L"BootNext" +#define VarBootCurrent L"BootCurrent" +#define VarDriverOption L"Driver%04x" +#define VarDriverOrder L"DriverOrder" +#define VarConsoleInpDev L"ConInDev" +#define VarConsoleOutDev L"ConOutDev" +#define VarErrorOutDev L"ErrOutDev" + +#define LanguageCodeEnglish "eng" + +extern EFI_DEVICE_PATH RootDevicePath[]; +extern EFI_DEVICE_PATH EndDevicePath[]; +extern EFI_DEVICE_PATH EndInstanceDevicePath[]; + +// +// Other public data in the EFI library +// + +extern EFI_MEMORY_TYPE PoolAllocationType; + +// +// STATIC - Name is internal to the module +// INTERNAL - Name is internal to the component (i.e., directory) +// BOOTSERVCE - Name of a boot service function +// + +#define STATIC +#define INTERNAL +#define BOOTSERVICE + +// +// Prototypes +// + +VOID +InitializeLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +VOID +InitializeUnicodeSupport ( + CHAR8 *LangCode + ); + +VOID +EFIDebugVariable ( + VOID + ); + +VOID +Exit( + IN EFI_STATUS ExitStatus, + IN UINTN ExitDataSize, + IN CHAR16 *ExitData OPTIONAL + ); + +INTN +GetShellArgcArgv( + EFI_HANDLE ImageHandle, + CHAR16 **Argv[] /* Statically allocated */ + ); + +VOID +SetCrc ( + IN OUT EFI_TABLE_HEADER *Hdr + ); + +VOID +SetCrcAltSize ( + IN UINTN Size, + IN OUT EFI_TABLE_HEADER *Hdr + ); + +BOOLEAN +CheckCrc ( + IN UINTN MaxSize, + IN OUT EFI_TABLE_HEADER *Hdr + ); + +BOOLEAN +CheckCrcAltSize ( + IN UINTN MaxSize, + IN UINTN Size, + IN OUT EFI_TABLE_HEADER *Hdr + ); + +UINT32 +CalculateCrc ( + UINT8 *pt, + UINTN Size + ); + +VOID +ZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ); + +VOID +SetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ); + +VOID +CopyMem ( + IN VOID *Dest, + IN CONST VOID *Src, + IN UINTN len + ); + +INTN +CompareMem ( + IN CONST VOID *Dest, + IN CONST VOID *Src, + IN UINTN len + ); + +INTN +StrCmp ( + IN CONST CHAR16 *s1, + IN CONST CHAR16 *s2 + ); + +INTN +StrnCmp ( + IN CONST CHAR16 *s1, + IN CONST CHAR16 *s2, + IN UINTN len + ); + +INTN +StriCmp ( + IN CONST CHAR16 *s1, + IN CONST CHAR16 *s2 + ); + +VOID +StrLwr ( + IN CHAR16 *Str + ); + +VOID +StrUpr ( + IN CHAR16 *Str + ); + +VOID +StrCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ); + +VOID +StrnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +CHAR16 * +StpCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ); + +CHAR16 * +StpnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +VOID +StrCat ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ); + +VOID +StrnCat ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +UINTN +StrLen ( + IN CONST CHAR16 *s1 + ); + +UINTN +StrnLen ( + IN CONST CHAR16 *s1, + IN UINTN Len + ); + +UINTN +StrSize ( + IN CONST CHAR16 *s1 + ); + +CHAR16 * +StrDuplicate ( + IN CONST CHAR16 *Src + ); + +UINTN +strlena ( + IN CONST CHAR8 *s1 + ); + +UINTN +strcmpa ( + IN CONST CHAR8 *s1, + IN CONST CHAR8 *s2 + ); + +UINTN +strncmpa ( + IN CONST CHAR8 *s1, + IN CONST CHAR8 *s2, + IN UINTN len + ); + +UINTN +xtoi ( + CONST CHAR16 *str + ); + +UINTN +Atoi ( + CONST CHAR16 *str + ); + +BOOLEAN +MetaMatch ( + IN CHAR16 *String, + IN CHAR16 *Pattern + ); + +BOOLEAN +MetaiMatch ( + IN CHAR16 *String, + IN CHAR16 *Pattern + ); + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ); + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ); + +VOID +InitializeLock ( + IN OUT FLOCK *Lock, + IN EFI_TPL Priority + ); + +VOID +AcquireLock ( + IN FLOCK *Lock + ); + +VOID +ReleaseLock ( + IN FLOCK *Lock + ); + + +INTN +CompareGuid( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ); + +VOID * +AllocatePool ( + IN UINTN Size + ); + +VOID * +AllocateZeroPool ( + IN UINTN Size + ); + +VOID * +ReallocatePool ( + IN VOID *OldPool, + IN UINTN OldSize, + IN UINTN NewSize + ); + +VOID +FreePool ( + IN VOID *p + ); + + +VOID +Output ( + IN CHAR16 *Str + ); + +VOID +Input ( + IN CHAR16 *Prompt OPTIONAL, + OUT CHAR16 *InStr, + IN UINTN StrLen + ); + +VOID +IInput ( + IN SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut, + IN SIMPLE_INPUT_INTERFACE *ConIn, + IN CHAR16 *Prompt OPTIONAL, + OUT CHAR16 *InStr, + IN UINTN StrLen + ); + +UINTN +Print ( + IN CONST CHAR16 *fmt, + ... + ); + +UINTN +VPrint ( + IN CONST CHAR16 *fmt, + va_list args + ); + +UINTN +SPrint ( + OUT CHAR16 *Str, + IN UINTN StrSize, + IN CONST CHAR16 *fmt, + ... + ); + +UINTN +VSPrint ( + OUT CHAR16 *Str, + IN UINTN StrSize, + IN CONST CHAR16 *fmt, + va_list args + ); + +CHAR16 * +VPoolPrint ( + IN CONST CHAR16 *fmt, + va_list args + ); + +CHAR16 * +PoolPrint ( + IN CONST CHAR16 *fmt, + ... + ); + +typedef struct { + CHAR16 *str; + UINTN len; + UINTN maxlen; +} POOL_PRINT; + +CHAR16 * +CatPrint ( + IN OUT POOL_PRINT *Str, + IN CONST CHAR16 *fmt, + ... + ); + +UINTN +PrintAt ( + IN UINTN Column, + IN UINTN Row, + IN CONST CHAR16 *fmt, + ... + ); + +UINTN +IPrint ( + IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, + IN CONST CHAR16 *fmt, + ... + ); + +UINTN +IPrintAt ( + IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, + IN UINTN Column, + IN UINTN Row, + IN CONST CHAR16 *fmt, + ... + ); + +UINTN +APrint ( + IN CONST CHAR8 *fmt, + ... + ); + +VOID +ValueToHex ( + IN CHAR16 *Buffer, + IN UINT64 v + ); + +VOID +ValueToString ( + IN CHAR16 *Buffer, + IN BOOLEAN Comma, + IN INT64 v + ); + +VOID +FloatToString ( + IN CHAR16 *Buffer, + IN BOOLEAN Comma, + IN double v + ); + +VOID +TimeToString ( + OUT CHAR16 *Buffer, + IN EFI_TIME *Time + ); + +VOID +GuidToString ( + OUT CHAR16 *Buffer, + IN EFI_GUID *Guid + ); + +VOID +StatusToString ( + OUT CHAR16 *Buffer, + EFI_STATUS Status + ); + +VOID +DumpHex ( + IN UINTN Indent, + IN UINTN Offset, + IN UINTN DataSize, + IN VOID *UserData + ); + +BOOLEAN +GrowBuffer( + IN OUT EFI_STATUS *Status, + IN OUT VOID **Buffer, + IN UINTN BufferSize + ); + +EFI_MEMORY_DESCRIPTOR * +LibMemoryMap ( + OUT UINTN *NoEntries, + OUT UINTN *MapKey, + OUT UINTN *DescriptorSize, + OUT UINT32 *DescriptorVersion + ); + +VOID * +LibGetVariable ( + IN CHAR16 *Name, + IN EFI_GUID *VendorGuid + ); + +VOID * +LibGetVariableAndSize ( + IN CHAR16 *Name, + IN EFI_GUID *VendorGuid, + OUT UINTN *VarSize + ); + +EFI_STATUS +LibDeleteVariable ( + IN CHAR16 *VarName, + IN EFI_GUID *VarGuid + ); + +EFI_STATUS +LibSetNVVariable ( + IN CHAR16 *VarName, + IN EFI_GUID *VarGuid, + IN UINTN DataSize, + IN VOID *Data + ); + +EFI_STATUS +LibSetVariable ( + IN CHAR16 *VarName, + IN EFI_GUID *VarGuid, + IN UINTN DataSize, + IN VOID *Data + ); +EFI_STATUS +LibInsertToTailOfBootOrder ( + IN UINT16 BootOption, + IN BOOLEAN OnlyInsertIfEmpty + ); + +EFI_STATUS +LibLocateProtocol ( + IN EFI_GUID *ProtocolGuid, + OUT VOID **Interface + ); + +EFI_STATUS +LibLocateHandle ( + IN EFI_LOCATE_SEARCH_TYPE SearchType, + IN EFI_GUID *Protocol OPTIONAL, + IN VOID *SearchKey OPTIONAL, + IN OUT UINTN *NoHandles, + OUT EFI_HANDLE **Buffer + ); + +EFI_STATUS +LibLocateHandleByDiskSignature ( + IN UINT8 MBRType, + IN UINT8 SignatureType, + IN VOID *Signature, + IN OUT UINTN *NoHandles, + OUT EFI_HANDLE **Buffer + ); + +EFI_STATUS +LibInstallProtocolInterfaces ( + IN OUT EFI_HANDLE *Handle, + ... + ); + +VOID +LibUninstallProtocolInterfaces ( + IN EFI_HANDLE Handle, + ... + ); + +EFI_STATUS +LibReinstallProtocolInterfaces ( + IN OUT EFI_HANDLE *Handle, + ... + ); + +EFI_EVENT +LibCreateProtocolNotifyEvent ( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT VOID *Registration + ); + +EFI_STATUS +WaitForSingleEvent ( + IN EFI_EVENT Event, + IN UINT64 Timeout OPTIONAL + ); + +VOID +WaitForEventWithTimeout ( + IN EFI_EVENT Event, + IN UINTN Timeout, + IN UINTN Row, + IN UINTN Column, + IN CHAR16 *String, + IN EFI_INPUT_KEY TimeoutKey, + OUT EFI_INPUT_KEY *Key + ); + +EFI_FILE_HANDLE +LibOpenRoot ( + IN EFI_HANDLE DeviceHandle + ); + +EFI_FILE_INFO * +LibFileInfo ( + IN EFI_FILE_HANDLE FHand + ); + +EFI_FILE_SYSTEM_INFO * +LibFileSystemInfo ( + IN EFI_FILE_HANDLE FHand + ); + +EFI_FILE_SYSTEM_VOLUME_LABEL_INFO * +LibFileSystemVolumeLabelInfo ( + IN EFI_FILE_HANDLE FHand + ); + +BOOLEAN +ValidMBR( + IN MASTER_BOOT_RECORD *Mbr, + IN EFI_BLOCK_IO *BlkIo + ); + +BOOLEAN +LibMatchDevicePaths ( + IN EFI_DEVICE_PATH *Multi, + IN EFI_DEVICE_PATH *Single + ); + +EFI_DEVICE_PATH * +LibDuplicateDevicePathInstance ( + IN EFI_DEVICE_PATH *DevPath + ); + +EFI_DEVICE_PATH * +DevicePathFromHandle ( + IN EFI_HANDLE Handle + ); + +EFI_DEVICE_PATH * +DevicePathInstance ( + IN OUT EFI_DEVICE_PATH **DevicePath, + OUT UINTN *Size + ); + +UINTN +DevicePathInstanceCount ( + IN EFI_DEVICE_PATH *DevicePath + ); + +EFI_DEVICE_PATH * +AppendDevicePath ( + IN EFI_DEVICE_PATH *Src1, + IN EFI_DEVICE_PATH *Src2 + ); + +EFI_DEVICE_PATH * +AppendDevicePathNode ( + IN EFI_DEVICE_PATH *Src1, + IN EFI_DEVICE_PATH *Src2 + ); + +EFI_DEVICE_PATH* +AppendDevicePathInstance ( + IN EFI_DEVICE_PATH *Src, + IN EFI_DEVICE_PATH *Instance + ); + +EFI_DEVICE_PATH * +FileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ); + +UINTN +DevicePathSize ( + IN EFI_DEVICE_PATH *DevPath + ); + +EFI_DEVICE_PATH * +DuplicateDevicePath ( + IN EFI_DEVICE_PATH *DevPath + ); + +EFI_DEVICE_PATH * +UnpackDevicePath ( + IN EFI_DEVICE_PATH *DevPath + ); + +EFI_STATUS +LibDevicePathToInterface ( + IN EFI_GUID *Protocol, + IN EFI_DEVICE_PATH *FilePath, + OUT VOID **Interface + ); + +CHAR16 * +DevicePathToStr ( + EFI_DEVICE_PATH *DevPath + ); + +// +// BugBug: I need my own include files +// +typedef struct { + UINT8 Register; + UINT8 Function; + UINT8 Device; + UINT8 Bus; + UINT32 Reserved; +} EFI_ADDRESS; + +typedef union { + UINT64 Address; + EFI_ADDRESS EfiAddress; +} EFI_PCI_ADDRESS_UNION; + + +EFI_STATUS +PciFindDeviceClass ( + IN OUT EFI_PCI_ADDRESS_UNION *Address, + IN UINT8 BaseClass, + IN UINT8 SubClass + ); + +EFI_STATUS +PciFindDevice ( + IN OUT EFI_PCI_ADDRESS_UNION *DeviceAddress, + IN UINT16 VendorId, + IN UINT16 DeviceId, + IN OUT PCI_TYPE00 *Pci + ); + +// +// SIMPLE_READ_FILE object used to access files +// + +typedef VOID *SIMPLE_READ_FILE; + +EFI_STATUS +OpenSimpleReadFile ( + IN BOOLEAN BootPolicy, + IN VOID *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + IN OUT EFI_DEVICE_PATH **FilePath, + OUT EFI_HANDLE *DeviceHandle, + OUT SIMPLE_READ_FILE *SimpleReadHandle + ); + +EFI_STATUS +ReadSimpleReadFile ( + IN SIMPLE_READ_FILE SimpleReadHandle, + IN UINTN Offset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ); + + +VOID +CloseSimpleReadFile ( + IN SIMPLE_READ_FILE SimpleReadHandle + ); + +VOID +InitializeGuid ( + VOID + ); + +UINT8 +DecimaltoBCD( + IN UINT8 DecValue + ); + +UINT8 +BCDtoDecimal( + IN UINT8 BcdValue + ); + +EFI_STATUS +LibGetSystemConfigurationTable( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ); + +BOOLEAN +LibIsValidTextGraphics ( + IN CHAR16 Graphic, + OUT CHAR8 *PcAnsi, OPTIONAL + OUT CHAR8 *Ascii OPTIONAL + ); + +BOOLEAN +IsValidAscii ( + IN CHAR16 Ascii + ); + +BOOLEAN +IsValidEfiCntlChar ( + IN CHAR16 c + ); + +CHAR16 * +LibGetUiString ( + IN EFI_HANDLE Handle, + IN UI_STRING_TYPE StringType, + IN ISO_639_2 *LangCode, + IN BOOLEAN ReturnDevicePathStrOnMismatch + ); + +CHAR8* +LibGetSmbiosString ( + IN SMBIOS_STRUCTURE_POINTER *Smbios, + IN UINT16 StringNumber + ); + +EFI_STATUS +LibGetSmbiosSystemGuidAndSerialNumber ( + IN EFI_GUID *SystemGuid, + OUT CHAR8 **SystemSerialNumber + ); + + +EFI_STATUS +InitializeGlobalIoDevice ( + IN EFI_DEVICE_PATH *DevicePath, + IN EFI_GUID *Protocol, + IN CHAR8 *ErrorStr, + OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs + ); + +UINT32 +ReadPort ( + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_IO_WIDTH Width, + IN UINTN Port + ); + +UINT32 +WritePort ( + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_IO_WIDTH Width, + IN UINTN Port, + IN UINTN Data + ); + +UINT32 +ReadPciConfig ( + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_IO_WIDTH Width, + IN UINTN Port + ); + +UINT32 +WritePciConfig ( + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_IO_WIDTH Width, + IN UINTN Port, + IN UINTN Data + ); + +extern EFI_DEVICE_IO_INTERFACE *GlobalIoFncs; + +#define outp(_Port, _DataByte) (UINT8)WritePort(GlobalIoFncs, IO_UINT8, (UINTN)_Port, (UINTN)_DataByte) +#define inp(_Port) (UINT8)ReadPort(GlobalIoFncs, IO_UINT8, (UINTN)_Port) +#define outpw(_Port, _DataByte) (UINT16)WritePort(GlobalIoFncs, IO_UINT16, (UINTN)_Port, (UINTN)_DataByte) +#define inpw(_Port) (UINT16)ReadPort(GlobalIoFncs, IO_UINT16, (UINTN)_Port) +#define outpd(_Port, _DataByte) (UINT32)WritePort(GlobalIoFncs, IO_UINT32, (UINTN)_Port, (UINTN)_DataByte) +#define inpd(_Port) (UINT32)ReadPort(GlobalIoFncs, IO_UINT32, (UINTN)_Port) + +#define writepci8(_Addr, _DataByte) (UINT8)WritePciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr, (UINTN)_DataByte) +#define readpci8(_Addr) (UINT8)ReadPciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr) +#define writepci16(_Addr, _DataByte) (UINT16)WritePciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr, (UINTN)_DataByte) +#define readpci16(_Addr) (UINT16)ReadPciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr) +#define writepci32(_Addr, _DataByte) (UINT32)WritePciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr, (UINTN)_DataByte) +#define readpci32(_Addr) (UINT32)ReadPciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr) + +#define Pause() WaitForSingleEvent (ST->ConIn->WaitForKey, 0) +#define Port80(_PostCode) GlobalIoFncs->Io.Write (GlobalIoFncs, IO_UINT16, (UINT64)0x80, 1, &(_PostCode)) + +#endif diff --git a/gnu-efi/inc/efilink.h b/gnu-efi/inc/efilink.h new file mode 100644 index 0000000..cc5aa2d --- /dev/null +++ b/gnu-efi/inc/efilink.h @@ -0,0 +1,177 @@ +#ifndef _EFI_LINK_H +#define _EFI_LINK_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + link.h (renamed efilink.h to avoid conflicts) + +Abstract: + + EFI link list macro's + + + +Revision History + +--*/ + +#ifndef EFI_NT_EMUL + +// +// List entry - doubly linked list +// + +typedef struct _LIST_ENTRY { + struct _LIST_ENTRY *Flink; + struct _LIST_ENTRY *Blink; +} LIST_ENTRY; + +#endif + + +// +// VOID +// InitializeListHead( +// LIST_ENTRY *ListHead +// ); +// + +#define InitializeListHead(ListHead) \ + (ListHead)->Flink = ListHead; \ + (ListHead)->Blink = ListHead; + +// +// BOOLEAN +// IsListEmpty( +// PLIST_ENTRY ListHead +// ); +// + +#define IsListEmpty(ListHead) \ + ((ListHead)->Flink == (ListHead)) + +// +// VOID +// RemoveEntryList( +// PLIST_ENTRY Entry +// ); +// + +#define _RemoveEntryList(Entry) { \ + LIST_ENTRY *_Blink, *_Flink; \ + _Flink = (Entry)->Flink; \ + _Blink = (Entry)->Blink; \ + _Blink->Flink = _Flink; \ + _Flink->Blink = _Blink; \ + } + +#if EFI_DEBUG + #define RemoveEntryList(Entry) \ + _RemoveEntryList(Entry); \ + (Entry)->Flink = (LIST_ENTRY *) BAD_POINTER; \ + (Entry)->Blink = (LIST_ENTRY *) BAD_POINTER; +#else + #define RemoveEntryList(Entry) \ + _RemoveEntryList(Entry); +#endif + +// +// VOID +// InsertTailList( +// PLIST_ENTRY ListHead, +// PLIST_ENTRY Entry +// ); +// + +#define InsertTailList(ListHead,Entry) {\ + LIST_ENTRY *_ListHead, *_Blink; \ + _ListHead = (ListHead); \ + _Blink = _ListHead->Blink; \ + (Entry)->Flink = _ListHead; \ + (Entry)->Blink = _Blink; \ + _Blink->Flink = (Entry); \ + _ListHead->Blink = (Entry); \ + } + +// +// VOID +// InsertHeadList( +// PLIST_ENTRY ListHead, +// PLIST_ENTRY Entry +// ); +// + +#define InsertHeadList(ListHead,Entry) {\ + LIST_ENTRY *_ListHead, *_Flink; \ + _ListHead = (ListHead); \ + _Flink = _ListHead->Flink; \ + (Entry)->Flink = _Flink; \ + (Entry)->Blink = _ListHead; \ + _Flink->Blink = (Entry); \ + _ListHead->Flink = (Entry); \ + } + +// VOID +// SwapListEntries( +// PLIST_ENTRY Entry1, +// PLIST_ENTRY Entry2 +// ); +// +// Put Entry2 before Entry1 +// +#define SwapListEntries(Entry1,Entry2) {\ + LIST_ENTRY *Entry1Flink, *Entry1Blink; \ + LIST_ENTRY *Entry2Flink, *Entry2Blink; \ + Entry2Flink = (Entry2)->Flink; \ + Entry2Blink = (Entry2)->Blink; \ + Entry1Flink = (Entry1)->Flink; \ + Entry1Blink = (Entry1)->Blink; \ + Entry2Blink->Flink = Entry2Flink; \ + Entry2Flink->Blink = Entry2Blink; \ + (Entry2)->Flink = Entry1; \ + (Entry2)->Blink = Entry1Blink; \ + Entry1Blink->Flink = (Entry2); \ + (Entry1)->Blink = (Entry2); \ + } + +// +// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure +// + +#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(intptr_t)(&(((TYPE *) 0)->Field))) + +// +// CONTAINING_RECORD - returns a pointer to the structure +// from one of it's elements. +// + +#define _CR(Record, TYPE, Field) \ + ((TYPE *) ( (CHAR8 *)(Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) + +#if EFI_DEBUG + #define CR(Record, TYPE, Field, Sig) \ + _CR(Record, TYPE, Field)->Signature != Sig ? \ + (TYPE *) ASSERT_STRUCT(_CR(Record, TYPE, Field), Record) : \ + _CR(Record, TYPE, Field) +#else + #define CR(Record, TYPE, Field, Signature) \ + _CR(Record, TYPE, Field) +#endif + + +// +// A lock structure +// + +typedef struct _FLOCK { + EFI_TPL Tpl; + EFI_TPL OwnerTpl; + UINTN Lock; +} FLOCK; + +#endif + diff --git a/gnu-efi/inc/efinet.h b/gnu-efi/inc/efinet.h new file mode 100644 index 0000000..6215816 --- /dev/null +++ b/gnu-efi/inc/efinet.h @@ -0,0 +1,348 @@ +#ifndef _EFINET_H +#define _EFINET_H + + +/*++ +Copyright (c) 1999 Intel Corporation + +Module Name: + efinet.h + +Abstract: + EFI Simple Network protocol + +Revision History +--*/ + + +/////////////////////////////////////////////////////////////////////////////// +// +// Simple Network Protocol +// + +#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ + { 0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } + +INTERFACE_DECL(_EFI_SIMPLE_NETWORK_PROTOCOL); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef struct { + // + // Total number of frames received. Includes frames with errors and + // dropped frames. + // + UINT64 RxTotalFrames; + + // + // Number of valid frames received and copied into receive buffers. + // + UINT64 RxGoodFrames; + + // + // Number of frames below the minimum length for the media. + // This would be <64 for ethernet. + // + UINT64 RxUndersizeFrames; + + // + // Number of frames longer than the maxminum length for the + // media. This would be >1500 for ethernet. + // + UINT64 RxOversizeFrames; + + // + // Valid frames that were dropped because receive buffers were full. + // + UINT64 RxDroppedFrames; + + // + // Number of valid unicast frames received and not dropped. + // + UINT64 RxUnicastFrames; + + // + // Number of valid broadcast frames received and not dropped. + // + UINT64 RxBroadcastFrames; + + // + // Number of valid mutlicast frames received and not dropped. + // + UINT64 RxMulticastFrames; + + // + // Number of frames w/ CRC or alignment errors. + // + UINT64 RxCrcErrorFrames; + + // + // Total number of bytes received. Includes frames with errors + // and dropped frames. + // + UINT64 RxTotalBytes; + + // + // Transmit statistics. + // + UINT64 TxTotalFrames; + UINT64 TxGoodFrames; + UINT64 TxUndersizeFrames; + UINT64 TxOversizeFrames; + UINT64 TxDroppedFrames; + UINT64 TxUnicastFrames; + UINT64 TxBroadcastFrames; + UINT64 TxMulticastFrames; + UINT64 TxCrcErrorFrames; + UINT64 TxTotalBytes; + + // + // Number of collisions detection on this subnet. + // + UINT64 Collisions; + + // + // Number of frames destined for unsupported protocol. + // + UINT64 UnsupportedProtocol; + +} EFI_NETWORK_STATISTICS; + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef enum { + EfiSimpleNetworkStopped, + EfiSimpleNetworkStarted, + EfiSimpleNetworkInitialized, + EfiSimpleNetworkMaxState +} EFI_SIMPLE_NETWORK_STATE; + +/////////////////////////////////////////////////////////////////////////////// +// + +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01 +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02 +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04 +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 + +/////////////////////////////////////////////////////////////////////////////// +// + +#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01 +#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02 +#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04 +#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08 + +/////////////////////////////////////////////////////////////////////////////// +// +#define MAX_MCAST_FILTER_CNT 16 +typedef struct { + UINT32 State; + UINT32 HwAddressSize; + UINT32 MediaHeaderSize; + UINT32 MaxPacketSize; + UINT32 NvRamSize; + UINT32 NvRamAccessSize; + UINT32 ReceiveFilterMask; + UINT32 ReceiveFilterSetting; + UINT32 MaxMCastFilterCount; + UINT32 MCastFilterCount; + EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT]; + EFI_MAC_ADDRESS CurrentAddress; + EFI_MAC_ADDRESS BroadcastAddress; + EFI_MAC_ADDRESS PermanentAddress; + UINT8 IfType; + BOOLEAN MacAddressChangeable; + BOOLEAN MultipleTxSupported; + BOOLEAN MediaPresentSupported; + BOOLEAN MediaPresent; +} EFI_SIMPLE_NETWORK_MODE; + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_START) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_STOP) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN UINTN ExtraRxBufferSize OPTIONAL, + IN UINTN ExtraTxBufferSize OPTIONAL +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_RESET) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN ExtendedVerification +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN UINT32 Enable, + IN UINT32 Disable, + IN BOOLEAN ResetMCastFilter, + IN UINTN MCastFilterCnt OPTIONAL, + IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN Reset, + IN EFI_MAC_ADDRESS *New OPTIONAL +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN Reset, + IN OUT UINTN *StatisticsSize OPTIONAL, + OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN IPv6, + IN EFI_IP_ADDRESS *IP, + OUT EFI_MAC_ADDRESS *MAC +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_NVDATA) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN ReadWrite, + IN UINTN Offset, + IN UINTN BufferSize, + IN OUT VOID *Buffer +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + OUT UINT32 *InterruptStatus OPTIONAL, + OUT VOID **TxBuf OPTIONAL +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN UINTN HeaderSize, + IN UINTN BufferSize, + IN VOID *Buffer, + IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, + IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, + IN UINT16 *Protocol OPTIONAL +); + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE) ( + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + OUT UINTN *HeaderSize OPTIONAL, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer, + OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, + OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL, + OUT UINT16 *Protocol OPTIONAL +); + +/////////////////////////////////////////////////////////////////////////////// +// + +#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 +#define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION + +typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL { + UINT64 Revision; + EFI_SIMPLE_NETWORK_START Start; + EFI_SIMPLE_NETWORK_STOP Stop; + EFI_SIMPLE_NETWORK_INITIALIZE Initialize; + EFI_SIMPLE_NETWORK_RESET Reset; + EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown; + EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters; + EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress; + EFI_SIMPLE_NETWORK_STATISTICS Statistics; + EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac; + EFI_SIMPLE_NETWORK_NVDATA NvData; + EFI_SIMPLE_NETWORK_GET_STATUS GetStatus; + EFI_SIMPLE_NETWORK_TRANSMIT Transmit; + EFI_SIMPLE_NETWORK_RECEIVE Receive; + EFI_EVENT WaitForPacket; + EFI_SIMPLE_NETWORK_MODE *Mode; +} EFI_SIMPLE_NETWORK_PROTOCOL; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_SIMPLE_NETWORK_PROTOCOL' GUID definition, from older +// versions of gnu-efi, is now obsoleted. +// Use 'EFI_SIMPLE_NETWORK_PROTOCOL_GUID' instead. + +typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL _EFI_SIMPLE_NETWORK; +typedef EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK; + +#endif /* _EFINET_H */ diff --git a/gnu-efi/inc/efipart.h b/gnu-efi/inc/efipart.h new file mode 100644 index 0000000..d4c5573 --- /dev/null +++ b/gnu-efi/inc/efipart.h @@ -0,0 +1,61 @@ +#ifndef _EFI_PART_H +#define _EFI_PART_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efipart.h + +Abstract: + Info about disk partitions and Master Boot Records + + + + +Revision History + +--*/ + +// +// +// + +#define EFI_PARTITION 0xef +#define MBR_SIZE 512 + +#pragma pack(1) + +typedef struct { + UINT8 BootIndicator; + UINT8 StartHead; + UINT8 StartSector; + UINT8 StartTrack; + UINT8 OSIndicator; + UINT8 EndHead; + UINT8 EndSector; + UINT8 EndTrack; + UINT8 StartingLBA[4]; + UINT8 SizeInLBA[4]; +} MBR_PARTITION_RECORD; + +#define EXTRACT_UINT32(D) (UINT32)(D[0] | (D[1] << 8) | (D[2] << 16) | (D[3] << 24)) + +#define MBR_SIGNATURE 0xaa55 +#define MIN_MBR_DEVICE_SIZE 0x80000 +#define MBR_ERRATA_PAD 0x40000 // 128 MB + +#define MAX_MBR_PARTITIONS 4 +typedef struct { + UINT8 BootStrapCode[440]; + UINT8 UniqueMbrSignature[4]; + UINT8 Unknown[2]; + MBR_PARTITION_RECORD Partition[MAX_MBR_PARTITIONS]; + UINT16 Signature; +} MASTER_BOOT_RECORD; +#pragma pack() + + +#endif diff --git a/gnu-efi/inc/efipciio.h b/gnu-efi/inc/efipciio.h new file mode 100644 index 0000000..e885387 --- /dev/null +++ b/gnu-efi/inc/efipciio.h @@ -0,0 +1,399 @@ +#ifndef _EFI_PCI_IO_H +#define _EFI_PCI_IO_H + +#define EFI_PCI_IO_PROTOCOL_GUID \ + { 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a} } + +#define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \ + { 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +INTERFACE_DECL(_EFI_PCI_IO_PROTOCOL); +INTERFACE_DECL(_EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL); + +typedef enum { + EfiPciIoWidthUint8, + EfiPciIoWidthUint16, + EfiPciIoWidthUint32, + EfiPciIoWidthUint64, + EfiPciIoWidthFifoUint8, + EfiPciIoWidthFifoUint16, + EfiPciIoWidthFifoUint32, + EfiPciIoWidthFifoUint64, + EfiPciIoWidthFillUint8, + EfiPciIoWidthFillUint16, + EfiPciIoWidthFillUint32, + EfiPciIoWidthFillUint64, + EfiPciIoWidthMaximum +} EFI_PCI_IO_PROTOCOL_WIDTH, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH; + +#define EFI_PCI_IO_PASS_THROUGH_BAR 0xff + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 BarIndex, + IN UINT64 Offset, + IN UINT64 Mask, + IN UINT64 Value, + IN UINT64 Delay, + OUT UINT64 *Result +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINT64 Mask, + IN UINT64 Value, + IN UINT64 Delay, + OUT UINT64 *Result +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 BarIndex, + IN UINT64 Offset, + IN UINTN Count, + IN OUT VOID *Buffer +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer +); + +typedef struct { + EFI_PCI_IO_PROTOCOL_IO_MEM Read; + EFI_PCI_IO_PROTOCOL_IO_MEM Write; +} EFI_PCI_IO_PROTOCOL_ACCESS; + +typedef struct { + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT32 Offset, + IN UINTN Count, + IN OUT VOID *Buffer +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + OUT VOID **Resources +); + +typedef struct { + EFI_PCI_IO_PROTOCOL_CONFIG Read; + EFI_PCI_IO_PROTOCOL_CONFIG Write; +} EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 DestBarIndex, + IN UINT64 DestOffset, + IN UINT8 SrcBarIndex, + IN UINT64 SrcOffset, + IN UINTN Count +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 DestAddress, + IN UINT64 SrcAddress, + IN UINTN Count +); + +typedef enum { + EfiPciIoOperationBusMasterRead, + EfiPciIoOperationBusMasterWrite, + EfiPciIoOperationBusMasterCommonBuffer, + EfiPciIoOperationMaximum +} EFI_PCI_IO_PROTOCOL_OPERATION; + +typedef enum { + EfiPciOperationBusMasterRead, + EfiPciOperationBusMasterWrite, + EfiPciOperationBusMasterCommonBuffer, + EfiPciOperationBusMasterRead64, + EfiPciOperationBusMasterWrite64, + EfiPciOperationBusMasterCommonBuffer64, + EfiPciOperationMaximum +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_MAP) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN VOID *Mapping +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN VOID *Mapping +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + OUT VOID **HostAddress, + IN UINT64 Attributes +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT VOID **HostAddress, + IN UINT64 Attributes +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH) ( + IN struct _EFI_PCI_IO_PROTOCOL *This +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + OUT UINTN *SegmentNumber, + OUT UINTN *BusNumber, + OUT UINTN *DeviceNumber, + OUT UINTN *FunctionNumber +); + +#define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 +#define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002 +#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004 +#define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008 +#define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010 +#define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 +#define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 +#define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 +#define EFI_PCI_ATTRIBUTE_IO 0x0100 +#define EFI_PCI_ATTRIBUTE_MEMORY 0x0200 +#define EFI_PCI_ATTRIBUTE_BUS_MASTER 0x0400 +#define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800 +#define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000 +#define EFI_PCI_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 +#define EFI_PCI_ATTRIBUTE_EMBEDDED_ROM 0x4000 +#define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 +#define EFI_PCI_ATTRIBUTE_ISA_IO_16 0x10000 +#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 +#define EFI_PCI_ATTRIBUTE_VGA_IO_16 0x40000 + +#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO +#define EFI_PCI_IO_ATTRIBUTE_ISA_IO EFI_PCI_ATTRIBUTE_ISA_IO +#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO +#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY EFI_PCI_ATTRIBUTE_VGA_MEMORY +#define EFI_PCI_IO_ATTRIBUTE_VGA_IO EFI_PCI_ATTRIBUTE_VGA_IO +#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO +#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE +#define EFI_PCI_IO_ATTRIBUTE_IO EFI_PCI_ATTRIBUTE_IO +#define EFI_PCI_IO_ATTRIBUTE_MEMORY EFI_PCI_ATTRIBUTE_MEMORY +#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER EFI_PCI_ATTRIBUTE_BUS_MASTER +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED EFI_PCI_ATTRIBUTE_MEMORY_CACHED +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE EFI_PCI_ATTRIBUTE_MEMORY_DISABLE +#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE EFI_PCI_ATTRIBUTE_EMBEDDED_DEVICE +#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM EFI_PCI_ATTRIBUTE_EMBEDDED_ROM +#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE +#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 EFI_PCI_ATTRIBUTE_ISA_IO_16 +#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 +#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 EFI_PCI_ATTRIBUTE_VGA_IO_16 + +#define EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER \ + (EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED | EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE) + +#define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER \ + (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER) + +typedef struct { + UINT8 Register; + UINT8 Function; + UINT8 Device; + UINT8 Bus; + UINT32 ExtendedRegister; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS; + +typedef enum { + EfiPciIoAttributeOperationGet, + EfiPciIoAttributeOperationSet, + EfiPciIoAttributeOperationEnable, + EfiPciIoAttributeOperationDisable, + EfiPciIoAttributeOperationSupported, + EfiPciIoAttributeOperationMaximum +} EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation, + IN UINT64 Attributes, + OUT UINT64 *Result OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN UINT8 BarIndex, + OUT UINT64 *Supports OPTIONAL, + OUT VOID **Resources OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + OUT UINT64 *Supports, + OUT UINT64 *Attributes +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES) ( + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN UINT64 Attributes, + IN UINT8 BarIndex, + IN OUT UINT64 *Offset, + IN OUT UINT64 *Length +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN UINT64 Attributes, + IN OUT UINT64 *ResourceBase, + IN OUT UINT64 *ResourceLength +); + +typedef struct _EFI_PCI_IO_PROTOCOL { + EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem; + EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo; + EFI_PCI_IO_PROTOCOL_ACCESS Mem; + EFI_PCI_IO_PROTOCOL_ACCESS Io; + EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci; + EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem; + EFI_PCI_IO_PROTOCOL_MAP Map; + EFI_PCI_IO_PROTOCOL_UNMAP Unmap; + EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; + EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer; + EFI_PCI_IO_PROTOCOL_FLUSH Flush; + EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation; + EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes; + EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes; + EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes; + UINT64 RomSize; + VOID *RomImage; +} EFI_PCI_IO_PROTOCOL; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_PCI_IO_PROTOCOL' GUID definition, from older versions +// of gnu-efi, is now obsoleted. +// Use 'EFI_PCI_IO_PROTOCOL_GUID' instead. + +typedef struct _EFI_PCI_IO_PROTOCOL _EFI_PCI_IO; +typedef EFI_PCI_IO_PROTOCOL EFI_PCI_IO; + +typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL { + EFI_HANDLE ParentHandle; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration; + UINT32 SegmentNumber; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL; + +#endif /* _EFI_PCI_IO_H */ diff --git a/gnu-efi/inc/efipoint.h b/gnu-efi/inc/efipoint.h new file mode 100644 index 0000000..4dbcf18 --- /dev/null +++ b/gnu-efi/inc/efipoint.h @@ -0,0 +1,115 @@ +/* Copyright (C) 2014 by John Cronin + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _EFI_POINT_H +#define _EFI_POINT_H + +#define EFI_SIMPLE_POINTER_PROTOCOL_GUID \ + { 0x31878c87, 0xb75, 0x11d5, { 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } + +INTERFACE_DECL(_EFI_SIMPLE_POINTER); + +typedef struct { + INT32 RelativeMovementX; + INT32 RelativeMovementY; + INT32 RelativeMovementZ; + BOOLEAN LeftButton; + BOOLEAN RightButton; +} EFI_SIMPLE_POINTER_STATE; + +typedef struct { + UINT64 ResolutionX; + UINT64 ResolutionY; + UINT64 ResolutionZ; + BOOLEAN LeftButton; + BOOLEAN RightButton; +} EFI_SIMPLE_POINTER_MODE; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_POINTER_RESET) ( + IN struct _EFI_SIMPLE_POINTER *This, + IN BOOLEAN ExtendedVerification +); + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) ( + IN struct _EFI_SIMPLE_POINTER *This, + IN OUT EFI_SIMPLE_POINTER_STATE *State +); + +typedef struct _EFI_SIMPLE_POINTER { + EFI_SIMPLE_POINTER_RESET Reset; + EFI_SIMPLE_POINTER_GET_STATE GetState; + EFI_EVENT WaitForInput; + EFI_SIMPLE_POINTER_MODE *Mode; +} EFI_SIMPLE_POINTER_PROTOCOL; + +#define EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \ + { 0x8D59D32B, 0xC655, 0x4AE9, { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } } + +INTERFACE_DECL(_EFI_ABSOLUTE_POINTER_PROTOCOL); + +typedef struct { + UINT64 AbsoluteMinX; + UINT64 AbsoluteMinY; + UINT64 AbsoluteMinZ; + UINT64 AbsoluteMaxX; + UINT64 AbsoluteMaxY; + UINT64 AbsoluteMaxZ; + UINT32 Attributes; +} EFI_ABSOLUTE_POINTER_MODE; + +typedef struct { + UINT64 CurrentX; + UINT64 CurrentY; + UINT64 CurrentZ; + UINT32 ActiveButtons; +} EFI_ABSOLUTE_POINTER_STATE; + +#define EFI_ABSP_SupportsAltActive 0x00000001 +#define EFI_ABSP_SupportsPressureAsZ 0x00000002 +#define EFI_ABSP_TouchActive 0x00000001 +#define EFI_ABS_AltActive 0x00000002 + +typedef +EFI_STATUS +(EFIAPI *EFI_ABSOLUTE_POINTER_RESET) ( + IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, + IN BOOLEAN ExtendedVerification +); + +typedef +EFI_STATUS +(EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE) ( + IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, + IN OUT EFI_ABSOLUTE_POINTER_STATE *State +); + +typedef struct _EFI_ABSOLUTE_POINTER_PROTOCOL { + EFI_ABSOLUTE_POINTER_RESET Reset; + EFI_ABSOLUTE_POINTER_GET_STATE GetState; + EFI_EVENT WaitForInput; + EFI_ABSOLUTE_POINTER_MODE *Mode; +} EFI_ABSOLUTE_POINTER_PROTOCOL; + +#endif diff --git a/gnu-efi/inc/efiprot.h b/gnu-efi/inc/efiprot.h new file mode 100644 index 0000000..53fc560 --- /dev/null +++ b/gnu-efi/inc/efiprot.h @@ -0,0 +1,1424 @@ +#ifndef _EFI_PROT_H +#define _EFI_PROT_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efiprot.h + +Abstract: + + EFI Protocols + + + +Revision History + +--*/ + +// +// FPSWA library protocol +// +#define EFI_FPSWA_PROTOCOL_GUID \ + { 0xc41b6531, 0x97b9, 0x11d3, {0x9a, 0x29, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define FPSWA_PROTOCOL EFI_FPSWA_PROTOCOL_GUID + +// +// Device Path protocol +// + +#define EFI_DEVICE_PATH_PROTOCOL_GUID \ + { 0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH_PROTOCOL_GUID + + +// +// Block IO protocol +// + +#define EFI_BLOCK_IO_PROTOCOL_GUID \ + { 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID + +#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000 +#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001 +#define EFI_BLOCK_IO_PROTOCOL_REVISION3 ((2<<16) | 31) +#define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION +#define EFI_BLOCK_IO_INTERFACE_REVISION2 EFI_BLOCK_IO_PROTOCOL_REVISION2 +#define EFI_BLOCK_IO_INTERFACE_REVISION3 EFI_BLOCK_IO_PROTOCOL_REVISION3 + +INTERFACE_DECL(_EFI_BLOCK_IO_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_RESET) ( + IN struct _EFI_BLOCK_IO_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_READ) ( + IN struct _EFI_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_WRITE) ( + IN struct _EFI_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN UINTN BufferSize, + IN VOID *Buffer + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_FLUSH) ( + IN struct _EFI_BLOCK_IO_PROTOCOL *This + ); + + + +typedef struct { + UINT32 MediaId; + BOOLEAN RemovableMedia; + BOOLEAN MediaPresent; + + BOOLEAN LogicalPartition; + BOOLEAN ReadOnly; + BOOLEAN WriteCaching; + + UINT32 BlockSize; + UINT32 IoAlign; + + EFI_LBA LastBlock; + + /* revision 2 */ + EFI_LBA LowestAlignedLba; + UINT32 LogicalBlocksPerPhysicalBlock; + /* revision 3 */ + UINT32 OptimalTransferLengthGranularity; +} EFI_BLOCK_IO_MEDIA; + +typedef struct _EFI_BLOCK_IO_PROTOCOL { + UINT64 Revision; + + EFI_BLOCK_IO_MEDIA *Media; + + EFI_BLOCK_RESET Reset; + EFI_BLOCK_READ ReadBlocks; + EFI_BLOCK_WRITE WriteBlocks; + EFI_BLOCK_FLUSH FlushBlocks; + +} EFI_BLOCK_IO_PROTOCOL; + +typedef struct _EFI_BLOCK_IO_PROTOCOL _EFI_BLOCK_IO; +typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO; + +#define EFI_BLOCK_IO2_PROTOCOL_GUID \ + { 0xa77b2472, 0xe282, 0x4e9f, {0xa2, 0x45, 0xc2, 0xc0, 0xe2, 0x7b, 0xbc, 0xc1} } + +INTERFACE_DECL(_EFI_BLOCK_IO2_PROTOCOL); + +typedef struct { + EFI_EVENT Event; + EFI_STATUS TransactionStatus; +} EFI_BLOCK_IO2_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_RESET_EX) ( + IN struct _EFI_BLOCK_IO2_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_READ_EX) ( + IN struct _EFI_BLOCK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN OUT EFI_BLOCK_IO2_TOKEN *Token, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_WRITE_EX) ( + IN struct _EFI_BLOCK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN OUT EFI_BLOCK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_FLUSH_EX) ( + IN struct _EFI_BLOCK_IO2_PROTOCOL *This, + IN OUT EFI_BLOCK_IO2_TOKEN *Token + ); + +typedef struct _EFI_BLOCK_IO2_PROTOCOL { + EFI_BLOCK_IO_MEDIA *Media; + EFI_BLOCK_RESET_EX Reset; + EFI_BLOCK_READ_EX ReadBlocksEx; + EFI_BLOCK_WRITE_EX WriteBlocksEx; + EFI_BLOCK_FLUSH_EX FlushBlocksEx; +} EFI_BLOCK_IO2_PROTOCOL; + +// +// Disk Block IO protocol +// + +#define EFI_DISK_IO_PROTOCOL_GUID \ + { 0xce345171, 0xba0b, 0x11d2, {0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define DISK_IO_PROTOCOL EFI_DISK_IO_PROTOCOL_GUID + +#define EFI_DISK_IO_PROTOCOL_REVISION 0x00010000 +#define EFI_DISK_IO_INTERFACE_REVISION EFI_DISK_IO_PROTOCOL_REVISION + +INTERFACE_DECL(_EFI_DISK_IO_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_READ) ( + IN struct _EFI_DISK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_WRITE) ( + IN struct _EFI_DISK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN UINTN BufferSize, + IN VOID *Buffer + ); + + +typedef struct _EFI_DISK_IO_PROTOCOL { + UINT64 Revision; + EFI_DISK_READ ReadDisk; + EFI_DISK_WRITE WriteDisk; +} EFI_DISK_IO_PROTOCOL; + +typedef struct _EFI_DISK_IO_PROTOCOL _EFI_DISK_IO; +typedef EFI_DISK_IO_PROTOCOL EFI_DISK_IO; + + +#define EFI_DISK_IO2_PROTOCOL_GUID \ + { 0x151c8eae, 0x7f2c, 0x472c, {0x9e, 0x54, 0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88} } + +#define EFI_DISK_IO2_PROTOCOL_REVISION 0x00020000 + +INTERFACE_DECL(_EFI_DISK_IO2_PROTOCOL); + +typedef struct { + EFI_EVENT Event; + EFI_STATUS TransactionStatus; +} EFI_DISK_IO2_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_CANCEL_EX) ( + IN struct _EFI_DISK_IO2_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_READ_EX) ( + IN struct _EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_WRITE_EX) ( + IN struct _EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_FLUSH_EX) ( + IN struct _EFI_DISK_IO2_PROTOCOL *This, + IN OUT EFI_DISK_IO2_TOKEN *Token + ); + +typedef struct _EFI_DISK_IO2_PROTOCOL { + UINT64 Revision; + EFI_DISK_CANCEL_EX Cancel; + EFI_DISK_READ_EX ReadDiskEx; + EFI_DISK_WRITE_EX WriteDiskEx; + EFI_DISK_FLUSH_EX FlushDiskEx; +} EFI_DISK_IO2_PROTOCOL; + +// +// Simple file system protocol +// + +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ + { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL); +INTERFACE_DECL(_EFI_FILE_HANDLE); + +typedef +EFI_STATUS +(EFIAPI *EFI_VOLUME_OPEN) ( + IN struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, + OUT struct _EFI_FILE_HANDLE **Root + ); + +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000 +#define EFI_FILE_IO_INTERFACE_REVISION EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION + +typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL { + UINT64 Revision; + EFI_VOLUME_OPEN OpenVolume; +} EFI_SIMPLE_FILE_SYSTEM_PROTOCOL; + +typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL _EFI_FILE_IO_INTERFACE; +typedef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_FILE_IO_INTERFACE; + +// +// +// + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_OPEN) ( + IN struct _EFI_FILE_HANDLE *File, + OUT struct _EFI_FILE_HANDLE **NewHandle, + IN CHAR16 *FileName, + IN UINT64 OpenMode, + IN UINT64 Attributes + ); + +// Open modes +#define EFI_FILE_MODE_READ 0x0000000000000001 +#define EFI_FILE_MODE_WRITE 0x0000000000000002 +#define EFI_FILE_MODE_CREATE 0x8000000000000000 + +// File attributes +#define EFI_FILE_READ_ONLY 0x0000000000000001 +#define EFI_FILE_HIDDEN 0x0000000000000002 +#define EFI_FILE_SYSTEM 0x0000000000000004 +#define EFI_FILE_RESERVIED 0x0000000000000008 +#define EFI_FILE_DIRECTORY 0x0000000000000010 +#define EFI_FILE_ARCHIVE 0x0000000000000020 +#define EFI_FILE_VALID_ATTR 0x0000000000000037 + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_CLOSE) ( + IN struct _EFI_FILE_HANDLE *File + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_DELETE) ( + IN struct _EFI_FILE_HANDLE *File + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_READ) ( + IN struct _EFI_FILE_HANDLE *File, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_WRITE) ( + IN struct _EFI_FILE_HANDLE *File, + IN OUT UINTN *BufferSize, + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_SET_POSITION) ( + IN struct _EFI_FILE_HANDLE *File, + IN UINT64 Position + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_GET_POSITION) ( + IN struct _EFI_FILE_HANDLE *File, + OUT UINT64 *Position + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_GET_INFO) ( + IN struct _EFI_FILE_HANDLE *File, + IN EFI_GUID *InformationType, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_SET_INFO) ( + IN struct _EFI_FILE_HANDLE *File, + IN EFI_GUID *InformationType, + IN UINTN BufferSize, + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_FLUSH) ( + IN struct _EFI_FILE_HANDLE *File + ); + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + UINTN BufferSize; + VOID *Buffer; +} EFI_FILE_IO_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_OPEN_EX)( + IN struct _EFI_FILE_HANDLE *File, + OUT struct _EFI_FILE_HANDLE **NewHandle, + IN CHAR16 *FileName, + IN UINT64 OpenMode, + IN UINT64 Attributes, + IN OUT EFI_FILE_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_READ_EX) ( + IN struct _EFI_FILE_HANDLE *File, + IN OUT EFI_FILE_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_WRITE_EX) ( + IN struct _EFI_FILE_HANDLE *File, + IN OUT EFI_FILE_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_FLUSH_EX) ( + IN struct _EFI_FILE_HANDLE *File, + IN OUT EFI_FILE_IO_TOKEN *Token + ); + +#define EFI_FILE_PROTOCOL_REVISION 0x00010000 +#define EFI_FILE_PROTOCOL_REVISION2 0x00020000 +#define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2 +#define EFI_FILE_HANDLE_REVISION EFI_FILE_PROTOCOL_REVISION + +typedef struct _EFI_FILE_HANDLE { + UINT64 Revision; + EFI_FILE_OPEN Open; + EFI_FILE_CLOSE Close; + EFI_FILE_DELETE Delete; + EFI_FILE_READ Read; + EFI_FILE_WRITE Write; + EFI_FILE_GET_POSITION GetPosition; + EFI_FILE_SET_POSITION SetPosition; + EFI_FILE_GET_INFO GetInfo; + EFI_FILE_SET_INFO SetInfo; + EFI_FILE_FLUSH Flush; + EFI_FILE_OPEN_EX OpenEx; + EFI_FILE_READ_EX ReadEx; + EFI_FILE_WRITE_EX WriteEx; + EFI_FILE_FLUSH_EX FlushEx; +} EFI_FILE_PROTOCOL, *EFI_FILE_HANDLE; + +typedef EFI_FILE_PROTOCOL EFI_FILE; + + +// +// File information types +// + +#define EFI_FILE_INFO_ID \ + { 0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } + +typedef struct { + UINT64 Size; + UINT64 FileSize; + UINT64 PhysicalSize; + EFI_TIME CreateTime; + EFI_TIME LastAccessTime; + EFI_TIME ModificationTime; + UINT64 Attribute; + CHAR16 FileName[1]; +} EFI_FILE_INFO; + +// +// The FileName field of the EFI_FILE_INFO data structure is variable length. +// Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to +// be the size of the data structure without the FileName field. The following macro +// computes this size correctly no matter how big the FileName array is declared. +// This is required to make the EFI_FILE_INFO data structure ANSI compilant. +// + +#define SIZE_OF_EFI_FILE_INFO EFI_FIELD_OFFSET(EFI_FILE_INFO,FileName) + +#define EFI_FILE_SYSTEM_INFO_ID \ + { 0x9576e93, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } + +typedef struct { + UINT64 Size; + BOOLEAN ReadOnly; + UINT64 VolumeSize; + UINT64 FreeSpace; + UINT32 BlockSize; + CHAR16 VolumeLabel[1]; +} EFI_FILE_SYSTEM_INFO; + +// +// The VolumeLabel field of the EFI_FILE_SYSTEM_INFO data structure is variable length. +// Whenever code needs to know the size of the EFI_FILE_SYSTEM_INFO data structure, it needs +// to be the size of the data structure without the VolumeLable field. The following macro +// computes this size correctly no matter how big the VolumeLable array is declared. +// This is required to make the EFI_FILE_SYSTEM_INFO data structure ANSI compilant. +// + +#define SIZE_OF_EFI_FILE_SYSTEM_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_INFO,VolumeLabel) + +#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID \ + { 0xDB47D7D3,0xFE81, 0x11d3, {0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } + +typedef struct { + CHAR16 VolumeLabel[1]; +} EFI_FILE_SYSTEM_VOLUME_LABEL_INFO; + +#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_VOLUME_LABEL_INFO,VolumeLabel) + +// +// Load file protocol +// + + +#define EFI_LOAD_FILE_PROTOCOL_GUID \ + { 0x56EC3091, 0x954C, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } +#define LOAD_FILE_PROTOCOL EFI_LOAD_FILE_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_LOAD_FILE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_LOAD_FILE) ( + IN struct _EFI_LOAD_FILE_PROTOCOL *This, + IN EFI_DEVICE_PATH *FilePath, + IN BOOLEAN BootPolicy, + IN OUT UINTN *BufferSize, + IN VOID *Buffer OPTIONAL + ); + +typedef struct _EFI_LOAD_FILE_PROTOCOL { + EFI_LOAD_FILE LoadFile; +} EFI_LOAD_FILE_PROTOCOL; + +typedef struct _EFI_LOAD_FILE_PROTOCOL _EFI_LOAD_FILE_INTERFACE; +typedef EFI_LOAD_FILE_PROTOCOL EFI_LOAD_FILE_INTERFACE; + +// +// Device IO protocol +// + +#define EFI_DEVICE_IO_PROTOCOL_GUID \ + { 0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_DEVICE_IO_PROTOCOL); + +typedef enum { + IO_UINT8, + IO_UINT16, + IO_UINT32, + IO_UINT64, +// +// Specification Change: Copy from MMIO to MMIO vs. MMIO to buffer, buffer to MMIO +// + MMIO_COPY_UINT8, + MMIO_COPY_UINT16, + MMIO_COPY_UINT32, + MMIO_COPY_UINT64 +} EFI_IO_WIDTH; + +#define EFI_PCI_ADDRESS(_bus,_dev,_func) \ + ( (UINT64) ( (((UINTN)_bus) << 24) + (((UINTN)_dev) << 16) + (((UINTN)_func) << 8) ) ) + + +typedef +EFI_STATUS +(EFIAPI *EFI_DEVICE_IO) ( + IN struct _EFI_DEVICE_IO_PROTOCOL *This, + IN EFI_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +typedef struct { + EFI_DEVICE_IO Read; + EFI_DEVICE_IO Write; +} EFI_IO_ACCESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_DEVICE_PATH) ( + IN struct _EFI_DEVICE_IO_PROTOCOL *This, + IN UINT64 Address, + IN OUT EFI_DEVICE_PATH **PciDevicePath + ); + +typedef enum { + EfiBusMasterRead, + EfiBusMasterWrite, + EfiBusMasterCommonBuffer +} EFI_IO_OPERATION_TYPE; + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_MAP) ( + IN struct _EFI_DEVICE_IO_PROTOCOL *This, + IN EFI_IO_OPERATION_TYPE Operation, + IN EFI_PHYSICAL_ADDRESS *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_UNMAP) ( + IN struct _EFI_DEVICE_IO_PROTOCOL *This, + IN VOID *Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_ALLOCATE_BUFFER) ( + IN struct _EFI_DEVICE_IO_PROTOCOL *This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *HostAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_FLUSH) ( + IN struct _EFI_DEVICE_IO_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_FREE_BUFFER) ( + IN struct _EFI_DEVICE_IO_PROTOCOL *This, + IN UINTN Pages, + IN EFI_PHYSICAL_ADDRESS HostAddress + ); + +typedef struct _EFI_DEVICE_IO_PROTOCOL { + EFI_IO_ACCESS Mem; + EFI_IO_ACCESS Io; + EFI_IO_ACCESS Pci; + EFI_IO_MAP Map; + EFI_PCI_DEVICE_PATH PciDevicePath; + EFI_IO_UNMAP Unmap; + EFI_IO_ALLOCATE_BUFFER AllocateBuffer; + EFI_IO_FLUSH Flush; + EFI_IO_FREE_BUFFER FreeBuffer; +} EFI_DEVICE_IO_PROTOCOL; + +typedef struct _EFI_DEVICE_IO_PROTOCOL _EFI_DEVICE_IO_INTERFACE; +typedef EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_INTERFACE; + +// +// Unicode Collation protocol +// + +#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \ + { 0x1d85cd7f, 0xf43d, 0x11d2, {0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define UNICODE_COLLATION_PROTOCOL EFI_UNICODE_COLLATION_PROTOCOL_GUID + +#define EFI_UNICODE_BYTE_ORDER_MARK (CHAR16)(0xfeff) +#define UNICODE_BYTE_ORDER_MARK EFI_UNICODE_BYTE_ORDER_MARK + +INTERFACE_DECL(_EFI_UNICODE_COLLATION_PROTOCOL); + +typedef +INTN +(EFIAPI *EFI_UNICODE_STRICOLL) ( + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, + IN CHAR16 *s1, + IN CHAR16 *s2 + ); + +typedef +BOOLEAN +(EFIAPI *EFI_UNICODE_METAIMATCH) ( + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, + IN CHAR16 *String, + IN CHAR16 *Pattern + ); + +typedef +VOID +(EFIAPI *EFI_UNICODE_STRLWR) ( + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, + IN OUT CHAR16 *Str + ); + +typedef +VOID +(EFIAPI *EFI_UNICODE_STRUPR) ( + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, + IN OUT CHAR16 *Str + ); + +typedef +VOID +(EFIAPI *EFI_UNICODE_FATTOSTR) ( + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, + IN UINTN FatSize, + IN CHAR8 *Fat, + OUT CHAR16 *String + ); + +typedef +BOOLEAN +(EFIAPI *EFI_UNICODE_STRTOFAT) ( + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, + IN CHAR16 *String, + IN UINTN FatSize, + OUT CHAR8 *Fat + ); + +// +// Hash Protocol +// +#define EFI_HASH_PROTOCOL_GUID \ + { 0xC5184932, 0xDBA5, 0x46DB, { 0xA5, 0xBA, 0xCC, 0x0B, 0xDA, 0x9C, 0x14, 0x35 } } +#define HASH_PROTOCOL EFI_HASH_PROTOCOL_GUID + +#define EFI_HASH_ALGORITHM_SHA1_GUID \ + { 0x2AE9D80F, 0x3FB2, 0x4095, { 0xB7, 0xB1, 0xE9, 0x31, 0x57, 0xB9, 0x46, 0xB6 } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA1 EFI_HASH_ALGORITHM_SHA1_GUID + +#define EFI_HASH_ALGORITHM_SHA224_GUID \ + { 0x8DF01A06, 0x9BD5, 0x4BF7, { 0xB0, 0x21, 0xDB, 0x4F, 0xD9, 0xCC, 0xF4, 0x5B } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA224 EFI_HASH_ALGORITHM_SHA224_GUID + +#define EFI_HASH_ALGORITHM_SHA256_GUID \ + { 0x51AA59DE, 0xFDF2, 0x4EA3, { 0xBC, 0x63, 0x87, 0x5F, 0xB7, 0x84, 0x2E, 0xE9 } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA256 EFI_HASH_ALGORITHM_SHA256_GUID + +#define EFI_HASH_ALGORITHM_SHA384_GUID \ + { 0xEFA96432, 0xDE33, 0x4DD2, { 0xAE, 0xE6, 0x32, 0x8C, 0x33, 0xDF, 0x77, 0x7A } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA384 EFI_HASH_ALGORITHM_SHA384_GUID + +#define EFI_HASH_ALGORITHM_SHA512_GUID \ + { 0xCAA4381E, 0x750C, 0x4770, { 0xB8, 0x70, 0x7A, 0x23, 0xB4, 0xE4, 0x21, 0x30 } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA512 EFI_HASH_ALGORITHM_SHA512_GUID + +#define EFI_HASH_ALGORITHM_MD5_GUID \ + { 0x0AF7C79C, 0x65B5, 0x4319, { 0xB0, 0xAE, 0x44, 0xEC, 0x48, 0x4E, 0x4A, 0xD7 } } // Deprecated +#define EFI_HASH_ALGORITHM_MD5 EFI_HASH_ALGORITHM_MD5_GUID + +#define EFI_HASH_ALGORITHM_SHA1_NOPAD_GUID \ + { 0x24C5DC2F, 0x53E2, 0x40CA, { 0x9E, 0xD6, 0xA5, 0xD9, 0xA4, 0x9F, 0x46, 0x3B } } +#define EFI_HASH_ALGORITHM_SHA1_NOPAD EFI_HASH_ALGORITHM_SHA1_NOPAD_GUID + +#define EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID \ + { 0x8628752A, 0x6CB7, 0x4814, { 0x96, 0xFC, 0x24, 0xA8, 0x15, 0xAC, 0x22, 0x26 } } +#define EFI_HASH_ALGORITHM_SHA256_NOPAD EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID + + +INTERFACE_DECL(_EFI_HASH_PROTOCOL); + +typedef UINT8 EFI_MD5_HASH[16]; +typedef UINT8 EFI_SHA1_HASH[20]; +typedef UINT8 EFI_SHA224_HASH[28]; +typedef UINT8 EFI_SHA256_HASH[32]; +typedef UINT8 EFI_SHA384_HASH[48]; +typedef UINT8 EFI_SHA512_HASH[64]; +typedef union _EFI_HASH_OUTPUT { + EFI_MD5_HASH *Md5Hash; + EFI_SHA1_HASH *Sha1Hash; + EFI_SHA224_HASH *Sha224Hash; + EFI_SHA256_HASH *Sha256Hash; + EFI_SHA384_HASH *Sha384Hash; + EFI_SHA512_HASH *Sha512Hash; +} EFI_HASH_OUTPUT; + +typedef +EFI_STATUS +(EFIAPI *EFI_HASH_GET_HASH_SIZE) ( + IN CONST struct _EFI_HASH_PROTOCOL *This, + IN CONST EFI_GUID *HashAlgorithm, + OUT UINTN *HashSize); + +typedef +EFI_STATUS +(EFIAPI *EFI_HASH_HASH) ( + IN CONST struct _EFI_HASH_PROTOCOL *This, + IN CONST EFI_GUID *HashAlgorithm, + IN BOOLEAN Extend, + IN CONST UINT8 *Message, + IN UINT64 MessageSize, + IN OUT EFI_HASH_OUTPUT *Hash); + +typedef struct _EFI_HASH_PROTOCOL { + EFI_HASH_GET_HASH_SIZE GetHashSize; + EFI_HASH_HASH Hash; +} EFI_HASH_PROTOCOL; + +typedef struct _EFI_HASH_PROTOCOL _EFI_HASH; +typedef EFI_HASH_PROTOCOL EFI_HASH; + + +typedef struct _EFI_UNICODE_COLLATION_PROTOCOL { + + // general + EFI_UNICODE_STRICOLL StriColl; + EFI_UNICODE_METAIMATCH MetaiMatch; + EFI_UNICODE_STRLWR StrLwr; + EFI_UNICODE_STRUPR StrUpr; + + // for supporting fat volumes + EFI_UNICODE_FATTOSTR FatToStr; + EFI_UNICODE_STRTOFAT StrToFat; + + CHAR8 *SupportedLanguages; +} EFI_UNICODE_COLLATION_PROTOCOL; + +typedef EFI_UNICODE_COLLATION_PROTOCOL EFI_UNICODE_COLLATION_INTERFACE; + +/* Graphics output protocol */ +#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ + { 0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } } +typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL; + +typedef struct { + UINT32 RedMask; + UINT32 GreenMask; + UINT32 BlueMask; + UINT32 ReservedMask; +} EFI_PIXEL_BITMASK; + +typedef enum { + PixelRedGreenBlueReserved8BitPerColor, + PixelBlueGreenRedReserved8BitPerColor, + PixelBitMask, + PixelBltOnly, + PixelFormatMax +} EFI_GRAPHICS_PIXEL_FORMAT; + +typedef struct { + UINT32 Version; + UINT32 HorizontalResolution; + UINT32 VerticalResolution; + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; + EFI_PIXEL_BITMASK PixelInformation; + UINT32 PixelsPerScanLine; +} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION; + +/** + Return the current video mode information. + + @param This Protocol instance pointer. + @param ModeNumber The mode number to return information on. + @param SizeOfInfo A pointer to the size, in bytes, of the Info buffer. + @param Info A pointer to callee allocated buffer that returns information about ModeNumber. + + @retval EFI_SUCCESS Mode information returned. + @retval EFI_BUFFER_TOO_SMALL The Info buffer was too small. + @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the video mode. + @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode () + @retval EFI_INVALID_PARAMETER One of the input args was NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE) ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, + IN UINT32 ModeNumber, + OUT UINTN *SizeOfInfo, + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info + ) +; + +/** + Return the current video mode information. + + @param This Protocol instance pointer. + @param ModeNumber The mode number to be set. + + @retval EFI_SUCCESS Graphics mode was changed. + @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. + @retval EFI_UNSUPPORTED ModeNumber is not supported by this device. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE) ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, + IN UINT32 ModeNumber + ); + +typedef struct { + UINT8 Blue; + UINT8 Green; + UINT8 Red; + UINT8 Reserved; +} EFI_GRAPHICS_OUTPUT_BLT_PIXEL; + +typedef union { + EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel; + UINT32 Raw; +} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION; + +typedef enum { + EfiBltVideoFill, + EfiBltVideoToBltBuffer, + EfiBltBufferToVideo, + EfiBltVideoToVideo, + EfiGraphicsOutputBltOperationMax +} EFI_GRAPHICS_OUTPUT_BLT_OPERATION; + +/** + The following table defines actions for BltOperations: + + EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY) + directly to every pixel of the video display rectangle + (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). + Only one pixel will be used from the BltBuffer. Delta is NOT used. + + EfiBltVideoToBltBuffer - Read data from the video display rectangle + (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in + the BltBuffer rectangle (DestinationX, DestinationY ) + (DestinationX + Width, DestinationY + Height). If DestinationX or + DestinationY is not zero then Delta must be set to the length in bytes + of a row in the BltBuffer. + + EfiBltBufferToVideo - Write data from the BltBuffer rectangle + (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the + video display rectangle (DestinationX, DestinationY) + (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is + not zero then Delta must be set to the length in bytes of a row in the + BltBuffer. + + EfiBltVideoToVideo - Copy from the video display rectangle (SourceX, SourceY) + (SourceX + Width, SourceY + Height) .to the video display rectangle + (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). + The BltBuffer and Delta are not used in this mode. + + @param This Protocol instance pointer. + @param BltBuffer Buffer containing data to blit into video buffer. This + buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) + @param BltOperation Operation to perform on BlitBuffer and video memory + @param SourceX X coordinate of source for the BltBuffer. + @param SourceY Y coordinate of source for the BltBuffer. + @param DestinationX X coordinate of destination for the BltBuffer. + @param DestinationY Y coordinate of destination for the BltBuffer. + @param Width Width of rectangle in BltBuffer in pixels. + @param Height Hight of rectangle in BltBuffer in pixels. + @param Delta OPTIONAL + + @retval EFI_SUCCESS The Blt operation completed. + @retval EFI_INVALID_PARAMETER BltOperation is not valid. + @retval EFI_DEVICE_ERROR A hardware error occured writting to the video buffer. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT) ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL + IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta OPTIONAL + ); + +typedef struct { + UINT32 MaxMode; + UINT32 Mode; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + UINTN SizeOfInfo; + EFI_PHYSICAL_ADDRESS FrameBufferBase; + UINTN FrameBufferSize; +} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE; + +struct _EFI_GRAPHICS_OUTPUT_PROTOCOL { + EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode; + EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode; + EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT Blt; + EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; +}; + + + +/* + * EFI EDID Discovered Protocol + * UEFI Specification Version 2.5 Section 11.9 + */ +#define EFI_EDID_DISCOVERED_PROTOCOL_GUID \ + { 0x1C0C34F6, 0xD380, 0x41FA, { 0xA0, 0x49, 0x8a, 0xD0, 0x6C, 0x1A, 0x66, 0xAA} } + +typedef struct _EFI_EDID_DISCOVERED_PROTOCOL { + UINT32 SizeOfEdid; + UINT8 *Edid; +} EFI_EDID_DISCOVERED_PROTOCOL; + + + +/* + * EFI EDID Active Protocol + * UEFI Specification Version 2.5 Section 11.9 + */ +#define EFI_EDID_ACTIVE_PROTOCOL_GUID \ + { 0xBD8C1056, 0x9F36, 0x44EC, { 0x92, 0xA8, 0xA6, 0x33, 0x7F, 0x81, 0x79, 0x86} } + +typedef struct _EFI_EDID_ACTIVE_PROTOCOL { + UINT32 SizeOfEdid; + UINT8 *Edid; +} EFI_EDID_ACTIVE_PROTOCOL; + + + +/* + * EFI EDID Override Protocol + * UEFI Specification Version 2.5 Section 11.9 + */ +#define EFI_EDID_OVERRIDE_PROTOCOL_GUID \ + { 0x48ECB431, 0xFB72, 0x45C0, { 0xA9, 0x22, 0xF4, 0x58, 0xFE, 0x04, 0x0B, 0xD5} } + +INTERFACE_DECL(_EFI_EDID_OVERRIDE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID) ( + IN struct _EFI_EDID_OVERRIDE_PROTOCOL *This, + IN EFI_HANDLE *ChildHandle, + OUT UINT32 *Attributes, + IN OUT UINTN *EdidSize, + IN OUT UINT8 **Edid); + +typedef struct _EFI_EDID_OVERRIDE_PROTOCOL { + EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID GetEdid; +} EFI_EDID_OVERRIDE_PROTOCOL; + + + +INTERFACE_DECL(_EFI_SERVICE_BINDING); + +typedef +EFI_STATUS +(EFIAPI *EFI_SERVICE_BINDING_CREATE_CHILD) ( + IN struct _EFI_SERVICE_BINDING *This, + IN EFI_HANDLE *ChildHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SERVICE_BINDING_DESTROY_CHILD) ( + IN struct _EFI_SERVICE_BINDING *This, + IN EFI_HANDLE ChildHandle + ); + +typedef struct _EFI_SERVICE_BINDING { + EFI_SERVICE_BINDING_CREATE_CHILD CreateChild; + EFI_SERVICE_BINDING_DESTROY_CHILD DestroyChild; +} EFI_SERVICE_BINDING; + + + +/* + * EFI Driver Binding Protocol + * UEFI Specification Version 2.5 Section 10.1 + */ +#define EFI_DRIVER_BINDING_PROTOCOL_GUID \ + { 0x18A031AB, 0xB443, 0x4D1A, { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71} } +#define DRIVER_BINDING_PROTOCOL EFI_DRIVER_BINDING_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_DRIVER_BINDING_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_BINDING_PROTOCOL_SUPPORTED) ( + IN struct _EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_BINDING_PROTOCOL_START) ( + IN struct _EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_BINDING_PROTOCOL_STOP) ( + IN struct _EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL); + +typedef struct _EFI_DRIVER_BINDING_PROTOCOL { + EFI_DRIVER_BINDING_PROTOCOL_SUPPORTED Supported; + EFI_DRIVER_BINDING_PROTOCOL_START Start; + EFI_DRIVER_BINDING_PROTOCOL_STOP Stop; + UINT32 Version; + EFI_HANDLE ImageHandle; + EFI_HANDLE DriverBindingHandle; +} EFI_DRIVER_BINDING_PROTOCOL; + +typedef struct _EFI_DRIVER_BINDING_PROTOCOL _EFI_DRIVER_BINDING; +typedef EFI_DRIVER_BINDING_PROTOCOL EFI_DRIVER_BINDING; + + +/* + * Backwards compatibility with older GNU-EFI versions. Deprecated. + */ +#define EFI_DRIVER_SUPPORTED EFI_DRIVER_BINDING_PROTOCOL_SUPPORTED +#define EFI_DRIVER_START EFI_DRIVER_BINDING_PROTOCOL_START +#define EFI_DRIVER_STOP EFI_DRIVER_BINDING_PROTOCOL_STOP + + + +/* + * EFI Component Name Protocol + * Deprecated - use EFI Component Name 2 Protocol instead + */ +#define EFI_COMPONENT_NAME_PROTOCOL_GUID \ + {0x107A772C, 0xD5E1, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } +#define COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_COMPONENT_NAME_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_COMPONENT_NAME_GET_DRIVER_NAME) ( + IN struct _EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName); + +typedef +EFI_STATUS +(EFIAPI *EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) ( + IN struct _EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName); + +typedef struct _EFI_COMPONENT_NAME_PROTOCOL { + EFI_COMPONENT_NAME_GET_DRIVER_NAME GetDriverName; + EFI_COMPONENT_NAME_GET_CONTROLLER_NAME GetControllerName; + CHAR8 *SupportedLanguages; +} EFI_COMPONENT_NAME_PROTOCOL; + +typedef struct _EFI_COMPONENT_NAME_PROTOCOL _EFI_COMPONENT_NAME; +typedef EFI_COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME; + + +/* + * EFI Component Name 2 Protocol + * UEFI Specification Version 2.5 Section 10.5 + */ +#define EFI_COMPONENT_NAME2_PROTOCOL_GUID \ + {0x6A7A5CFF, 0xE8D9, 0x4F70, { 0xBA, 0xDA, 0x75, 0xAB, 0x30, 0x25, 0xCE, 0x14} } +#define COMPONENT_NAME2_PROTOCOL EFI_COMPONENT_NAME2_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_COMPONENT_NAME2_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ( + IN struct _EFI_COMPONENT_NAME2_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName); + +typedef +EFI_STATUS +(EFIAPI *EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ( + IN struct _EFI_COMPONENT_NAME2_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName); + +typedef struct _EFI_COMPONENT_NAME2_PROTOCOL { + EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName; + EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME GetControllerName; + CHAR8 *SupportedLanguages; +} EFI_COMPONENT_NAME2_PROTOCOL; + +typedef struct _EFI_COMPONENT_NAME2_PROTOCOL _EFI_COMPONENT_NAME2; +typedef EFI_COMPONENT_NAME2_PROTOCOL EFI_COMPONENT_NAME2; + + + +/* + * EFI Loaded Image Protocol + * UEFI Specification Version 2.5 Section 8.1 + */ +#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ + { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } +#define LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE_PROTOCOL_GUID + +#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000 +#define EFI_IMAGE_INFORMATION_REVISION EFI_LOADED_IMAGE_PROTOCOL_REVISION + +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_UNLOAD) ( + IN EFI_HANDLE ImageHandle + ); + +typedef struct { + UINT32 Revision; + EFI_HANDLE ParentHandle; + struct _EFI_SYSTEM_TABLE *SystemTable; + + // Source location of image + EFI_HANDLE DeviceHandle; + EFI_DEVICE_PATH *FilePath; + VOID *Reserved; + + // Images load options + UINT32 LoadOptionsSize; + VOID *LoadOptions; + + // Location of where image was loaded + VOID *ImageBase; + UINT64 ImageSize; + EFI_MEMORY_TYPE ImageCodeType; + EFI_MEMORY_TYPE ImageDataType; + + // If the driver image supports a dynamic unload request + EFI_IMAGE_UNLOAD Unload; +} EFI_LOADED_IMAGE_PROTOCOL; + +typedef EFI_LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE; + + + +/* + * Random Number Generator Protocol + * UEFI Specification Version 2.5 Section 35.5 + */ +#define EFI_RNG_PROTOCOL_GUID \ + { 0x3152bca5, 0xeade, 0x433d, {0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44} } + +typedef EFI_GUID EFI_RNG_ALGORITHM; + +#define EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID \ + {0xa7af67cb, 0x603b, 0x4d42, {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96} } + +#define EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID \ + {0xc5149b43, 0xae85, 0x4f53, {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7} } + +#define EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID \ + {0x44f0de6e, 0x4d8c, 0x4045, {0xa8, 0xc7, 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e} } + +#define EFI_RNG_ALGORITHM_X9_31_3DES_GUID \ + {0x63c4785a, 0xca34, 0x4012, {0xa3, 0xc8, 0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46} } + +#define EFI_RNG_ALGORITHM_X9_31_AES_GUID \ + {0xacd03321, 0x777e, 0x4d3d, {0xb1, 0xc8, 0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9} } + +#define EFI_RNG_ALGORITHM_RAW \ + {0xe43176d7, 0xb6e8, 0x4827, {0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61} } + +INTERFACE_DECL(_EFI_RNG_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_RNG_GET_INFO) ( + IN struct _EFI_RNG_PROTOCOL *This, + IN OUT UINTN *RNGAlgorithmListSize, + OUT EFI_RNG_ALGORITHM *RNGAlgorithmList +); + +typedef +EFI_STATUS +(EFIAPI *EFI_RNG_GET_RNG) ( + IN struct _EFI_RNG_PROTOCOL *This, + IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL + IN UINTN RNGValueLength, + OUT UINT8 *RNGValue +); + +typedef struct _EFI_RNG_PROTOCOL { + EFI_RNG_GET_INFO GetInfo; + EFI_RNG_GET_RNG GetRNG; +} EFI_RNG_PROTOCOL; + + +// +// EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL +// + +#define EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID \ + { 0x6b30c738, 0xa391, 0x11d4, {0x9a, 0x3b, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +INTERFACE_DECL(_EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER) ( +IN struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, +IN EFI_HANDLE ControllerHandle, +IN OUT EFI_HANDLE *DriverImageHandle); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH) ( +IN struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, +IN EFI_HANDLE ControllerHandle, +IN OUT EFI_DEVICE_PATH **DriverImagePath); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED) ( +IN struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, +IN EFI_HANDLE ControllerHandle, +IN EFI_DEVICE_PATH *DriverImagePath, +IN EFI_HANDLE DriverImageHandle); + +typedef struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL { + EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER GetDriver; + EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH GetDriverPath; + EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED DriverLoaded; +} EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL; + +// +// EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL +// + +#define EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID \ + { 0x3bc1b285, 0x8a15, 0x4a82, {0xaa, 0xbf, 0x4d, 0x7d, 0x13, 0xfb, 0x32, 0x65} } + +INTERFACE_DECL(_EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER) ( +IN struct _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *This, +IN OUT EFI_HANDLE *DriverImageHandle); + +typedef struct _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL { + EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER GetDriver; +} EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL; + +// +// EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL +// + +#define EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL_GUID \ + { 0xb1ee129e, 0xda36, 0x4181, {0x91, 0xf8, 0x04, 0xa4, 0x92, 0x37, 0x66, 0xa7} } + +INTERFACE_DECL(_EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL); + +typedef +UINT32 +(EFIAPI *EFI_DRIVER_FAMILY_OVERRIDE_GET_VERSION) ( +IN struct _EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL *This); + +typedef struct _EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL { + EFI_DRIVER_FAMILY_OVERRIDE_GET_VERSION GetVersion; +} EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL; + +// +// EFI_EBC_PROTOCOL +// + +#define EFI_EBC_INTERPRETER_PROTOCOL_GUID \ + {0x13ac6dd1, 0x73d0, 0x11d4, {0xb0, 0x6b, 0x00, 0xaa, 0x00, 0xbd, 0x6d, 0xe7} } + +#define EFI_EBC_PROTOCOL_GUID EFI_EBC_INTERPRETER_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_EBC_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_CREATE_THUNK)( + IN struct _EFI_EBC_PROTOCOL *This, + IN EFI_HANDLE ImageHandle, + IN VOID *EbcEntryPoint, + OUT VOID **Thunk); + +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_UNLOAD_IMAGE)( + IN struct _EFI_EBC_PROTOCOL *This, + IN EFI_HANDLE ImageHandle); + +typedef +EFI_STATUS +(EFIAPI *EBC_ICACHE_FLUSH)( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length); + +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_REGISTER_ICACHE_FLUSH)( + IN struct _EFI_EBC_PROTOCOL *This, + IN EBC_ICACHE_FLUSH Flush); + +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_GET_VERSION)( + IN struct _EFI_EBC_PROTOCOL *This, + IN OUT UINT64 *Version); + +typedef struct _EFI_EBC_PROTOCOL { + EFI_EBC_CREATE_THUNK CreateThunk; + EFI_EBC_UNLOAD_IMAGE UnloadImage; + EFI_EBC_REGISTER_ICACHE_FLUSH RegisterICacheFlush; + EFI_EBC_GET_VERSION GetVersion; +} EFI_EBC_PROTOCOL; + +#endif diff --git a/gnu-efi/inc/efipxebc.h b/gnu-efi/inc/efipxebc.h new file mode 100644 index 0000000..3760c7c --- /dev/null +++ b/gnu-efi/inc/efipxebc.h @@ -0,0 +1,482 @@ +#ifndef _EFIPXEBC_H +#define _EFIPXEBC_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efipxebc.h + +Abstract: + + EFI PXE Base Code Protocol + + + +Revision History + +--*/ + +// +// PXE Base Code protocol +// + +#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \ + { 0x03c4e603, 0xac28, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +INTERFACE_DECL(_EFI_PXE_BASE_CODE_PROTOCOL); + +#define DEFAULT_TTL 4 +#define DEFAULT_ToS 0 +// +// Address definitions +// + +typedef union { + UINT32 Addr[4]; + EFI_IPv4_ADDRESS v4; + EFI_IPv6_ADDRESS v6; +} EFI_IP_ADDRESS; + +typedef UINT16 EFI_PXE_BASE_CODE_UDP_PORT; + +// +// Packet definitions +// + +typedef struct { + UINT8 BootpOpcode; + UINT8 BootpHwType; + UINT8 BootpHwAddrLen; + UINT8 BootpGateHops; + UINT32 BootpIdent; + UINT16 BootpSeconds; + UINT16 BootpFlags; + UINT8 BootpCiAddr[4]; + UINT8 BootpYiAddr[4]; + UINT8 BootpSiAddr[4]; + UINT8 BootpGiAddr[4]; + UINT8 BootpHwAddr[16]; + UINT8 BootpSrvName[64]; + UINT8 BootpBootFile[128]; + UINT32 DhcpMagik; + UINT8 DhcpOptions[56]; +} EFI_PXE_BASE_CODE_DHCPV4_PACKET; + +typedef struct { + UINT32 MessageType:8; + UINT32 TransactionId:24; + UINT8 DhcpOptions[1024]; +} EFI_PXE_BASE_CODE_DHCPV6_PACKET; + +typedef union { + UINT8 Raw[1472]; + EFI_PXE_BASE_CODE_DHCPV4_PACKET Dhcpv4; + EFI_PXE_BASE_CODE_DHCPV6_PACKET Dhcpv6; +} EFI_PXE_BASE_CODE_PACKET; + +typedef struct { + UINT8 Type; + UINT8 Code; + UINT16 Checksum; + union { + UINT32 reserved; + UINT32 Mtu; + UINT32 Pointer; + struct { + UINT16 Identifier; + UINT16 Sequence; + } Echo; + } u; + UINT8 Data[494]; +} EFI_PXE_BASE_CODE_ICMP_ERROR; + +typedef struct { + UINT8 ErrorCode; + CHAR8 ErrorString[127]; +} EFI_PXE_BASE_CODE_TFTP_ERROR; + +// +// IP Receive Filter definitions +// +#define EFI_PXE_BASE_CODE_MAX_IPCNT 8 +typedef struct { + UINT8 Filters; + UINT8 IpCnt; + UINT16 reserved; + EFI_IP_ADDRESS IpList[EFI_PXE_BASE_CODE_MAX_IPCNT]; +} EFI_PXE_BASE_CODE_IP_FILTER; + +#define EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP 0x0001 +#define EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST 0x0002 +#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS 0x0004 +#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST 0x0008 + +// +// ARP Cache definitions +// + +typedef struct { + EFI_IP_ADDRESS IpAddr; + EFI_MAC_ADDRESS MacAddr; +} EFI_PXE_BASE_CODE_ARP_ENTRY; + +typedef struct { + EFI_IP_ADDRESS IpAddr; + EFI_IP_ADDRESS SubnetMask; + EFI_IP_ADDRESS GwAddr; +} EFI_PXE_BASE_CODE_ROUTE_ENTRY; + +// +// UDP definitions +// + +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP 0x0001 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT 0x0002 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP 0x0004 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT 0x0008 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER 0x0010 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_MAY_FRAGMENT 0x0020 + +// +// Discover() definitions +// + +#define EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP 0 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_MS_WINNT_RIS 1 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_INTEL_LCM 2 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_DOSUNDI 3 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_NEC_ESMPRO 4 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_WSoD 5 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_LCCM 6 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_CA_UNICENTER_TNG 7 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_HP_OPENVIEW 8 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_9 9 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_10 10 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_11 11 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_NOT_USED_12 12 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_INSTALL 13 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_BOOT 14 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_REMBO 15 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_BEOBOOT 16 +// +// 17 through 32767 are reserved +// 32768 through 65279 are for vendor use +// 65280 through 65534 are reserved +// +#define EFI_PXE_BASE_CODE_BOOT_TYPE_PXETEST 65535 + +#define EFI_PXE_BASE_CODE_BOOT_LAYER_MASK 0x7FFF +#define EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL 0x0000 + + +typedef struct { + UINT16 Type; + BOOLEAN AcceptAnyResponse; + UINT8 Reserved; + EFI_IP_ADDRESS IpAddr; +} EFI_PXE_BASE_CODE_SRVLIST; + +typedef struct { + BOOLEAN UseMCast; + BOOLEAN UseBCast; + BOOLEAN UseUCast; + BOOLEAN MustUseList; + EFI_IP_ADDRESS ServerMCastIp; + UINT16 IpCnt; + EFI_PXE_BASE_CODE_SRVLIST SrvList[1]; +} EFI_PXE_BASE_CODE_DISCOVER_INFO; + +// +// Mtftp() definitions +// + +typedef enum { + EFI_PXE_BASE_CODE_TFTP_FIRST, + EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE, + EFI_PXE_BASE_CODE_TFTP_READ_FILE, + EFI_PXE_BASE_CODE_TFTP_WRITE_FILE, + EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY, + EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE, + EFI_PXE_BASE_CODE_MTFTP_READ_FILE, + EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY, + EFI_PXE_BASE_CODE_MTFTP_LAST +} EFI_PXE_BASE_CODE_TFTP_OPCODE; + +typedef struct { + EFI_IP_ADDRESS MCastIp; + EFI_PXE_BASE_CODE_UDP_PORT CPort; + EFI_PXE_BASE_CODE_UDP_PORT SPort; + UINT16 ListenTimeout; + UINT16 TransmitTimeout; +} EFI_PXE_BASE_CODE_MTFTP_INFO; + +// +// PXE Base Code Mode structure +// + +#define EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8 +#define EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8 + +typedef struct { + BOOLEAN Started; + BOOLEAN Ipv6Available; + BOOLEAN Ipv6Supported; + BOOLEAN UsingIpv6; + BOOLEAN BisSupported; + BOOLEAN BisDetected; + BOOLEAN AutoArp; + BOOLEAN SendGUID; + BOOLEAN DhcpDiscoverValid; + BOOLEAN DhcpAckReceived; + BOOLEAN ProxyOfferReceived; + BOOLEAN PxeDiscoverValid; + BOOLEAN PxeReplyReceived; + BOOLEAN PxeBisReplyReceived; + BOOLEAN IcmpErrorReceived; + BOOLEAN TftpErrorReceived; + BOOLEAN MakeCallbacks; + UINT8 TTL; + UINT8 ToS; + EFI_IP_ADDRESS StationIp; + EFI_IP_ADDRESS SubnetMask; + EFI_PXE_BASE_CODE_PACKET DhcpDiscover; + EFI_PXE_BASE_CODE_PACKET DhcpAck; + EFI_PXE_BASE_CODE_PACKET ProxyOffer; + EFI_PXE_BASE_CODE_PACKET PxeDiscover; + EFI_PXE_BASE_CODE_PACKET PxeReply; + EFI_PXE_BASE_CODE_PACKET PxeBisReply; + EFI_PXE_BASE_CODE_IP_FILTER IpFilter; + UINT32 ArpCacheEntries; + EFI_PXE_BASE_CODE_ARP_ENTRY ArpCache[EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES]; + UINT32 RouteTableEntries; + EFI_PXE_BASE_CODE_ROUTE_ENTRY RouteTable[EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES]; + EFI_PXE_BASE_CODE_ICMP_ERROR IcmpError; + EFI_PXE_BASE_CODE_TFTP_ERROR TftpError; +} EFI_PXE_BASE_CODE_MODE; + +// +// PXE Base Code Interface Function definitions +// + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_START) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN BOOLEAN UseIpv6 + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_STOP) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_DHCP) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN BOOLEAN SortOffers + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_DISCOVER) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN UINT16 Type, + IN UINT16 *Layer, + IN BOOLEAN UseBis, + IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO *Info OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_MTFTP) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation, + IN OUT VOID *BufferPtr OPTIONAL, + IN BOOLEAN Overwrite, + IN OUT UINT64 *BufferSize, + IN UINTN *BlockSize OPTIONAL, + IN EFI_IP_ADDRESS *ServerIp, + IN UINT8 *Filename, + IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL, + IN BOOLEAN DontUseBuffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_UDP_WRITE) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN UINT16 OpFlags, + IN EFI_IP_ADDRESS *DestIp, + IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort, + IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL + IN EFI_IP_ADDRESS *SrcIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL + IN UINTN *HeaderSize, OPTIONAL + IN VOID *HeaderPtr, OPTIONAL + IN UINTN *BufferSize, + IN VOID *BufferPtr + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_UDP_READ) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN UINT16 OpFlags, + IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL + IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL + IN UINTN *HeaderSize, OPTIONAL + IN VOID *HeaderPtr, OPTIONAL + IN OUT UINTN *BufferSize, + IN VOID *BufferPtr + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_SET_IP_FILTER) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_ARP) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_IP_ADDRESS *IpAddr, + IN EFI_MAC_ADDRESS *MacAddr OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_SET_PARAMETERS) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN BOOLEAN *NewAutoArp, OPTIONAL + IN BOOLEAN *NewSendGUID, OPTIONAL + IN UINT8 *NewTTL, OPTIONAL + IN UINT8 *NewToS, OPTIONAL + IN BOOLEAN *NewMakeCallback OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_SET_STATION_IP) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL + IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_SET_PACKETS) ( + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + BOOLEAN *NewDhcpDiscoverValid, OPTIONAL + BOOLEAN *NewDhcpAckReceived, OPTIONAL + BOOLEAN *NewProxyOfferReceived, OPTIONAL + BOOLEAN *NewPxeDiscoverValid, OPTIONAL + BOOLEAN *NewPxeReplyReceived, OPTIONAL + BOOLEAN *NewPxeBisReplyReceived,OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewDhcpDiscover, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewDhcpAck, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewProxyOffer, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewPxeDiscover, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewPxeReply, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewPxeBisReply OPTIONAL + ); + +// +// PXE Base Code Protocol structure +// + +#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION 0x00010000 +#define EFI_PXE_BASE_CODE_INTERFACE_REVISION EFI_PXE_BASE_CODE_PROTOCOL_REVISION + +typedef struct _EFI_PXE_BASE_CODE_PROTOCOL { + UINT64 Revision; + EFI_PXE_BASE_CODE_START Start; + EFI_PXE_BASE_CODE_STOP Stop; + EFI_PXE_BASE_CODE_DHCP Dhcp; + EFI_PXE_BASE_CODE_DISCOVER Discover; + EFI_PXE_BASE_CODE_MTFTP Mtftp; + EFI_PXE_BASE_CODE_UDP_WRITE UdpWrite; + EFI_PXE_BASE_CODE_UDP_READ UdpRead; + EFI_PXE_BASE_CODE_SET_IP_FILTER SetIpFilter; + EFI_PXE_BASE_CODE_ARP Arp; + EFI_PXE_BASE_CODE_SET_PARAMETERS SetParameters; + EFI_PXE_BASE_CODE_SET_STATION_IP SetStationIp; + EFI_PXE_BASE_CODE_SET_PACKETS SetPackets; + EFI_PXE_BASE_CODE_MODE *Mode; +} EFI_PXE_BASE_CODE_PROTOCOL; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_PXE_BASE_CODE_PROTOCOL' GUID definition, from older +// versions of gnu-efi, is now obsoleted. +// Use 'EFI_PXE_BASE_CODE_PROTOCOL_GUID' instead. + +typedef struct _EFI_PXE_BASE_CODE_PROTOCOL _EFI_PXE_BASE_CODE; +typedef struct _EFI_PXE_BASE_CODE_PROTOCOL EFI_PXE_BASE_CODE; + +// +// Call Back Definitions +// + +#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID \ + { 0x245dca21, 0xfb7b, 0x11d3, {0x8f, 0x01, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } + +// +// Revision Number +// + +#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION 0x00010000 +#define EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION + +INTERFACE_DECL(_EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL); + +typedef enum { + EFI_PXE_BASE_CODE_FUNCTION_FIRST, + EFI_PXE_BASE_CODE_FUNCTION_DHCP, + EFI_PXE_BASE_CODE_FUNCTION_DISCOVER, + EFI_PXE_BASE_CODE_FUNCTION_MTFTP, + EFI_PXE_BASE_CODE_FUNCTION_UDP_WRITE, + EFI_PXE_BASE_CODE_FUNCTION_UDP_READ, + EFI_PXE_BASE_CODE_FUNCTION_ARP, + EFI_PXE_BASE_CODE_FUNCTION_IGMP, + EFI_PXE_BASE_CODE_PXE_FUNCTION_LAST +} EFI_PXE_BASE_CODE_FUNCTION; + +typedef enum { + EFI_PXE_BASE_CODE_CALLBACK_STATUS_FIRST, + EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT, + EFI_PXE_BASE_CODE_CALLBACK_STATUS_LAST +} EFI_PXE_BASE_CODE_CALLBACK_STATUS; + +typedef +EFI_PXE_BASE_CODE_CALLBACK_STATUS +(EFIAPI *EFI_PXE_CALLBACK) ( + IN struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *This, + IN EFI_PXE_BASE_CODE_FUNCTION Function, + IN BOOLEAN Received, + IN UINT32 PacketLen, + IN EFI_PXE_BASE_CODE_PACKET *Packet OPTIONAL + ); + +typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL { + UINT64 Revision; + EFI_PXE_CALLBACK Callback; +} EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL' GUID definition, from +// older versions of gnu-efi, is now obsoleted. +// Use 'EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID' instead. + +typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL _EFI_PXE_BASE_CODE_CALLBACK; +typedef EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL EFI_PXE_BASE_CODE_CALLBACK; + +#endif /* _EFIPXEBC_H */ diff --git a/gnu-efi/inc/efirtlib.h b/gnu-efi/inc/efirtlib.h new file mode 100644 index 0000000..49d0b4d --- /dev/null +++ b/gnu-efi/inc/efirtlib.h @@ -0,0 +1,179 @@ +#ifndef _EFI_RT_LIB_INCLUDE_ +#define _EFI_RT_LIB_INCLUDE_ +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efilib.h + +Abstract: + + EFI Runtime library functions + + + +Revision History + +--*/ + +#include "efidebug.h" +#include "efipart.h" +#include "efilibplat.h" + + +VOID +RUNTIMEFUNCTION +RtZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ); + +VOID +RUNTIMEFUNCTION +RtSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ); + +VOID +RUNTIMEFUNCTION +RtCopyMem ( + IN VOID *Dest, + IN CONST VOID *Src, + IN UINTN len + ); + +INTN +RUNTIMEFUNCTION +RtCompareMem ( + IN CONST VOID *Dest, + IN CONST VOID *Src, + IN UINTN len + ); + +INTN +RUNTIMEFUNCTION +RtStrCmp ( + IN CONST CHAR16 *s1, + IN CONST CHAR16 *s2 + ); + + +VOID +RUNTIMEFUNCTION +RtStrCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ); + +VOID +RUNTIMEFUNCTION +RtStrnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +CHAR16 * +RUNTIMEFUNCTION +RtStpCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ); + +CHAR16 * +RUNTIMEFUNCTION +RtStpnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +VOID +RUNTIMEFUNCTION +RtStrCat ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ); + +VOID +RUNTIMEFUNCTION +RtStrnCat ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +UINTN +RUNTIMEFUNCTION +RtStrLen ( + IN CONST CHAR16 *s1 + ); + +UINTN +RUNTIMEFUNCTION +RtStrnLen ( + IN CONST CHAR16 *s1, + IN UINTN Len + ); + +UINTN +RUNTIMEFUNCTION +RtStrSize ( + IN CONST CHAR16 *s1 + ); + +INTN +RUNTIMEFUNCTION +RtCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ); + +UINT8 +RUNTIMEFUNCTION +RtDecimaltoBCD( + IN UINT8 BcdValue + ); + +UINT8 +RUNTIMEFUNCTION +RtBCDtoDecimal( + IN UINT8 BcdValue + ); + +// +// Virtual mapping transition support. (Only used during +// the virtual address change transisition) +// + +VOID +RUNTIMEFUNCTION +RtLibEnableVirtualMappings ( + VOID + ); + +VOID +RUNTIMEFUNCTION +RtConvertList ( + IN UINTN DebugDisposition, + IN OUT LIST_ENTRY *ListHead + ); + +VOID +RUNTIMEFUNCTION +RtAcquireLock ( + IN FLOCK *Lock + ); + +VOID +RUNTIMEFUNCTION +RtReleaseLock ( + IN FLOCK *Lock + ); + + +#endif diff --git a/gnu-efi/inc/efiser.h b/gnu-efi/inc/efiser.h new file mode 100644 index 0000000..45a463e --- /dev/null +++ b/gnu-efi/inc/efiser.h @@ -0,0 +1,136 @@ +#ifndef _EFI_SER_H +#define _EFI_SER_H + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efiser.h + +Abstract: + + EFI serial protocol + +Revision History + +--*/ + +// +// Serial protocol +// + +#define EFI_SERIAL_IO_PROTOCOL_GUID \ + { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} } +#define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_SERIAL_IO_PROTOCOL); + +typedef enum { + DefaultParity, + NoParity, + EvenParity, + OddParity, + MarkParity, + SpaceParity +} EFI_PARITY_TYPE; + +typedef enum { + DefaultStopBits, + OneStopBit, // 1 stop bit + OneFiveStopBits, // 1.5 stop bits + TwoStopBits // 2 stop bits +} EFI_STOP_BITS_TYPE; + +#define EFI_SERIAL_CLEAR_TO_SEND 0x0010 // RO +#define EFI_SERIAL_DATA_SET_READY 0x0020 // RO +#define EFI_SERIAL_RING_INDICATE 0x0040 // RO +#define EFI_SERIAL_CARRIER_DETECT 0x0080 // RO +#define EFI_SERIAL_REQUEST_TO_SEND 0x0002 // WO +#define EFI_SERIAL_DATA_TERMINAL_READY 0x0001 // WO +#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x0100 // RO +#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x0200 // RO +#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x1000 // RW +#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x2000 // RW +#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x4000 // RW + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_RESET) ( + IN struct _EFI_SERIAL_IO_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) ( + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + IN UINT64 BaudRate, + IN UINT32 ReceiveFifoDepth, + IN UINT32 Timeout, + IN EFI_PARITY_TYPE Parity, + IN UINT8 DataBits, + IN EFI_STOP_BITS_TYPE StopBits + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) ( + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + IN UINT32 Control + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) ( + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + OUT UINT32 *Control + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_WRITE) ( + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + IN OUT UINTN *BufferSize, + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_READ) ( + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ); + +typedef struct { + UINT32 ControlMask; + + // current Attributes + UINT32 Timeout; + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + UINT32 DataBits; + UINT32 Parity; + UINT32 StopBits; +} SERIAL_IO_MODE; + +#define SERIAL_IO_INTERFACE_REVISION 0x00010000 + +typedef struct _EFI_SERIAL_IO_PROTOCOL { + UINT32 Revision; + EFI_SERIAL_RESET Reset; + EFI_SERIAL_SET_ATTRIBUTES SetAttributes; + EFI_SERIAL_SET_CONTROL_BITS SetControl; + EFI_SERIAL_GET_CONTROL_BITS GetControl; + EFI_SERIAL_WRITE Write; + EFI_SERIAL_READ Read; + + SERIAL_IO_MODE *Mode; +} EFI_SERIAL_IO_PROTOCOL; + +typedef struct _EFI_SERIAL_IO_PROTOCOL _SERIAL_IO_INTERFACE; +typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE; + +#endif + diff --git a/gnu-efi/inc/efisetjmp.h b/gnu-efi/inc/efisetjmp.h new file mode 100644 index 0000000..de69194 --- /dev/null +++ b/gnu-efi/inc/efisetjmp.h @@ -0,0 +1,10 @@ +#ifndef GNU_EFI_SETJMP_H +#define GNU_EFI_SETJMP_H + +#include "eficompiler.h" +#include "efisetjmp_arch.h" + +extern UINTN setjmp(jmp_buf env) __attribute__((returns_twice)); +extern VOID longjmp(jmp_buf env, UINTN value) __attribute__((noreturn)); + +#endif /* GNU_EFI_SETJMP_H */ diff --git a/gnu-efi/inc/efishellintf.h b/gnu-efi/inc/efishellintf.h new file mode 100644 index 0000000..e649acd --- /dev/null +++ b/gnu-efi/inc/efishellintf.h @@ -0,0 +1,94 @@ +/** @file + SHELL_INTERFACE_PROTOCOL from EDK shell (no spec). + + Shell Interface - additional information (over image_info) provided + to an application started by the shell. + + ConIo provides a file-style interface to the console. + + The shell interface's and data (including ConIo) are only valid during + the applications Entry Point. Once the application returns from it's + entry point the data is freed by the invoking shell. + + Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/* + * This is based on ShellPkg/Include/Protocol/EfiShellInterface.h from EDK II. + */ + +#ifndef _SHELLINTERFACE_H_ +#define _SHELLINTERFACE_H_ + + +#define SHELL_INTERFACE_PROTOCOL_GUID \ + { \ + 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \ + } + +/// +/// Bit definitions for EFI_SHELL_ARG_INFO +/// +typedef enum { + ARG_NO_ATTRIB = 0x0, + ARG_IS_QUOTED = 1<<0, + ARG_PARTIALLY_QUOTED = 1<<1, + ARG_FIRST_HALF_QUOTED = 1<<2, + ARG_FIRST_CHAR_IS_ESC = 1<<3 +} EFI_SHELL_ARG_INFO_TYPES; + +/// +/// Attributes for an argument. +/// +typedef struct _EFI_SHELL_ARG_INFO { + UINT32 Attributes; +} EFI_SHELL_ARG_INFO; + +/// +/// This protocol provides access to additional information about a shell application. +/// +typedef struct { + /// + /// Handle back to original image handle & image information. + /// + EFI_HANDLE ImageHandle; + EFI_LOADED_IMAGE *Info; + + /// + /// Parsed arg list converted more C-like format. + /// + CHAR16 **Argv; + UINTN Argc; + + /// + /// Storage for file redirection args after parsing. + /// + CHAR16 **RedirArgv; + UINTN RedirArgc; + + /// + /// A file style handle for console io. + /// + EFI_FILE *StdIn; + EFI_FILE *StdOut; + EFI_FILE *StdErr; + + /// + /// List of attributes for each argument. + /// + EFI_SHELL_ARG_INFO *ArgInfo; + + /// + /// Whether we are echoing. + /// + BOOLEAN EchoOn; +} EFI_SHELL_INTERFACE; + +#endif diff --git a/gnu-efi/inc/efishellparm.h b/gnu-efi/inc/efishellparm.h new file mode 100644 index 0000000..da120e5 --- /dev/null +++ b/gnu-efi/inc/efishellparm.h @@ -0,0 +1,63 @@ +/** @file + EFI_SHELL_PARAMETERS_PROTOCOL as defined in the UEFI Shell 2.0 specification. + + Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/* + * This is based on ShellPkg/Include/Protocol/EfiShellParameters.h from EDK II. + */ + +#ifndef __EFI_SHELL_PARAMETERS_PROTOCOL__ +#define __EFI_SHELL_PARAMETERS_PROTOCOL__ + + +// EDK2's ShellBase.h +typedef VOID *SHELL_FILE_HANDLE; + +#define EFI_SHELL_PARAMETERS_PROTOCOL_GUID \ + { \ + 0x752f3136, 0x4e16, 0x4fdc, { 0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca } \ + } + +typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL { + /// + /// Points to an Argc-element array of points to NULL-terminated strings containing + /// the command-line parameters. The first entry in the array is always the full file + /// path of the executable. Any quotation marks that were used to preserve + /// whitespace have been removed. + /// + CHAR16 **Argv; + + /// + /// The number of elements in the Argv array. + /// + UINTN Argc; + + /// + /// The file handle for the standard input for this executable. This may be different + /// from the ConInHandle in EFI_SYSTEM_TABLE. + /// + SHELL_FILE_HANDLE StdIn; + + /// + /// The file handle for the standard output for this executable. This may be different + /// from the ConOutHandle in EFI_SYSTEM_TABLE. + /// + SHELL_FILE_HANDLE StdOut; + + /// + /// The file handle for the standard error output for this executable. This may be + /// different from the StdErrHandle in EFI_SYSTEM_TABLE. + /// + SHELL_FILE_HANDLE StdErr; +} EFI_SHELL_PARAMETERS_PROTOCOL; + +#endif diff --git a/gnu-efi/inc/efistdarg.h b/gnu-efi/inc/efistdarg.h new file mode 100644 index 0000000..bb04b31 --- /dev/null +++ b/gnu-efi/inc/efistdarg.h @@ -0,0 +1,33 @@ +#ifndef _EFISTDARG_H_ +#define _EFISTDARG_H_ + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + devpath.h + +Abstract: + + Defines for parsing the EFI Device Path structures + + + +Revision History + +--*/ + +#ifndef GNU_EFI_USE_EXTERNAL_STDARG +typedef __builtin_va_list va_list; + +# define va_start(v,l) __builtin_va_start(v,l) +# define va_end(v) __builtin_va_end(v) +# define va_arg(v,l) __builtin_va_arg(v,l) +# define va_copy(d,s) __builtin_va_copy(d,s) +#else +# include +#endif + +#endif diff --git a/gnu-efi/inc/efitcp.h b/gnu-efi/inc/efitcp.h new file mode 100644 index 0000000..6c5df7f --- /dev/null +++ b/gnu-efi/inc/efitcp.h @@ -0,0 +1,391 @@ +#ifndef _EFI_TCP_H +#define _EFI_TCP_H + +/*++ +Copyright (c) 2013 Intel Corporation + +--*/ + +#define EFI_TCP4_SERVICE_BINDING_PROTOCOL \ + { 0x00720665, 0x67eb, 0x4a99, {0xba, 0xf7, 0xd3, 0xc3, 0x3a, 0x1c,0x7c, 0xc9}} + +#define EFI_TCP4_PROTOCOL \ + { 0x65530bc7, 0xa359, 0x410f, {0xb0, 0x10, 0x5a, 0xad, 0xc7, 0xec, 0x2b, 0x62}} + +#define EFI_TCP6_SERVICE_BINDING_PROTOCOL \ + { 0xec20eb79, 0x6c1a, 0x4664, {0x9a, 0xd, 0xd2, 0xe4, 0xcc, 0x16, 0xd6, 0x64}} + +#define EFI_TCP6_PROTOCOL \ + { 0x46e44855, 0xbd60, 0x4ab7, {0xab, 0xd, 0xa6, 0x79, 0xb9, 0x44, 0x7d, 0x77}} + +INTERFACE_DECL(_EFI_TCP4); +INTERFACE_DECL(_EFI_TCP6); + +typedef struct { + BOOLEAN UseDefaultAddress; + EFI_IPv4_ADDRESS StationAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT16 StationPort; + EFI_IPv4_ADDRESS RemoteAddress; + UINT16 RemotePort; + BOOLEAN ActiveFlag; +} EFI_TCP4_ACCESS_POINT; + +typedef struct { + UINT32 ReceiveBufferSize; + UINT32 SendBufferSize; + UINT32 MaxSynBackLog; + UINT32 ConnectionTimeout; + UINT32 DataRetries; + UINT32 FinTimeout; + UINT32 TimeWaitTimeout; + UINT32 KeepAliveProbes; + UINT32 KeepAliveTime; + UINT32 KeepAliveInterval; + BOOLEAN EnableNagle; + BOOLEAN EnableTimeStamp; + BOOLEAN EnableWindowScaling; + BOOLEAN EnableSelectiveAck; + BOOLEAN EnablePAthMtuDiscovery; +} EFI_TCP4_OPTION; + +typedef struct { + // Receiving Filters + // I/O parameters + UINT8 TypeOfService; + UINT8 TimeToLive; + + // Access Point + EFI_TCP4_ACCESS_POINT AccessPoint; + + // TCP Control Options + EFI_TCP4_OPTION *ControlOption; +} EFI_TCP4_CONFIG_DATA; + +typedef enum { + Tcp4StateClosed = 0, + Tcp4StateListen = 1, + Tcp4StateSynSent = 2, + Tcp4StateSynReceived = 3, + Tcp4StateEstablished = 4, + Tcp4StateFinWait1 = 5, + Tcp4StateFinWait2 = 6, + Tcp4StateClosing = 7, + Tcp4StateTimeWait = 8, + Tcp4StateCloseWait = 9, + Tcp4StateLastAck = 10 +} EFI_TCP4_CONNECTION_STATE; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_GET_MODE_DATA) ( + IN struct _EFI_TCP4 *This, + OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL, + OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL, + OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_CONFIGURE) ( + IN struct _EFI_TCP4 *This, + IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_ROUTES) ( + IN struct _EFI_TCP4 *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv4_ADDRESS *SubnetAddress, + IN EFI_IPv4_ADDRESS *SubnetMask, + IN EFI_IPv4_ADDRESS *GatewayAddress +); + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; +} EFI_TCP4_COMPLETION_TOKEN; + +typedef struct { + EFI_TCP4_COMPLETION_TOKEN CompletionToken; +} EFI_TCP4_CONNECTION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_CONNECT) ( + IN struct _EFI_TCP4 *This, + IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken + ); + +typedef struct { + EFI_TCP4_COMPLETION_TOKEN CompletionToken; + EFI_HANDLE NewChildHandle; +} EFI_TCP4_LISTEN_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_ACCEPT) ( + IN struct _EFI_TCP4 *This, + IN EFI_TCP4_LISTEN_TOKEN *ListenToken + ); + +#define EFI_CONNECTION_FIN EFIERR(104) +#define EFI_CONNECTION_RESET EFIERR(105) +#define EFI_CONNECTION_REFUSED EFIERR(106) + +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_TCP4_FRAGMENT_DATA; + +typedef struct { + BOOLEAN UrgentFlag; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_TCP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_TCP4_RECEIVE_DATA; + +typedef struct { + BOOLEAN Push; + BOOLEAN Urgent; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_TCP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_TCP4_TRANSMIT_DATA; + +typedef struct { + EFI_TCP4_COMPLETION_TOKEN CompletionToken; + union { + EFI_TCP4_RECEIVE_DATA *RxData; + EFI_TCP4_TRANSMIT_DATA *TxData; + } Packet; +} EFI_TCP4_IO_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_TRANSMIT) ( + IN struct _EFI_TCP4 *This, + IN EFI_TCP4_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_RECEIVE) ( + IN struct _EFI_TCP4 *This, + IN EFI_TCP4_IO_TOKEN *Token + ); + +typedef struct { + EFI_TCP4_COMPLETION_TOKEN CompletionToken; + BOOLEAN AbortOnClose; +} EFI_TCP4_CLOSE_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_CLOSE)( + IN struct _EFI_TCP4 *This, + IN EFI_TCP4_CLOSE_TOKEN *CloseToken + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_CANCEL)( + IN struct _EFI_TCP4 *This, + IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_POLL) ( + IN struct _EFI_TCP4 *This + ); + +typedef struct _EFI_TCP4 { + EFI_TCP4_GET_MODE_DATA GetModeData; + EFI_TCP4_CONFIGURE Configure; + EFI_TCP4_ROUTES Routes; + EFI_TCP4_CONNECT Connect; + EFI_TCP4_ACCEPT Accept; + EFI_TCP4_TRANSMIT Transmit; + EFI_TCP4_RECEIVE Receive; + EFI_TCP4_CLOSE Close; + EFI_TCP4_CANCEL Cancel; + EFI_TCP4_POLL Poll; +} EFI_TCP4; + +typedef enum { + Tcp6StateClosed = 0, + Tcp6StateListen = 1, + Tcp6StateSynSent = 2, + Tcp6StateSynReceived = 3, + Tcp6StateEstablished = 4, + Tcp6StateFinWait1 = 5, + Tcp6StateFinWait2 = 6, + Tcp6StateClosing = 7, + Tcp6StateTimeWait = 8, + Tcp6StateCloseWait = 9, + Tcp6StateLastAck = 10 +} EFI_TCP6_CONNECTION_STATE; + +typedef struct { + EFI_IPv6_ADDRESS StationAddress; + UINT16 StationPort; + EFI_IPv6_ADDRESS RemoteAddress; + UINT16 RemotePort; + BOOLEAN ActiveFlag; +} EFI_TCP6_ACCESS_POINT; + +typedef struct { + UINT32 ReceiveBufferSize; + UINT32 SendBufferSize; + UINT32 MaxSynBackLog; + UINT32 ConnectionTimeout; + UINT32 DataRetries; + UINT32 FinTimeout; + UINT32 TimeWaitTimeout; + UINT32 KeepAliveProbes; + UINT32 KeepAliveTime; + UINT32 KeepAliveInterval; + BOOLEAN EnableNagle; + BOOLEAN EnableTimeStamp; + BOOLEAN EnableWindbowScaling; + BOOLEAN EnableSelectiveAck; + BOOLEAN EnablePathMtuDiscovery; +} EFI_TCP6_OPTION; + +typedef struct { + UINT8 TrafficClass; + UINT8 HopLimit; + EFI_TCP6_ACCESS_POINT AccessPoint; + EFI_TCP6_OPTION *ControlOption; +} EFI_TCP6_CONFIG_DATA; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_GET_MODE_DATA) ( + IN struct _EFI_TCP6 *This, + OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL, + OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL, + OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_CONFIGURE) ( + IN struct _EFI_TCP6 *This, + IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL + ); + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; +} EFI_TCP6_COMPLETION_TOKEN; + +typedef struct { + EFI_TCP6_COMPLETION_TOKEN CompletionToken; +} EFI_TCP6_CONNECTION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_CONNECT) ( + IN struct _EFI_TCP6 *This, + IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken + ); + +typedef struct { + EFI_TCP6_COMPLETION_TOKEN CompletionToken; + EFI_HANDLE NewChildHandle; +} EFI_TCP6_LISTEN_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_ACCEPT) ( + IN struct _EFI_TCP6 *This, + IN EFI_TCP6_LISTEN_TOKEN *ListenToken + ); + +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_TCP6_FRAGMENT_DATA; + +typedef struct { + BOOLEAN UrgentFlag; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_TCP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_TCP6_RECEIVE_DATA; + +typedef struct { + BOOLEAN Push; + BOOLEAN Urgent; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_TCP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_TCP6_TRANSMIT_DATA; + +typedef struct { + EFI_TCP6_COMPLETION_TOKEN CompletionToken; + union { + EFI_TCP6_RECEIVE_DATA *RxData; + EFI_TCP6_TRANSMIT_DATA *TxData; + } Packet; +} EFI_TCP6_IO_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_TRANSMIT) ( + IN struct _EFI_TCP6 *This, + IN EFI_TCP6_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_RECEIVE) ( + IN struct _EFI_TCP6 *This, + IN EFI_TCP6_IO_TOKEN *Token + ); + +typedef struct { + EFI_TCP6_COMPLETION_TOKEN CompletionToken; + BOOLEAN AbortOnClose; +} EFI_TCP6_CLOSE_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_CLOSE)( + IN struct _EFI_TCP6 *This, + IN EFI_TCP6_CLOSE_TOKEN *CloseToken + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_CANCEL)( + IN struct _EFI_TCP6 *This, + IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_POLL) ( + IN struct _EFI_TCP6 *This + ); + +typedef struct _EFI_TCP6 { + EFI_TCP6_GET_MODE_DATA GetModeData; + EFI_TCP6_CONFIGURE Configure; + EFI_TCP6_CONNECT Connect; + EFI_TCP6_ACCEPT Accept; + EFI_TCP6_TRANSMIT Transmit; + EFI_TCP6_RECEIVE Receive; + EFI_TCP6_CLOSE Close; + EFI_TCP6_CANCEL Cancel; + EFI_TCP6_POLL Poll; +} EFI_TCP6; + +#endif /* _EFI_TCP_H */ diff --git a/gnu-efi/inc/efiudp.h b/gnu-efi/inc/efiudp.h new file mode 100644 index 0000000..7c8b467 --- /dev/null +++ b/gnu-efi/inc/efiudp.h @@ -0,0 +1,272 @@ +#ifndef _EFI_UDP_H +#define _EFI_UDP_H + + +/*++ +Copyright (c) 2013 Intel Corporation + +--*/ + +#define EFI_UDP4_SERVICE_BINDING_PROTOCOL \ + { 0x83f01464, 0x99bd, 0x45e5, {0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6} } + +#define EFI_UDP4_PROTOCOL \ + { 0x3ad9df29, 0x4501, 0x478d, {0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3} } + +#define EFI_UDP6_SERVICE_BINDING_PROTOCOL \ + { 0x66ed4721, 0x3c98, 0x4d3e, {0x81, 0xe3, 0xd0, 0x3d, 0xd3, 0x9a, 0x72, 0x54} } + +#define EFI_UDP6_PROTOCOL \ + { 0x4f948815, 0xb4b9, 0x43cb, {0x8a, 0x33, 0x90, 0xe0, 0x60, 0xb3,0x49, 0x55} } + +INTERFACE_DECL(_EFI_UDP4); +INTERFACE_DECL(_EFI_UDP6); + +typedef struct { + BOOLEAN AcceptBroadcast; + BOOLEAN AcceptPromiscuous; + BOOLEAN AcceptAnyPort; + BOOLEAN AllowDuplicatePort; + UINT8 TypeOfService; + UINT8 TimeToLive; + BOOLEAN DoNotFragment; + UINT32 ReceiveTimeout; + UINT32 TransmitTimeout; + BOOLEAN UseDefaultAddress; + EFI_IPv4_ADDRESS StationAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT16 StationPort; + EFI_IPv4_ADDRESS RemoteAddress; + UINT16 RemotePort; +} EFI_UDP4_CONFIG_DATA; + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_GET_MODE_DATA) ( + IN struct _EFI_UDP4 *This, + OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL, + OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_CONFIGURE) ( + IN struct _EFI_UDP4 *This, + IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_GROUPS) ( + IN struct _EFI_UDP4 *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_ROUTES) ( + IN struct _EFI_UDP4 *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv4_ADDRESS *SubnetAddress, + IN EFI_IPv4_ADDRESS *SubnetMask, + IN EFI_IPv4_ADDRESS *GatewayAddress + ); + +#define EFI_NETWORK_UNREACHABLE EFIERR(100) +#define EFI_HOST_UNREACHABLE EFIERR(101) +#define EFI_PROTOCOL_UNREACHABLE EFIERR(102) +#define EFI_PORT_UNREACHABLE EFIERR(103) + +typedef struct { + EFI_IPv4_ADDRESS SourceAddress; + UINT16 SourcePort; + EFI_IPv4_ADDRESS DestinationAddress; + UINT16 DestinationPort; +} EFI_UDP4_SESSION_DATA; + +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_UDP4_FRAGMENT_DATA; + +typedef struct { + EFI_TIME TimeStamp; + EFI_EVENT RecycleSignal; + EFI_UDP4_SESSION_DATA UdpSession; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_UDP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_UDP4_RECEIVE_DATA; + +typedef struct { + EFI_UDP4_SESSION_DATA *UdpSessionData; + EFI_IPv4_ADDRESS *GatewayAddress; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_UDP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_UDP4_TRANSMIT_DATA; + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + union { + EFI_UDP4_RECEIVE_DATA *RxData; + EFI_UDP4_TRANSMIT_DATA *TxData; + } Packet; +} EFI_UDP4_COMPLETION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_TRANSMIT) ( + IN struct _EFI_UDP4 *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_RECEIVE) ( + IN struct _EFI_UDP4 *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_CANCEL)( + IN struct _EFI_UDP4 *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_POLL) ( + IN struct _EFI_UDP4 *This + ); + +typedef struct _EFI_UDP4 { + EFI_UDP4_GET_MODE_DATA GetModeData; + EFI_UDP4_CONFIGURE Configure; + EFI_UDP4_GROUPS Groups; + EFI_UDP4_ROUTES Routes; + EFI_UDP4_TRANSMIT Transmit; + EFI_UDP4_RECEIVE Receive; + EFI_UDP4_CANCEL Cancel; + EFI_UDP4_POLL Poll; +} EFI_UDP4; + +typedef struct { + BOOLEAN AcceptPromiscuous; + BOOLEAN AcceptAnyPort; + BOOLEAN AllowDuplicatePort; + UINT8 TrafficClass; + UINT8 HopLimit; + UINT32 ReceiveTimeout; + UINT32 TransmitTimeout; + EFI_IPv6_ADDRESS StationAddress; + UINT16 StationPort; + EFI_IPv6_ADDRESS RemoteAddress; + UINT16 RemotePort; +} EFI_UDP6_CONFIG_DATA; + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP6_GET_MODE_DATA) ( + IN struct _EFI_UDP6 *This, + OUT EFI_UDP6_CONFIG_DATA *Udp6ConfigData OPTIONAL, + OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP6_CONFIGURE) ( + IN struct _EFI_UDP6 *This, + IN EFI_UDP6_CONFIG_DATA *UdpConfigData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP6_GROUPS) ( + IN struct _EFI_UDP6 *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv6_ADDRESS *MulticastAddress OPTIONAL + ); + +typedef struct { + EFI_IPv6_ADDRESS SourceAddress; + UINT16 SourcePort; + EFI_IPv6_ADDRESS DestinationAddress; + UINT16 DestinationPort; +} EFI_UDP6_SESSION_DATA; + +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_UDP6_FRAGMENT_DATA; + +typedef struct { + EFI_TIME TimeStamp; + EFI_EVENT RecycleSignal; + EFI_UDP6_SESSION_DATA UdpSession; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_UDP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_UDP6_RECEIVE_DATA; + +typedef struct { + EFI_UDP6_SESSION_DATA *UdpSessionData; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_UDP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_UDP6_TRANSMIT_DATA; + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + union { + EFI_UDP6_RECEIVE_DATA *RxData; + EFI_UDP6_TRANSMIT_DATA *TxData; + } Packet; +} EFI_UDP6_COMPLETION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP6_TRANSMIT) ( + IN struct _EFI_UDP6 *This, + IN EFI_UDP6_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP6_RECEIVE) ( + IN struct _EFI_UDP6 *This, + IN EFI_UDP6_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP6_CANCEL)( + IN struct _EFI_UDP6 *This, + IN EFI_UDP6_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP6_POLL) ( + IN struct _EFI_UDP6 *This + ); + +typedef struct _EFI_UDP6 { + EFI_UDP6_GET_MODE_DATA GetModeData; + EFI_UDP6_CONFIGURE Configure; + EFI_UDP6_GROUPS Groups; + EFI_UDP6_TRANSMIT Transmit; + EFI_UDP6_RECEIVE Receive; + EFI_UDP6_CANCEL Cancel; + EFI_UDP6_POLL Poll; +} EFI_UDP6; + +#endif /* _EFI_UDP_H */ diff --git a/gnu-efi/inc/efiui.h b/gnu-efi/inc/efiui.h new file mode 100644 index 0000000..3756936 --- /dev/null +++ b/gnu-efi/inc/efiui.h @@ -0,0 +1,58 @@ +#ifndef _EFI_UI_H +#define _EFI_UI_H + +/*++ + +Copyright (c) 200 Intel Corporation + +Module Name: + + EfiUi.h + +Abstract: + Protocol used to build User Interface (UI) stuff. + + This protocol is just data. It is a multi dimentional array. + For each string there is an array of UI_STRING_ENTRY. Each string + is for a different language translation of the same string. The list + is terminated by a NULL UiString. There can be any number of + UI_STRING_ENTRY arrays. A NULL array terminates the list. A NULL array + entry contains all zeros. + + Thus the shortest possible EFI_UI_PROTOCOL has three UI_STRING_ENTRY. + The String, it's NULL terminator, and the NULL terminator for the entire + thing. + + +Revision History + +--*/ + +#define EFI_UI_INTERFACE_PROTOCOL_GUID \ + { 0x32dd7981, 0x2d27, 0x11d4, {0xbc, 0x8b, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } +#define EFI_UI_PROTOCOL EFI_UI_INTERFACE_PROTOCOL_GUID + + +typedef enum { + UiDeviceString, + UiVendorString, + UiMaxString +} UI_STRING_TYPE; + +typedef struct { + ISO_639_2 *LangCode; + CHAR16 *UiString; +} UI_STRING_ENTRY; + +#define EFI_UI_INTERFACE_PROTOCOL_VERSION 0x00010000 +#define EFI_UI_VERSION EFI_UI_INTERFACE_PROTOCOL_VERSION + +typedef struct _EFI_UI_INTERFACE_PROTOCOL { + UINT32 Version; + UI_STRING_ENTRY *Entry; +} EFI_UI_INTERFACE_PROTOCOL; + +typedef struct _EFI_UI_INTERFACE_PROTOCOL _UI_INTERFACE; +typedef EFI_UI_INTERFACE_PROTOCOL UI_INTERFACE; + +#endif diff --git a/gnu-efi/inc/libsmbios.h b/gnu-efi/inc/libsmbios.h new file mode 100644 index 0000000..8f1a28e --- /dev/null +++ b/gnu-efi/inc/libsmbios.h @@ -0,0 +1,132 @@ +#ifndef _LIB_SMBIOS_H +#define _LIB_SMBIOS_H +/*++ + +Copyright (c) 2000 Intel Corporation + +Module Name: + + LibSmbios.h + +Abstract: + + Lib include for SMBIOS services. Used to get system serial number and GUID + +Revision History + +--*/ + +// +// Define SMBIOS tables. +// +#pragma pack(1) +typedef struct { + UINT8 AnchorString[4]; + UINT8 EntryPointStructureChecksum; + UINT8 EntryPointLength; + UINT8 MajorVersion; + UINT8 MinorVersion; + UINT16 MaxStructureSize; + UINT8 EntryPointRevision; + UINT8 FormattedArea[5]; + UINT8 IntermediateAnchorString[5]; + UINT8 IntermediateChecksum; + UINT16 TableLength; + UINT32 TableAddress; + UINT16 NumberOfSmbiosStructures; + UINT8 SmbiosBcdRevision; +} SMBIOS_STRUCTURE_TABLE; + +// +// Please note that SMBIOS structures can be odd byte aligned since the +// unformated section of each record is a set of arbitrary size strings. +// + +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 Handle[2]; +} SMBIOS_HEADER; + +typedef UINT8 SMBIOS_STRING; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Vendor; + SMBIOS_STRING BiosVersion; + UINT8 BiosSegment[2]; + SMBIOS_STRING BiosReleaseDate; + UINT8 BiosSize; + UINT8 BiosCharacteristics[8]; +} SMBIOS_TYPE0; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Manufacturer; + SMBIOS_STRING ProductName; + SMBIOS_STRING Version; + SMBIOS_STRING SerialNumber; + + // + // always byte copy this data to prevent alignment faults! + // + EFI_GUID Uuid; + + UINT8 WakeUpType; +} SMBIOS_TYPE1; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Manufacturer; + SMBIOS_STRING ProductName; + SMBIOS_STRING Version; + SMBIOS_STRING SerialNumber; +} SMBIOS_TYPE2; + +typedef struct { + SMBIOS_HEADER Hdr; + SMBIOS_STRING Manufacturer; + UINT8 Type; + SMBIOS_STRING Version; + SMBIOS_STRING SerialNumber; + SMBIOS_STRING AssetTag; + UINT8 BootupState; + UINT8 PowerSupplyState; + UINT8 ThermalState; + UINT8 SecurityStatus; + UINT8 OemDefined[4]; +} SMBIOS_TYPE3; + +typedef struct { + SMBIOS_HEADER Hdr; + UINT8 Socket; + UINT8 ProcessorType; + UINT8 ProcessorFamily; + SMBIOS_STRING ProcessorManufacture; + UINT8 ProcessorId[8]; + SMBIOS_STRING ProcessorVersion; + UINT8 Voltage; + UINT8 ExternalClock[2]; + UINT8 MaxSpeed[2]; + UINT8 CurrentSpeed[2]; + UINT8 Status; + UINT8 ProcessorUpgrade; + UINT8 L1CacheHandle[2]; + UINT8 L2CacheHandle[2]; + UINT8 L3CacheHandle[2]; +} SMBIOS_TYPE4; + +typedef union { + SMBIOS_HEADER *Hdr; + SMBIOS_TYPE0 *Type0; + SMBIOS_TYPE1 *Type1; + SMBIOS_TYPE2 *Type2; + SMBIOS_TYPE3 *Type3; + SMBIOS_TYPE4 *Type4; + UINT8 *Raw; +} SMBIOS_STRUCTURE_POINTER; +#pragma pack() + + +#endif + diff --git a/gnu-efi/inc/pci22.h b/gnu-efi/inc/pci22.h new file mode 100644 index 0000000..b94f519 --- /dev/null +++ b/gnu-efi/inc/pci22.h @@ -0,0 +1,193 @@ +#ifndef _PCI22_H +#define _PCI22_H + +/*++ + +Copyright (c) 1999 Intel Corporation + +Module Name: + + pci22.h + +Abstract: + Support for PCI 2.2 standard. + + + + +Revision History + +--*/ + +#ifdef SOFT_SDV +#define PCI_MAX_BUS 1 +#else +#define PCI_MAX_BUS 255 +#endif + +#define PCI_MAX_DEVICE 31 +#define PCI_MAX_FUNC 7 + +// +// Command +// +#define PCI_VGA_PALETTE_SNOOP_DISABLED 0x20 + +#pragma pack(1) +typedef struct { + UINT16 VendorId; + UINT16 DeviceId; + UINT16 Command; + UINT16 Status; + UINT8 RevisionID; + UINT8 ClassCode[3]; + UINT8 CacheLineSize; + UINT8 LaytencyTimer; + UINT8 HeaderType; + UINT8 BIST; +} PCI_DEVICE_INDEPENDENT_REGION; + +typedef struct { + UINT32 Bar[6]; + UINT32 CISPtr; + UINT16 SubsystemVendorID; + UINT16 SubsystemID; + UINT32 ExpansionRomBar; + UINT32 Reserved[2]; + UINT8 InterruptLine; + UINT8 InterruptPin; + UINT8 MinGnt; + UINT8 MaxLat; +} PCI_DEVICE_HEADER_TYPE_REGION; + +typedef struct { + PCI_DEVICE_INDEPENDENT_REGION Hdr; + PCI_DEVICE_HEADER_TYPE_REGION Device; +} PCI_TYPE00; + +typedef struct { + UINT32 Bar[2]; + UINT8 PrimaryBus; + UINT8 SecondaryBus; + UINT8 SubordinateBus; + UINT8 SecondaryLatencyTimer; + UINT8 IoBase; + UINT8 IoLimit; + UINT16 SecondaryStatus; + UINT16 MemoryBase; + UINT16 MemoryLimit; + UINT16 PrefetchableMemoryBase; + UINT16 PrefetchableMemoryLimit; + UINT32 PrefetchableBaseUpper32; + UINT32 PrefetchableLimitUpper32; + UINT16 IoBaseUpper16; + UINT16 IoLimitUpper16; + UINT32 Reserved; + UINT32 ExpansionRomBAR; + UINT8 InterruptLine; + UINT8 InterruptPin; + UINT16 BridgeControl; +} PCI_BRIDGE_CONTROL_REGISTER; + +#define PCI_CLASS_DISPLAY_CTRL 0x03 +#define PCI_CLASS_VGA 0x00 + +#define PCI_CLASS_BRIDGE 0x06 +#define PCI_CLASS_ISA 0x01 +#define PCI_CLASS_ISA_POSITIVE_DECODE 0x80 + +#define PCI_CLASS_NETWORK 0x02 +#define PCI_CLASS_ETHERNET 0x00 + +#define HEADER_TYPE_DEVICE 0x00 +#define HEADER_TYPE_PCI_TO_PCI_BRIDGE 0x01 +#define HEADER_TYPE_MULTI_FUNCTION 0x80 +#define HEADER_LAYOUT_CODE 0x7f + +#define IS_PCI_BRIDGE(_p) ((((_p)->Hdr.HeaderType) & HEADER_LAYOUT_CODE) == HEADER_TYPE_PCI_TO_PCI_BRIDGE) +#define IS_PCI_MULTI_FUNC(_p) (((_p)->Hdr.HeaderType) & HEADER_TYPE_MULTI_FUNCTION) + +typedef struct { + PCI_DEVICE_INDEPENDENT_REGION Hdr; + PCI_BRIDGE_CONTROL_REGISTER Bridge; +} PCI_TYPE01; + +typedef struct { + UINT8 Register; + UINT8 Function; + UINT8 Device; + UINT8 Bus; + UINT8 Reserved[4]; +} DEFIO_PCI_ADDR; + +typedef struct { + UINT32 Reg : 8; + UINT32 Func : 3; + UINT32 Dev : 5; + UINT32 Bus : 8; + UINT32 Reserved: 7; + UINT32 Enable : 1; +} PCI_CONFIG_ACCESS_CF8; + +#pragma pack() + +#define EFI_ROOT_BRIDGE_LIST 'eprb' +typedef struct { + UINTN Signature; + + UINT16 BridgeNumber; + UINT16 PrimaryBus; + UINT16 SubordinateBus; + + EFI_DEVICE_PATH *DevicePath; + + LIST_ENTRY Link; +} PCI_ROOT_BRIDGE_ENTRY; + + +#define PCI_EXPANSION_ROM_HEADER_SIGNATURE 0xaa55 +#define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE 0x0EF1 +#define PCI_DATA_STRUCTURE_SIGNATURE EFI_SIGNATURE_32('P','C','I','R') + +#pragma pack(1) +typedef struct { + UINT16 Signature; // 0xaa55 + UINT8 Reserved[0x16]; + UINT16 PcirOffset; +} PCI_EXPANSION_ROM_HEADER; + + +typedef struct { + UINT16 Signature; // 0xaa55 + UINT16 InitializationSize; + UINT16 EfiSignature; // 0x0EF1 + UINT16 EfiSubsystem; + UINT16 EfiMachineType; + UINT8 Reserved[0x0A]; + UINT16 EfiImageHeaderOffset; + UINT16 PcirOffset; +} EFI_PCI_EXPANSION_ROM_HEADER; + +typedef struct { + UINT32 Signature; // "PCIR" + UINT16 VendorId; + UINT16 DeviceId; + UINT16 Reserved0; + UINT16 Length; + UINT8 Revision; + UINT8 ClassCode[3]; + UINT16 ImageLength; + UINT16 CodeRevision; + UINT8 CodeType; + UINT8 Indicator; + UINT16 Reserved1; +} PCI_DATA_STRUCTURE; +#pragma pack() + +#endif + + + + + + diff --git a/gnu-efi/inc/romload.h b/gnu-efi/inc/romload.h new file mode 100644 index 0000000..0506011 --- /dev/null +++ b/gnu-efi/inc/romload.h @@ -0,0 +1,41 @@ +#ifndef _EFI_ROMLOAD_H +#define _EFI_ROMLOAD_H + +#define ROM_SIGNATURE 0xaa55 +#define PCIDS_SIGNATURE "PCIR" +#pragma pack(push) +#pragma pack(1) +typedef struct +{ + UINT8 Pcids_Sig[4]; + UINT16 VendId; + UINT16 DevId; + UINT16 Vpd_Off; + UINT16 Size; + UINT8 Rev; + UINT8 Class_Code[3]; + UINT16 Image_Len; + UINT16 Rev_Lvl; + UINT8 Code_Type; + UINT8 Indi; + UINT16 Rsvd; +}PciDataStructure; +typedef struct +{ + UINT16 Size; + UINT32 Header_Sig; + UINT16 SubSystem; + UINT16 MachineType; + UINT8 Resvd[10]; + UINT16 EfiOffset; +}ArchData; +typedef struct +{ + UINT16 Rom_Sig; + ArchData Arch_Data; + UINT16 Pcids_Off; + UINT8 resvd[38]; +}RomHeader; +#pragma pack(pop) + +#endif diff --git a/gnu-efi/inc/x86_64/efibind.h b/gnu-efi/inc/x86_64/efibind.h new file mode 100644 index 0000000..ae40595 --- /dev/null +++ b/gnu-efi/inc/x86_64/efibind.h @@ -0,0 +1,392 @@ +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efefind.h + +Abstract: + + EFI to compile bindings + + + + +Revision History + +--*/ +#ifndef X86_64_EFI_BIND +#define X86_64_EFI_BIND +#ifndef __GNUC__ +#pragma pack() +#endif + +#if defined(GNU_EFI_USE_MS_ABI) + #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))||(defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 2))) + #define HAVE_USE_MS_ABI 1 + #else + #error Compiler is too old for GNU_EFI_USE_MS_ABI + #endif +#endif + +// +// Basic int types of various widths +// + +#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) + + // No ANSI C 1999/2000 stdint.h integer width declarations + + #if defined(_MSC_EXTENSIONS) + + // Use Microsoft C compiler integer width declarations + + typedef unsigned __int64 uint64_t; + typedef __int64 int64_t; + typedef unsigned __int32 uint32_t; + typedef __int32 int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #elif defined(__GNUC__) + typedef int __attribute__((__mode__(__DI__))) int64_t; + typedef unsigned int __attribute__((__mode__(__DI__))) uint64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef signed char int8_t; + #elif defined(UNIX_LP64) + + /* Use LP64 programming model from C_FLAGS for integer width declarations */ + + typedef unsigned long uint64_t; + typedef long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #else + + /* Assume P64 programming model from C_FLAGS for integer width declarations */ + + typedef unsigned long long uint64_t __attribute__((aligned (8))); + typedef long long int64_t __attribute__((aligned (8))); + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #endif + typedef uint64_t uintptr_t; + typedef int64_t intptr_t; +#elif defined(__GNUC__) + #include +#endif + +// +// Basic EFI types of various widths +// + +#ifndef __WCHAR_TYPE__ +# define __WCHAR_TYPE__ short +#endif + +typedef uint64_t UINT64; +typedef int64_t INT64; + +#ifndef _BASETSD_H_ + typedef uint32_t UINT32; + typedef int32_t INT32; +#endif + +typedef uint16_t UINT16; +typedef int16_t INT16; +typedef uint8_t UINT8; +typedef int8_t INT8; +typedef __WCHAR_TYPE__ WCHAR; + +#undef VOID +#define VOID void + + +typedef int64_t INTN; +typedef uint64_t UINTN; + +#ifdef EFI_NT_EMULATOR + #define POST_CODE(_Data) +#else + #ifdef EFI_DEBUG +#define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al + #else + #define POST_CODE(_Data) + #endif +#endif + +#define EFIERR(a) (0x8000000000000000 | a) +#define EFI_ERROR_MASK 0x8000000000000000 +#define EFIERR_OEM(a) (0xc000000000000000 | a) + + +#define BAD_POINTER 0xFBFBFBFBFBFBFBFB +#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF + +#ifdef EFI_NT_EMULATOR + #define BREAKPOINT() __asm { int 3 } +#else + #define BREAKPOINT() while (TRUE); // Make it hang on Bios[Dbg]32 +#endif + +// +// Pointers must be aligned to these address to function +// + +#define MIN_ALIGNMENT_SIZE 4 + +#define ALIGN_VARIABLE(Value ,Adjustment) \ + (UINTN)Adjustment = 0; \ + if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ + (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ + Value = (UINTN)Value + (UINTN)Adjustment + + +// +// Define macros to build data structure signatures from characters. +// + +#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) +#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) +#define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32)) +// +// To export & import functions in the EFI emulator environment +// + +#ifdef EFI_NT_EMULATOR + #define EXPORTAPI __declspec( dllexport ) +#else + #define EXPORTAPI +#endif + + +// +// EFIAPI - prototype calling convention for EFI function pointers +// BOOTSERVICE - prototype for implementation of a boot service interface +// RUNTIMESERVICE - prototype for implementation of a runtime service interface +// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service +// RUNTIME_CODE - pragma macro for declaring runtime code +// + +#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options + #ifdef _MSC_EXTENSIONS + #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler + #elif defined(HAVE_USE_MS_ABI) + // Force amd64/ms calling conventions. + #define EFIAPI __attribute__((ms_abi)) + #else + #define EFIAPI // Substitute expresion to force C calling convention + #endif +#endif + +#define BOOTSERVICE +//#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a +//#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a +#define RUNTIMESERVICE +#define RUNTIMEFUNCTION + + +#define RUNTIME_CODE(a) alloc_text("rtcode", a) +#define BEGIN_RUNTIME_DATA() data_seg("rtdata") +#define END_RUNTIME_DATA() data_seg("") + +#define VOLATILE volatile + +#define MEMORY_FENCE() + +#ifdef EFI_NT_EMULATOR + +// +// To help ensure proper coding of integrated drivers, they are +// compiled as DLLs. In NT they require a dll init entry pointer. +// The macro puts a stub entry point into the DLL so it will load. +// + +#define EFI_DRIVER_ENTRY_POINT(InitFunction) \ + UINTN \ + __stdcall \ + _DllMainCRTStartup ( \ + UINTN Inst, \ + UINTN reason_for_call, \ + VOID *rserved \ + ) \ + { \ + return 1; \ + } \ + \ + int \ + EXPORTAPI \ + __cdecl \ + InitializeDriver ( \ + void *ImageHandle, \ + void *SystemTable \ + ) \ + { \ + return InitFunction(ImageHandle, SystemTable); \ + } + + + #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ + (_if)->LoadInternal(type, name, NULL) + +#else // EFI_NT_EMULATOR + +// +// When build similiar to FW, then link everything together as +// one big module. For the MSVC toolchain, we simply tell the +// linker what our driver init function is using /ENTRY. +// +#if defined(_MSC_EXTENSIONS) + #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ + __pragma(comment(linker, "/ENTRY:" # InitFunction)) +#else + #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ + UINTN \ + InitializeDriver ( \ + VOID *ImageHandle, \ + VOID *SystemTable \ + ) \ + { \ + return InitFunction(ImageHandle, \ + SystemTable); \ + } \ + \ + EFI_STATUS efi_main( \ + EFI_HANDLE image, \ + EFI_SYSTEM_TABLE *systab \ + ) __attribute__((weak, \ + alias ("InitializeDriver"))); +#endif + + #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ + (_if)->LoadInternal(type, name, entry) + +#endif // EFI_NT_EMULATOR + +// +// Some compilers don't support the forward reference construct: +// typedef struct XXXXX +// +// The following macro provide a workaround for such cases. +// +#ifdef NO_INTERFACE_DECL +#define INTERFACE_DECL(x) +#else +#if defined(__GNUC__) || defined(_MSC_EXTENSIONS) +#define INTERFACE_DECL(x) struct x +#else +#define INTERFACE_DECL(x) typedef struct x +#endif +#endif + +/* for x86_64, EFI_FUNCTION_WRAPPER must be defined */ +#if defined(HAVE_USE_MS_ABI) +#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__) +#else +/* + Credits for macro-magic: + https://groups.google.com/forum/?fromgroups#!topic/comp.std.c/d-6Mj5Lko_s + http://efesx.com/2010/08/31/overloading-macros/ +*/ +#define __VA_NARG__(...) \ + __VA_NARG_(_0, ## __VA_ARGS__, __RSEQ_N()) +#define __VA_NARG_(...) \ + __VA_ARG_N(__VA_ARGS__) +#define __VA_ARG_N( \ + _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,N,...) N +#define __RSEQ_N() \ + 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 + +#define __VA_ARG_NSUFFIX__(prefix,...) \ + __VA_ARG_NSUFFIX_N(prefix, __VA_NARG__(__VA_ARGS__)) +#define __VA_ARG_NSUFFIX_N(prefix,nargs) \ + __VA_ARG_NSUFFIX_N_(prefix, nargs) +#define __VA_ARG_NSUFFIX_N_(prefix,nargs) \ + prefix ## nargs + +/* Prototypes of EFI cdecl -> stdcall trampolines */ +UINT64 efi_call0(void *func); +UINT64 efi_call1(void *func, UINT64 arg1); +UINT64 efi_call2(void *func, UINT64 arg1, UINT64 arg2); +UINT64 efi_call3(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3); +UINT64 efi_call4(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, + UINT64 arg4); +UINT64 efi_call5(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, + UINT64 arg4, UINT64 arg5); +UINT64 efi_call6(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, + UINT64 arg4, UINT64 arg5, UINT64 arg6); +UINT64 efi_call7(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, + UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7); +UINT64 efi_call8(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, + UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7, + UINT64 arg8); +UINT64 efi_call9(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, + UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7, + UINT64 arg8, UINT64 arg9); +UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, + UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7, + UINT64 arg8, UINT64 arg9, UINT64 arg10); + +/* Front-ends to efi_callX to avoid compiler warnings */ +#define _cast64_efi_call0(f) \ + efi_call0(f) +#define _cast64_efi_call1(f,a1) \ + efi_call1(f, (UINT64)(a1)) +#define _cast64_efi_call2(f,a1,a2) \ + efi_call2(f, (UINT64)(a1), (UINT64)(a2)) +#define _cast64_efi_call3(f,a1,a2,a3) \ + efi_call3(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3)) +#define _cast64_efi_call4(f,a1,a2,a3,a4) \ + efi_call4(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4)) +#define _cast64_efi_call5(f,a1,a2,a3,a4,a5) \ + efi_call5(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ + (UINT64)(a5)) +#define _cast64_efi_call6(f,a1,a2,a3,a4,a5,a6) \ + efi_call6(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ + (UINT64)(a5), (UINT64)(a6)) +#define _cast64_efi_call7(f,a1,a2,a3,a4,a5,a6,a7) \ + efi_call7(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ + (UINT64)(a5), (UINT64)(a6), (UINT64)(a7)) +#define _cast64_efi_call8(f,a1,a2,a3,a4,a5,a6,a7,a8) \ + efi_call8(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ + (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8)) +#define _cast64_efi_call9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) \ + efi_call9(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ + (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8), \ + (UINT64)(a9)) +#define _cast64_efi_call10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \ + efi_call10(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ + (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8), \ + (UINT64)(a9), (UINT64)(a10)) + +/* main wrapper (va_num ignored) */ +#define uefi_call_wrapper(func,va_num,...) \ + __VA_ARG_NSUFFIX__(_cast64_efi_call, __VA_ARGS__) (func , ##__VA_ARGS__) + +#endif + +#if defined(HAVE_USE_MS_ABI) && !defined(_MSC_EXTENSIONS) + #define EFI_FUNCTION __attribute__((ms_abi)) +#else + #define EFI_FUNCTION +#endif + +#ifdef _MSC_EXTENSIONS +#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP +#endif + +#endif diff --git a/gnu-efi/inc/x86_64/efilibplat.h b/gnu-efi/inc/x86_64/efilibplat.h new file mode 100644 index 0000000..3844578 --- /dev/null +++ b/gnu-efi/inc/x86_64/efilibplat.h @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efilibplat.h + +Abstract: + + EFI to compile bindings + + + + +Revision History + +--*/ + +VOID +InitializeLibPlatform ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + diff --git a/gnu-efi/inc/x86_64/efisetjmp_arch.h b/gnu-efi/inc/x86_64/efisetjmp_arch.h new file mode 100644 index 0000000..b1ad1fe --- /dev/null +++ b/gnu-efi/inc/x86_64/efisetjmp_arch.h @@ -0,0 +1,22 @@ +#ifndef GNU_EFI_X86_64_SETJMP_H +#define GNU_EFI_X86_64_SETJMP_H + +#define JMPBUF_ALIGN 8 + +typedef struct { + UINT64 Rbx; + UINT64 Rsp; + UINT64 Rbp; + + UINT64 Rdi; + UINT64 Rsi; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; + UINT64 Rip; + UINT64 MxCsr; + UINT8 XmmBuffer[160]; // XMM6 - XMM15 +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; + +#endif /* GNU_EFI_X86_64_SETJMP_H */ diff --git a/gnu-efi/inc/x86_64/pe.h b/gnu-efi/inc/x86_64/pe.h new file mode 100644 index 0000000..979b936 --- /dev/null +++ b/gnu-efi/inc/x86_64/pe.h @@ -0,0 +1,595 @@ +/* + PE32+ header file + */ +#ifndef _PE_H +#define _PE_H + +#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ +#define IMAGE_OS2_SIGNATURE 0x454E // NE +#define IMAGE_OS2_SIGNATURE_LE 0x454C // LE +#define IMAGE_NT_SIGNATURE 0x00004550 // PE00 +#define IMAGE_EDOS_SIGNATURE 0x44454550 // PEED + + +typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header + UINT16 e_magic; // Magic number + UINT16 e_cblp; // Bytes on last page of file + UINT16 e_cp; // Pages in file + UINT16 e_crlc; // Relocations + UINT16 e_cparhdr; // Size of header in paragraphs + UINT16 e_minalloc; // Minimum extra paragraphs needed + UINT16 e_maxalloc; // Maximum extra paragraphs needed + UINT16 e_ss; // Initial (relative) SS value + UINT16 e_sp; // Initial SP value + UINT16 e_csum; // Checksum + UINT16 e_ip; // Initial IP value + UINT16 e_cs; // Initial (relative) CS value + UINT16 e_lfarlc; // File address of relocation table + UINT16 e_ovno; // Overlay number + UINT16 e_res[4]; // Reserved words + UINT16 e_oemid; // OEM identifier (for e_oeminfo) + UINT16 e_oeminfo; // OEM information; e_oemid specific + UINT16 e_res2[10]; // Reserved words + UINT32 e_lfanew; // File address of new exe header + } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; + +typedef struct _IMAGE_OS2_HEADER { // OS/2 .EXE header + UINT16 ne_magic; // Magic number + UINT8 ne_ver; // Version number + UINT8 ne_rev; // Revision number + UINT16 ne_enttab; // Offset of Entry Table + UINT16 ne_cbenttab; // Number of bytes in Entry Table + UINT32 ne_crc; // Checksum of whole file + UINT16 ne_flags; // Flag UINT16 + UINT16 ne_autodata; // Automatic data segment number + UINT16 ne_heap; // Initial heap allocation + UINT16 ne_stack; // Initial stack allocation + UINT32 ne_csip; // Initial CS:IP setting + UINT32 ne_sssp; // Initial SS:SP setting + UINT16 ne_cseg; // Count of file segments + UINT16 ne_cmod; // Entries in Module Reference Table + UINT16 ne_cbnrestab; // Size of non-resident name table + UINT16 ne_segtab; // Offset of Segment Table + UINT16 ne_rsrctab; // Offset of Resource Table + UINT16 ne_restab; // Offset of resident name table + UINT16 ne_modtab; // Offset of Module Reference Table + UINT16 ne_imptab; // Offset of Imported Names Table + UINT32 ne_nrestab; // Offset of Non-resident Names Table + UINT16 ne_cmovent; // Count of movable entries + UINT16 ne_align; // Segment alignment shift count + UINT16 ne_cres; // Count of resource segments + UINT8 ne_exetyp; // Target Operating system + UINT8 ne_flagsothers; // Other .EXE flags + UINT16 ne_pretthunks; // offset to return thunks + UINT16 ne_psegrefbytes; // offset to segment ref. bytes + UINT16 ne_swaparea; // Minimum code swap area size + UINT16 ne_expver; // Expected Windows version number + } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER; + +// +// File header format. +// + +typedef struct _IMAGE_FILE_HEADER { + UINT16 Machine; + UINT16 NumberOfSections; + UINT32 TimeDateStamp; + UINT32 PointerToSymbolTable; + UINT32 NumberOfSymbols; + UINT16 SizeOfOptionalHeader; + UINT16 Characteristics; +} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; + +#define IMAGE_SIZEOF_FILE_HEADER 20 + +#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file. +#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references). +#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file. +#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file. +#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed. +#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine. +#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file +#define IMAGE_FILE_SYSTEM 0x1000 // System File. +#define IMAGE_FILE_DLL 0x2000 // File is a DLL. +#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed. + +#define IMAGE_FILE_MACHINE_UNKNOWN 0 +#define IMAGE_FILE_MACHINE_I386 0x14c // Intel 386. +#define IMAGE_FILE_MACHINE_R3000 0x162 // MIPS little-endian, 0540 big-endian +#define IMAGE_FILE_MACHINE_R4000 0x166 // MIPS little-endian +#define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP +#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x1c2 // Arm/Thumb +#define IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM PowerPC Little-Endian +#define IMAGE_FILE_MACHINE_IA64 0x200 // IA-64 +#define IMAGE_FILE_MACHINE_TAHOE 0x7cc // Intel EM machine +#define IMAGE_FILE_MACHINE_EBC 0xebc // EFI Byte Code +#define IMAGE_FILE_MACHINE_X64 0x8664 // x86_64 +// +// Directory format. +// + +typedef struct _IMAGE_DATA_DIRECTORY { + UINT32 VirtualAddress; + UINT32 Size; +} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; + +#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 + +// +// Optional header format. +// + +typedef struct _IMAGE_OPTIONAL_HEADER { + // + // Standard fields. + // + + UINT16 Magic; + UINT8 MajorLinkerVersion; + UINT8 MinorLinkerVersion; + UINT32 SizeOfCode; + UINT32 SizeOfInitializedData; + UINT32 SizeOfUninitializedData; + UINT32 AddressOfEntryPoint; + UINT32 BaseOfCode; + UINT32 BaseOfData; + + // + // NT additional fields. + // + + UINT32 ImageBase; + UINT32 SectionAlignment; + UINT32 FileAlignment; + UINT16 MajorOperatingSystemVersion; + UINT16 MinorOperatingSystemVersion; + UINT16 MajorImageVersion; + UINT16 MinorImageVersion; + UINT16 MajorSubsystemVersion; + UINT16 MinorSubsystemVersion; + UINT32 Reserved1; + UINT32 SizeOfImage; + UINT32 SizeOfHeaders; + UINT32 CheckSum; + UINT16 Subsystem; + UINT16 DllCharacteristics; + UINT32 SizeOfStackReserve; + UINT32 SizeOfStackCommit; + UINT32 SizeOfHeapReserve; + UINT32 SizeOfHeapCommit; + UINT32 LoaderFlags; + UINT32 NumberOfRvaAndSizes; + IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; +} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER; + +typedef struct _IMAGE_ROM_OPTIONAL_HEADER { + UINT16 Magic; + UINT8 MajorLinkerVersion; + UINT8 MinorLinkerVersion; + UINT32 SizeOfCode; + UINT32 SizeOfInitializedData; + UINT32 SizeOfUninitializedData; + UINT32 AddressOfEntryPoint; + UINT32 BaseOfCode; + UINT32 BaseOfData; + UINT32 BaseOfBss; + UINT32 GprMask; + UINT32 CprMask[4]; + UINT32 GpValue; +} IMAGE_ROM_OPTIONAL_HEADER, *PIMAGE_ROM_OPTIONAL_HEADER; + +#define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56 +#define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28 +#define IMAGE_SIZEOF_NT_OPTIONAL_HEADER 224 + +#define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b +#define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107 + +typedef struct _IMAGE_NT_HEADERS { + UINT32 Signature; + IMAGE_FILE_HEADER FileHeader; + IMAGE_OPTIONAL_HEADER OptionalHeader; +} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS; + +typedef struct _IMAGE_ROM_HEADERS { + IMAGE_FILE_HEADER FileHeader; + IMAGE_ROM_OPTIONAL_HEADER OptionalHeader; +} IMAGE_ROM_HEADERS, *PIMAGE_ROM_HEADERS; + +#define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER) \ + ((UINT32)ntheader + \ + FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) + \ + ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader \ + )) + + +// Subsystem Values + +#define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem. +#define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem. +#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem. +#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem. +#define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem. +#define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image run in the Posix character subsystem. + + +// Directory Entries + +#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory +#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory +#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory +#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory +#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory +#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table +#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory +#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // Description String +#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // Machine Value (MIPS GP) +#define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory +#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory + +// +// Section header format. +// + +#define IMAGE_SIZEOF_SHORT_NAME 8 + +typedef struct _IMAGE_SECTION_HEADER { + UINT8 Name[IMAGE_SIZEOF_SHORT_NAME]; + union { + UINT32 PhysicalAddress; + UINT32 VirtualSize; + } Misc; + UINT32 VirtualAddress; + UINT32 SizeOfRawData; + UINT32 PointerToRawData; + UINT32 PointerToRelocations; + UINT32 PointerToLinenumbers; + UINT16 NumberOfRelocations; + UINT16 NumberOfLinenumbers; + UINT32 Characteristics; +} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; + +#define IMAGE_SIZEOF_SECTION_HEADER 40 + +#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved. + +#define IMAGE_SCN_CNT_CODE 0x00000020 // Section contains code. +#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 // Section contains initialized data. +#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 // Section contains uninitialized data. + +#define IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved. +#define IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information. +#define IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image. +#define IMAGE_SCN_LNK_COMDAT 0x00001000 // Section contents comdat. + +#define IMAGE_SCN_ALIGN_1BYTES 0x00100000 // +#define IMAGE_SCN_ALIGN_2BYTES 0x00200000 // +#define IMAGE_SCN_ALIGN_4BYTES 0x00300000 // +#define IMAGE_SCN_ALIGN_8BYTES 0x00400000 // +#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default alignment if no others are specified. +#define IMAGE_SCN_ALIGN_32BYTES 0x00600000 // +#define IMAGE_SCN_ALIGN_64BYTES 0x00700000 // + +#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 // Section can be discarded. +#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 // Section is not cachable. +#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 // Section is not pageable. +#define IMAGE_SCN_MEM_SHARED 0x10000000 // Section is shareable. +#define IMAGE_SCN_MEM_EXECUTE 0x20000000 // Section is executable. +#define IMAGE_SCN_MEM_READ 0x40000000 // Section is readable. +#define IMAGE_SCN_MEM_WRITE 0x80000000 // Section is writeable. + +// +// Symbol format. +// + + +#define IMAGE_SIZEOF_SYMBOL 18 + +// +// Section values. +// +// Symbols have a section number of the section in which they are +// defined. Otherwise, section numbers have the following meanings: +// + +#define IMAGE_SYM_UNDEFINED (UINT16)0 // Symbol is undefined or is common. +#define IMAGE_SYM_ABSOLUTE (UINT16)-1 // Symbol is an absolute value. +#define IMAGE_SYM_DEBUG (UINT16)-2 // Symbol is a special debug item. + +// +// Type (fundamental) values. +// + +#define IMAGE_SYM_TYPE_NULL 0 // no type. +#define IMAGE_SYM_TYPE_VOID 1 // +#define IMAGE_SYM_TYPE_CHAR 2 // type character. +#define IMAGE_SYM_TYPE_SHORT 3 // type short integer. +#define IMAGE_SYM_TYPE_INT 4 // +#define IMAGE_SYM_TYPE_LONG 5 // +#define IMAGE_SYM_TYPE_FLOAT 6 // +#define IMAGE_SYM_TYPE_DOUBLE 7 // +#define IMAGE_SYM_TYPE_STRUCT 8 // +#define IMAGE_SYM_TYPE_UNION 9 // +#define IMAGE_SYM_TYPE_ENUM 10 // enumeration. +#define IMAGE_SYM_TYPE_MOE 11 // member of enumeration. +#define IMAGE_SYM_TYPE_BYTE 12 // +#define IMAGE_SYM_TYPE_WORD 13 // +#define IMAGE_SYM_TYPE_UINT 14 // +#define IMAGE_SYM_TYPE_DWORD 15 // + +// +// Type (derived) values. +// + +#define IMAGE_SYM_DTYPE_NULL 0 // no derived type. +#define IMAGE_SYM_DTYPE_POINTER 1 // pointer. +#define IMAGE_SYM_DTYPE_FUNCTION 2 // function. +#define IMAGE_SYM_DTYPE_ARRAY 3 // array. + +// +// Storage classes. +// + +#define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1 +#define IMAGE_SYM_CLASS_NULL 0 +#define IMAGE_SYM_CLASS_AUTOMATIC 1 +#define IMAGE_SYM_CLASS_EXTERNAL 2 +#define IMAGE_SYM_CLASS_STATIC 3 +#define IMAGE_SYM_CLASS_REGISTER 4 +#define IMAGE_SYM_CLASS_EXTERNAL_DEF 5 +#define IMAGE_SYM_CLASS_LABEL 6 +#define IMAGE_SYM_CLASS_UNDEFINED_LABEL 7 +#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8 +#define IMAGE_SYM_CLASS_ARGUMENT 9 +#define IMAGE_SYM_CLASS_STRUCT_TAG 10 +#define IMAGE_SYM_CLASS_MEMBER_OF_UNION 11 +#define IMAGE_SYM_CLASS_UNION_TAG 12 +#define IMAGE_SYM_CLASS_TYPE_DEFINITION 13 +#define IMAGE_SYM_CLASS_UNDEFINED_STATIC 14 +#define IMAGE_SYM_CLASS_ENUM_TAG 15 +#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16 +#define IMAGE_SYM_CLASS_REGISTER_PARAM 17 +#define IMAGE_SYM_CLASS_BIT_FIELD 18 +#define IMAGE_SYM_CLASS_BLOCK 100 +#define IMAGE_SYM_CLASS_FUNCTION 101 +#define IMAGE_SYM_CLASS_END_OF_STRUCT 102 +#define IMAGE_SYM_CLASS_FILE 103 +// new +#define IMAGE_SYM_CLASS_SECTION 104 +#define IMAGE_SYM_CLASS_WEAK_EXTERNAL 105 + +// type packing constants + +#define N_BTMASK 017 +#define N_TMASK 060 +#define N_TMASK1 0300 +#define N_TMASK2 0360 +#define N_BTSHFT 4 +#define N_TSHIFT 2 + +// MACROS + +// +// Communal selection types. +// + +#define IMAGE_COMDAT_SELECT_NODUPLICATES 1 +#define IMAGE_COMDAT_SELECT_ANY 2 +#define IMAGE_COMDAT_SELECT_SAME_SIZE 3 +#define IMAGE_COMDAT_SELECT_EXACT_MATCH 4 +#define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5 + +#define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1 +#define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2 +#define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3 + + +// +// Relocation format. +// + +typedef struct _IMAGE_RELOCATION { + UINT32 VirtualAddress; + UINT32 SymbolTableIndex; + UINT16 Type; +} IMAGE_RELOCATION; + +#define IMAGE_SIZEOF_RELOCATION 10 + +// +// I386 relocation types. +// + +#define IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary +#define IMAGE_REL_I386_DIR16 01 // Direct 16-bit reference to the symbols virtual address +#define IMAGE_REL_I386_REL16 02 // PC-relative 16-bit reference to the symbols virtual address +#define IMAGE_REL_I386_DIR32 06 // Direct 32-bit reference to the symbols virtual address +#define IMAGE_REL_I386_DIR32NB 07 // Direct 32-bit reference to the symbols virtual address, base not included +#define IMAGE_REL_I386_SEG12 011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address +#define IMAGE_REL_I386_SECTION 012 +#define IMAGE_REL_I386_SECREL 013 +#define IMAGE_REL_I386_REL32 024 // PC-relative 32-bit reference to the symbols virtual address + +// +// MIPS relocation types. +// + +#define IMAGE_REL_MIPS_ABSOLUTE 0 // Reference is absolute, no relocation is necessary +#define IMAGE_REL_MIPS_REFHALF 01 +#define IMAGE_REL_MIPS_REFWORD 02 +#define IMAGE_REL_MIPS_JMPADDR 03 +#define IMAGE_REL_MIPS_REFHI 04 +#define IMAGE_REL_MIPS_REFLO 05 +#define IMAGE_REL_MIPS_GPREL 06 +#define IMAGE_REL_MIPS_LITERAL 07 +#define IMAGE_REL_MIPS_SECTION 012 +#define IMAGE_REL_MIPS_SECREL 013 +#define IMAGE_REL_MIPS_REFWORDNB 042 +#define IMAGE_REL_MIPS_PAIR 045 + +// +// Alpha Relocation types. +// + +#define IMAGE_REL_ALPHA_ABSOLUTE 0x0 +#define IMAGE_REL_ALPHA_REFLONG 0x1 +#define IMAGE_REL_ALPHA_REFQUAD 0x2 +#define IMAGE_REL_ALPHA_GPREL32 0x3 +#define IMAGE_REL_ALPHA_LITERAL 0x4 +#define IMAGE_REL_ALPHA_LITUSE 0x5 +#define IMAGE_REL_ALPHA_GPDISP 0x6 +#define IMAGE_REL_ALPHA_BRADDR 0x7 +#define IMAGE_REL_ALPHA_HINT 0x8 +#define IMAGE_REL_ALPHA_INLINE_REFLONG 0x9 +#define IMAGE_REL_ALPHA_REFHI 0xA +#define IMAGE_REL_ALPHA_REFLO 0xB +#define IMAGE_REL_ALPHA_PAIR 0xC +#define IMAGE_REL_ALPHA_MATCH 0xD +#define IMAGE_REL_ALPHA_SECTION 0xE +#define IMAGE_REL_ALPHA_SECREL 0xF +#define IMAGE_REL_ALPHA_REFLONGNB 0x10 + +// +// IBM PowerPC relocation types. +// + +#define IMAGE_REL_PPC_ABSOLUTE 0x0000 // NOP +#define IMAGE_REL_PPC_ADDR64 0x0001 // 64-bit address +#define IMAGE_REL_PPC_ADDR32 0x0002 // 32-bit address +#define IMAGE_REL_PPC_ADDR24 0x0003 // 26-bit address, shifted left 2 (branch absolute) +#define IMAGE_REL_PPC_ADDR16 0x0004 // 16-bit address +#define IMAGE_REL_PPC_ADDR14 0x0005 // 16-bit address, shifted left 2 (load doubleword) +#define IMAGE_REL_PPC_REL24 0x0006 // 26-bit PC-relative offset, shifted left 2 (branch relative) +#define IMAGE_REL_PPC_REL14 0x0007 // 16-bit PC-relative offset, shifted left 2 (br cond relative) +#define IMAGE_REL_PPC_TOCREL16 0x0008 // 16-bit offset from TOC base +#define IMAGE_REL_PPC_TOCREL14 0x0009 // 16-bit offset from TOC base, shifted left 2 (load doubleword) + +#define IMAGE_REL_PPC_ADDR32NB 0x000A // 32-bit addr w/o image base +#define IMAGE_REL_PPC_SECREL 0x000B // va of containing section (as in an image sectionhdr) +#define IMAGE_REL_PPC_SECTION 0x000C // sectionheader number +#define IMAGE_REL_PPC_IFGLUE 0x000D // substitute TOC restore instruction iff symbol is glue code +#define IMAGE_REL_PPC_IMGLUE 0x000E // symbol is glue code; virtual address is TOC restore instruction + +#define IMAGE_REL_PPC_TYPEMASK 0x00FF // mask to isolate above values in IMAGE_RELOCATION.Type + +// Flag bits in IMAGE_RELOCATION.TYPE + +#define IMAGE_REL_PPC_NEG 0x0100 // subtract reloc value rather than adding it +#define IMAGE_REL_PPC_BRTAKEN 0x0200 // fix branch prediction bit to predict branch taken +#define IMAGE_REL_PPC_BRNTAKEN 0x0400 // fix branch prediction bit to predict branch not taken +#define IMAGE_REL_PPC_TOCDEFN 0x0800 // toc slot defined in file (or, data in toc) + +// +// Based relocation format. +// + +typedef struct _IMAGE_BASE_RELOCATION { + UINT32 VirtualAddress; + UINT32 SizeOfBlock; +// UINT16 TypeOffset[1]; +} IMAGE_BASE_RELOCATION, *PIMAGE_BASE_RELOCATION; + +#define IMAGE_SIZEOF_BASE_RELOCATION 8 + +// +// Based relocation types. +// + +#define IMAGE_REL_BASED_ABSOLUTE 0 +#define IMAGE_REL_BASED_HIGH 1 +#define IMAGE_REL_BASED_LOW 2 +#define IMAGE_REL_BASED_HIGHLOW 3 +#define IMAGE_REL_BASED_HIGHADJ 4 +#define IMAGE_REL_BASED_MIPS_JMPADDR 5 +#define IMAGE_REL_BASED_IA64_IMM64 9 +#define IMAGE_REL_BASED_DIR64 10 + +// +// Line number format. +// + +typedef struct _IMAGE_LINENUMBER { + union { + UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0. + UINT32 VirtualAddress; // Virtual address of line number. + } Type; + UINT16 Linenumber; // Line number. +} IMAGE_LINENUMBER; + +#define IMAGE_SIZEOF_LINENUMBER 6 + +// +// Archive format. +// + +#define IMAGE_ARCHIVE_START_SIZE 8 +#define IMAGE_ARCHIVE_START "!\n" +#define IMAGE_ARCHIVE_END "`\n" +#define IMAGE_ARCHIVE_PAD "\n" +#define IMAGE_ARCHIVE_LINKER_MEMBER "/ " +#define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// " + +typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER { + UINT8 Name[16]; // File member name - `/' terminated. + UINT8 Date[12]; // File member date - decimal. + UINT8 UserID[6]; // File member user id - decimal. + UINT8 GroupID[6]; // File member group id - decimal. + UINT8 Mode[8]; // File member mode - octal. + UINT8 Size[10]; // File member size - decimal. + UINT8 EndHeader[2]; // String to end header. +} IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER; + +#define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60 + +// +// DLL support. +// + +// +// Export Format +// + +typedef struct _IMAGE_EXPORT_DIRECTORY { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT16 MajorVersion; + UINT16 MinorVersion; + UINT32 Name; + UINT32 Base; + UINT32 NumberOfFunctions; + UINT32 NumberOfNames; + UINT32 *AddressOfFunctions; + UINT32 *AddressOfNames; + UINT32 *AddressOfNameOrdinals; +} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; + +// +// Import Format +// + +typedef struct _IMAGE_IMPORT_BY_NAME { + UINT16 Hint; + UINT8 Name[1]; +} IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME; + +typedef struct _IMAGE_THUNK_DATA { + union { + UINT32 Function; + UINT32 Ordinal; + PIMAGE_IMPORT_BY_NAME AddressOfData; + } u1; +} IMAGE_THUNK_DATA, *PIMAGE_THUNK_DATA; + +#define IMAGE_ORDINAL_FLAG 0x80000000 +#define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0) +#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) + +typedef struct _IMAGE_IMPORT_DESCRIPTOR { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT32 ForwarderChain; + UINT32 Name; + PIMAGE_THUNK_DATA FirstThunk; +} IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR; + +#endif diff --git a/gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o b/gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o new file mode 100644 index 0000000..43fa4c1 Binary files /dev/null and b/gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o differ diff --git a/gnu-efi/x86_64/gnuefi/libgnuefi.a b/gnu-efi/x86_64/gnuefi/libgnuefi.a new file mode 100644 index 0000000..ed1b03d Binary files /dev/null and b/gnu-efi/x86_64/gnuefi/libgnuefi.a differ diff --git a/gnu-efi/x86_64/gnuefi/reloc_x86_64.o b/gnu-efi/x86_64/gnuefi/reloc_x86_64.o new file mode 100644 index 0000000..73be003 Binary files /dev/null and b/gnu-efi/x86_64/gnuefi/reloc_x86_64.o differ diff --git a/gnu-efi/x86_64/lib/boxdraw.o b/gnu-efi/x86_64/lib/boxdraw.o new file mode 100644 index 0000000..81df938 Binary files /dev/null and b/gnu-efi/x86_64/lib/boxdraw.o differ diff --git a/gnu-efi/x86_64/lib/cmdline.o b/gnu-efi/x86_64/lib/cmdline.o new file mode 100644 index 0000000..d5e319f Binary files /dev/null and b/gnu-efi/x86_64/lib/cmdline.o differ diff --git a/gnu-efi/x86_64/lib/console.o b/gnu-efi/x86_64/lib/console.o new file mode 100644 index 0000000..6d634ae Binary files /dev/null and b/gnu-efi/x86_64/lib/console.o differ diff --git a/gnu-efi/x86_64/lib/crc.o b/gnu-efi/x86_64/lib/crc.o new file mode 100644 index 0000000..74b57b6 Binary files /dev/null and b/gnu-efi/x86_64/lib/crc.o differ diff --git a/gnu-efi/x86_64/lib/data.o b/gnu-efi/x86_64/lib/data.o new file mode 100644 index 0000000..9ef93f1 Binary files /dev/null and b/gnu-efi/x86_64/lib/data.o differ diff --git a/gnu-efi/x86_64/lib/debug.o b/gnu-efi/x86_64/lib/debug.o new file mode 100644 index 0000000..514ad16 Binary files /dev/null and b/gnu-efi/x86_64/lib/debug.o differ diff --git a/gnu-efi/x86_64/lib/dpath.o b/gnu-efi/x86_64/lib/dpath.o new file mode 100644 index 0000000..4206784 Binary files /dev/null and b/gnu-efi/x86_64/lib/dpath.o differ diff --git a/gnu-efi/x86_64/lib/error.o b/gnu-efi/x86_64/lib/error.o new file mode 100644 index 0000000..59bf93b Binary files /dev/null and b/gnu-efi/x86_64/lib/error.o differ diff --git a/gnu-efi/x86_64/lib/event.o b/gnu-efi/x86_64/lib/event.o new file mode 100644 index 0000000..31528f7 Binary files /dev/null and b/gnu-efi/x86_64/lib/event.o differ diff --git a/gnu-efi/x86_64/lib/exit.o b/gnu-efi/x86_64/lib/exit.o new file mode 100644 index 0000000..d623528 Binary files /dev/null and b/gnu-efi/x86_64/lib/exit.o differ diff --git a/gnu-efi/x86_64/lib/guid.o b/gnu-efi/x86_64/lib/guid.o new file mode 100644 index 0000000..fbccab1 Binary files /dev/null and b/gnu-efi/x86_64/lib/guid.o differ diff --git a/gnu-efi/x86_64/lib/hand.o b/gnu-efi/x86_64/lib/hand.o new file mode 100644 index 0000000..35a644e Binary files /dev/null and b/gnu-efi/x86_64/lib/hand.o differ diff --git a/gnu-efi/x86_64/lib/hw.o b/gnu-efi/x86_64/lib/hw.o new file mode 100644 index 0000000..f698cfc Binary files /dev/null and b/gnu-efi/x86_64/lib/hw.o differ diff --git a/gnu-efi/x86_64/lib/init.o b/gnu-efi/x86_64/lib/init.o new file mode 100644 index 0000000..0e8363d Binary files /dev/null and b/gnu-efi/x86_64/lib/init.o differ diff --git a/gnu-efi/x86_64/lib/libefi.a b/gnu-efi/x86_64/lib/libefi.a new file mode 100644 index 0000000..e9b3d47 Binary files /dev/null and b/gnu-efi/x86_64/lib/libefi.a differ diff --git a/gnu-efi/x86_64/lib/lock.o b/gnu-efi/x86_64/lib/lock.o new file mode 100644 index 0000000..f5e5c95 Binary files /dev/null and b/gnu-efi/x86_64/lib/lock.o differ diff --git a/gnu-efi/x86_64/lib/misc.o b/gnu-efi/x86_64/lib/misc.o new file mode 100644 index 0000000..0cdbc06 Binary files /dev/null and b/gnu-efi/x86_64/lib/misc.o differ diff --git a/gnu-efi/x86_64/lib/print.o b/gnu-efi/x86_64/lib/print.o new file mode 100644 index 0000000..1cdb332 Binary files /dev/null and b/gnu-efi/x86_64/lib/print.o differ diff --git a/gnu-efi/x86_64/lib/smbios.o b/gnu-efi/x86_64/lib/smbios.o new file mode 100644 index 0000000..57ca79c Binary files /dev/null and b/gnu-efi/x86_64/lib/smbios.o differ diff --git a/gnu-efi/x86_64/lib/sread.o b/gnu-efi/x86_64/lib/sread.o new file mode 100644 index 0000000..a682ad6 Binary files /dev/null and b/gnu-efi/x86_64/lib/sread.o differ diff --git a/gnu-efi/x86_64/lib/str.o b/gnu-efi/x86_64/lib/str.o new file mode 100644 index 0000000..7a4774c Binary files /dev/null and b/gnu-efi/x86_64/lib/str.o differ diff --git a/gnu-efi/x86_64/lib/x86_64/callwrap.o b/gnu-efi/x86_64/lib/x86_64/callwrap.o new file mode 100644 index 0000000..c8a6d30 Binary files /dev/null and b/gnu-efi/x86_64/lib/x86_64/callwrap.o differ diff --git a/gnu-efi/x86_64/lib/x86_64/efi_stub.o b/gnu-efi/x86_64/lib/x86_64/efi_stub.o new file mode 100644 index 0000000..32aa018 Binary files /dev/null and b/gnu-efi/x86_64/lib/x86_64/efi_stub.o differ diff --git a/gnu-efi/x86_64/lib/x86_64/initplat.o b/gnu-efi/x86_64/lib/x86_64/initplat.o new file mode 100644 index 0000000..4e1744b Binary files /dev/null and b/gnu-efi/x86_64/lib/x86_64/initplat.o differ diff --git a/gnu-efi/x86_64/lib/x86_64/math.o b/gnu-efi/x86_64/lib/x86_64/math.o new file mode 100644 index 0000000..94ae859 Binary files /dev/null and b/gnu-efi/x86_64/lib/x86_64/math.o differ diff --git a/gnu-efi/x86_64/lib/x86_64/setjmp.o b/gnu-efi/x86_64/lib/x86_64/setjmp.o new file mode 100644 index 0000000..3d9470e Binary files /dev/null and b/gnu-efi/x86_64/lib/x86_64/setjmp.o differ diff --git a/neutron.nbuild b/neutron.nbuild index f344b2f..d19a316 100644 --- a/neutron.nbuild +++ b/neutron.nbuild @@ -1,27 +1,22 @@ -.asm -src/muon/1stg.asm -src/muon/2stg.asm .c -src/quark-c/quark.c -src/quark-c/isr_wrapper.s -src/quark-c/a20.s -src/quark-c/stdlib.c +src/quark.c +src/isr_wrapper.s +src/a20.s +src/stdlib.c -src/quark-c/gui/gui.c -src/quark-c/gui/stdgui.c +src/gui/gui.c +src/gui/stdgui.c -src/quark-c/drivers/diskio.c -src/quark-c/drivers/gfx.c -src/quark-c/drivers/usb.c -src/quark-c/drivers/pci.c -src/quark-c/drivers/ata.c -src/quark-c/drivers/pic.c -src/quark-c/drivers/pit.c -src/quark-c/drivers/ps2.c -src/quark-c/drivers/acpi.c -src/quark-c/drivers/ps2_kbd.c -.crawout -build/quark.bin +src/drivers/diskio.c +src/drivers/gfx.c +src/drivers/usb.c +src/drivers/pci.c +src/drivers/ata.c +src/drivers/pic.c +src/drivers/pit.c +src/drivers/ps2.c +src/drivers/acpi.c +src/drivers/ps2_kbd.c .fs build/quark.bin>quark neutron.nbuild>nbuild \ No newline at end of file diff --git a/src/quark-c/a20.s b/src/a20.s similarity index 100% rename from src/quark-c/a20.s rename to src/a20.s diff --git a/src/quark-c/drivers/acpi.c b/src/drivers/acpi.c similarity index 94% rename from src/quark-c/drivers/acpi.c rename to src/drivers/acpi.c index 6fea5da..7ad542f 100644 --- a/src/quark-c/drivers/acpi.c +++ b/src/drivers/acpi.c @@ -46,13 +46,13 @@ uint32_t acpi_init(void){ } //Check the DSDT - if(!acpi_sdt_checksum((acpi_sdt_hdr_t*)fadt->dsdt)){ + if(!acpi_sdt_checksum((acpi_sdt_hdr_t*)(uint64_t)fadt->dsdt)){ gfx_verbose_println("Error: DSDT is not valid"); return 0; } //Search for the \_S5 package in DSDT - char* s5_addr = (char*)fadt->dsdt + sizeof(acpi_sdt_hdr_t); - uint32_t dsdt_len = *((uint32_t*)fadt->dsdt + 1) - sizeof(acpi_sdt_hdr_t); + char* s5_addr = (char*)(uint64_t)fadt->dsdt + sizeof(acpi_sdt_hdr_t); + uint32_t dsdt_len = *((uint32_t*)(uint64_t)fadt->dsdt + 1) - sizeof(acpi_sdt_hdr_t); while(dsdt_len-- > 0){ if(memcmp(s5_addr, "_S5_", 4) == 0) break; @@ -137,7 +137,7 @@ uint8_t acpi_sdt_checksum(acpi_sdt_hdr_t* rsdt){ // table mod 256 is zero, the table is valid uint8_t sum = 0; for(uint32_t i = 0; i < rsdt->len; i++){ - uint8_t byte = *(uint8_t*)((uint32_t)rsdt + i); + uint8_t byte = *(uint8_t*)((uint64_t)rsdt + i); sum += byte; } return sum == 0; diff --git a/src/quark-c/drivers/acpi.h b/src/drivers/acpi.h similarity index 100% rename from src/quark-c/drivers/acpi.h rename to src/drivers/acpi.h diff --git a/src/quark-c/drivers/ata.c b/src/drivers/ata.c similarity index 100% rename from src/quark-c/drivers/ata.c rename to src/drivers/ata.c diff --git a/src/quark-c/drivers/ata.h b/src/drivers/ata.h similarity index 100% rename from src/quark-c/drivers/ata.h rename to src/drivers/ata.h diff --git a/src/quark-c/drivers/diskio.c b/src/drivers/diskio.c similarity index 98% rename from src/quark-c/drivers/diskio.c rename to src/drivers/diskio.c index 53a34c1..860623b 100644 --- a/src/quark-c/drivers/diskio.c +++ b/src/drivers/diskio.c @@ -32,7 +32,7 @@ void diskio_init(void){ ata_read_sect(i >> 1, i & 1, 0, 1, buffer); //Go through all the partition entries for(uint8_t p = 0; p < 4; p++){ - uint32_t p_base = (uint32_t)buffer + 0x1BE + (p * 16); + uint64_t p_base = (uint64_t)buffer + 0x1BE + (p * 16); //Write the partition disk type, number and MBR entry number partitions[cur_part].device_type = DISK_PATA; partitions[cur_part].device_no = i; diff --git a/src/quark-c/drivers/diskio.h b/src/drivers/diskio.h similarity index 100% rename from src/quark-c/drivers/diskio.h rename to src/drivers/diskio.h diff --git a/src/quark-c/drivers/gfx.c b/src/drivers/gfx.c similarity index 99% rename from src/quark-c/drivers/gfx.c rename to src/drivers/gfx.c index fb0b317..8bd10b3 100644 --- a/src/quark-c/drivers/gfx.c +++ b/src/drivers/gfx.c @@ -43,7 +43,7 @@ color32_t* gfx_buffer(void){ */ void gfx_init(void){ //Read the VBE buffer pointer (it was written in memory by the second stage loader) - vbe_buffer = (color32_t*)(*(int*)(0x8FC00)); + vbe_buffer = (color32_t*)(*(uint64_t*)(0x8FC00UL)); //Read the display resolution uint32_t res = *(uint32_t*)(0x8FC04); res_y = res & 0xFFFF; diff --git a/src/quark-c/drivers/gfx.h b/src/drivers/gfx.h similarity index 100% rename from src/quark-c/drivers/gfx.h rename to src/drivers/gfx.h diff --git a/src/quark-c/drivers/pci.c b/src/drivers/pci.c similarity index 100% rename from src/quark-c/drivers/pci.c rename to src/drivers/pci.c diff --git a/src/quark-c/drivers/pci.h b/src/drivers/pci.h similarity index 100% rename from src/quark-c/drivers/pci.h rename to src/drivers/pci.h diff --git a/src/quark-c/drivers/pic.c b/src/drivers/pic.c similarity index 100% rename from src/quark-c/drivers/pic.c rename to src/drivers/pic.c diff --git a/src/quark-c/drivers/pic.h b/src/drivers/pic.h similarity index 100% rename from src/quark-c/drivers/pic.h rename to src/drivers/pic.h diff --git a/src/quark-c/drivers/pit.c b/src/drivers/pit.c similarity index 92% rename from src/quark-c/drivers/pit.c rename to src/drivers/pit.c index a9a12c0..6dacd85 100644 --- a/src/quark-c/drivers/pit.c +++ b/src/drivers/pit.c @@ -21,13 +21,13 @@ void pit_configure_irq0_ticks(uint16_t div){ //Configure channel 0 as lo-hi access, rate generation, 16-bit binary mode outb(PIT_MC, 0b00110100); //Save the flags and disable interrupts - __asm__ volatile("pushfl; cli"); + __asm__ volatile("pushfq; cli"); //Output lower bits of the divider outb(PIT_C0, div); //Output higher bits of the divider outb(PIT_C0, div >> 8); //Restore the flags, enabling interrupts if they were enabled before - __asm__ volatile("popfl"); + __asm__ volatile("popfq"); } /* diff --git a/src/quark-c/drivers/pit.h b/src/drivers/pit.h similarity index 100% rename from src/quark-c/drivers/pit.h rename to src/drivers/pit.h diff --git a/src/quark-c/drivers/ps2.c b/src/drivers/ps2.c similarity index 100% rename from src/quark-c/drivers/ps2.c rename to src/drivers/ps2.c diff --git a/src/quark-c/drivers/ps2.h b/src/drivers/ps2.h similarity index 100% rename from src/quark-c/drivers/ps2.h rename to src/drivers/ps2.h diff --git a/src/quark-c/drivers/ps2_kbd.c b/src/drivers/ps2_kbd.c similarity index 100% rename from src/quark-c/drivers/ps2_kbd.c rename to src/drivers/ps2_kbd.c diff --git a/src/quark-c/drivers/ps2_kbd.h b/src/drivers/ps2_kbd.h similarity index 100% rename from src/quark-c/drivers/ps2_kbd.h rename to src/drivers/ps2_kbd.h diff --git a/src/quark-c/drivers/usb.c b/src/drivers/usb.c similarity index 88% rename from src/quark-c/drivers/usb.c rename to src/drivers/usb.c index 65598c9..9c860e2 100644 --- a/src/quark-c/drivers/usb.c +++ b/src/drivers/usb.c @@ -24,8 +24,8 @@ void ehci_init(){ unsigned char ehci_add_cont(unsigned char b, unsigned char d){ //Add the controller to the list ehci_conts[ehci_cont_count].pci_addr = (b << 8) | d; - int bar0 = (((int)pci_read_config_16(b, d, 0, 0x12) << 16) | (int)pci_read_config_16(b, d, 0, 0x10)) & 0xFFFFFF00; - ehci_conts[ehci_cont_count].capreg_addr = (void*)bar0; + uint32_t bar0 = (((uint32_t)pci_read_config_16(b, d, 0, 0x12) << 16) | (uint32_t)pci_read_config_16(b, d, 0, 0x10)) & 0xFFFFFF00; + ehci_conts[ehci_cont_count].capreg_addr = (void*)(uint64_t)bar0; //Reset the controller //ehci_write_opreg_dw(ehci_cont_count, EHCI_OPREG_USBCMD, 2); //Wait for it to actually reset @@ -35,10 +35,10 @@ unsigned char ehci_add_cont(unsigned char b, unsigned char d){ ehci_write_opreg_dw(ehci_cont_count, EHCI_OPREG_USBINTR, 0); ehci_write_opreg_dw(ehci_cont_count, EHCI_OPREG_USBCMD, 0x00080031); //Decode some register values - int hcsparams = ehci_read_capreg(ehci_cont_count, EHCI_CAPREG_HCSPARAMS); + uint32_t hcsparams = ehci_read_capreg(ehci_cont_count, EHCI_CAPREG_HCSPARAMS); ehci_conts[ehci_cont_count].port_cnt = hcsparams; ehci_conts[ehci_cont_count].dbg_port = (hcsparams & ((1 << 23) | (1 << 22) | (1 << 21) | (1 << 20))) >> 20; - short hci_ver_bcd = ehci_read_capreg(ehci_cont_count, EHCI_CAPREG_HCIVERSION) & 0x0000FFFF; + uint16_t hci_ver_bcd = ehci_read_capreg(ehci_cont_count, EHCI_CAPREG_HCIVERSION) & 0x0000FFFF; ehci_conts[ehci_cont_count].hci_ver[0] = ((hci_ver_bcd & 0xF000) >> 24) + '0'; ehci_conts[ehci_cont_count].hci_ver[1] = ((hci_ver_bcd & 0x0F00) >> 16) + '0'; ehci_conts[ehci_cont_count].hci_ver[2] = '.'; diff --git a/src/quark-c/drivers/usb.h b/src/drivers/usb.h similarity index 100% rename from src/quark-c/drivers/usb.h rename to src/drivers/usb.h diff --git a/src/quark-c/fonts/font_neutral.h b/src/fonts/font_neutral.h similarity index 80% rename from src/quark-c/fonts/font_neutral.h rename to src/fonts/font_neutral.h index 089b038..edaba03 100644 --- a/src/quark-c/fonts/font_neutral.h +++ b/src/fonts/font_neutral.h @@ -22,33 +22,33 @@ static const unsigned char font_neutral[] = { 0x00, 0x00, 0x00, 0x00, 0x60, 0x18, 0x06, 0x00, 0x00, 0x00, 0x3E, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, 0x00, 0x62, 0x51, 0x49, 0x46, 0x00, 0x00, 0x22, 0x41, 0x49, 0x36, 0x00, 0x00, 0x0F, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x4F, 0x49, 0x49, 0x31, 0x00, 0x00, 0x3C, 0x4A, -0x49, 0x31, 0x00, 0x00, 0x41, 0x31, 0x0D, 0x03, 0x00, 0x00, 0x36, 0x49, 0x49, 0x36, 0x00, 0x00, +0x49, 0x31, 0x00, 0x00, 0x61, 0x19, 0x05, 0x03, 0x00, 0x00, 0x36, 0x49, 0x49, 0x36, 0x00, 0x00, 0x46, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x00, 0x02, 0x51, 0x09, 0x06, 0x00, 0x00, 0x3C, 0x42, 0x5A, 0x5C, 0x00, 0x00, 0x7E, 0x11, 0x11, 0x7E, 0x00, 0x00, 0x7F, 0x49, 0x49, 0x36, 0x00, 0x00, 0x3E, 0x41, 0x41, 0x22, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x7F, 0x49, 0x49, 0x41, 0x00, 0x00, 0x7F, 0x09, 0x09, 0x01, 0x00, 0x00, 0x3E, 0x41, 0x51, 0x71, 0x00, 0x00, 0x7F, 0x08, 0x08, 0x7F, 0x00, 0x00, -0x41, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x41, 0x41, 0x3F, 0x01, 0x00, 0x00, 0x7F, 0x08, 0x14, 0x63, -0x00, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x00, 0x00, 0x7F, 0x02, 0x02, 0x7F, 0x00, 0x00, 0x7F, 0x10, -0x20, 0x7F, 0x00, 0x00, 0x3E, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x7F, 0x09, 0x09, 0x06, 0x00, 0x00, +0x41, 0x7F, 0x41, 0x00, 0x00, 0x00, 0x41, 0x41, 0x3F, 0x01, 0x00, 0x00, 0x7F, 0x08, 0x14, 0x63, +0x00, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x00, 0x00, 0x7F, 0x02, 0x04, 0x02, 0x7F, 0x00, 0x7F, 0x08, +0x10, 0x7F, 0x00, 0x00, 0x3E, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x7F, 0x09, 0x09, 0x06, 0x00, 0x00, 0x3E, 0x41, 0x61, 0x7E, 0x00, 0x00, 0x7E, 0x09, 0x09, 0x76, 0x00, 0x00, 0x46, 0x49, 0x49, 0x31, -0x00, 0x00, 0x01, 0x01, 0x7F, 0x01, 0x00, 0x00, 0x3F, 0x40, 0x40, 0x3F, 0x00, 0x00, 0x3F, 0x40, -0x40, 0x3F, 0x00, 0x00, 0x3F, 0x40, 0x20, 0x40, 0x3F, 0x00, 0x67, 0x18, 0x18, 0x67, 0x00, 0x00, -0x43, 0x34, 0x0C, 0x03, 0x00, 0x00, 0x61, 0x51, 0x4D, 0x43, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, +0x00, 0x00, 0x01, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x3F, 0x40, 0x40, 0x3F, 0x00, 0x00, 0x1F, 0x20, +0x40, 0x20, 0x1F, 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x41, 0x22, 0x1C, 0x22, 0x41, 0x00, +0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x61, 0x59, 0x45, 0x43, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, 0x00, 0x06, 0x18, 0x60, 0x00, 0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x54, 0x54, 0x78, 0x00, 0x00, 0x7F, 0x48, 0x48, 0x30, 0x00, 0x00, 0x30, 0x48, 0x48, 0x48, -0x00, 0x00, 0x30, 0x48, 0x48, 0x7F, 0x00, 0x00, 0x38, 0x54, 0x54, 0x44, 0x00, 0x00, 0x7E, 0x09, +0x00, 0x00, 0x30, 0x48, 0x48, 0x7F, 0x00, 0x00, 0x38, 0x54, 0x54, 0x58, 0x00, 0x00, 0x7E, 0x09, 0x09, 0x01, 0x00, 0x00, 0x48, 0x54, 0x54, 0x3C, 0x00, 0x00, 0x7F, 0x08, 0x08, 0x70, 0x00, 0x00, -0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x40, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, +0x00, 0x7A, 0x00, 0x00, 0x00, 0x00, 0x40, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x3F, 0x40, 0x40, 0x00, 0x00, 0x00, 0x78, 0x04, 0x08, 0x04, 0x78, 0x00, 0x7C, 0x04, 0x04, 0x78, 0x00, 0x00, 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0xFC, 0x24, 0x24, 0x18, 0x00, 0x00, -0x18, 0x24, 0x24, 0xFC, 0x00, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x00, 0x00, 0x48, 0x54, 0x54, 0x24, -0x00, 0x00, 0x04, 0x7F, 0x04, 0x00, 0x00, 0x00, 0x3C, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x3C, 0x40, -0x40, 0x3C, 0x00, 0x00, 0x3C, 0x40, 0x20, 0x40, 0x3C, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, -0x4C, 0x50, 0x50, 0x3C, 0x00, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x00, 0x00, 0x18, 0x7F, 0x41, 0x41, -0x41, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x18, 0x00, 0x10, 0x08, +0x18, 0x24, 0x24, 0xFC, 0x00, 0x00, 0x7C, 0x08, 0x04, 0x00, 0x00, 0x00, 0x48, 0x54, 0x54, 0x24, +0x00, 0x00, 0x04, 0x7F, 0x04, 0x00, 0x00, 0x00, 0x3C, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x1C, 0x20, +0x40, 0x3C, 0x00, 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, +0x4C, 0x50, 0x50, 0x3C, 0x00, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x00, 0x00, 0x08, 0x36, 0x41, 0x41, +0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x36, 0x08, 0x00, 0x10, 0x08, 0x10, 0x08, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/src/quark-c/gui/gui.c b/src/gui/gui.c similarity index 99% rename from src/quark-c/gui/gui.c rename to src/gui/gui.c index 7fa1ed0..85cd889 100644 --- a/src/quark-c/gui/gui.c +++ b/src/gui/gui.c @@ -141,7 +141,7 @@ void gui_destroy_window(window_t* win){ while((last = &windows[i++])->title); i--; //Calculate index of the deleted window in the window list - uint32_t idx = ((uint32_t)win - (uint32_t)windows) / sizeof(window_t); + uint32_t idx = ((uint64_t)win - (uint64_t)windows) / sizeof(window_t); //Move the windows that stand after one that we just deleted, one to the left for(uint32_t j = idx + 1; j < i; j++){ windows[j - 1] = windows[j]; diff --git a/src/quark-c/gui/gui.h b/src/gui/gui.h similarity index 100% rename from src/quark-c/gui/gui.h rename to src/gui/gui.h diff --git a/src/quark-c/gui/stdgui.c b/src/gui/stdgui.c similarity index 100% rename from src/quark-c/gui/stdgui.c rename to src/gui/stdgui.c diff --git a/src/quark-c/gui/stdgui.h b/src/gui/stdgui.h similarity index 100% rename from src/quark-c/gui/stdgui.h rename to src/gui/stdgui.h diff --git a/src/quark-c/images/neutron_logo.xbm b/src/images/neutron_logo.xbm similarity index 100% rename from src/quark-c/images/neutron_logo.xbm rename to src/images/neutron_logo.xbm diff --git a/src/quark-c/images/power.xbm b/src/images/power.xbm similarity index 100% rename from src/quark-c/images/power.xbm rename to src/images/power.xbm diff --git a/src/quark-c/images/system.xbm b/src/images/system.xbm similarity index 100% rename from src/quark-c/images/system.xbm rename to src/images/system.xbm diff --git a/src/quark-c/isr_wrapper.s b/src/isr_wrapper.s similarity index 75% rename from src/quark-c/isr_wrapper.s rename to src/isr_wrapper.s index 22f17f5..b08974c 100644 --- a/src/quark-c/isr_wrapper.s +++ b/src/isr_wrapper.s @@ -3,126 +3,126 @@ .align 4 exc_wrapper: - pop edx + pop rdx cld call quark_exc iret exc_wrapper_code: - pop ecx - pop edx + pop rcx + pop rdx cld call quark_exc iret irq0_wrap: - pushad + ;//pushaq push 0 call quark_irq add esp, 4 - popad + ;//popaq iret irq1_wrap: - pushad + ;//pushaq push 1 call quark_irq add esp, 4 - popad + ;//popaq iret irq2_wrap: - pushad + ;//pushaq push 2 call quark_irq add esp, 4 - popad + ;//popaq iret irq3_wrap: - pushad + ;//pushaq push 3 call quark_irq add esp, 4 - popad + ;//popaq iret irq4_wrap: - pushad + ;//pushaq push 4 call quark_irq add esp, 4 - popad + ;//popaq iret irq5_wrap: - pushad + ;//pushaq push 5 call quark_irq add esp, 4 - popad + ;//popaq iret irq6_wrap: - pushad + ;//pushaq push 6 call quark_irq add esp, 4 - popad + ;//popaq iret irq7_wrap: - pushad + ;//pushaq push 7 call quark_irq add esp, 4 - popad + ;//popaq iret irq8_wrap: - pushad + ;//pushaq push 8 call quark_irq add esp, 4 - popad + ;//popaq iret irq9_wrap: - pushad + ;//pushaq push 9 call quark_irq add esp, 4 - popad + ;//popaq iret irq10_wrap: - pushad + ;//pushaq push 10 call quark_irq add esp, 4 - popad + ;//popaq iret irq11_wrap: - pushad + ;//pushaq push 11 call quark_irq add esp, 4 - popad + ;//popaq iret irq12_wrap: - pushad + ;//pushaq push 12 call quark_irq add esp, 4 - popad + ;//popaq iret irq13_wrap: - pushad + ;//pushaq push 13 call quark_irq add esp, 4 - popad + ;//popaq iret irq14_wrap: - pushad + ;//pushaq push 14 call quark_irq add esp, 4 - popad + ;//popaq iret irq15_wrap: - pushad + ;//pushaq push 14 call quark_irq add esp, 4 - popad + ;//popaq iret diff --git a/src/muon/1stg.asm b/src/muon/1stg.asm deleted file mode 100644 index e392fe7..0000000 --- a/src/muon/1stg.asm +++ /dev/null @@ -1,128 +0,0 @@ -;Neutron project -;Muon - first stage loader - -org 0x7C00 -use16 - -entry: - cli ;Immediately disable interrupts - mov ax, 0x0300 - mov ss, ax - xor ax, ax - push dx ;save the boot drive number - xor ch, ch ;clear CH -lp: - xor ax, ax ;set the segment registers - mov ds, ax ;data segment - mov es, ax ;E data segment - mov fs, ax ;F data segment - mov gs, ax ;G data segment - call screen_clear ;clear the screen - xor bx, bx ;clear BX - mov ch, 0x0F ;set the colors: white on black - mov dx, startup_literal ;set the string to be printed - call print_str ;print the string - mov ax, 0x50 ; - mov es, ax ;set ES to the load ptr - xor bx, bx ;clear BX - mov al, 4 ;4 sectors to read - pop dx ;restore drive number - xor dh, dh ;head 0 - xor ch, ch ;cylinder 0 - mov cl, 2 ;sector 2 - mov ah, 2 ;BIOS routine no. - int 0x13 ;BIOS call - cmp ah, 0 ;compare return code with success - jne print_io_err ;print io err if not successful - xor bx, bx ;clear BX - mov ax, [es:bx] ;read the signature - cmp ax, 0xEBA1 ;check the signature - je run_2nd ;run the 2nd stage loader if successful - mov bx, 160 ;set the screen position: 1st line counting from 0 - mov ch, 0x0C ;set the colors: light red on black - mov dx, error_literal ;set the string to be printed - call print_str ;print the string - mov dx, error_bad_signature_literal ;set the string to be printed - call print_str ;print the string - jmp $ ;infinite loop -print_io_err: - mov bx, 160 ;set the screen position: 1st line counting from 0 - mov ch, 0x0C ;set the colors: light red on black - mov dx, error_literal ;set the string to be printed - call print_str ;print the string - mov dx, error_diskio_literal ;set the string to be printed - call print_str ;print the string - jmp $ ;infinite loop -run_2nd: - push 0x050 ;select the 2nd stage segment - pop gs ; - xor bx, bx ;and offset - mov [gs:bx], dl ;tell the drive number to the 2nd stage loader - mov bx, 160 ;set the screen position: 1st line counting from 0 - mov ch, 0x0A ;set the colors: light green on black - mov dx, successful_literal ;set the string to be printed - call print_str ;print the string - mov ax, 0x50 ; - jmp 0x050:0x0002 ;jump to the 2stg code - mov bx, 320 ;set the screen position: 1st line counting from 0 - mov ch, 0x0C ;set the colors: light red on black - mov dx, error_literal ;set the string to be printed - call print_str ;print the string - mov dx, error_noexec_literal ;set the string to be printed - call print_str ;print the string - jmp $ - -print_char: - push ds ;save the DS - mov ax, 0xB800 ; - mov ds, ax ;point to the VGA buffer - mov [bx], cx ;move the data to the buffer - pop ds ;restore the DS - add bx, 2 ;increment the pointer by 2 - ret ;return from subroutine - -print_str: - xchg bx, dx ;swap BX and DX - mov cl, [bx] ;load the char - xchg bx, dx ;swap BX and DX - cmp cl, 0 ;compare the char with 0 - je print_ret ;return if equal - call print_char ;print the char - inc dx ;increment the pointer - jmp print_str ;it's a loop after all -print_ret: - ret ;return from subroutine - -screen_clear: - xor bx, bx ;clear BX - xor cx, cx ;clear CX -screen_clear_loop: - call print_char ;print the char - cmp bx, 3999 ;check if we have reached the end of the screen - jge screen_clear_exit ;exit if so - jmp screen_clear_loop ;continue if not -screen_clear_exit: - ret ;return from subroutine - -startup_literal: db "Muon-1 [a part of nOS] has been started", 0 -error_literal: db "Load error: ", 0 -error_bad_signature_literal: db "bad signature", 0 -error_diskio_literal: db "disk I/O", 0 -error_noexec_literal: db "Muon-2 didn't execute", 0 -successful_literal: db "Executing Muon-2", 0 - -times 446-($-$$) db 0 ;fill-in - -;MBR partition table -mbr_part_entry_1: - mbr_pe1_status: db 0x80 - mbr_pe1_start_chs: db 0, 0, 0 - mbr_pe1_part_type: db 0x58 - mbr_pe1_end_chs: db 0, 0, 0 - mbr_pe1_start_lba: dd 9 - mbr_pe1_length_lba: dd 2872 -mbr_part_entry_2: dd 0, 0, 0, 0 -mbr_part_entry_3: dd 0, 0, 0, 0 -mbr_part_entry_4: dd 0, 0, 0, 0 - -dw 0xAA55 ;boot signature \ No newline at end of file diff --git a/src/muon/2stg.asm b/src/muon/2stg.asm deleted file mode 100644 index 45cd2f3..0000000 --- a/src/muon/2stg.asm +++ /dev/null @@ -1,241 +0,0 @@ -;Neutron project -;Muon - second stage loader - -%define nfs_buffer 0x800 -;%define use_verbose_selection - -org 0x0000 -use16 - -dw 0xEBA1 ;signature for the 1st stage loader - -entry: - mov ax, 0x600 ;load 0x600 into SS - mov ss, ax ; - mov sp, 0xFFFF ;set the stack pointer - cli ;disable interrupts - mov al, 0x80 ;disable non-maskable interrupts - out 0x70, al ; - mov ax, cs ; - mov ds, ax ;set DS to CS - mov byte al, [ds:0] ;fetch the drive number - mov byte [ds:nfs_drive_no], al ;tell it to the nFS driver - mov bx, 320 ;set the screen position: 2nd line counting from 0 - mov ch, 0x0F ;set the colors: white on black - call nfs_init ;read boot drive geometry - call nfs_load_master_sector ;load the nFS data - mov ch, 0x0F ;set the colors: white on black - jmp krnl ;try to load the kernel -krnl: - call krnl_load ;load the kernel - cmp ax, 0 ;check if the load was successful - jne krnl_ret ;return if not - push 0x93C0 ;segment 0x93C0 - this is where the map is stored - pop es ; - xor di, di ;clear DI - call map_memory ;map the memory - mov ch, 0x0F ;print the debug message - mov dx, krnl_debug_run ; - call print_str_line ; -%ifdef use_verbose_selection - push es ; - push ax ; - verbose_prompt: ; - mov ch, 0x0D ;print the verbose mode prompt - mov dx, krnl_verbose_prompt - call print_str_line ; - xor ah, ah ;input a character - int 16h ; - cmp al, 'v' ;check if V was pressed - jne v_prompt_not_v ; - push 0x8FC0 ;load 0x8C0 - pop es ;into ES - mov byte [es:16], 1 ;indicate the verbose mode - jmp v_prompt_escape ;escape - v_prompt_not_v: ; - cmp al, 'n' ;check if N was pressed - jne verbose_prompt ; - push 0x8FC0 ;load 0x8C0 - pop es ;into ES - mov byte [es:16], 0 ;indicate the normal mode - v_prompt_escape: ; - pop ax ; - pop es ; -%else - push es ; - push 0x8FC0 ;load 0x8C0 - pop es ;into ES - mov byte [es:16], 1 ;indicate the verbose mode - pop es ; -%endif - mov ch, 0x0F ;print another debug message - mov dx, krnl_debug_video; - call print_str ; - call gfx_go_best ;exit the text mode, as the kernel can't do it on its own - push 0x8FC0 ;load 0x8C0 - pop es ;into ES - mov [es:0], ecx ;save ECX (gfx buf linear address) in RAM - mov [es:4], edx ;save EDX (gfx resolution) in RAM - mov [es:8], ah ;save AH (gfx bits per pixel) in RAM - mov dl, [ds:nfs_drive_no] ;get the drive number - mov byte [es:9], dl ;save boot drive in RAM - jmp krnl_run ;run the kernel -krnl_ret: - mov ch, 0x0C - mov dx, krnl_error - call print_str_line - jmp $ -krnl_load: - ;load the kernel into RAM - mov dx, krnl_debug_ldstart ;print the debug message - mov ch, 0x0F ; - call print_str ; - push gs ;save the registers - push es ; - push si ; - push di ; - push ax ; - push dx ; - push ecx ; - push bx ; - mov ax, ds ;move DS - mov gs, ax ;into GS - mov ax, krnl_file ;find the kernel file - call nfs_find ; - cmp byte [ds:nfs_status], 0 ;check if the operation was successful - jne krnl_load_ret_err ;return immediately if not - mov bx, dx ;load DX into the indexing register - mov ax, [ds:bx+28] ;load the file location into AX - mov dx, [ds:bx+24] ;load the file size into DX - push 0xF0 ;load 0xF0 into - pop es ;ES - xor di, di ;clear DI -krnl_load_cycle: - cmp dx, 0 ;check if the entire file was read - jbe krnl_load_ret ;return if so - pop bx - push dx - push cx - mov dx, krnl_debug_ld - mov ch, 0x0F - call print_str - pop cx - pop dx - push bx - call nfs_read_drive_sector ;read one sector - cmp byte [ds:nfs_status], 0 ;check if the operation was successful - jne krnl_load_ret_err ;return immediately if not - mov ecx, 512 ;set the number of bytes to copy: 512 - mov si, nfs_buffer ;set SI to the nFS buffer - rep movsb ;copy the bytes - inc ax ;increment the sector number - cmp dx, 512 ;if less than a sector is remaining - jbe krnl_load_ret ;return - sub dx, 512 ;subtract the sector size from the file size - jmp krnl_load_cycle ;looping -krnl_load_ret_err: - pop bx ;restore the registers - pop ecx ; - pop dx ; - pop ax ; - pop di ; - pop si ; - pop es ; - pop gs ; - mov ax, 1 ;tell that the error occured - ret ;return from subroutine -krnl_load_ret: - pop bx ;restore the registers - pop ecx ; - pop dx ; - pop ax ; - pop di ; - pop si ; - pop es ; - pop gs ; - mov ax, 0 ;tell that the load was successfull - ret ;return from subroutine -krnl_run: - ;shit is getting unreal here - ;i mean, switch the CPU into the protected mode - ;(opposite of what we've had before up until now, the real mode) - cli ;disable interrupts - mov al, 0x80 ;disable non-maskable interrupts - out 0x70, al ; - mov ax, 0xEC00 ;notify the BIOS about us switching to the 32-bit protected mode - mov bl, 1 ; - int 15h ; - push 0x050 ;load 0x050 - pop ds ;into the data segment - mov ecx, gdt_end - gdt ;copy the entire GDT - mov si, gdt ;source: predefined GDT - push 0 ;destination: start of the memory - pop es ; - xor di, di ; - rep movsb ;copy - mov ecx, 6 ;copy the entire GDT descriptor - mov si, gdt_desc ;source: predefined GDT descriptor - xor di, di ;destination: start of the memory - rep movsb ;copy - xor dx, dx ;set DS to 0 - mov ds, dx ; - lgdt [0] ;Load Global Descriptor Table - push cs ;load CS into DS - pop ds ; - mov eax, cr0 ;load the control register 0 into EAX - or eax, 0x00000001 ;enable protected mode - mov cr0, eax ;load the EAX the control register 0 - ;YAAY! we're in Protected Mode now! - mov ax, 0x10 ;load 0x10 - mov ds, ax ;into DS - mov ss, ax ;and SS - mov es, ax ;and ES - mov fs, ax ;and FS - mov gs, ax ;and GS - mov esp, 0x4FFFFF ;set the top-of-stack pointer - pushf ;set IOPL to 3 - pop ax ; - or ax, 3 << 12 ; - push ax ; - popf ; - jmp 8:0xF00 ;far jump into the beforehand-loaded kernel - -%include "nfs_driver.asm" ;include the nFS driver -%include "gfx_driver.asm" ;include the graphics driver -%include "stdlib.asm" ;include the "standard library" - -krnl_error: db "An error occured while loading Quark", 0 -krnl_file: db "quark", 0 -krnl_debug_ldstart: db "Loading Quark", 0 -krnl_debug_ld: db ".", 0 -krnl_debug_run: db "done", 0 -krnl_debug_video: db "Choosing video mode", 0 -krnl_verbose_prompt: db "[v]erbose or [n]ormal mode?", 0 - -gdt: ;Global Descriptor Table -gdt_null: ;null segment - dd 0 - dd 0 -gdt_code: ;GDT code segment - dw 0xFFFF - dw 0 - db 0 - db 10011010b - db 11001111b - db 0 -gdt_data: ;GDT data segment - dw 0xFFFF - dw 0 - db 0 - db 10010010b - db 11001111b - db 0 -gdt_end: -gdt_desc: ;GDT descriptor - dw gdt_end - gdt - 1 - dd 0 ;we store GDT at the start of the memory - -reboot_cmd: - db 0xEA - dw 0x0000, 0xFFFF - ret diff --git a/src/muon/gfx_driver.asm b/src/muon/gfx_driver.asm deleted file mode 100644 index f3411a3..0000000 --- a/src/muon/gfx_driver.asm +++ /dev/null @@ -1,87 +0,0 @@ -;Neutron project -;Graphics driver - -gfx_go_best: ;switches the video mode to the best available one - ; Saves video buffer linear address into ECX, - ; resolution into EDX, bpp in AH - call gfx_get_mode_list ;get mode list pointer in ES:DI - gfx_go_best_loop: ; - mov dx, word [es:di] ;load a mode number - cmp dx, 0xffff ;0xffff = the end of the list - je gfx_go_best_ret ; - or dh, 1 << 6 ;set the linear framebuffer flag - push dx ;save DX - call gfx_get_mode ;get mode parameters - cmp ah, 32 ;only try 32bpp modes - jne gfx_go_best_skip ; - test al, 1 << 0 ;check if mode is supported - jz gfx_go_best_skip ; - test al, 1 << 4 ;check if mode is a graphical one - jz gfx_go_best_skip ; - cmp edx, [ds:gfx_best_res] ;compare the resolution with the best currently discovered one - jbe gfx_go_best_skip ; - mov [ds:gfx_best_res], edx ;if we hadn't skipped yet, store resolution and number - pop word [ds:gfx_best_mod] ; - push word [ds:gfx_best_mod] ; - gfx_go_best_skip: ; - pop dx ;restore DX - add di, 4 ;move on to the next mode - jmp gfx_go_best_loop ; - gfx_go_best_ret: ; - mov dx, [ds:gfx_best_mod] ;load the best mode - call gfx_go_mode ;go to it - ret ;return from subroutine - -gfx_go_mode: ;switches the video mode to one which number is stored in DX - ; Saves video buffer linear address into ECX, - ; resolution into EDX, bpp in AH - push bx ;save the registers - push es ; - mov ax, 4f02h ;set BIOS function: set VBE mode - mov bx, dx ;VBE mode - or bh, 01000000b ;raise the flag indicating that we want a flat video buffer - int 10h ;call BIOS routine - call gfx_get_mode ;get mode parameters - pop es ;restore the registers - pop bx ; - ret ;return from subroutine - -gfx_get_mode: ;returns information about a VBE mode - ;input: DX = mode number - ;output: ECX = linear framebuffer address - ; EDX = resolution - ; AH = bits per pixel - ; AL = lower bits of mode attributes - push di ;save DI - push es ;save ES - mov ax, 4f01h ;set BIOS function: get VBE mode properties - mov cx, dx ;VBE mode - push 0xf50 ;load info into 0xf50:0x0000 - pop es ; - xor di, di ; - int 10h ;call BIOS routine - mov dword ecx, [es:0x28] ;move the buffer linear address into ECX - movzx edx, word [es:0x12] ;load width - shl edx, 16 ; - mov dx, word [es:0x14] ;load height - mov ah, byte [es:0x19] ;load bits per pixel - mov al, byte [es:0x00] ;load mode attributes - pop es ;restore ES - pop di ;restore DI - ret ;return from subroutine - -gfx_get_mode_list: ;reads VBE mode list - ;output: list pointer in ES:DI - push 0x1050 ;load controller info into 0x1050:0x0000 - pop es ; - xor di, di ; - mov ax, 0x4f00 ; - int 10h ; - mov eax, dword [es:di+0xe] ;load the list pointer into EAX - mov di, ax ;AX[15:0] = DI - shr eax, 16 ; - mov es, ax ;AX[31:16] = ES - ret ;return from subroutine - -gfx_best_res: dd 0 ;the best resolution currently found by gfx_go_best -gfx_best_mod: dw 0 ;the number of the best resolution currently found by gfx_go_best \ No newline at end of file diff --git a/src/muon/nfs_driver.asm b/src/muon/nfs_driver.asm deleted file mode 100644 index 84a54fc..0000000 --- a/src/muon/nfs_driver.asm +++ /dev/null @@ -1,223 +0,0 @@ -;Neutron project -;nFS driver - -nfs_drive_no: db 0xFF -nfs_partition_no: db 0xFF -nfs_status: db 0xFF - -nfs_spt: db 18 -nfs_hds: db 2 - -nfs_part_name: db ' ', 0 -nfs_cluster_size: db 0xFF -nfs_mft_size: db 0xFF - -nfs_init: ;reads drive geometry - ;input: none - ;output: none - ; - test byte [ds:nfs_drive_no], 0x80 ;check if it's a hard drive - jz nfs_init_ret ;return immediately if not - ; - push ax ;save the registers - push dx ; - push cx ; - ; - mov ah, 8 ;int 13h function 8 - mov dl, [ds:nfs_drive_no] ;select drive - int 13h ; - add dh, 1 ;value in DH is one less than it should be, number of heads - and cl, 0x3F ;sectors per track - mov [ds:nfs_hds], dh ;store number of heads - mov [ds:nfs_spt], cl ;store sectors per track - ; - pop cx ;restore the registers - pop dx ; - pop ax ; - ; - nfs_init_ret: ; - ret ;return from subroutine - -nfs_read_drive_sector: ;reads a sector from the drive - ;input: AX = LBA of the sector - ; BL = 1 to force read - ; otherwise caching is used - ;output: nfs_status = 0 on success - ; 1 on disk I/O err - ; nfs_buffer contains valid data only if - ; nfs_status is 0 - ; - nop ; - nop ; - nop ; - nop ; - push ax ;save all registers - push bx ; - push cx ; - push dx ; - push es ; - xor bx, bx ;clear BX -nfs_rs_retry: ; - ; - push ds ;set the load segment to the data segment - pop es ;>> - ; - push bx ;save BX - push ax ;save AX - mov cl, [ds:nfs_spt] ;load sectors per track into CL - xor ch, ch ;clear CH - xor dx, dx ;clear DX - div cx ;divide DX:AX by CX, storing the quotient in AX and the remainder in DX - mov cl, dl ;store the remainder in CL - inc cl ;add 1 to CL - mov bl, [ds:nfs_hds] ;load heads into BL - xor bh, bh ;clear BH - xor dx, dx ;clear DX - div bx ;divide DX:AX by BX (BL), storing the quotient in AX and the remainder in DX - shl dx, 8 ;store the remainder in DH - shr al, 3 ;AL >>= 3 - and al, 0xC0 ;AL &= 0xC0 - or cl, al ;CL |= AL - mov al, [ds:nfs_spt] ;load Sectors Per Track into AL - mul byte [ds:nfs_hds] ;multiply AL by Heads and store the result in AX - mov bx, ax ;move SPT*HDS into BX - pop ax ;restore AX (original LBA) - push ax ;save AX - push dx ;save DX - xor dx, dx ;clear DX - div bx ;divide DX:AX (LBA) by BX (SPT*HDS), storing the quotient in AX and the remainder in DX - mov ch, al ;move AL into CH (cylinder for the BIOS) - pop dx ;restore DX - ; - mov dl, [ds:nfs_drive_no] ;set the drive number to load from - mov al, 1 ;set the amount of sectors to read: 1 - mov ah, 2 ;BIOS routine no.: disk read - mov bx, nfs_buffer ;set the target location: a buffer - int 0x13 ;execute the BIOS routine - pop ax ;restore AX - pop bx ;restore BX - jc nfs_rs_io_err ;I/O error handler - ;cmp ah, 0 ;check if the operation was successful - ;jne nfs_rs_io_err ;I/O error handler - mov byte [ds:nfs_status], 0 ;set the success flag - jmp nfs_read_sector_return ;jump straight to the return handler if the operation was successful -nfs_rs_io_err: - mov byte [ds:nfs_status], 1 ;set the disk I/O err flag - inc bh ;increment the error counter - cmp bh, 5 ;give it five tries - jae nfs_read_sector_return ; - push cx ; - mov cx, 10000 ;wait 10K iterations - nfs_rs_loop: loop nfs_rs_loop ; - pop cx ; - jmp nfs_rs_retry ; -nfs_read_sector_return: - pop es ;restore all registers - pop dx ; - pop cx ; - pop bx ; - pop ax ; - ret ;return from subroutine - -nfs_check_drive_fs: ;checks if a drive has valid nFS signature - ;input: none - ;output: nfs_status = 0 if drive has the correct signature - ; 1 on disk I/O err - ; 2 otherwise - ; - push ax ;save AX - ; - mov ax, 9 ;set the sector to be read: nFS master sector - call nfs_read_drive_sector ;read it - cmp byte [ds:nfs_status], 0 ;check if the read was successful - jne nfs_cdfs_return ;return from subroutine preserving the status code if not - cmp dword [ds:nfs_buffer], 0xDEADF500 ;check the signature - je nfs_cdfs_return ;return from subroutine if the signature is correct - mov byte [ds:nfs_status], 2 ;set the non-valid signature flag otherwise - jmp nfs_cdfs_return ;return from subroutine -nfs_cdfs_return: - pop ax ;restore EAX - ret ;return from subroutine - -nfs_load_master_sector: ;loads and parses the master sector info - ;input: nothing - ;output: nfs_status = 0 on success - ; 1 on disk I/O err - ; 2 on an incorrect signature - ; - push ax ;save all registers - push bx ; - xor bx, bx ;clear BX - call nfs_check_drive_fs ;check the signature - ;this has an added advantage of the sector already being buffered - cmp byte [ds:nfs_status], 0 ;check the success - jne nfs_lms_return ;return from subroutine preserving the status code if an error occured -nfs_lms_copy_loop: - add bx, 4 ;add the offset for the label - mov byte al, [ds:nfs_buffer+bx] ;intermediately load a byte - sub bx, 4 ;subtract it to return to the normal state - mov byte [ds:nfs_part_name+bx], al ;copy a byte - inc bx ;increment pointer - cmp bx, 19 ;terminate the copying at 18 bytes - je nfs_lms_return ;>> - jmp nfs_lms_copy_loop ;loop should be a loop -nfs_lms_return: - pop bx ;restore all registers - pop ax ; - ret ;return from subroutine - -nfs_load_master_filetable: ;loads the master file table - ;input: nothing - ;output: nfs_status = 0 on success - ; 1 on disk I/O err - ; - push ax ;save AX - mov ax, 10 ;set the sector to be read: master filetable - call nfs_read_drive_sector ;read the sector - pop ax ;restore AX - ret ;return from subroutine - -nfs_find: ;find a file on the disk - ;input: GS:AX = the target file name - ;output: nfs_status = 0 on success - ; 1 on disk I/O err - ; 2 if file wasn't found - ; DS:DX contains the found entry (only valid if nfs_status = 0) - push ax ;save AX - push cx ;save CX - push bx ;save BX - call nfs_load_master_filetable ;load the master file table - cmp byte [ds:nfs_status], 0 ;check if operation was successful - jne nfs_find_ret ;return preserving the status if not - xor bx, bx ;clear BX -nfs_find_search_loop: - mov dl, [ds:nfs_buffer+bx] ;load one byte from memory - cmp dl, 0 ;check if we've reached the end of the file list - je nfs_find_error_ret ;return from subroutine if so - mov dx, bx ;set the string to be compaed: candidate file name - add dx, nfs_buffer ;also add the buffer offset to the total one - pop cx ;restore screen pos - xchg bx, cx ;swap CX and BX - push ds ;move - pop fs ;FS <- DS - push ax ;save AX - call str_cmp ;compare the string at GS:AX (input) and FS:DX (candidate) - cmp al, 1 ;if they're equal - pop ax ;restore AX - je nfs_find_found_ret ;jump to the found routine - xchg bx, cx ;swap CX and BX - push cx ;save screen pos - add bx, 32 ;increment the pointer - jmp nfs_find_search_loop ;looping -nfs_find_ret: - pop bx ;restore BX - pop cx ;restore CX - pop ax ;restore AX - ret ;return from subroutine -nfs_find_error_ret: - mov byte [ds:nfs_status], 2 ;set the status code 2 - jmp nfs_find_ret ;return normally -nfs_find_found_ret: - push bx - mov byte [ds:nfs_status], 0 ;set the status code 0 - jmp nfs_find_ret ;return normally \ No newline at end of file diff --git a/src/muon/stdlib.asm b/src/muon/stdlib.asm deleted file mode 100644 index 51f7179..0000000 --- a/src/muon/stdlib.asm +++ /dev/null @@ -1,166 +0,0 @@ -;Neutron project -;Standard library for STG2 - -print_char: ;prints a char - ;input: CL = character to print - ; CH = color of the characther - ; BX = position - ; bx = (x * 80 + y) * 2 - ;output: character on the screen - ; BX = BX + 2 - ; - push ds ;save the DS - push 0xB800 ; - pop ds ;point to the VGA buffer - mov [ds:bx], cx ;move the data to the buffer - add bx, 2 ;increment the pointer by 2 - pop ds ;restore the DS - cmp bx, 4000 ;check if we're out of the screen bounds - je print_char_scroll ;scroll if so - ret ;return from subroutine -print_char_scroll: - call print_ln ;print a new line - ret ;return from subroutine - -print_str: ;prints a string - ;input: DS:DX = first character of the zero-terminated string - ; CH = color - ; BX = position - ; bx = (x * 80 + y) * 2 - ;output: string on the screen - ; BX = BX + 2 - ; - xchg bx, dx ;swap BX and DX - mov cl, [ds:bx] ;load the char - xchg bx, dx ;swap BX and DX - cmp cl, 0 ;compare the char with 0 - je print_ret ;return if equal - call print_char ;print the char - inc dx ;increment the pointer - jmp print_str ;it's a loop after all -print_ret: - ret ;return from subroutine - -print_32b_hex: - xor dx, dx - print_32b_hex_loop: - movzx si, al - and si, 0xf - mov cl, [ds:si+hex_num_const] - call print_char - shr eax, 4 - inc dx - cmp dx, 8 - jb print_32b_hex_loop - ret - -print_str_line: ;prints a string and then goes to a new line - ; - call print_str ;normal string printout - call print_ln ;go to the new line - ret - -print_ln: ;moves the text position one line down and scrolls if needed - ; - push dx ;save DX - xchg ax, bx ;swap AX and BX - xor dx, dx ;clear DX - mov cx, 160 ;set the dvider - div cx ;divide DX AX (AX) by CX (160) - inc ax ;go to the next line - cmp ax, 25 ;if we're out of the screen bounds - jl continue_print_ln ;continue execution - call shift_scrn_up ;shift the screen up - mov ax, 24 ;go to the last line - continue_print_ln: - mul cx ;multiply AX by CX (160) - xchg ax, bx ;swap AX and BX - pop dx ;restore DX - ret ;return from subroutine - -shift_scrn_up: - pusha ;save all registers - push cx ;save video attributes - mov ah, 6 ;select BIOS function: scroll up - mov cx, 0 ;top left corner: ln,col 0,0 - mov dh, 24 ;bottom right corner: ln 24 - mov dl, 79 ; col 79 - mov al, 1 ;add 1 line - pop bx ;restore video attributes - xor bl, bl ;clear BL - int 0x10 ;call BIOS routine - popa ;restore all registers - ret ;return from subroutine - -str_cmp: ;compares two strings - ;input: string1 = GS:AX - ; string2 = FS:DX - ;output: - ; AL = 0 if they aren't equal - ; AL = 1 if they are - push ax ;save AX - push bx ;save BX - push cx ;save CX - push dx ;save DX - mov bx, ax ;move AX to BX -str_cmp_loop: - mov bx, ax ;load AX into the indexing register - mov ch, [gs:bx] ;load str2 byte at the desired offset - mov bx, dx ;load DX into the indexing register - mov cl, [fs:bx] ;load str1 byte at the desired offset - cmp cl, ch ;compare str1 and str2 bytes at the desired offset - jne str_neq ;jump to the inequality return subroutine - mov bx, ax ;load AX into the indexing register - cmp byte [gs:bx], 0 ;compare str1 at the desired offset to zero - je str_zero_check ;check the second - inc ax ;increment the str1 offset - inc dx ;increment the str2 offset - jmp str_cmp_loop ;looping -str_neq: - pop dx ;restore DX - pop cx ;restore CX - pop bx ;restore BX - pop ax ;restore AX - xor al, al ;clear AL - ret ;return from subroutine -str_zero_check: - mov bx, dx ;load DX into the indexing register - cmp byte [fs:bx], 0 ;compare str2 at the desired offset to zero - je str_eq ;jump to the equality return subroutine - jmp str_neq ;jump to the inequality return subroutine -str_eq: - pop dx ;restore DX - pop cx ;restore CX - pop bx ;restore BX - pop ax ;restore AX - mov al, 1 ;set the AL to 1 - ret ;return from subroutine - -map_memory: ;makes the memory map - ;input: ES:DI = location to save the map to - ;output: the map at ES:DI - ; - pushad ;save the registers - xor ebx, ebx ;clear EBX - mov edx, 0x534D4150 ;magic -map_memory_cycle: ; - mov dword eax, 0xE820 ;magic - mov ecx, 24 ;magic - int 0x15 ;gently ask the BIOS - jc map_memory_done ;exit when done - cmp ebx, 0 ; - je map_memory_done ;the same thing - xor ch, ch ;clear CH - add di, cx ;increment the pointer - cmp cl, 24 ;Make all the entries - je map_memory_skip_add ;24-byte aligned - add di, 4 ; - map_memory_skip_add: ; - jmp map_memory_cycle ;do it again -map_memory_done: ; - add di, 20 ;zero the next entry out - mov dword [ds:di], 0 ;to indicate the end - popad ;restore the registers - ret ;return from subroutine - -hex_num_const: db '0123456789ABCDEF' \ No newline at end of file diff --git a/src/quark-c/quark.c b/src/quark.c similarity index 77% rename from src/quark-c/quark.c rename to src/quark.c index 4bc89d2..c0ad2d1 100644 --- a/src/quark-c/quark.c +++ b/src/quark.c @@ -1,6 +1,8 @@ //Neutron Project -//Quark-C - the C kernel -//(there previously was Quark, written in assembly language) +//Quark - the kernel + +#include +#include #include "./stdlib.h" @@ -45,6 +47,9 @@ extern void irq15_wrap(void); uint8_t quark_verbose; +//Pointer to the EFI system table +EFI_SYSTEM_TABLE* quark_efi_systable; + /* * This function is called whenever the user chooses the system color */ @@ -115,7 +120,15 @@ void quark_boot_status(char* str, uint32_t progress){ /* * The entry point for the kernel */ -void main(void){ +EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable){ + //Disable the watchdog timer + SystemTable->BootServices->SetWatchdogTimer(0, 0, 0, NULL); + //Save the system table pointer + quark_efi_systable = SystemTable; + //Print the boot string + SystemTable->ConOut->OutputString(SystemTable->ConOut, (CHAR16*)L"Neutron (UEFI version) is starting up"); + while(1); + //Disable interrupts __asm__ volatile("cli"); //Initialize x87 FPU @@ -134,32 +147,32 @@ void main(void){ struct idt_entry* idt = (struct idt_entry*)malloc(256 * sizeof(struct idt_entry)); //Set every exception IDT entry using the same pattern for(int i = 0; i < 32; i++){ - int wrapper_address = (int)&exc_wrapper; + uint64_t wrapper_address = (uint64_t)&exc_wrapper; if(i == 8 || (i >= 10 && i <= 14) || i == 17 || i == 30) //Set a special wrapper for exceptions that push error code onto stack - wrapper_address = (int)&exc_wrapper_code; - idt[i].offset_lower = wrapper_address & 0xFFFF; - idt[i].offset_higher = (wrapper_address >> 16) & 0xFFFF; + wrapper_address = (uint64_t)&exc_wrapper_code; + idt[i].offset_lower = (uint32_t)(uint64_t)wrapper_address & 0xFFFF; + idt[i].offset_higher = ((uint32_t)(uint64_t)wrapper_address >> 16) & 0xFFFF; idt[i].code_selector = 0x08; idt[i].zero = 0; idt[i].type_attr = 0b10001110; } //Set up gates for IRQs - idt[32] = IDT_ENTRY_ISR((uint32_t)&irq0_wrap); - idt[33] = IDT_ENTRY_ISR((uint32_t)&irq1_wrap); - idt[34] = IDT_ENTRY_ISR((uint32_t)&irq2_wrap); - idt[35] = IDT_ENTRY_ISR((uint32_t)&irq3_wrap); - idt[36] = IDT_ENTRY_ISR((uint32_t)&irq4_wrap); - idt[37] = IDT_ENTRY_ISR((uint32_t)&irq5_wrap); - idt[38] = IDT_ENTRY_ISR((uint32_t)&irq6_wrap); - idt[39] = IDT_ENTRY_ISR((uint32_t)&irq7_wrap); - idt[40] = IDT_ENTRY_ISR((uint32_t)&irq8_wrap); - idt[41] = IDT_ENTRY_ISR((uint32_t)&irq9_wrap); - idt[42] = IDT_ENTRY_ISR((uint32_t)&irq10_wrap); - idt[43] = IDT_ENTRY_ISR((uint32_t)&irq11_wrap); - idt[44] = IDT_ENTRY_ISR((uint32_t)&irq12_wrap); - idt[45] = IDT_ENTRY_ISR((uint32_t)&irq13_wrap); - idt[46] = IDT_ENTRY_ISR((uint32_t)&irq14_wrap); - idt[47] = IDT_ENTRY_ISR((uint32_t)&irq15_wrap); + idt[32] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq0_wrap); + idt[33] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq1_wrap); + idt[34] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq2_wrap); + idt[35] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq3_wrap); + idt[36] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq4_wrap); + idt[37] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq5_wrap); + idt[38] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq6_wrap); + idt[39] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq7_wrap); + idt[40] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq8_wrap); + idt[41] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq9_wrap); + idt[42] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq10_wrap); + idt[43] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq11_wrap); + idt[44] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq12_wrap); + idt[45] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq13_wrap); + idt[46] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq14_wrap); + idt[47] = IDT_ENTRY_ISR((uint32_t)(uint64_t)&irq15_wrap); //Load IDT idt_d.base = (void*)idt; idt_d.limit = 256 * sizeof(struct idt_entry); diff --git a/src/quark-c/stdlib.c b/src/stdlib.c similarity index 94% rename from src/quark-c/stdlib.c rename to src/stdlib.c index 32185b9..3bc9ce8 100644 --- a/src/quark-c/stdlib.c +++ b/src/stdlib.c @@ -55,25 +55,17 @@ void dram_init(void){ //Type=0 marks the end while((blk_type = *(uint32_t*)(block_base + 16)) != 0){ //Fetch block base - uint32_t base = *(uint32_t*)(block_base); - //Fetch block base upper bits - uint32_t base_upper = *(uint32_t*)(block_base + 4); + uint64_t base = *(uint64_t*)(block_base); //Fetch block length - uint32_t size = *(uint32_t*)(block_base + 8); - //Fetch block length upper bits - uint32_t size_upper = *(uint32_t*)(block_base + 12); + uint64_t size = *(uint64_t*)(block_base + 8); //Record the total amount of available RAM - total_ram_size += ((uint64_t)size_upper << 32) | ((uint64_t)size << 32); + total_ram_size += size; //Only record the block if it's marked as type 1 (usable RAM) - // and its base doesn't exceed 4 GB (upper bits are clear) - if(blk_type == 1 && size > 0 && base_upper == 0){ - //If size upper bytes are not zero, set the lower ones to the maximum value - if(size_upper > 0) - size = 0xFFFFFFFF; + if(blk_type == 1 && size > 0){ //Only record the block if it stretches over the fifth megabyte // and its size is larger than the currently found one if(size + base >= 5 * 1024 * 1024 && size > largest_blk_size){ - size_t shrink = (5 * 1024 * 1025) - base; + uint64_t shrink = (5 * 1024 * 1025) - base; size -= shrink; largest_blk_size = size; largset_blk_ptr = (void*)base + shrink; @@ -108,7 +100,7 @@ void* malloc(size_t size){ // have enough memory and need to crash if(first_free_block == NULL){ #ifdef STDLIB_CARSH_ON_ALLOC_ERR - crash_label_2: gfx_panic((uint32_t)&&crash_label_2, QUARK_PANIC_NOMEM_CODE); + crash_label_2: gfx_panic((uint64_t)&&crash_label_2, QUARK_PANIC_NOMEM_CODE); #else return NULL; #endif @@ -125,7 +117,7 @@ void* malloc(size_t size){ } //If we still didn't find free space, we defenitely don't have enough RAM #ifdef STDLIB_CARSH_ON_ALLOC_ERR - crash_label_3: gfx_panic((uint32_t)&&crash_label_3, QUARK_PANIC_NOMEM_CODE); + crash_label_3: gfx_panic((uint64_t)&&crash_label_3, QUARK_PANIC_NOMEM_CODE); #else return NULL; #endif @@ -179,7 +171,7 @@ void free(void* ptr){ /* * Allocate a block of memory and fill it with zeroes */ -void* calloc(uint32_t num, size_t size){ +void* calloc(uint64_t num, size_t size){ //Allocate the memory using malloc() void* malloc_res = malloc(num * size); if(malloc_res != NULL) //If the returned pointer isn't null, memset() with zeroes and return it @@ -191,7 +183,7 @@ void* calloc(uint32_t num, size_t size){ /* * Fill a chunk of memory with certain values */ -void* memset(void* dst, int ch, unsigned int size){ +void* memset(void* dst, int ch, size_t size){ //Convert ch to 8 bits unsigned char c = (unsigned char)ch; //Fill the chunk with them @@ -204,7 +196,7 @@ void* memset(void* dst, int ch, unsigned int size){ /* * Copy a block of memory */ -void* memcpy(void* destination, const void* source, uint32_t num){ +void* memcpy(void* destination, const void* source, size_t num){ //We can use the REP MOVx instruction to perform a blazing-fast memory-to-memory data transfer //D = 4 bytes at a time //W = 2 bytes at a time diff --git a/src/quark-c/stdlib.h b/src/stdlib.h similarity index 86% rename from src/quark-c/stdlib.h rename to src/stdlib.h index 7f964c8..394bd6c 100644 --- a/src/quark-c/stdlib.h +++ b/src/stdlib.h @@ -1,26 +1,26 @@ #ifndef STDLIB_H #define STDLIB_H -//Null pointer -#define NULL 0 +#ifndef NULL +#define NULL ((void*)0) +#endif //The address that dynamic memory allocation starts from #define STDLIB_DRAM_START 0x500000 //The quark version displayed on startup -#define QUARK_VERSION_STR "v0.1.11" +#define QUARK_VERSION_STR "v0.2.0" //Standard type definitions -typedef unsigned int size_t; typedef unsigned char uint8_t; typedef signed char int8_t; typedef unsigned short uint16_t; -typedef signed char int16_t; +typedef signed short int16_t; typedef unsigned int uint32_t; typedef signed int int32_t; -typedef unsigned long long uint64_t; -typedef signed long long int64_t; -typedef unsigned int size_t; +typedef long long unsigned int uint64_t; +typedef long long signed int int64_t; +typedef uint64_t size_t; /* * Structure defining a linked list node @@ -65,7 +65,7 @@ struct idt_entry { } __attribute__ ((packed)); //A macro that creates generic IDT entries -#define IDT_ENTRY(OFFS, CSEL, TYPE) ((struct idt_entry){.offset_lower = (OFFS) & 0xFFFF, .code_selector = CSEL, .zero = 0, .type_attr = TYPE, .offset_higher = (((OFFS) >> 16) & 0xFFFF)}) +#define IDT_ENTRY(OFFS, CSEL, TYPE) ((struct idt_entry){.offset_lower = ((uint32_t)OFFS) & 0xFFFF, .code_selector = ((uint32_t)CSEL), .zero = 0, .type_attr = TYPE, .offset_higher = ((((uint32_t)OFFS) >> 16) & 0xFFFF)}) //A macro that creates Quark ISR IDT entries #define IDT_ENTRY_ISR(OFFS) (IDT_ENTRY(OFFS, 8, 0b10001110)) @@ -100,12 +100,12 @@ uint32_t stdlib_usable_ram(void); void dram_init(void); void* malloc(size_t size); void free(void* ptr); -void* calloc(uint32_t num, size_t size); +void* calloc(uint64_t num, size_t size); //Memory operation functions -void* memset(void* dst, int ch, uint32_t size); -void* memcpy(void* destination, const void* source, uint32_t num); +void* memset(void* dst, int ch, size_t size); +void* memcpy(void* destination, const void* source, size_t num); //I/O port operation functions diff --git a/src/test.c b/src/test.c new file mode 100644 index 0000000..9925fea --- /dev/null +++ b/src/test.c @@ -0,0 +1,7 @@ +#include +#include + +EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable){ + SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Hello, UEFI!\n\r"); + while(1); +} \ No newline at end of file