Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
Upload Main Code
  • Loading branch information
Zero-Tang committed Mar 11, 2021
0 parents commit 6855439
Show file tree
Hide file tree
Showing 10 changed files with 507 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto

*.c linguist-language=C
*.h linguist-language=C
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
*.efi

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# Miscellaneous
*.cod
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 unknown

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.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# UefiDiskAccess
Simple Demo of Accessing Disks with Block I/O Protocol

## Introduction
This project is a simple demo of accessing disks using Block I/O Protocol in UEFI Environment.

## Requirement
To run this project, a working computer with UEFI firmware is required.

## Build
If it is your first time to build this project, you should run `build_prep.bat` to prepare for compilation. <br>
The required compiler for this project is Win64 LLVM. You may download it from [GitHub](https://github.com/llvm/llvm-project/releases). <br>
The required library for this project is TianoCore EDK II. You may download it from [GitHub](https://github.com/tianocore/edk2/releases). <br>
You are required to pre-compile the EDK II library. The method to compile is unofficial. You may use the script from [EDK II Library](https://github.com/MickeyMeowMeowHouse/EDK-II-Library) to build EDK II library. For detailed steps to pre-compile, consult that repository to proceed.

## Test
Setup a USB flash stick with GUID Partition Table (GPT). Construct a partition and format it into FAT32 file system. <br>
Copy the compiled `bootx64.efi` to `\EFI\BOOT\bootx64.efi` in your flash stick. <br>
Enter your firmware settings. Set the device option prior to the operating system. Disable Secure Boot unless you can sign the executable.

## License
This repository is under the MIT license.
22 changes: 22 additions & 0 deletions build/build_prep.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off

title Project: UefiDiskAccess, Preparation, UEFI (AMD64 Architecture)
echo Project: UefiDiskAccess
echo Platform: Unified Extensible Firmware Interface
echo Preset: Directory Build
echo Powered by [email protected]
pause.

echo Starting Compilation Preparations
mkdir ..\bin

echo Making Directories for UefiDiskAccess Checked Build, 64-Bit UEFI
mkdir ..\bin\compchk_uefix64
mkdir ..\bin\compchk_uefix64\Intermediate

echo Making Directories for UefiDiskAccess Free Build, 64-Bit UEFI
mkdir ..\bin\compfre_uefix64
mkdir ..\bin\compfre_uefix64\Intermediate

echo Preparation Completed!
pause.
13 changes: 13 additions & 0 deletions build/cleanup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off

title Project: UefiDiskAccess, Cleanup, UEFI (AMD64 Architecture)
echo Project: UefiDiskAccess
echo Platform: Unified Extensible Firmware Interface
echo Preset: Cleanup
echo Powered by [email protected]

del ..\bin\compchk_uefix64 /q /s
del ..\bin\compfre_uefix64 /q /s

echo Completed!
pause.
24 changes: 24 additions & 0 deletions build/compchk_uefix64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
set edkpath=C:\UefiDKII
set mdepath=C:\UefiDKII\MdePkg
set libpath=C:\UefiDKII\Bin\MdePkg
set binpath=..\bin\compchk_uefix64
set objpath=..\bin\compchk_uefix64\Intermediate

title Compiling UefiDiskAccess, Checked Build, UEFI (AMD64 Architecture)
echo Project: UefiDiskAccess
echo Platform: Unified Extensible Firmware Interface
echo Preset: Debug/Checked Build
echo Powered by [email protected]
clang-cl --version
lld-link --version
pause

echo ============Start Compiling============
clang-cl ..\src\efimain.c /I"%mdepath%\Include" /I"%mdepath%\Include\X64" /D"_EFI_BOOT" /Zi /W3 /WX /Ot /Fa"%objpath%\efimain.cod" /Fo"%objpath%\efimain.obj" /GS- /Gr /TC /c -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types

echo ============Start Linking============
lld-link "%objpath%\efimain.obj" /NODEFAULTLIB /LIBPATH:"%libpath%\compchk_uefix64" "BaseLib.lib" "BaseDebugPrintErrorLevelLib.lib" "BaseMemoryLib.lib" "BasePrintLib.lib" "UefiLib.lib" "UefiDebugLibConOut.lib" "UefiMemoryAllocationLib.lib" "UefiDevicePathLib.Lib" "UefiBootServicesTableLib.Lib" "UefiRuntimeServicesTableLib.Lib" /OUT:"%binpath%\bootx64.efi" /SUBSYSTEM:EFI_APPLICATION /ENTRY:"EfiMain" /DEBUG /PDB:"%objpath%\bootx64.pdb" /Machine:X64

echo Completed!
pause.
24 changes: 24 additions & 0 deletions build/compfre_uefix64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
set edkpath=C:\UefiDKII
set mdepath=C:\UefiDKII\MdePkg
set libpath=C:\UefiDKII\Bin\MdePkg
set binpath=..\bin\compfre_uefix64
set objpath=..\bin\compfre_uefix64\Intermediate

title Compiling UefiDiskAccess, Free Build, UEFI (AMD64 Architecture)
echo Project: UefiDiskAccess
echo Platform: Unified Extensible Firmware Interface
echo Preset: Release/Free Build
echo Powered by [email protected]
clang-cl --version
lld-link --version
pause

echo ============Start Compiling============
clang-cl ..\src\efimain.c /I"%mdepath%\Include" /I"%mdepath%\Include\X64" /D"_EFI_BOOT" /Zi /W3 /WX /O2 /Fa"%objpath%\efimain.cod" /Fo"%objpath%\efimain.obj" /GS- /Gr /TC /c -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types

echo ============Start Linking============
lld-link "%objpath%\efimain.obj" /NODEFAULTLIB /LIBPATH:"%libpath%\compfre_uefix64" "BaseLib.lib" "BaseDebugPrintErrorLevelLib.lib" "BaseMemoryLib.lib" "BasePrintLib.lib" "UefiLib.lib" "UefiDebugLibConOut.lib" "UefiMemoryAllocationLib.lib" "UefiDevicePathLib.Lib" "UefiBootServicesTableLib.Lib" "UefiRuntimeServicesTableLib.Lib" /OUT:"%binpath%\bootx64.efi" /OPT:REF /SUBSYSTEM:EFI_APPLICATION /ENTRY:"EfiMain" /DEBUG /PDB:"%objpath%\bootx64.pdb" /Machine:X64

echo Completed!
pause.
Loading

0 comments on commit 6855439

Please sign in to comment.