Compare commits
300 Commits
edk2-stabl
...
edk2-stabl
Author | SHA1 | Date | |
---|---|---|---|
b24306f15d | |||
8a57673316 | |||
c28e376edc | |||
85589ddbf6 | |||
1193aa2dfb | |||
42af706dfb | |||
c9b7c6e0cc | |||
b360b0b589 | |||
1f54eaa725 | |||
bd676f080a | |||
96b8b5fd10 | |||
f78b937c95 | |||
d4ac53aa91 | |||
c09dbc92e9 | |||
6fb09da89f | |||
a4b7aa362d | |||
33189f0527 | |||
007a95055b | |||
45b1612659 | |||
017564d637 | |||
5b3c682d91 | |||
17a02163bd | |||
312ef7a0a4 | |||
0dbd356983 | |||
dc1118fa0d | |||
5816bd3eab | |||
5751d60821 | |||
13136cc311 | |||
742dafd2cc | |||
103fa647d1 | |||
ba79becd55 | |||
49a2d8cbf5 | |||
55c05427b9 | |||
336da55ca8 | |||
7f25ddbc03 | |||
929804b172 | |||
e95b44c90e | |||
862ea6e836 | |||
ae35314e7b | |||
8542fc5f95 | |||
76b3d45b75 | |||
f4b7b473b4 | |||
a867f3a704 | |||
6777e67383 | |||
8cc5590eab | |||
1aa1ec4574 | |||
541a077bd1 | |||
ce37f45955 | |||
5b39832e18 | |||
ee67067f17 | |||
7e5c603cba | |||
21320ef669 | |||
7709988dd8 | |||
772c5bb8dc | |||
5801910013 | |||
59c48c9314 | |||
5302bd81d9 | |||
b66056ef21 | |||
e73d1bf96a | |||
7b6cbe0a81 | |||
196be601f9 | |||
71082d3d1b | |||
fdcea7ff6f | |||
1552050ce7 | |||
6ecdda71fe | |||
a2da72b2ca | |||
c712ce2bb1 | |||
7438a85bf1 | |||
6062002bd5 | |||
14a731096d | |||
9dd14fc91c | |||
079a58276b | |||
13d9e8ec98 | |||
45920941d9 | |||
d463c56ddd | |||
c095122d4b | |||
7935be0fbd | |||
e910f076ad | |||
6612ff8561 | |||
15c596aeeb | |||
ae8272ef78 | |||
9ec2cc1f31 | |||
de9e5b7dc7 | |||
ee1f8262b8 | |||
f129b1f06f | |||
c63a10ecb7 | |||
ab5ab2f603 | |||
195f011973 | |||
8ed8568922 | |||
b451c69088 | |||
45e3842970 | |||
a6c0418651 | |||
e6ea1464a8 | |||
4de8d61bce | |||
b819388772 | |||
5711ff4d0b | |||
b47575801e | |||
3a72ec71cd | |||
f14fff5135 | |||
38f6d78c3b | |||
5fe5b6f94f | |||
740e3bb634 | |||
2e2db65e39 | |||
b2d0ed20fd | |||
9006967c8d | |||
deb01dfd7f | |||
c67bf628c8 | |||
26bf034a59 | |||
7b6c8b30a5 | |||
d250d408cf | |||
b04cf355a0 | |||
0fa1217726 | |||
e366a41ef0 | |||
51941f7558 | |||
3ebe1ff5c9 | |||
8d2691c3d5 | |||
5d8b5d171c | |||
d59c5a20f8 | |||
90ad4b3b34 | |||
c039fa7ff0 | |||
4d30352445 | |||
7a6e6ae933 | |||
41d8bb3038 | |||
759e3c6d21 | |||
557dede8a6 | |||
ec37fd9c1f | |||
e35a746cf5 | |||
ce306e48eb | |||
69ddfee1c3 | |||
b2b8def4e3 | |||
fd5fc4bbb7 | |||
0e7147fe75 | |||
7f1861be2b | |||
e07d27e24d | |||
2a68abf6ee | |||
c802f8935c | |||
79dcaf7054 | |||
64ef0dd1d3 | |||
1203eba58e | |||
2722856a87 | |||
8b8ae609a7 | |||
04eacd3943 | |||
64bccda534 | |||
21ee379407 | |||
61be49e0f7 | |||
2686468c43 | |||
adf070ff56 | |||
8c06c53b58 | |||
a124cd4ef9 | |||
d5efc875ef | |||
2b20a34fd5 | |||
f6df289a1c | |||
7594c5bfe2 | |||
66bce05f6d | |||
d8ef774346 | |||
2ccefa32a6 | |||
9afcd48a94 | |||
e81a81e584 | |||
e139829dd6 | |||
b2bbe3df54 | |||
8cf2bdfcfb | |||
a50b65ce22 | |||
0077c22f6d | |||
30631f0a26 | |||
0f1d7477c0 | |||
06544455d0 | |||
67484aed69 | |||
ea3a12d970 | |||
b7b8872031 | |||
b928eb44d5 | |||
d4d7c9ad5f | |||
9c703bc0f1 | |||
2c354252be | |||
f5a6e1bab5 | |||
f4e3ce5f53 | |||
b95908e043 | |||
504ae26b80 | |||
26210f9436 | |||
8eb79b5f4f | |||
202fb22be6 | |||
d39f8d88ec | |||
11b15336f0 | |||
d706f8fec2 | |||
ade62c18f4 | |||
19914edc5a | |||
a19b648952 | |||
d2b998fbdc | |||
7c3b2892ea | |||
d9822304ce | |||
34819f2cac | |||
f2dc28f0b6 | |||
cca9cd3dd6 | |||
707c71a01b | |||
3053183d41 | |||
2fe8edfe55 | |||
e2289d19d8 | |||
2ddacfb6b8 | |||
c82ab4d8c1 | |||
d25b803e51 | |||
7b28310008 | |||
85a678bf76 | |||
965292135b | |||
ffdde9d719 | |||
2527723de9 | |||
94e0a7bddb | |||
b2f7ee2ded | |||
ca78281c25 | |||
1832eb15aa | |||
dc453b5164 | |||
7c0ad2c338 | |||
e5efcf8be8 | |||
053e878bfb | |||
91415a36ae | |||
c1e126b119 | |||
b878648967 | |||
47d20b54f9 | |||
c411b485b6 | |||
39de741e2d | |||
5220bd211d | |||
ac0a286f4d | |||
d1050b9dff | |||
2f88bd3a12 | |||
1436aea4d5 | |||
7c7184e201 | |||
111f2228dd | |||
45ce0a67bb | |||
bcdcc4160d | |||
a550d468a6 | |||
e7108d0e96 | |||
731c67e1d7 | |||
7c34237831 | |||
2b16a4fb91 | |||
40b0b23ed3 | |||
429309e0c6 | |||
7c2a6033c1 | |||
f9f4fb2329 | |||
deba54761a | |||
8e875037bf | |||
ed7f7c9168 | |||
098307e082 | |||
db52c7f755 | |||
4a9d411662 | |||
e3b855f283 | |||
ea85f0fe13 | |||
78bc3bdd2a | |||
e35dd32821 | |||
4ec586b9f6 | |||
902e76de19 | |||
f9c9215b55 | |||
18908e6131 | |||
9b8507cabe | |||
12710fe93b | |||
dc8fe5ec95 | |||
237295f46d | |||
79d49e162e | |||
8874fa199d | |||
d0e2f8232a | |||
e3917e22e7 | |||
9c721071d3 | |||
c69fc80c80 | |||
792433088c | |||
fe2d81892f | |||
c8f46130f8 | |||
9607597a74 | |||
2863ba97ca | |||
1871d28eaf | |||
96e1cba5c1 | |||
586fda4800 | |||
4a1aee13d8 | |||
e905fbb05a | |||
ca56749b0e | |||
47719926e8 | |||
c49ca4a29e | |||
5f289f3ae3 | |||
87000d7708 | |||
917e98f3e5 | |||
9c7da8d804 | |||
a1878955b2 | |||
c5b3a56e4f | |||
1d2482e1e3 | |||
a4a582e180 | |||
dfafa8e453 | |||
f0f3f5aae7 | |||
c057347977 | |||
c30c40d6c6 | |||
9944508e85 | |||
60fa40be45 | |||
df790cd6b3 | |||
9deb937076 | |||
d7d30e8f21 | |||
d5744ecba8 | |||
c97fee87f0 | |||
1939fc9569 | |||
365dced2c3 | |||
76a1ce4d5f | |||
99f84ff473 | |||
3019f1bbab | |||
854462bd34 | |||
69877614fd | |||
ef9a059cdb |
@ -17,7 +17,7 @@ parameters:
|
|||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
- job: Build_${{ parameters.tool_chain_tag }}
|
- job: Build_${{ parameters.tool_chain_tag }}
|
||||||
|
timeoutInMinutes: 120
|
||||||
#Use matrix to speed up the build process
|
#Use matrix to speed up the build process
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -30,7 +30,6 @@ class EccCheck(ICiBuildPlugin):
|
|||||||
},
|
},
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ReModifyFile = re.compile(r'[B-Q,S-Z]+[\d]*\t(.*)')
|
|
||||||
FindModifyFile = re.compile(r'\+\+\+ b\/(.*)')
|
FindModifyFile = re.compile(r'\+\+\+ b\/(.*)')
|
||||||
LineScopePattern = (r'@@ -\d*\,*\d* \+\d*\,*\d* @@.*')
|
LineScopePattern = (r'@@ -\d*\,*\d* \+\d*\,*\d* @@.*')
|
||||||
LineNumRange = re.compile(r'@@ -\d*\,*\d* \+(\d*)\,*(\d*) @@.*')
|
LineNumRange = re.compile(r'@@ -\d*\,*\d* \+(\d*)\,*(\d*) @@.*')
|
||||||
@ -69,77 +68,174 @@ class EccCheck(ICiBuildPlugin):
|
|||||||
env.set_shell_var('WORKSPACE', workspace_path)
|
env.set_shell_var('WORKSPACE', workspace_path)
|
||||||
env.set_shell_var('PACKAGES_PATH', os.pathsep.join(Edk2pathObj.PackagePathList))
|
env.set_shell_var('PACKAGES_PATH', os.pathsep.join(Edk2pathObj.PackagePathList))
|
||||||
self.ECC_PASS = True
|
self.ECC_PASS = True
|
||||||
self.ApplyConfig(pkgconfig, workspace_path, basetools_path, packagename)
|
|
||||||
modify_dir_list = self.GetModifyDir(packagename)
|
# Create temp directory
|
||||||
patch = self.GetDiff(packagename)
|
temp_path = os.path.join(workspace_path, 'Build', '.pytool', 'Plugin', 'EccCheck')
|
||||||
ecc_diff_range = self.GetDiffRange(patch, packagename, workspace_path)
|
try:
|
||||||
self.GenerateEccReport(modify_dir_list, ecc_diff_range, workspace_path, basetools_path)
|
# Delete temp directory
|
||||||
ecc_log = os.path.join(workspace_path, "Ecc.log")
|
if os.path.exists(temp_path):
|
||||||
self.RevertCode()
|
shutil.rmtree(temp_path)
|
||||||
|
# Copy package being scanned to temp_path
|
||||||
|
shutil.copytree (
|
||||||
|
os.path.join(workspace_path, packagename),
|
||||||
|
os.path.join(temp_path, packagename),
|
||||||
|
symlinks=True
|
||||||
|
)
|
||||||
|
# Copy exception.xml to temp_path
|
||||||
|
shutil.copyfile (
|
||||||
|
os.path.join(basetools_path, "Source", "Python", "Ecc", "exception.xml"),
|
||||||
|
os.path.join(temp_path, "exception.xml")
|
||||||
|
)
|
||||||
|
# Output file to use for git diff operations
|
||||||
|
temp_diff_output = os.path.join (temp_path, 'diff.txt')
|
||||||
|
|
||||||
|
self.ApplyConfig(pkgconfig, temp_path, packagename)
|
||||||
|
modify_dir_list = self.GetModifyDir(packagename, temp_diff_output)
|
||||||
|
patch = self.GetDiff(packagename, temp_diff_output)
|
||||||
|
ecc_diff_range = self.GetDiffRange(patch, packagename, temp_path)
|
||||||
|
#
|
||||||
|
# Use temp_path as working directory when running ECC tool
|
||||||
|
#
|
||||||
|
self.GenerateEccReport(modify_dir_list, ecc_diff_range, temp_path, basetools_path)
|
||||||
|
ecc_log = os.path.join(temp_path, "Ecc.log")
|
||||||
if self.ECC_PASS:
|
if self.ECC_PASS:
|
||||||
|
# Delete temp directory
|
||||||
|
if os.path.exists(temp_path):
|
||||||
|
shutil.rmtree(temp_path)
|
||||||
tc.SetSuccess()
|
tc.SetSuccess()
|
||||||
self.RemoveFile(ecc_log)
|
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
with open(ecc_log, encoding='utf8') as output:
|
with open(ecc_log, encoding='utf8') as output:
|
||||||
ecc_output = output.readlines()
|
ecc_output = output.readlines()
|
||||||
for line in ecc_output:
|
for line in ecc_output:
|
||||||
logging.error(line.strip())
|
logging.error(line.strip())
|
||||||
self.RemoveFile(ecc_log)
|
# Delete temp directory
|
||||||
tc.SetFailed("EccCheck failed for {0}".format(packagename), "Ecc detected issues")
|
if os.path.exists(temp_path):
|
||||||
|
shutil.rmtree(temp_path)
|
||||||
|
tc.SetFailed("EccCheck failed for {0}".format(packagename), "CHECK FAILED")
|
||||||
|
return 1
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
# If EccCheck is interrupted by keybard interrupt, then return failure
|
||||||
|
# Delete temp directory
|
||||||
|
if os.path.exists(temp_path):
|
||||||
|
shutil.rmtree(temp_path)
|
||||||
|
tc.SetFailed("EccCheck interrupted for {0}".format(packagename), "CHECK FAILED")
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
# If EccCheck fails for any other exception type, raise the exception
|
||||||
|
# Delete temp directory
|
||||||
|
if os.path.exists(temp_path):
|
||||||
|
shutil.rmtree(temp_path)
|
||||||
|
tc.SetFailed("EccCheck exception for {0}".format(packagename), "CHECK FAILED")
|
||||||
|
raise
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def RevertCode(self) -> None:
|
def GetDiff(self, pkg: str, temp_diff_output: str) -> List[str]:
|
||||||
submoudle_params = "submodule update --init"
|
patch = []
|
||||||
RunCmd("git", submoudle_params)
|
#
|
||||||
reset_params = "reset HEAD --hard"
|
# Generate unified diff between origin/master and HEAD.
|
||||||
RunCmd("git", reset_params)
|
#
|
||||||
|
params = "diff --output={} --unified=0 origin/master HEAD".format(temp_diff_output)
|
||||||
def GetDiff(self, pkg: str) -> List[str]:
|
RunCmd("git", params)
|
||||||
return_buffer = StringIO()
|
with open(temp_diff_output) as file:
|
||||||
params = "diff --unified=0 origin/master HEAD"
|
patch = file.read().strip().split('\n')
|
||||||
RunCmd("git", params, outstream=return_buffer)
|
|
||||||
p = return_buffer.getvalue().strip()
|
|
||||||
patch = p.split("\n")
|
|
||||||
return_buffer.close()
|
|
||||||
|
|
||||||
return patch
|
return patch
|
||||||
|
|
||||||
def RemoveFile(self, file: str) -> None:
|
def GetModifyDir(self, pkg: str, temp_diff_output: str) -> List[str]:
|
||||||
if os.path.exists(file):
|
#
|
||||||
os.remove(file)
|
# Generate diff between origin/master and HEAD using --diff-filter to
|
||||||
return
|
# exclude deleted and renamed files that do not need to be scanned by
|
||||||
|
# ECC. Also use --name-status to only generate the names of the files
|
||||||
|
# with differences. The output format of this git diff command is a
|
||||||
|
# list of files with the change status and the filename. The filename
|
||||||
|
# is always at the end of the line. Examples:
|
||||||
|
#
|
||||||
|
# M MdeModulePkg/Application/CapsuleApp/CapsuleApp.h
|
||||||
|
# M MdeModulePkg/Application/UiApp/FrontPage.h
|
||||||
|
#
|
||||||
|
params = "diff --output={} --diff-filter=dr --name-status origin/master HEAD".format(temp_diff_output)
|
||||||
|
RunCmd("git", params)
|
||||||
|
dir_list = []
|
||||||
|
with open(temp_diff_output) as file:
|
||||||
|
dir_list = file.read().strip().split('\n')
|
||||||
|
|
||||||
def GetModifyDir(self, pkg: str) -> List[str]:
|
|
||||||
return_buffer = StringIO()
|
|
||||||
params = "diff --name-status" + ' HEAD' + ' origin/master'
|
|
||||||
RunCmd("git", params, outstream=return_buffer)
|
|
||||||
p1 = return_buffer.getvalue().strip()
|
|
||||||
dir_list = p1.split("\n")
|
|
||||||
return_buffer.close()
|
|
||||||
modify_dir_list = []
|
modify_dir_list = []
|
||||||
for modify_dir in dir_list:
|
for modify_dir in dir_list:
|
||||||
file_path = self.ReModifyFile.findall(modify_dir)
|
#
|
||||||
if file_path:
|
# Parse file name from the end of the line
|
||||||
file_dir = os.path.dirname(file_path[0])
|
#
|
||||||
else:
|
file_path = modify_dir.strip().split()
|
||||||
|
#
|
||||||
|
# Skip lines that do not have at least 2 elements (status and file name)
|
||||||
|
#
|
||||||
|
if len(file_path) < 2:
|
||||||
continue
|
continue
|
||||||
if pkg in file_dir and file_dir != pkg:
|
#
|
||||||
modify_dir_list.append('%s' % file_dir)
|
# Parse the directory name from the file name
|
||||||
else:
|
#
|
||||||
|
file_dir = os.path.dirname(file_path[-1])
|
||||||
|
#
|
||||||
|
# Skip directory names that do not start with the package being scanned.
|
||||||
|
#
|
||||||
|
if file_dir.split('/')[0] != pkg:
|
||||||
continue
|
continue
|
||||||
|
#
|
||||||
|
# Skip directory names that are identical to the package being scanned.
|
||||||
|
# The assumption here is that there are no source files at the package
|
||||||
|
# root. Instead, the only expected files in the package root are
|
||||||
|
# EDK II meta data files (DEC, DSC, FDF).
|
||||||
|
#
|
||||||
|
if file_dir == pkg:
|
||||||
|
continue
|
||||||
|
#
|
||||||
|
# Skip directory names that are already in the modified dir list
|
||||||
|
#
|
||||||
|
if file_dir in modify_dir_list:
|
||||||
|
continue
|
||||||
|
#
|
||||||
|
# Add the candidate directory to scan to the modified dir list
|
||||||
|
#
|
||||||
|
modify_dir_list.append(file_dir)
|
||||||
|
|
||||||
modify_dir_list = list(set(modify_dir_list))
|
#
|
||||||
return modify_dir_list
|
# Remove duplicates from modify_dir_list
|
||||||
|
# Given a folder path, ECC performs a recursive scan of that folder.
|
||||||
|
# If a parent and child folder are both present in modify_dir_list,
|
||||||
|
# then ECC will perform redudanct scans of source files. In order
|
||||||
|
# to prevent redundant scans, if a parent and child folder are both
|
||||||
|
# present, then remove all the child folders.
|
||||||
|
#
|
||||||
|
# For example, if modified_dir_list contains the following elements:
|
||||||
|
# MdeModulePkg/Core/Dxe
|
||||||
|
# MdeModulePkg/Core/Dxe/Hand
|
||||||
|
# MdeModulePkg/Core/Dxe/Mem
|
||||||
|
#
|
||||||
|
# Then MdeModulePkg/Core/Dxe/Hand and MdeModulePkg/Core/Dxe/Mem should
|
||||||
|
# be removed because the files in those folders are covered by a scan
|
||||||
|
# of MdeModulePkg/Core/Dxe.
|
||||||
|
#
|
||||||
|
filtered_list = []
|
||||||
|
for dir1 in modify_dir_list:
|
||||||
|
Append = True
|
||||||
|
for dir2 in modify_dir_list:
|
||||||
|
if dir1 == dir2:
|
||||||
|
continue
|
||||||
|
common = os.path.commonpath([dir1, dir2])
|
||||||
|
if os.path.normpath(common) == os.path.normpath(dir2):
|
||||||
|
Append = False
|
||||||
|
break
|
||||||
|
if Append and dir1 not in filtered_list:
|
||||||
|
filtered_list.append(dir1)
|
||||||
|
return filtered_list
|
||||||
|
|
||||||
def GetDiffRange(self, patch_diff: List[str], pkg: str, workingdir: str) -> Dict[str, List[Tuple[int, int]]]:
|
def GetDiffRange(self, patch_diff: List[str], pkg: str, temp_path: str) -> Dict[str, List[Tuple[int, int]]]:
|
||||||
IsDelete = True
|
IsDelete = True
|
||||||
StartCheck = False
|
StartCheck = False
|
||||||
range_directory: Dict[str, List[Tuple[int, int]]] = {}
|
range_directory: Dict[str, List[Tuple[int, int]]] = {}
|
||||||
for line in patch_diff:
|
for line in patch_diff:
|
||||||
modify_file = self.FindModifyFile.findall(line)
|
modify_file = self.FindModifyFile.findall(line)
|
||||||
if modify_file and pkg in modify_file[0] and not StartCheck and os.path.isfile(modify_file[0]):
|
if modify_file and pkg in modify_file[0] and not StartCheck and os.path.isfile(modify_file[0]):
|
||||||
modify_file_comment_dic = self.GetCommentRange(modify_file[0], workingdir)
|
modify_file_comment_dic = self.GetCommentRange(modify_file[0], temp_path)
|
||||||
IsDelete = False
|
IsDelete = False
|
||||||
StartCheck = True
|
StartCheck = True
|
||||||
modify_file_dic = modify_file[0]
|
modify_file_dic = modify_file[0]
|
||||||
@ -158,11 +254,13 @@ class EccCheck(ICiBuildPlugin):
|
|||||||
range_directory[modify_file_dic].append(i)
|
range_directory[modify_file_dic].append(i)
|
||||||
return range_directory
|
return range_directory
|
||||||
|
|
||||||
def GetCommentRange(self, modify_file: str, workingdir: str) -> List[Tuple[int, int]]:
|
def GetCommentRange(self, modify_file: str, temp_path: str) -> List[Tuple[int, int]]:
|
||||||
modify_file_path = os.path.join(workingdir, modify_file)
|
comment_range: List[Tuple[int, int]] = []
|
||||||
|
modify_file_path = os.path.join(temp_path, modify_file)
|
||||||
|
if not os.path.exists (modify_file_path):
|
||||||
|
return comment_range
|
||||||
with open(modify_file_path) as f:
|
with open(modify_file_path) as f:
|
||||||
line_no = 1
|
line_no = 1
|
||||||
comment_range: List[Tuple[int, int]] = []
|
|
||||||
Start = False
|
Start = False
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith('/**'):
|
if line.startswith('/**'):
|
||||||
@ -179,35 +277,33 @@ class EccCheck(ICiBuildPlugin):
|
|||||||
return comment_range
|
return comment_range
|
||||||
|
|
||||||
def GenerateEccReport(self, modify_dir_list: List[str], ecc_diff_range: Dict[str, List[Tuple[int, int]]],
|
def GenerateEccReport(self, modify_dir_list: List[str], ecc_diff_range: Dict[str, List[Tuple[int, int]]],
|
||||||
workspace_path: str, basetools_path: str) -> None:
|
temp_path: str, basetools_path: str) -> None:
|
||||||
ecc_need = False
|
ecc_need = False
|
||||||
ecc_run = True
|
ecc_run = True
|
||||||
config = os.path.join(basetools_path, "Source", "Python", "Ecc", "config.ini")
|
config = os.path.normpath(os.path.join(basetools_path, "Source", "Python", "Ecc", "config.ini"))
|
||||||
exception = os.path.join(basetools_path, "Source", "Python", "Ecc", "exception.xml")
|
exception = os.path.normpath(os.path.join(temp_path, "exception.xml"))
|
||||||
report = os.path.join(workspace_path, "Ecc.csv")
|
report = os.path.normpath(os.path.join(temp_path, "Ecc.csv"))
|
||||||
for modify_dir in modify_dir_list:
|
for modify_dir in modify_dir_list:
|
||||||
target = os.path.join(workspace_path, modify_dir)
|
target = os.path.normpath(os.path.join(temp_path, modify_dir))
|
||||||
logging.info('Run ECC tool for the commit in %s' % modify_dir)
|
logging.info('Run ECC tool for the commit in %s' % modify_dir)
|
||||||
ecc_need = True
|
ecc_need = True
|
||||||
ecc_params = "-c {0} -e {1} -t {2} -r {3}".format(config, exception, target, report)
|
ecc_params = "-c {0} -e {1} -t {2} -r {3}".format(config, exception, target, report)
|
||||||
return_code = RunCmd("Ecc", ecc_params, workingdir=workspace_path)
|
return_code = RunCmd("Ecc", ecc_params, workingdir=temp_path)
|
||||||
if return_code != 0:
|
if return_code != 0:
|
||||||
ecc_run = False
|
ecc_run = False
|
||||||
break
|
break
|
||||||
if not ecc_run:
|
if not ecc_run:
|
||||||
logging.error('Fail to run ECC tool')
|
logging.error('Fail to run ECC tool')
|
||||||
self.ParseEccReport(ecc_diff_range, workspace_path)
|
self.ParseEccReport(ecc_diff_range, temp_path)
|
||||||
|
|
||||||
if not ecc_need:
|
if not ecc_need:
|
||||||
logging.info("Doesn't need run ECC check")
|
logging.info("Doesn't need run ECC check")
|
||||||
|
|
||||||
revert_params = "checkout -- {}".format(exception)
|
|
||||||
RunCmd("git", revert_params)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def ParseEccReport(self, ecc_diff_range: Dict[str, List[Tuple[int, int]]], workspace_path: str) -> None:
|
def ParseEccReport(self, ecc_diff_range: Dict[str, List[Tuple[int, int]]], temp_path: str) -> None:
|
||||||
ecc_log = os.path.join(workspace_path, "Ecc.log")
|
ecc_log = os.path.join(temp_path, "Ecc.log")
|
||||||
ecc_csv = os.path.join(workspace_path, "Ecc.csv")
|
ecc_csv = os.path.join(temp_path, "Ecc.csv")
|
||||||
row_lines = []
|
row_lines = []
|
||||||
ignore_error_code = self.GetIgnoreErrorCode()
|
ignore_error_code = self.GetIgnoreErrorCode()
|
||||||
if os.path.exists(ecc_csv):
|
if os.path.exists(ecc_csv):
|
||||||
@ -236,16 +332,16 @@ class EccCheck(ICiBuildPlugin):
|
|||||||
log.writelines(all_line)
|
log.writelines(all_line)
|
||||||
return
|
return
|
||||||
|
|
||||||
def ApplyConfig(self, pkgconfig: Dict[str, List[str]], workspace_path: str, basetools_path: str, pkg: str) -> None:
|
def ApplyConfig(self, pkgconfig: Dict[str, List[str]], temp_path: str, pkg: str) -> None:
|
||||||
if "IgnoreFiles" in pkgconfig:
|
if "IgnoreFiles" in pkgconfig:
|
||||||
for a in pkgconfig["IgnoreFiles"]:
|
for a in pkgconfig["IgnoreFiles"]:
|
||||||
a = os.path.join(workspace_path, pkg, a)
|
a = os.path.join(temp_path, pkg, a)
|
||||||
a = a.replace(os.sep, "/")
|
a = a.replace(os.sep, "/")
|
||||||
|
|
||||||
logging.info("Ignoring Files {0}".format(a))
|
logging.info("Ignoring Files {0}".format(a))
|
||||||
if os.path.exists(a):
|
if os.path.exists(a):
|
||||||
if os.path.isfile(a):
|
if os.path.isfile(a):
|
||||||
self.RemoveFile(a)
|
os.remove(a)
|
||||||
elif os.path.isdir(a):
|
elif os.path.isdir(a):
|
||||||
shutil.rmtree(a)
|
shutil.rmtree(a)
|
||||||
else:
|
else:
|
||||||
@ -253,7 +349,7 @@ class EccCheck(ICiBuildPlugin):
|
|||||||
|
|
||||||
if "ExceptionList" in pkgconfig:
|
if "ExceptionList" in pkgconfig:
|
||||||
exception_list = pkgconfig["ExceptionList"]
|
exception_list = pkgconfig["ExceptionList"]
|
||||||
exception_xml = os.path.join(basetools_path, "Source", "Python", "Ecc", "exception.xml")
|
exception_xml = os.path.join(temp_path, "exception.xml")
|
||||||
try:
|
try:
|
||||||
logging.info("Appending exceptions")
|
logging.info("Appending exceptions")
|
||||||
self.AppendException(exception_list, exception_xml)
|
self.AppendException(exception_list, exception_xml)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
##
|
##
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
@ -61,12 +62,19 @@ class LicenseCheck(ICiBuildPlugin):
|
|||||||
# - Junit Logger
|
# - Junit Logger
|
||||||
# - output_stream the StringIO output stream from this plugin via logging
|
# - output_stream the StringIO output stream from this plugin via logging
|
||||||
def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM, PLMHelper, tc, output_stream=None):
|
def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM, PLMHelper, tc, output_stream=None):
|
||||||
return_buffer = StringIO()
|
# Create temp directory
|
||||||
params = "diff --unified=0 origin/master HEAD"
|
temp_path = os.path.join(Edk2pathObj.WorkspacePath, 'Build', '.pytool', 'Plugin', 'LicenseCheck')
|
||||||
RunCmd("git", params, outstream=return_buffer)
|
if not os.path.exists(temp_path):
|
||||||
p = return_buffer.getvalue().strip()
|
os.makedirs(temp_path)
|
||||||
patch = p.split("\n")
|
# Output file to use for git diff operations
|
||||||
return_buffer.close()
|
temp_diff_output = os.path.join (temp_path, 'diff.txt')
|
||||||
|
params = "diff --output={} --unified=0 origin/master HEAD".format(temp_diff_output)
|
||||||
|
RunCmd("git", params)
|
||||||
|
with open(temp_diff_output) as file:
|
||||||
|
patch = file.read().strip().split("\n")
|
||||||
|
# Delete temp directory
|
||||||
|
if os.path.exists(temp_path):
|
||||||
|
shutil.rmtree(temp_path)
|
||||||
|
|
||||||
ignore_files = []
|
ignore_files = []
|
||||||
if "IgnoreFiles" in pkgconfig:
|
if "IgnoreFiles" in pkgconfig:
|
||||||
|
120
.pytool/Plugin/UncrustifyCheck/Readme.md
Normal file
120
.pytool/Plugin/UncrustifyCheck/Readme.md
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
# UncrustifyCheck Plugin
|
||||||
|
|
||||||
|
This CiBuildPlugin scans all the files in a given package and checks for coding standard compliance issues.
|
||||||
|
|
||||||
|
This plugin is enabled by default. If a package would like to prevent the plugin from reporting errors, it can do
|
||||||
|
so by enabling [`AuditOnly`](#auditonly) mode.
|
||||||
|
|
||||||
|
This plugin requires the directory containing the Uncrustify executable that should be used for this plugin to
|
||||||
|
be specified in an environment variable named `UNCRUSTIFY_CI_PATH`. This unique variable name is used to avoid confusion
|
||||||
|
with other paths to Uncrustify which might not be the expected build for use by this plugin.
|
||||||
|
|
||||||
|
By default, an Uncrustify configuration file named "uncrustify.cfg" located in the same directory as the plugin is
|
||||||
|
used. The value can be overridden to a package-specific path with the `ConfigFilePath` configuration file option.
|
||||||
|
|
||||||
|
* Uncrustify source code and documentation: https://github.com/uncrustify/uncrustify
|
||||||
|
* Project Mu Uncrustify fork source code and documentation: https://dev.azure.com/projectmu/Uncrustify
|
||||||
|
|
||||||
|
## Files Checked in a Package
|
||||||
|
|
||||||
|
By default, this plugin will discover all files in the package with the following default paths:
|
||||||
|
|
||||||
|
```python
|
||||||
|
[
|
||||||
|
# C source
|
||||||
|
"*.c",
|
||||||
|
"*.h"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
From this list of files, any files ignored by Git or residing in a Git submodule will be removed. If Git is not
|
||||||
|
found, submodules are not found, or ignored files are not found no changes are made to the list of discovered files.
|
||||||
|
|
||||||
|
To control the paths checked in a given package, review the configuration options described in this file.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The plugin can be configured with a few optional configuration options.
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
"UncrustifyCheck": {
|
||||||
|
"AdditionalIncludePaths": [], # Additional paths to check formatting (wildcards supported).
|
||||||
|
"AuditOnly": False, # Don't fail the build if there are errors. Just log them.
|
||||||
|
"ConfigFilePath": "", # Custom path to an Uncrustify config file.
|
||||||
|
"IgnoreStandardPaths": [], # Standard Plugin defined paths that should be ignored.
|
||||||
|
"OutputFileDiffs": False, # Output chunks of formatting diffs in the test case log.
|
||||||
|
# This can significantly slow down the plugin on very large packages.
|
||||||
|
"SkipGitExclusions": False # Don't exclude git ignored files and files in git submodules.
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `AdditionalIncludePaths`
|
||||||
|
|
||||||
|
A package configuration file can specify any additional paths to be included with this option.
|
||||||
|
|
||||||
|
At this time, it is recommended all files run against the plugin be written in the C or C++ language.
|
||||||
|
|
||||||
|
### `AuditOnly`
|
||||||
|
|
||||||
|
`Boolean` - Default is `False`.
|
||||||
|
|
||||||
|
If `True`, run the test in an "audit only mode" which will log all errors but instead of failing the build, it will set
|
||||||
|
the test as skipped. This allows visibility into the failures without breaking the build.
|
||||||
|
|
||||||
|
### `ConfigFilePath`
|
||||||
|
|
||||||
|
`String` - Default is `"uncrustify.cfg"`
|
||||||
|
|
||||||
|
When specified in the config file, this is a package relative path to the Uncrustify configuration file.
|
||||||
|
|
||||||
|
### `IgnoreStandardPaths`
|
||||||
|
|
||||||
|
This plugin by default will check the below standard paths. A package configuration file can specify any of these paths
|
||||||
|
to be ignored.
|
||||||
|
|
||||||
|
```python
|
||||||
|
[
|
||||||
|
# C source
|
||||||
|
"*.c",
|
||||||
|
"*.h"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
### `OutputFileDiffs`
|
||||||
|
|
||||||
|
`Boolean` - Default is `False`.
|
||||||
|
|
||||||
|
If `True`, output diffs of formatting changes into the test case log. This is helpful to exactly understand what changes
|
||||||
|
need to be made to the source code in order to fix a coding standard compliance issue.
|
||||||
|
|
||||||
|
Note that calculating the file diffs on a very large set of of results (e.g. >100 files) can significantly slow down
|
||||||
|
plugin execution.
|
||||||
|
|
||||||
|
### `SkipGitExclusions`
|
||||||
|
|
||||||
|
`Boolean` - Default is `False`.
|
||||||
|
|
||||||
|
By default, files in paths matched in a .gitignore file or a recognized git submodule are excluded. If this option
|
||||||
|
is `True`, the plugin will not attempt to recognize these files and exclude them.
|
||||||
|
|
||||||
|
## High-Level Plugin Operation
|
||||||
|
|
||||||
|
This plugin generates two main sets of temporary files:
|
||||||
|
|
||||||
|
1. A working directory in the directory `Build/.pytool/Plugin/Uncrustify`
|
||||||
|
2. For each source file with formatting errors, a sibling file with the `.uncrustify_plugin` extension
|
||||||
|
|
||||||
|
The working directory contains temporary files unique to operation of the plugin. All of these files are removed on
|
||||||
|
exit of the plugin including successful or unsuccessful execution (such as a Python exception occurring). If for any
|
||||||
|
reason, any files in the package exist prior to running the plugin with the `.uncrustify_plugin` extension, the plugin
|
||||||
|
will inform the user to remove these files and exit before running Uncrustify. This is to ensure the accuracy of the
|
||||||
|
results reported from each execution instance of the plugin.
|
||||||
|
|
||||||
|
The plugin determines the list of relevant files to check with Uncrustify and then invokes Uncrustify with that file
|
||||||
|
list. For any files not compliant to the configuration file provided, Uncrustify will generate a corresponding file
|
||||||
|
with the `.uncrustify_plugin` extension. The plugin discovers all of these files. If any such files are present, this
|
||||||
|
indicates a formatting issue was found and the test is marked failed (unless `AuditOnly` mode is enabled).
|
||||||
|
|
||||||
|
The test case log will contain a report of which files failed to format properly, allowing the user to run Uncrustify
|
||||||
|
against the file locally to fix the issue. If the `OutputFileDiffs` configuration option is set to `True`, the plugin
|
||||||
|
will output diff chunks for all code formatting issues in the test case log.
|
618
.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
Normal file
618
.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
Normal file
@ -0,0 +1,618 @@
|
|||||||
|
# @file UncrustifyCheck.py
|
||||||
|
#
|
||||||
|
# An edk2-pytool based plugin wrapper for Uncrustify
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
import configparser
|
||||||
|
import difflib
|
||||||
|
import errno
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import shutil
|
||||||
|
import timeit
|
||||||
|
from edk2toolext.environment import version_aggregator
|
||||||
|
from edk2toolext.environment.plugin_manager import PluginManager
|
||||||
|
from edk2toolext.environment.plugintypes.ci_build_plugin import ICiBuildPlugin
|
||||||
|
from edk2toolext.environment.plugintypes.uefi_helper_plugin import HelperFunctions
|
||||||
|
from edk2toolext.environment.var_dict import VarDict
|
||||||
|
from edk2toollib.log.junit_report_format import JunitReportTestCase
|
||||||
|
from edk2toollib.uefi.edk2.path_utilities import Edk2Path
|
||||||
|
from edk2toollib.utility_functions import RunCmd
|
||||||
|
from io import StringIO
|
||||||
|
from typing import Any, Dict, List, Tuple
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provide more user friendly messages for certain scenarios
|
||||||
|
#
|
||||||
|
class UncrustifyException(Exception):
|
||||||
|
def __init__(self, message, exit_code):
|
||||||
|
super().__init__(message)
|
||||||
|
self.exit_code = exit_code
|
||||||
|
|
||||||
|
|
||||||
|
class UncrustifyAppEnvVarNotFoundException(UncrustifyException):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message, -101)
|
||||||
|
|
||||||
|
|
||||||
|
class UncrustifyAppVersionErrorException(UncrustifyException):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message, -102)
|
||||||
|
|
||||||
|
|
||||||
|
class UncrustifyAppExecutionException(UncrustifyException):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message, -103)
|
||||||
|
|
||||||
|
|
||||||
|
class UncrustifyStalePluginFormattedFilesException(UncrustifyException):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message, -120)
|
||||||
|
|
||||||
|
|
||||||
|
class UncrustifyInputFileCreationErrorException(UncrustifyException):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message, -121)
|
||||||
|
|
||||||
|
class UncrustifyInvalidIgnoreStandardPathsException(UncrustifyException):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message, -122)
|
||||||
|
|
||||||
|
class UncrustifyGitIgnoreFileException(UncrustifyException):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message, -140)
|
||||||
|
|
||||||
|
|
||||||
|
class UncrustifyGitSubmoduleException(UncrustifyException):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message, -141)
|
||||||
|
|
||||||
|
|
||||||
|
class UncrustifyCheck(ICiBuildPlugin):
|
||||||
|
"""
|
||||||
|
A CiBuildPlugin that uses Uncrustify to check the source files in the
|
||||||
|
package being tested for coding standard issues.
|
||||||
|
|
||||||
|
By default, the plugin runs against standard C source file extensions but
|
||||||
|
its configuration can be modified through its configuration file.
|
||||||
|
|
||||||
|
Configuration options:
|
||||||
|
"UncrustifyCheck": {
|
||||||
|
"AdditionalIncludePaths": [], # Additional paths to check formatting (wildcards supported).
|
||||||
|
"AuditOnly": False, # Don't fail the build if there are errors. Just log them.
|
||||||
|
"ConfigFilePath": "", # Custom path to an Uncrustify config file.
|
||||||
|
"IgnoreStandardPaths": [], # Standard Plugin defined paths that should be ignored.
|
||||||
|
"OutputFileDiffs": False, # Output chunks of formatting diffs in the test case log.
|
||||||
|
# This can significantly slow down the plugin on very large packages.
|
||||||
|
"SkipGitExclusions": False # Don't exclude git ignored files and files in git submodules.
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
#
|
||||||
|
# By default, use an "uncrustify.cfg" config file in the plugin directory
|
||||||
|
# A package can override this path via "ConfigFilePath"
|
||||||
|
#
|
||||||
|
# Note: Values specified via "ConfigFilePath" are relative to the package
|
||||||
|
#
|
||||||
|
DEFAULT_CONFIG_FILE_PATH = os.path.join(
|
||||||
|
pathlib.Path(__file__).parent.resolve(), "uncrustify.cfg")
|
||||||
|
|
||||||
|
#
|
||||||
|
# The extension used for formatted files produced by this plugin
|
||||||
|
#
|
||||||
|
FORMATTED_FILE_EXTENSION = ".uncrustify_plugin"
|
||||||
|
|
||||||
|
#
|
||||||
|
# A package can add any additional paths with "AdditionalIncludePaths"
|
||||||
|
# A package can remove any of these paths with "IgnoreStandardPaths"
|
||||||
|
#
|
||||||
|
STANDARD_PLUGIN_DEFINED_PATHS = ("*.c", "*.h")
|
||||||
|
|
||||||
|
#
|
||||||
|
# The Uncrustify application path should set in this environment variable
|
||||||
|
#
|
||||||
|
UNCRUSTIFY_PATH_ENV_KEY = "UNCRUSTIFY_CI_PATH"
|
||||||
|
|
||||||
|
def GetTestName(self, packagename: str, environment: VarDict) -> Tuple:
|
||||||
|
""" Provide the testcase name and classname for use in reporting
|
||||||
|
|
||||||
|
Args:
|
||||||
|
packagename: string containing name of package to build
|
||||||
|
environment: The VarDict for the test to run in
|
||||||
|
Returns:
|
||||||
|
A tuple containing the testcase name and the classname
|
||||||
|
(testcasename, classname)
|
||||||
|
testclassname: a descriptive string for the testcase can include whitespace
|
||||||
|
classname: should be patterned <packagename>.<plugin>.<optionally any unique condition>
|
||||||
|
"""
|
||||||
|
return ("Check file coding standard compliance in " + packagename, packagename + ".UncrustifyCheck")
|
||||||
|
|
||||||
|
def RunBuildPlugin(self, package_rel_path: str, edk2_path: Edk2Path, package_config: Dict[str, List[str]], environment_config: Any, plugin_manager: PluginManager, plugin_manager_helper: HelperFunctions, tc: JunitReportTestCase, output_stream=None) -> int:
|
||||||
|
"""
|
||||||
|
External function of plugin. This function is used to perform the task of the CiBuild Plugin.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
- package_rel_path: edk2 workspace relative path to the package
|
||||||
|
- edk2_path: Edk2Path object with workspace and packages paths
|
||||||
|
- package_config: Dictionary with the package configuration
|
||||||
|
- environment_config: Environment configuration
|
||||||
|
- plugin_manager: Plugin Manager Instance
|
||||||
|
- plugin_manager_helper: Plugin Manager Helper Instance
|
||||||
|
- tc: JUnit test case
|
||||||
|
- output_stream: The StringIO output stream from this plugin (logging)
|
||||||
|
|
||||||
|
Returns
|
||||||
|
>0 : Number of errors found
|
||||||
|
0 : Passed successfully
|
||||||
|
-1 : Skipped for missing prereq
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# Initialize plugin and check pre-requisites.
|
||||||
|
self._initialize_environment_info(
|
||||||
|
package_rel_path, edk2_path, package_config, tc)
|
||||||
|
self._initialize_configuration()
|
||||||
|
self._check_for_preexisting_formatted_files()
|
||||||
|
|
||||||
|
# Log important context information.
|
||||||
|
self._log_uncrustify_app_info()
|
||||||
|
|
||||||
|
# Get template file contents if specified
|
||||||
|
self._get_template_file_contents()
|
||||||
|
|
||||||
|
# Create meta input files & directories
|
||||||
|
self._create_temp_working_directory()
|
||||||
|
self._create_uncrustify_file_list_file()
|
||||||
|
|
||||||
|
self._run_uncrustify()
|
||||||
|
|
||||||
|
# Post-execution actions.
|
||||||
|
self._process_uncrustify_results()
|
||||||
|
|
||||||
|
except UncrustifyException as e:
|
||||||
|
self._tc.LogStdError(
|
||||||
|
f"Uncrustify error {e.exit_code}. Details:\n\n{str(e)}")
|
||||||
|
logging.warning(
|
||||||
|
f"Uncrustify error {e.exit_code}. Details:\n\n{str(e)}")
|
||||||
|
return -1
|
||||||
|
else:
|
||||||
|
if self._formatted_file_error_count > 0:
|
||||||
|
if self._audit_only_mode:
|
||||||
|
logging.info(
|
||||||
|
"Setting test as skipped since AuditOnly is enabled")
|
||||||
|
self._tc.SetSkipped()
|
||||||
|
return -1
|
||||||
|
else:
|
||||||
|
self._tc.SetFailed(
|
||||||
|
f"{self._plugin_name} failed due to {self._formatted_file_error_count} incorrectly formatted files.", "CHECK_FAILED")
|
||||||
|
else:
|
||||||
|
self._tc.SetSuccess()
|
||||||
|
return self._formatted_file_error_count
|
||||||
|
finally:
|
||||||
|
self._cleanup_temporary_formatted_files()
|
||||||
|
self._cleanup_temporary_directory()
|
||||||
|
|
||||||
|
def _initialize_configuration(self) -> None:
|
||||||
|
"""
|
||||||
|
Initializes plugin configuration.
|
||||||
|
"""
|
||||||
|
self._initialize_app_info()
|
||||||
|
self._initialize_config_file_info()
|
||||||
|
self._initialize_file_to_format_info()
|
||||||
|
self._initialize_test_case_output_options()
|
||||||
|
|
||||||
|
def _check_for_preexisting_formatted_files(self) -> None:
|
||||||
|
"""
|
||||||
|
Checks if any formatted files from prior execution are present.
|
||||||
|
|
||||||
|
Existence of such files is an unexpected condition. This might result
|
||||||
|
from an error that occurred during a previous run or a premature exit from a debug scenario. In any case, the package should be clean before starting a new run.
|
||||||
|
"""
|
||||||
|
pre_existing_formatted_file_count = len(
|
||||||
|
[str(path.resolve()) for path in pathlib.Path(self._abs_package_path).rglob(f'*{UncrustifyCheck.FORMATTED_FILE_EXTENSION}')])
|
||||||
|
|
||||||
|
if pre_existing_formatted_file_count > 0:
|
||||||
|
raise UncrustifyStalePluginFormattedFilesException(
|
||||||
|
f"{pre_existing_formatted_file_count} formatted files already exist. To prevent overwriting these files, please remove them before running this plugin.")
|
||||||
|
|
||||||
|
def _cleanup_temporary_directory(self) -> None:
|
||||||
|
"""
|
||||||
|
Cleans up the temporary directory used for this execution instance.
|
||||||
|
|
||||||
|
This removes the directory and all files created during this instance.
|
||||||
|
"""
|
||||||
|
if hasattr(self, '_working_dir'):
|
||||||
|
self._remove_tree(self._working_dir)
|
||||||
|
|
||||||
|
def _cleanup_temporary_formatted_files(self) -> None:
|
||||||
|
"""
|
||||||
|
Cleans up the temporary formmatted files produced by Uncrustify.
|
||||||
|
|
||||||
|
This will recursively remove all formatted files generated by Uncrustify
|
||||||
|
during this execution instance.
|
||||||
|
"""
|
||||||
|
if hasattr(self, '_abs_package_path'):
|
||||||
|
formatted_files = [str(path.resolve()) for path in pathlib.Path(
|
||||||
|
self._abs_package_path).rglob(f'*{UncrustifyCheck.FORMATTED_FILE_EXTENSION}')]
|
||||||
|
|
||||||
|
for formatted_file in formatted_files:
|
||||||
|
os.remove(formatted_file)
|
||||||
|
|
||||||
|
def _create_temp_working_directory(self) -> None:
|
||||||
|
"""
|
||||||
|
Creates the temporary directory used for this execution instance.
|
||||||
|
"""
|
||||||
|
self._working_dir = os.path.join(
|
||||||
|
self._abs_workspace_path, "Build", ".pytool", "Plugin", f"{self._plugin_name}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
pathlib.Path(self._working_dir).mkdir(parents=True, exist_ok=True)
|
||||||
|
except OSError as e:
|
||||||
|
raise UncrustifyInputFileCreationErrorException(
|
||||||
|
f"Error creating plugin directory {self._working_dir}.\n\n{repr(e)}.")
|
||||||
|
|
||||||
|
def _create_uncrustify_file_list_file(self) -> None:
|
||||||
|
"""
|
||||||
|
Creates the file with the list of source files for Uncrustify to process.
|
||||||
|
"""
|
||||||
|
self._app_input_file_path = os.path.join(
|
||||||
|
self._working_dir, "uncrustify_file_list.txt")
|
||||||
|
|
||||||
|
with open(self._app_input_file_path, 'w', encoding='utf8') as f:
|
||||||
|
f.writelines(f"\n".join(self._abs_file_paths_to_format))
|
||||||
|
|
||||||
|
def _execute_uncrustify(self) -> None:
|
||||||
|
"""
|
||||||
|
Executes Uncrustify with the initialized configuration.
|
||||||
|
"""
|
||||||
|
output = StringIO()
|
||||||
|
self._app_exit_code = RunCmd(
|
||||||
|
self._app_path,
|
||||||
|
f"-c {self._app_config_file} -F {self._app_input_file_path} --if-changed --suffix {UncrustifyCheck.FORMATTED_FILE_EXTENSION}", outstream=output)
|
||||||
|
self._app_output = output.getvalue().strip().splitlines()
|
||||||
|
|
||||||
|
def _get_git_ignored_paths(self) -> List[str]:
|
||||||
|
""""
|
||||||
|
Returns a list of file absolute path strings to all files ignored in this git repository.
|
||||||
|
|
||||||
|
If git is not found, an empty list will be returned.
|
||||||
|
"""
|
||||||
|
if not shutil.which("git"):
|
||||||
|
logging.warn(
|
||||||
|
"Git is not found on this system. Git submodule paths will not be considered.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
outstream_buffer = StringIO()
|
||||||
|
exit_code = RunCmd("git", "ls-files --other",
|
||||||
|
workingdir=self._abs_workspace_path, outstream=outstream_buffer, logging_level=logging.NOTSET)
|
||||||
|
if (exit_code != 0):
|
||||||
|
raise UncrustifyGitIgnoreFileException(
|
||||||
|
f"An error occurred reading git ignore settings. This will prevent Uncrustify from running against the expected set of files.")
|
||||||
|
|
||||||
|
# Note: This will potentially be a large list, but at least sorted
|
||||||
|
return outstream_buffer.getvalue().strip().splitlines()
|
||||||
|
|
||||||
|
def _get_git_submodule_paths(self) -> List[str]:
|
||||||
|
"""
|
||||||
|
Returns a list of directory absolute path strings to the root of each submodule in the workspace repository.
|
||||||
|
|
||||||
|
If git is not found, an empty list will be returned.
|
||||||
|
"""
|
||||||
|
if not shutil.which("git"):
|
||||||
|
logging.warn(
|
||||||
|
"Git is not found on this system. Git submodule paths will not be considered.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
if os.path.isfile(os.path.join(self._abs_workspace_path, ".gitmodules")):
|
||||||
|
logging.info(
|
||||||
|
f".gitmodules file found. Excluding submodules in {self._package_name}.")
|
||||||
|
|
||||||
|
outstream_buffer = StringIO()
|
||||||
|
exit_code = RunCmd("git", "config --file .gitmodules --get-regexp path", workingdir=self._abs_workspace_path, outstream=outstream_buffer, logging_level=logging.NOTSET)
|
||||||
|
if (exit_code != 0):
|
||||||
|
raise UncrustifyGitSubmoduleException(
|
||||||
|
f".gitmodule file detected but an error occurred reading the file. Cannot proceed with unknown submodule paths.")
|
||||||
|
|
||||||
|
submodule_paths = []
|
||||||
|
for line in outstream_buffer.getvalue().strip().splitlines():
|
||||||
|
submodule_paths.append(
|
||||||
|
os.path.normpath(os.path.join(self._abs_workspace_path, line.split()[1])))
|
||||||
|
|
||||||
|
return submodule_paths
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def _get_template_file_contents(self) -> None:
|
||||||
|
"""
|
||||||
|
Gets the contents of Uncrustify template files if they are specified
|
||||||
|
in the Uncrustify configuration file.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self._file_template_contents = None
|
||||||
|
self._func_template_contents = None
|
||||||
|
|
||||||
|
# Allow no value to allow "set" statements in the config file which do
|
||||||
|
# not specify value assignment
|
||||||
|
parser = configparser.ConfigParser(allow_no_value=True)
|
||||||
|
with open(self._app_config_file, 'r') as cf:
|
||||||
|
parser.read_string("[dummy_section]\n" + cf.read())
|
||||||
|
|
||||||
|
try:
|
||||||
|
file_template_name = parser["dummy_section"]["cmt_insert_file_header"]
|
||||||
|
|
||||||
|
file_template_path = pathlib.Path(file_template_name)
|
||||||
|
|
||||||
|
if not file_template_path.is_file():
|
||||||
|
file_template_path = pathlib.Path(os.path.join(self._plugin_path, file_template_name))
|
||||||
|
self._file_template_contents = file_template_path.read_text()
|
||||||
|
except KeyError:
|
||||||
|
logging.warn("A file header template is not specified in the config file.")
|
||||||
|
except FileNotFoundError:
|
||||||
|
logging.warn("The specified file header template file was not found.")
|
||||||
|
try:
|
||||||
|
func_template_name = parser["dummy_section"]["cmt_insert_func_header"]
|
||||||
|
|
||||||
|
func_template_path = pathlib.Path(func_template_name)
|
||||||
|
|
||||||
|
if not func_template_path.is_file():
|
||||||
|
func_template_path = pathlib.Path(os.path.join(self._plugin_path, func_template_name))
|
||||||
|
self._func_template_contents = func_template_path.read_text()
|
||||||
|
except KeyError:
|
||||||
|
logging.warn("A function header template is not specified in the config file.")
|
||||||
|
except FileNotFoundError:
|
||||||
|
logging.warn("The specified function header template file was not found.")
|
||||||
|
|
||||||
|
def _initialize_app_info(self) -> None:
|
||||||
|
"""
|
||||||
|
Initialize Uncrustify application information.
|
||||||
|
|
||||||
|
This function will determine the application path and version.
|
||||||
|
"""
|
||||||
|
# Verify Uncrustify is specified in the environment.
|
||||||
|
if UncrustifyCheck.UNCRUSTIFY_PATH_ENV_KEY not in os.environ:
|
||||||
|
raise UncrustifyAppEnvVarNotFoundException(
|
||||||
|
f"Uncrustify environment variable {UncrustifyCheck.UNCRUSTIFY_PATH_ENV_KEY} is not present.")
|
||||||
|
|
||||||
|
self._app_path = shutil.which('uncrustify', path=os.environ[UncrustifyCheck.UNCRUSTIFY_PATH_ENV_KEY])
|
||||||
|
|
||||||
|
if self._app_path is None:
|
||||||
|
raise FileNotFoundError(
|
||||||
|
errno.ENOENT, os.strerror(errno.ENOENT), self._app_path)
|
||||||
|
|
||||||
|
self._app_path = os.path.normcase(os.path.normpath(self._app_path))
|
||||||
|
|
||||||
|
if not os.path.isfile(self._app_path):
|
||||||
|
raise FileNotFoundError(
|
||||||
|
errno.ENOENT, os.strerror(errno.ENOENT), self._app_path)
|
||||||
|
|
||||||
|
# Verify Uncrustify is present at the expected path.
|
||||||
|
return_buffer = StringIO()
|
||||||
|
ret = RunCmd(self._app_path, "--version", outstream=return_buffer)
|
||||||
|
if (ret != 0):
|
||||||
|
raise UncrustifyAppVersionErrorException(
|
||||||
|
f"Error occurred executing --version: {ret}.")
|
||||||
|
|
||||||
|
# Log Uncrustify version information.
|
||||||
|
self._app_version = return_buffer.getvalue().strip()
|
||||||
|
self._tc.LogStdOut(f"Uncrustify version: {self._app_version}")
|
||||||
|
version_aggregator.GetVersionAggregator().ReportVersion(
|
||||||
|
"Uncrustify", self._app_version, version_aggregator.VersionTypes.INFO)
|
||||||
|
|
||||||
|
def _initialize_config_file_info(self) -> None:
|
||||||
|
"""
|
||||||
|
Initialize Uncrustify configuration file info.
|
||||||
|
|
||||||
|
The config file path is relative to the package root.
|
||||||
|
"""
|
||||||
|
self._app_config_file = UncrustifyCheck.DEFAULT_CONFIG_FILE_PATH
|
||||||
|
if "ConfigFilePath" in self._package_config:
|
||||||
|
self._app_config_file = self._package_config["ConfigFilePath"].strip()
|
||||||
|
|
||||||
|
self._app_config_file = os.path.normpath(
|
||||||
|
os.path.join(self._abs_package_path, self._app_config_file))
|
||||||
|
|
||||||
|
if not os.path.isfile(self._app_config_file):
|
||||||
|
raise FileNotFoundError(
|
||||||
|
errno.ENOENT, os.strerror(errno.ENOENT), self._app_config_file)
|
||||||
|
|
||||||
|
def _initialize_environment_info(self, package_rel_path: str, edk2_path: Edk2Path, package_config: Dict[str, List[str]], tc: JunitReportTestCase) -> None:
|
||||||
|
"""
|
||||||
|
Initializes plugin environment information.
|
||||||
|
"""
|
||||||
|
self._abs_package_path = edk2_path.GetAbsolutePathOnThisSytemFromEdk2RelativePath(
|
||||||
|
package_rel_path)
|
||||||
|
self._abs_workspace_path = edk2_path.WorkspacePath
|
||||||
|
self._package_config = package_config
|
||||||
|
self._package_name = os.path.basename(
|
||||||
|
os.path.normpath(package_rel_path))
|
||||||
|
self._plugin_name = self.__class__.__name__
|
||||||
|
self._plugin_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
self._rel_package_path = package_rel_path
|
||||||
|
self._tc = tc
|
||||||
|
|
||||||
|
def _initialize_file_to_format_info(self) -> None:
|
||||||
|
"""
|
||||||
|
Forms the list of source files for Uncrustify to process.
|
||||||
|
"""
|
||||||
|
# Create a list of all the package relative file paths in the package to run against Uncrustify.
|
||||||
|
rel_file_paths_to_format = list(
|
||||||
|
UncrustifyCheck.STANDARD_PLUGIN_DEFINED_PATHS)
|
||||||
|
|
||||||
|
# Allow the ci.yaml to remove any of the pre-defined standard paths
|
||||||
|
if "IgnoreStandardPaths" in self._package_config:
|
||||||
|
for a in self._package_config["IgnoreStandardPaths"]:
|
||||||
|
if a.strip() in rel_file_paths_to_format:
|
||||||
|
self._tc.LogStdOut(
|
||||||
|
f"Ignoring standard path due to ci.yaml ignore: {a}")
|
||||||
|
rel_file_paths_to_format.remove(a.strip())
|
||||||
|
else:
|
||||||
|
raise UncrustifyInvalidIgnoreStandardPathsException(f"Invalid IgnoreStandardPaths value: {a}")
|
||||||
|
|
||||||
|
# Allow the ci.yaml to specify additional include paths for this package
|
||||||
|
if "AdditionalIncludePaths" in self._package_config:
|
||||||
|
rel_file_paths_to_format.extend(
|
||||||
|
self._package_config["AdditionalIncludePaths"])
|
||||||
|
|
||||||
|
self._abs_file_paths_to_format = []
|
||||||
|
for path in rel_file_paths_to_format:
|
||||||
|
self._abs_file_paths_to_format.extend(
|
||||||
|
[str(path.resolve()) for path in pathlib.Path(self._abs_package_path).rglob(path)])
|
||||||
|
|
||||||
|
if not "SkipGitExclusions" in self._package_config or not self._package_config["SkipGitExclusions"]:
|
||||||
|
# Remove files ignored by git
|
||||||
|
logging.info(
|
||||||
|
f"{self._package_name} file count before git ignore file exclusion: {len(self._abs_file_paths_to_format)}")
|
||||||
|
|
||||||
|
ignored_paths = self._get_git_ignored_paths()
|
||||||
|
self._abs_file_paths_to_format = list(
|
||||||
|
set(self._abs_file_paths_to_format).difference(ignored_paths))
|
||||||
|
|
||||||
|
logging.info(
|
||||||
|
f"{self._package_name} file count after git ignore file exclusion: {len(self._abs_file_paths_to_format)}")
|
||||||
|
|
||||||
|
# Remove files in submodules
|
||||||
|
logging.info(
|
||||||
|
f"{self._package_name} file count before submodule exclusion: {len(self._abs_file_paths_to_format)}")
|
||||||
|
|
||||||
|
submodule_paths = tuple(self._get_git_submodule_paths())
|
||||||
|
for path in submodule_paths:
|
||||||
|
logging.info(f" submodule path: {path}")
|
||||||
|
|
||||||
|
self._abs_file_paths_to_format = [
|
||||||
|
f for f in self._abs_file_paths_to_format if not f.startswith(submodule_paths)]
|
||||||
|
|
||||||
|
logging.info(
|
||||||
|
f"{self._package_name} file count after submodule exclusion: {len(self._abs_file_paths_to_format)}")
|
||||||
|
|
||||||
|
# Sort the files for more consistent results
|
||||||
|
self._abs_file_paths_to_format.sort()
|
||||||
|
|
||||||
|
def _initialize_test_case_output_options(self) -> None:
|
||||||
|
"""
|
||||||
|
Initializes options that influence test case output.
|
||||||
|
"""
|
||||||
|
self._audit_only_mode = False
|
||||||
|
self._output_file_diffs = False
|
||||||
|
|
||||||
|
if "AuditOnly" in self._package_config and self._package_config["AuditOnly"]:
|
||||||
|
self._audit_only_mode = True
|
||||||
|
|
||||||
|
if "OutputFileDiffs" in self._package_config and self._package_config["OutputFileDiffs"]:
|
||||||
|
self._output_file_diffs = True
|
||||||
|
|
||||||
|
def _log_uncrustify_app_info(self) -> None:
|
||||||
|
"""
|
||||||
|
Logs Uncrustify application information.
|
||||||
|
"""
|
||||||
|
self._tc.LogStdOut(f"Found Uncrustify at {self._app_path}")
|
||||||
|
self._tc.LogStdOut(f"Uncrustify version: {self._app_version}")
|
||||||
|
self._tc.LogStdOut('\n')
|
||||||
|
logging.info(f"Found Uncrustify at {self._app_path}")
|
||||||
|
logging.info(f"Uncrustify version: {self._app_version}")
|
||||||
|
logging.info('\n')
|
||||||
|
|
||||||
|
def _process_uncrustify_results(self) -> None:
|
||||||
|
"""
|
||||||
|
Process the results from Uncrustify.
|
||||||
|
|
||||||
|
Determines whether formatting errors are present and logs failures.
|
||||||
|
"""
|
||||||
|
formatted_files = [str(path.resolve()) for path in pathlib.Path(
|
||||||
|
self._abs_package_path).rglob(f'*{UncrustifyCheck.FORMATTED_FILE_EXTENSION}')]
|
||||||
|
|
||||||
|
self._formatted_file_error_count = len(formatted_files)
|
||||||
|
|
||||||
|
if self._formatted_file_error_count > 0:
|
||||||
|
self._tc.LogStdError("Files with formatting errors:\n")
|
||||||
|
|
||||||
|
if self._output_file_diffs:
|
||||||
|
logging.info("Calculating file diffs. This might take a while...")
|
||||||
|
|
||||||
|
for formatted_file in formatted_files:
|
||||||
|
pre_formatted_file = formatted_file[:-
|
||||||
|
len(UncrustifyCheck.FORMATTED_FILE_EXTENSION)]
|
||||||
|
logging.error(pre_formatted_file)
|
||||||
|
|
||||||
|
if (self._output_file_diffs or
|
||||||
|
self._file_template_contents is not None or
|
||||||
|
self._func_template_contents is not None):
|
||||||
|
self._tc.LogStdError(
|
||||||
|
f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}\n")
|
||||||
|
|
||||||
|
with open(formatted_file) as ff:
|
||||||
|
formatted_file_text = ff.read()
|
||||||
|
|
||||||
|
if (self._file_template_contents is not None and
|
||||||
|
self._file_template_contents in formatted_file_text):
|
||||||
|
self._tc.LogStdError(f"File header is missing in {os.path.relpath(pre_formatted_file, self._abs_package_path)}\n")
|
||||||
|
|
||||||
|
if (self._func_template_contents is not None and
|
||||||
|
self._func_template_contents in formatted_file_text):
|
||||||
|
self._tc.LogStdError(f"A function header is missing in {os.path.relpath(pre_formatted_file, self._abs_package_path)}\n")
|
||||||
|
|
||||||
|
if self._output_file_diffs:
|
||||||
|
with open(pre_formatted_file) as pf:
|
||||||
|
pre_formatted_file_text = pf.read()
|
||||||
|
|
||||||
|
for line in difflib.unified_diff(pre_formatted_file_text.split('\n'), formatted_file_text.split('\n'), fromfile=pre_formatted_file, tofile=formatted_file, n=3):
|
||||||
|
self._tc.LogStdError(line)
|
||||||
|
|
||||||
|
self._tc.LogStdError('\n')
|
||||||
|
else:
|
||||||
|
self._tc.LogStdError(pre_formatted_file)
|
||||||
|
|
||||||
|
def _remove_tree(self, dir_path: str, ignore_errors: bool = False) -> None:
|
||||||
|
"""
|
||||||
|
Helper for removing a directory. Over time there have been
|
||||||
|
many private implementations of this due to reliability issues in the
|
||||||
|
shutil implementations. To consolidate on a single function this helper is added.
|
||||||
|
|
||||||
|
On error try to change file attributes. Also add retry logic.
|
||||||
|
|
||||||
|
This function is temporarily borrowed from edk2toollib.utility_functions
|
||||||
|
since the version used in edk2 is not recent enough to include the
|
||||||
|
function.
|
||||||
|
|
||||||
|
This function should be replaced by "RemoveTree" when it is available.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
- dir_path: Path to directory to remove.
|
||||||
|
- ignore_errors: Whether to ignore errors during removal
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _remove_readonly(func, path, _):
|
||||||
|
"""
|
||||||
|
Private function to attempt to change permissions on file/folder being deleted.
|
||||||
|
"""
|
||||||
|
os.chmod(path, os.stat.S_IWRITE)
|
||||||
|
func(path)
|
||||||
|
|
||||||
|
for _ in range(3): # retry up to 3 times
|
||||||
|
try:
|
||||||
|
shutil.rmtree(dir_path, ignore_errors=ignore_errors, onerror=_remove_readonly)
|
||||||
|
except OSError as err:
|
||||||
|
logging.warning(f"Failed to fully remove {dir_path}: {err}")
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f"Failed to remove {dir_path}")
|
||||||
|
|
||||||
|
def _run_uncrustify(self) -> None:
|
||||||
|
"""
|
||||||
|
Runs Uncrustify for this instance of plugin execution.
|
||||||
|
"""
|
||||||
|
logging.info("Executing Uncrustify. This might take a while...")
|
||||||
|
start_time = timeit.default_timer()
|
||||||
|
self._execute_uncrustify()
|
||||||
|
end_time = timeit.default_timer() - start_time
|
||||||
|
|
||||||
|
execution_summary = f"Uncrustify executed against {len(self._abs_file_paths_to_format)} files in {self._package_name} in {end_time:.2f} seconds.\n"
|
||||||
|
|
||||||
|
self._tc.LogStdOut(execution_summary)
|
||||||
|
logging.info(execution_summary)
|
||||||
|
|
||||||
|
if self._app_exit_code != 0 and self._app_exit_code != 1:
|
||||||
|
raise UncrustifyAppExecutionException(
|
||||||
|
f"Error {str(self._app_exit_code)} returned from Uncrustify:\n\n{str(self._app_output)}")
|
9
.pytool/Plugin/UncrustifyCheck/default_file_header.txt
Normal file
9
.pytool/Plugin/UncrustifyCheck/default_file_header.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/** @file
|
||||||
|
Brief description of the file's purpose.
|
||||||
|
|
||||||
|
Detailed description of the file's contents and other useful
|
||||||
|
information for a person viewing the file for the first time.
|
||||||
|
|
||||||
|
<<Copyright>>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
**/
|
15
.pytool/Plugin/UncrustifyCheck/default_function_header.txt
Normal file
15
.pytool/Plugin/UncrustifyCheck/default_function_header.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
Brief description of this function's purpose.
|
||||||
|
|
||||||
|
Follow it immediately with the detailed description.
|
||||||
|
|
||||||
|
@param[in] Arg1 Description of Arg1.
|
||||||
|
@param[in] Arg2 Description of Arg2 This is complicated and requires
|
||||||
|
multiple lines to describe.
|
||||||
|
@param[out] Arg3 Description of Arg3.
|
||||||
|
@param[in, out] Arg4 Description of Arg4.
|
||||||
|
|
||||||
|
@retval VAL_ONE Description of what VAL_ONE signifies.
|
||||||
|
@retval OTHER This is the only other return value. If there were other
|
||||||
|
return values, they would be listed.
|
||||||
|
**/
|
462
.pytool/Plugin/UncrustifyCheck/uncrustify.cfg
Normal file
462
.pytool/Plugin/UncrustifyCheck/uncrustify.cfg
Normal file
@ -0,0 +1,462 @@
|
|||||||
|
## @file
|
||||||
|
# Uncrustify Configuration File for EDK II C Code
|
||||||
|
#
|
||||||
|
# Coding Standard: https://edk2-docs.gitbook.io/edk-ii-c-coding-standards-specification/
|
||||||
|
#
|
||||||
|
# This configuration file is meant to be a "best attempt" to align with the
|
||||||
|
# definitions in the EDK II C Coding Standards Specification.
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
# Force UTF-8 encoding (no UTF-16)
|
||||||
|
enable_digraphs = false
|
||||||
|
utf8_byte = false
|
||||||
|
utf8_force = true
|
||||||
|
|
||||||
|
# Code width / line splitting
|
||||||
|
#code_width =120 # TODO: This causes non-deterministic behaviour in some cases when code wraps
|
||||||
|
ls_code_width =false
|
||||||
|
ls_for_split_full =true
|
||||||
|
ls_func_split_full =true
|
||||||
|
pos_comma =trail
|
||||||
|
|
||||||
|
# 5.1.7 All files must end with CRLF
|
||||||
|
newlines = crlf
|
||||||
|
|
||||||
|
# 5.1.2 Do not use tab characters
|
||||||
|
|
||||||
|
cmt_convert_tab_to_spaces = true # Whether to convert all tabs to spaces in comments. If false, tabs in
|
||||||
|
# comments are left alone, unless used for indenting.
|
||||||
|
indent_columns = 2 # Number of spaces for indentation
|
||||||
|
indent_with_tabs = 0 # Do not use TAB characters
|
||||||
|
string_replace_tab_chars = true # Replace TAB with SPACE
|
||||||
|
# Note: This will break .robot files but is needed for edk2 style
|
||||||
|
|
||||||
|
# 5.2.1.1 There shall be only one statement on a line (statement ends with ;)
|
||||||
|
nl_multi_line_cond = true # Add a newline between ')' and '{' if the ')' is on a different line than
|
||||||
|
# the if/for/etc.
|
||||||
|
nl_after_semicolon = true # Whether to add a newline after semicolons, except in 'for' statements.
|
||||||
|
|
||||||
|
# 5.2.1.3 An open brace '{' goes on the same line as the closing parenthesis ')' of simple predicate expressions
|
||||||
|
mod_full_brace_do = add # Add or remove braces on a single-line 'do' statement.
|
||||||
|
mod_full_brace_for = add
|
||||||
|
mod_full_brace_function = add # Add or remove braces on a single-line function definition.
|
||||||
|
mod_full_brace_if = add # Add or remove braces on a single-line 'if' statement. Braces will not be
|
||||||
|
# removed if the braced statement contains an 'else'.
|
||||||
|
mod_full_brace_if_chain = false
|
||||||
|
mod_full_brace_while = add
|
||||||
|
|
||||||
|
# 5.2.1.4 A close brace '}' always goes at the beginning of the last line of the body
|
||||||
|
eat_blanks_after_open_brace = true
|
||||||
|
eat_blanks_before_close_brace = true # Whether to remove blank lines before '}'.
|
||||||
|
|
||||||
|
# 5.2.2.2 Always put space before and after binary operators.
|
||||||
|
sp_assign = add # Add or remove space around assignment operator '=', '+=', etc.
|
||||||
|
sp_assign_default = add
|
||||||
|
sp_bool = add # Add or remove space around boolean operators '&&' and '||'.
|
||||||
|
sp_compare = add # Add or remove space around compare operator '<', '>', '==', etc.
|
||||||
|
|
||||||
|
# 5.2.2.3 Do not put space between unary operators and their object
|
||||||
|
sp_addr = remove # A or remove space after the '&' (address-of) unary operator.
|
||||||
|
sp_incdec = remove # Add or remove space between '++' and '--' the word to which it is being
|
||||||
|
# applied, as in '(--x)' or 'y++;'.
|
||||||
|
sp_inv = remove # Add or remove space after the '~' (invert) unary operator.
|
||||||
|
sp_not = remove # Add or remove space after the '!' (not) unary operator.
|
||||||
|
sp_sign = remove # Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'.
|
||||||
|
|
||||||
|
# 5.2.2.4 Subsequent lines of multi-line function calls should line up two spaces from the beginning of the function
|
||||||
|
# name
|
||||||
|
nl_func_call_args_multi_line = true # Whether to add a newline after each ',' in a function call if '(' and ')'
|
||||||
|
# are in different lines.
|
||||||
|
nl_func_call_args_multi_line_ignore_closures = false
|
||||||
|
|
||||||
|
# - Indent each argument 2 spaces from the start of the function name. If a
|
||||||
|
# function is called through a structure or union member, of type
|
||||||
|
# pointer-to-function, then indent each argument 2 spaces from the start of the
|
||||||
|
# member name.
|
||||||
|
indent_func_call_edk2_style = true # Use EDK2 indentation style for function calls (**CUSTOM SETTING**)
|
||||||
|
indent_paren_after_func_call = true # Whether to indent the open parenthesis of a function call, if the
|
||||||
|
# parenthesis is on its own line.
|
||||||
|
|
||||||
|
# - Align the close parenthesis with the start of the last argument
|
||||||
|
indent_paren_close = 0 # How to indent a close parenthesis after a newline.
|
||||||
|
# (0: Body, 1: Openparenthesis, 2: Brace level)
|
||||||
|
|
||||||
|
|
||||||
|
# 5.2.2.5 Always put space after commas or semicolons that separate items
|
||||||
|
sp_after_comma = force # Add or remove space after ',', i.e. 'a,b' vs. 'a, b'.
|
||||||
|
sp_before_comma = remove # Add or remove space before ','.
|
||||||
|
|
||||||
|
# 5.2.2.6 Always put space before an open parenthesis
|
||||||
|
sp_after_sparen = add # Add or remove space after ')' of control statements.
|
||||||
|
sp_attribute_paren = add # Add or remove space between '__attribute__' and '('.
|
||||||
|
sp_before_sparen = force # Add or remove space before '(' of control statements
|
||||||
|
# ('if', 'for', 'switch', 'while', etc.).
|
||||||
|
sp_defined_paren = force # Add or remove space between 'defined' and '(' in '#if defined (FOO)'.
|
||||||
|
sp_func_call_paren = force # Add or remove space between function name and '(' on function calls.
|
||||||
|
sp_func_call_paren_empty = force # Add or remove space between function name and '()' on function calls
|
||||||
|
# without parameters. If set to ignore (the default), sp_func_call_paren is
|
||||||
|
# used.
|
||||||
|
sp_func_def_paren = add # Add or remove space between alias name and '(' of a non-pointer function
|
||||||
|
# type typedef.
|
||||||
|
sp_func_proto_paren = add # Add or remove space between function name and '()' on function declaration
|
||||||
|
sp_sizeof_paren = force # Add or remove space between 'sizeof' and '('.
|
||||||
|
sp_type_func = add # Add or remove space between return type and function name. A minimum of 1
|
||||||
|
# is forced except for pointer return types.
|
||||||
|
|
||||||
|
# Not specified, but also good style to remove spaces inside parentheses (Optional)
|
||||||
|
sp_cparen_oparen = remove # Add or remove space between back-to-back parentheses, i.e. ')(' vs. ') ('.
|
||||||
|
sp_inside_fparen = remove # Add or remove space inside function '(' and ')'.
|
||||||
|
sp_inside_fparens = remove # Add or remove space inside empty function '()'.
|
||||||
|
sp_inside_paren = remove # Add or remove space inside '(' and ')'.
|
||||||
|
sp_inside_paren_cast = remove # Add or remove spaces inside cast parentheses. '(int)x'
|
||||||
|
sp_inside_square = remove # Add or remove space inside a non-empty '[' and ']'.
|
||||||
|
sp_paren_paren = remove # Add or remove space between nested parentheses, i.e. '((' vs. ') )'.
|
||||||
|
sp_square_fparen = remove # Add or remove space between ']' and '(' when part of a function call.
|
||||||
|
|
||||||
|
# 5.2.2.7 Put a space before an open brace if it is not on its own line
|
||||||
|
sp_do_brace_open = force # Add or remove space between 'do' and '{'.
|
||||||
|
sp_paren_brace = force # Add or remove space between ')' and '{'.
|
||||||
|
sp_sparen_brace = force # Add or remove space between ')' and '{' of of control statements.
|
||||||
|
|
||||||
|
# 5.2.2.8 Do not put spaces around structure member and pointer operators
|
||||||
|
sp_after_byref = remove # Add or remove space after reference sign '&', if followed by a word.
|
||||||
|
sp_before_byref = add # Add or remove space before a reference sign '&'.
|
||||||
|
sp_deref = remove # Add or remove space after the '*' (dereference) unary operator. This does
|
||||||
|
# not affect the spacing after a '*' that is part of a type.
|
||||||
|
sp_member = remove # Add or remove space around the '.' or '->' operators.
|
||||||
|
|
||||||
|
# 5.2.2.9 Do not put spaces before open brackets of array subscripts
|
||||||
|
sp_before_square = remove # Add or remove space before '[' (except '[]').
|
||||||
|
sp_before_squares = remove # Add or remove space before '[]'.
|
||||||
|
sp_before_vardef_square = remove # Add or remove space before '[' for a variable definition.
|
||||||
|
|
||||||
|
# 5.2.2.10 Use extra parentheses rather than depending on in-depth knowledge of the order of precedence of C
|
||||||
|
mod_full_paren_if_bool = true # Whether to fully parenthesize Boolean expressions in 'while' and 'if'
|
||||||
|
# statement, as in 'if (a && b > c)' => 'if (a && (b > c))'.
|
||||||
|
|
||||||
|
# 5.2.2.11 Align a continuation line with the part of the line that it continues.
|
||||||
|
use_indent_continue_only_once = true
|
||||||
|
|
||||||
|
# Additional '{}' bracing rules (Optional)
|
||||||
|
# NOTE - The style guide specifies two different styles for braces,
|
||||||
|
# so these are ignored for now to allow developers some flexibility.
|
||||||
|
nl_after_brace_close = true # Whether to add a newline after '}'. Does not apply if followed by a
|
||||||
|
# necessary ';'.
|
||||||
|
nl_brace_else = remove # Add or remove newline between '}' and 'else'.
|
||||||
|
nl_brace_while = remove # Add or remove newline between '}' and 'while' of 'do' statement.
|
||||||
|
nl_do_brace = remove # Add or remove newline between 'do' and '{'.
|
||||||
|
nl_else_brace = remove # Add or remove newline between 'else' and '{'.
|
||||||
|
nl_else_if = remove # Add or remove newline between 'else' and 'if'.
|
||||||
|
nl_elseif_brace = remove # Add or remove newline between 'else if' and '{'.
|
||||||
|
nl_enum_brace = remove # Add or remove newline between 'enum' and '{'.
|
||||||
|
nl_fcall_brace = remove # Add or remove newline between a function call's ')' and '{',
|
||||||
|
# as in 'list_for_each(item, &list) { }'.
|
||||||
|
nl_for_brace = remove # Add or remove newline between 'for' and '{'.
|
||||||
|
nl_if_brace = remove # Add or remove newline between 'if' and '{'.
|
||||||
|
nl_struct_brace = remove # Add or remove newline between 'struct and '{'.
|
||||||
|
nl_switch_brace = remove # Add or remove newline between 'switch' and '{'.
|
||||||
|
nl_union_brace = remove # Add or remove newline between 'union' and '{'.
|
||||||
|
nl_while_brace = remove # Add or remove newline between 'while' and '{'.
|
||||||
|
|
||||||
|
# Additional whitespace rules (Optional)
|
||||||
|
sp_after_ptr_star = remove # Add or remove space after pointer star '*', if followed by a word.
|
||||||
|
# Useful when paired with align_var_def_star_style==2
|
||||||
|
sp_after_ptr_star_func = remove # Add or remove space after a pointer star '*', if followed by a function
|
||||||
|
# prototype or function definition.
|
||||||
|
sp_after_semi = remove # Add or remove space after ';', except when followed by a comment.
|
||||||
|
sp_before_case_colon = remove # Add or remove space before case ':'.
|
||||||
|
sp_before_ptr_star = add # Add or remove space before pointer star '*'.
|
||||||
|
sp_before_ptr_star_func = add # Add or remove space before a pointer star '*', if followed by a function
|
||||||
|
# prototype or function definition.
|
||||||
|
sp_before_semi = remove # Add or remove space before ';'
|
||||||
|
sp_before_semi_for = remove # Add or remove space before ';' in non-empty 'for' statements.
|
||||||
|
sp_before_semi_for_empty = add # Add or remove space before a semicolon of an empty part of a for statement
|
||||||
|
sp_between_ptr_star = remove # Add or remove space between pointer stars '*'. (ie, 'VOID **')
|
||||||
|
sp_brace_close_while = force # Add or remove space between '}' and 'while'.
|
||||||
|
|
||||||
|
sp_after_cast = remove
|
||||||
|
sp_after_type = add
|
||||||
|
sp_balance_nested_parens = false
|
||||||
|
sp_before_nl_cont = add
|
||||||
|
sp_before_square_asm_block = ignore
|
||||||
|
sp_before_unnamed_byref = add
|
||||||
|
sp_brace_brace = ignore
|
||||||
|
sp_brace_else = force
|
||||||
|
sp_brace_typedef = add
|
||||||
|
sp_case_label = force
|
||||||
|
sp_cmt_cpp_doxygen = true
|
||||||
|
sp_cond_colon = add
|
||||||
|
sp_cond_question = add
|
||||||
|
sp_cpp_cast_paren = force
|
||||||
|
sp_else_brace = force
|
||||||
|
sp_endif_cmt = force
|
||||||
|
sp_enum_assign = add
|
||||||
|
sp_inside_braces = force
|
||||||
|
sp_inside_braces_empty = force
|
||||||
|
sp_inside_braces_enum = force
|
||||||
|
sp_inside_braces_struct = force
|
||||||
|
sp_pp_concat = add
|
||||||
|
sp_pp_stringify = add
|
||||||
|
sp_return_paren = add
|
||||||
|
sp_special_semi = force
|
||||||
|
sp_while_paren_open = force
|
||||||
|
|
||||||
|
# Additional Indentation Rules
|
||||||
|
indent_access_spec = 1
|
||||||
|
indent_access_spec_body = false
|
||||||
|
indent_align_assign = true
|
||||||
|
indent_align_string = true
|
||||||
|
indent_bool_paren = true
|
||||||
|
indent_brace_parent = false
|
||||||
|
indent_braces = false
|
||||||
|
indent_braces_no_class = false
|
||||||
|
indent_braces_no_func = true
|
||||||
|
indent_braces_no_struct = false
|
||||||
|
indent_class = false
|
||||||
|
indent_class_colon = false
|
||||||
|
indent_cmt_with_tabs = false # Whether to indent comments that are not at a brace level with tabs on
|
||||||
|
# a tabstop. Requires indent_with_tabs=2. If false, will use spaces.
|
||||||
|
indent_col1_comment = true
|
||||||
|
indent_col1_multi_string_literal= true
|
||||||
|
indent_comma_paren = true
|
||||||
|
indent_else_if = true
|
||||||
|
indent_extern = false
|
||||||
|
indent_first_bool_expr = true
|
||||||
|
|
||||||
|
indent_func_def_param_paren_pos_threshold = 0
|
||||||
|
indent_func_param_double = false
|
||||||
|
indent_func_proto_param = true
|
||||||
|
indent_ignore_asm_block = true
|
||||||
|
indent_label = 1
|
||||||
|
indent_member = 2
|
||||||
|
indent_namespace = false
|
||||||
|
indent_param = 2
|
||||||
|
indent_paren_nl = false
|
||||||
|
indent_paren_open_brace = false
|
||||||
|
indent_preserve_sql = false
|
||||||
|
indent_relative_single_line_comments = false
|
||||||
|
indent_sing_line_comments = 0
|
||||||
|
indent_single_newlines = false
|
||||||
|
indent_square_nl = false
|
||||||
|
indent_switch_case = 2
|
||||||
|
indent_template_param = true
|
||||||
|
indent_var_def_blk = 0
|
||||||
|
indent_var_def_cont = false
|
||||||
|
|
||||||
|
# Tidy-up rules (Optional)
|
||||||
|
mod_move_case_break = true # Whether to move a 'break' that appears after a fully braced 'case'
|
||||||
|
# before the close brace, as in 'case X: { ... } break;' =>
|
||||||
|
# 'case X: { ... break; }'.
|
||||||
|
mod_pawn_semicolon = false
|
||||||
|
mod_remove_empty_return = false # Whether to remove a void 'return;' that appears as the last statement
|
||||||
|
# in a function.
|
||||||
|
mod_remove_extra_semicolon = true
|
||||||
|
mod_sort_import = false
|
||||||
|
mod_sort_include = false
|
||||||
|
mod_sort_using = false
|
||||||
|
nl_after_case = false # Whether to add a newline after a 'case' statement.
|
||||||
|
nl_end_of_file = force # Add or remove newline at the end of the file.
|
||||||
|
nl_end_of_file_min = 1 # The minimum number of newlines at the end of the file
|
||||||
|
nl_max = 2 # The maximum number of consecutive newlines (3 = 2 blank lines).
|
||||||
|
nl_start_of_file = remove # Add or remove newlines at the start of the file.
|
||||||
|
|
||||||
|
# Code alignment rules (Optional)
|
||||||
|
align_asm_colon = false
|
||||||
|
align_assign_span = 1 # The span for aligning on '=' in assignments.
|
||||||
|
align_assign_thresh = 0
|
||||||
|
align_edk2_style = true # Whether to apply edk2-specific alignment formatting
|
||||||
|
align_enum_equ_span = 1 # The span for aligning on '=' in enums.
|
||||||
|
align_func_params = true # Whether to align variable definitions in prototypes and functions.
|
||||||
|
align_func_params_gap = 2
|
||||||
|
align_func_params_span = 2 # The span for aligning parameter definitions in function on parameter name.
|
||||||
|
align_func_params_thresh = 0
|
||||||
|
align_func_proto_span = 0
|
||||||
|
align_keep_tabs = false
|
||||||
|
align_left_shift = false
|
||||||
|
align_mix_var_proto = false
|
||||||
|
align_nl_cont = false
|
||||||
|
align_oc_decl_colon = false
|
||||||
|
align_on_operator = false
|
||||||
|
align_on_tabstop = false
|
||||||
|
align_pp_define_gap = 2
|
||||||
|
align_pp_define_span = 1
|
||||||
|
align_right_cmt_at_col = 0 # Align trailing comment at or beyond column N; 'pulls in' comments as
|
||||||
|
# a bonus side effect (0=ignore)
|
||||||
|
align_right_cmt_gap = 0 # If a trailing comment is more than this number of columns away from the
|
||||||
|
# text it follows,
|
||||||
|
# it will qualify for being aligned. This has to be > 0 to do anything.
|
||||||
|
align_right_cmt_mix = false # If aligning comments, mix with comments after '}' and #endif with less
|
||||||
|
# than 3 spaces before the comment
|
||||||
|
align_right_cmt_same_level = true # Whether to only align trailing comments that are at the same brace level.
|
||||||
|
align_right_cmt_span = 2 # The span for aligning comments that end lines.
|
||||||
|
align_same_func_call_params = false
|
||||||
|
align_single_line_brace = true
|
||||||
|
align_single_line_func = true
|
||||||
|
align_struct_init_span = 1 # The span for aligning struct initializer values.
|
||||||
|
align_typedef_amp_style = 1
|
||||||
|
align_typedef_func = 1 # How to align typedef'd functions with other typedefs.
|
||||||
|
# (0: No align, 1: Align open paranthesis, 2: Align function type name)
|
||||||
|
align_typedef_gap = 2
|
||||||
|
align_typedef_span = 1 # The span for aligning single-line typedefs.
|
||||||
|
align_typedef_star_style = 1
|
||||||
|
align_var_def_amp_style = 1
|
||||||
|
align_var_def_attribute = true
|
||||||
|
align_var_def_colon = true # Whether to align the colon in struct bit fields.
|
||||||
|
align_var_def_gap = 2 # The gap (minimum spacing for aligned items) for variable definitions.
|
||||||
|
align_var_def_inline = false
|
||||||
|
align_var_def_span = 1 # The span (lines needed to align) for aligning variable definitions.
|
||||||
|
align_var_def_star_style = 1 # How to consider (or treat) the '*' in the alignment of variable
|
||||||
|
# definitions.
|
||||||
|
# 0: Part of the type 'void * foo;' (default)
|
||||||
|
# 1: Part of the variable 'void *foo;'
|
||||||
|
# 2: Dangling 'void *foo;'
|
||||||
|
# (Note - should also set sp_after_ptr_star=remove)
|
||||||
|
align_var_struct_gap = 4
|
||||||
|
align_var_struct_span = 8 # The span for aligning struct/union member definitions.
|
||||||
|
align_var_struct_thresh = 0
|
||||||
|
align_with_tabs = false
|
||||||
|
|
||||||
|
# Comment formatting
|
||||||
|
cmt_align_doxygen_javadoc_tags = true # Whether to align doxygen javadoc-style tags ('@param', '@return', etc.)
|
||||||
|
# TODO: Eats '[' in '[in]'
|
||||||
|
cmt_c_group = false
|
||||||
|
cmt_c_nl_end = true # Whether to add a newline before the closing '*/' of the combined c-comment.
|
||||||
|
cmt_c_nl_start = true
|
||||||
|
cmt_cpp_group = false
|
||||||
|
cmt_cpp_nl_end = true
|
||||||
|
cmt_cpp_nl_start = true
|
||||||
|
cmt_cpp_to_c = false
|
||||||
|
cmt_indent_multi = false # Whether to apply changes to multi-line comments, including cmt_width,
|
||||||
|
# keyword substitution and leading chars.
|
||||||
|
cmt_insert_before_preproc = false
|
||||||
|
#cmt_insert_file_header = default_file_header.txt
|
||||||
|
#cmt_insert_func_header = default_function_header.txt
|
||||||
|
cmt_multi_check_last = false
|
||||||
|
cmt_multi_first_len_minimum = 2
|
||||||
|
cmt_reflow_mode = 1 # How to reflow comments.
|
||||||
|
# (0:No reflow, 1:No touching at all, 2: Full reflow)
|
||||||
|
cmt_sp_after_star_cont = 0 # The number of spaces to insert after the star on subsequent comment lines.
|
||||||
|
cmt_sp_before_star_cont = 0 # The number of spaces to insert at the start of subsequent comment lines.
|
||||||
|
cmt_star_cont = false # Whether to put a star on subsequent comment lines.
|
||||||
|
cmt_width = 120 # Try to wrap comments at N columns.
|
||||||
|
sp_cmt_cpp_start = add # Add or remove space after the opening of a C++ comment, as in
|
||||||
|
# '// <here> A'. NOTE: Breaks indentation within comments.
|
||||||
|
|
||||||
|
# Function definitions / declarations
|
||||||
|
indent_func_call_param = false # Whether to indent continued function call parameters one indent level,
|
||||||
|
# rather than aligning parameters under the open parenthesis.
|
||||||
|
indent_func_class_param = false # Whether to indent continued function call declaration one indent level,
|
||||||
|
# rather than aligning parameters under the open parenthesis.
|
||||||
|
indent_func_ctor_var_param = false # Whether to indent continued class variable constructors one indent level,
|
||||||
|
# rather than aligning parameters under the open parenthesis.
|
||||||
|
indent_func_def_param = true # Whether to indent continued function definition parameters one indent
|
||||||
|
# level, rather than aligning parameters under the open parenthesis.
|
||||||
|
nl_fdef_brace = add # Add or remove newline between function signature and '{'.
|
||||||
|
nl_func_call_end_multi_line = true # Whether to add a newline before ')' in a function call if '(' and ')' are
|
||||||
|
# in different lines.
|
||||||
|
nl_func_call_paren = remove # Add or remove newline between a function name and the opening '(' in the
|
||||||
|
# call.
|
||||||
|
nl_func_call_start_multi_line = true # Whether to add a newline after '(' in a function call if '(' and ')' are
|
||||||
|
# in different lines.
|
||||||
|
nl_func_decl_args = force # Add or remove newline after each ',' in a function declaration.
|
||||||
|
nl_func_decl_empty = add # Add or remove newline between '()' in a function declaration.
|
||||||
|
nl_func_def_args = force # Add or remove newline after each ',' in a function definition.
|
||||||
|
nl_func_def_empty = add # Add or remove newline between '()' in a function definition.
|
||||||
|
nl_func_def_paren = remove # Add or remove newline between a function name and the opening '('
|
||||||
|
# in the definition.
|
||||||
|
nl_func_paren = remove # Add or remove newline between a function name and the opening '(' in
|
||||||
|
# the declaration.
|
||||||
|
nl_func_type_name = add # Add or remove newline between return type and function name in a function
|
||||||
|
# definition.
|
||||||
|
sp_fparen_brace = force # Add or remove space between ')' and '{' of function.
|
||||||
|
use_indent_func_call_param = true # indent_func_call_param will be used
|
||||||
|
|
||||||
|
# Additional Newline Rules
|
||||||
|
nl_after_brace_open = true # Whether to add a newline after '{'. This also adds a newline
|
||||||
|
# before the matching '}'.
|
||||||
|
nl_after_brace_open_cmt = true # Whether to add a newline between the open brace and a
|
||||||
|
# trailing single-line comment.
|
||||||
|
# Requires nl_after_brace_open = true.
|
||||||
|
nl_after_do = add # Add or remove blank line after 'do/while' statement.
|
||||||
|
nl_after_for = add # Add or remove blank line after 'for' statement.
|
||||||
|
nl_after_func_body = 2 # The number of newlines after '}' of a multi-line function body
|
||||||
|
nl_after_func_body_one_liner = 2
|
||||||
|
nl_after_func_proto = 2
|
||||||
|
nl_after_func_proto_group = 2
|
||||||
|
nl_after_if = add
|
||||||
|
nl_after_multiline_comment = false
|
||||||
|
nl_after_return = false
|
||||||
|
nl_after_struct = 2
|
||||||
|
nl_after_switch = add
|
||||||
|
nl_after_vbrace_close = true
|
||||||
|
nl_after_vbrace_open = true
|
||||||
|
nl_after_vbrace_open_empty = true
|
||||||
|
nl_after_while = add
|
||||||
|
nl_assign_leave_one_liners = true
|
||||||
|
nl_before_block_comment = 2
|
||||||
|
nl_before_case = false
|
||||||
|
nl_before_do = ignore
|
||||||
|
nl_before_for = ignore
|
||||||
|
nl_before_if = ignore
|
||||||
|
nl_before_switch = ignore
|
||||||
|
nl_before_while = ignore
|
||||||
|
nl_before_whole_file_ifdef = 2
|
||||||
|
nl_brace_brace = force
|
||||||
|
nl_brace_struct_var = remove
|
||||||
|
nl_case_colon_brace = add
|
||||||
|
nl_class_leave_one_liners = false
|
||||||
|
nl_collapse_empty_body = false
|
||||||
|
nl_comment_func_def = 1
|
||||||
|
nl_create_for_one_liner = false
|
||||||
|
nl_create_if_one_liner = false
|
||||||
|
nl_create_while_one_liner = false
|
||||||
|
nl_define_macro = false
|
||||||
|
nl_ds_struct_enum_close_brace = true
|
||||||
|
nl_ds_struct_enum_cmt = false
|
||||||
|
nl_enum_leave_one_liners = false
|
||||||
|
nl_func_decl_end = add
|
||||||
|
nl_func_decl_start = add
|
||||||
|
nl_func_def_end = add
|
||||||
|
nl_func_def_start = add
|
||||||
|
nl_func_leave_one_liners = false
|
||||||
|
nl_func_proto_type_name = add
|
||||||
|
nl_func_var_def_blk = 1
|
||||||
|
nl_getset_leave_one_liners = false
|
||||||
|
nl_if_leave_one_liners = false
|
||||||
|
nl_multi_line_define = false
|
||||||
|
nl_squeeze_ifdef = false
|
||||||
|
nl_var_def_blk_end = 0
|
||||||
|
nl_var_def_blk_start = 0
|
||||||
|
|
||||||
|
# Preprocessor Rules
|
||||||
|
pp_define_at_level = true
|
||||||
|
pp_if_indent_code = false
|
||||||
|
pp_indent_func_def = false
|
||||||
|
pp_indent_extern = false
|
||||||
|
pp_ignore_define_body = true # Workaround: Turn off processing for #define body
|
||||||
|
# (current rules do not work for some defines)
|
||||||
|
pp_indent = add
|
||||||
|
pp_indent_at_level = true
|
||||||
|
pp_indent_count = 2
|
||||||
|
pp_indent_if = 2
|
||||||
|
pp_indent_region = 2
|
||||||
|
pp_region_indent_code = false
|
||||||
|
pp_space = remove
|
||||||
|
|
||||||
|
#
|
||||||
|
# The tokens below are assigned specific types so they are always recognized properly.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Explicitly define EDK II qualifiers
|
||||||
|
set QUALIFIER CONST
|
||||||
|
set QUALIFIER EFIAPI
|
||||||
|
set QUALIFIER IN
|
||||||
|
set QUALIFIER OPTIONAL
|
||||||
|
set QUALIFIER OUT
|
||||||
|
|
||||||
|
# Explicitly define EDK II types
|
||||||
|
set TYPE EFI_STATUS
|
||||||
|
set TYPE VOID
|
16
.pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml
Normal file
16
.pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
## @file
|
||||||
|
# Downloads the Uncrustify application from a Project Mu NuGet package.
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
{
|
||||||
|
"id": "uncrustify-ci-1",
|
||||||
|
"scope": "cibuild",
|
||||||
|
"type": "nuget",
|
||||||
|
"name": "mu-uncrustify-release",
|
||||||
|
"source": "https://pkgs.dev.azure.com/projectmu/Uncrustify/_packaging/mu_uncrustify/nuget/v3/index.json",
|
||||||
|
"version": "73.0.3",
|
||||||
|
"flags": ["set_shell_var", "host_specific"],
|
||||||
|
"var_name": "UNCRUSTIFY_CI_PATH"
|
||||||
|
}
|
11
.pytool/Plugin/UncrustifyCheck/uncrustify_plug_in.yaml
Normal file
11
.pytool/Plugin/UncrustifyCheck/uncrustify_plug_in.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
## @file
|
||||||
|
# CiBuildPlugin used to check coding standard compliance of EDK II style C source code
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
{
|
||||||
|
"scope": "cibuild",
|
||||||
|
"name": "Uncrustify Coding Standard Test",
|
||||||
|
"module": "UncrustifyCheck"
|
||||||
|
}
|
@ -264,6 +264,10 @@ BSD-2-Clause-Patent.
|
|||||||
Run the Ecc tool on the package. The Ecc tool is available in the BaseTools
|
Run the Ecc tool on the package. The Ecc tool is available in the BaseTools
|
||||||
package. It checks that the code complies to the EDKII coding standard.
|
package. It checks that the code complies to the EDKII coding standard.
|
||||||
|
|
||||||
|
### Coding Standard Compliance - UncrustifyCheck
|
||||||
|
|
||||||
|
Runs the Uncrustify application to check for coding standard compliance issues.
|
||||||
|
|
||||||
## PyTool Scopes
|
## PyTool Scopes
|
||||||
|
|
||||||
Scopes are how the PyTool ext_dep, path_env, and plugins are activated. Meaning
|
Scopes are how the PyTool ext_dep, path_env, and plugins are activated. Meaning
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
],
|
],
|
||||||
## Both file path and directory path are accepted.
|
## Both file path and directory path are accepted.
|
||||||
"IgnoreFiles": [
|
"IgnoreFiles": [
|
||||||
"Library/ArmSoftFloatLib/berkeley-softfloat-3"
|
"Library/ArmSoftFloatLib/berkeley-softfloat-3",
|
||||||
|
"Library/ArmSoftFloatLib/ArmSoftFloatLib.c",
|
||||||
|
"Library/CompilerIntrinsicsLib",
|
||||||
|
"Universal/Smbios/SmbiosMiscDxe"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ ArmCrashDumpDxeInitialize (
|
|||||||
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu);
|
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
return mCpu->RegisterInterruptHandler (mCpu,
|
return mCpu->RegisterInterruptHandler (
|
||||||
|
mCpu,
|
||||||
EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS,
|
EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS,
|
||||||
&DefaultExceptionHandler);
|
&DefaultExceptionHandler
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ UINTN mGicNumInterrupts = 0;
|
|||||||
|
|
||||||
HARDWARE_INTERRUPT_HANDLER *gRegisteredInterruptHandlers = NULL;
|
HARDWARE_INTERRUPT_HANDLER *gRegisteredInterruptHandlers = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calculate GICD_ICFGRn base address and corresponding bit
|
Calculate GICD_ICFGRn base address and corresponding bit
|
||||||
field Int_config[1] of the GIC distributor register.
|
field Int_config[1] of the GIC distributor register.
|
||||||
@ -71,8 +70,6 @@ GicGetDistributorIcfgBaseAndBit (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Register Handler for the specified interrupt source.
|
Register Handler for the specified interrupt source.
|
||||||
|
|
||||||
@ -137,17 +134,28 @@ CpuArchEventProtocolNotify (
|
|||||||
// Unregister the default exception handler.
|
// Unregister the default exception handler.
|
||||||
Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, NULL);
|
Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, NULL);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: Cpu->RegisterInterruptHandler() - %r\n",
|
DEBUG ((
|
||||||
__FUNCTION__, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: Cpu->RegisterInterruptHandler() - %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register to receive interrupts
|
// Register to receive interrupts
|
||||||
Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ,
|
Status = Cpu->RegisterInterruptHandler (
|
||||||
Context);
|
Cpu,
|
||||||
|
ARM_ARCH_EXCEPTION_IRQ,
|
||||||
|
Context
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: Cpu->RegisterInterruptHandler() - %r\n",
|
DEBUG ((
|
||||||
__FUNCTION__, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: Cpu->RegisterInterruptHandler() - %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->CloseEvent (Event);
|
gBS->CloseEvent (Event);
|
||||||
@ -191,7 +199,8 @@ InstallAndRegisterInterruptService (
|
|||||||
TPL_CALLBACK,
|
TPL_CALLBACK,
|
||||||
CpuArchEventProtocolNotify,
|
CpuArchEventProtocolNotify,
|
||||||
InterruptHandler,
|
InterruptHandler,
|
||||||
&mCpuArchProtocolNotifyEventRegistration);
|
&mCpuArchProtocolNotifyEventRegistration
|
||||||
|
);
|
||||||
|
|
||||||
// Register for an ExitBootServicesEvent
|
// Register for an ExitBootServicesEvent
|
||||||
Status = gBS->CreateEvent (
|
Status = gBS->CreateEvent (
|
||||||
|
@ -55,7 +55,6 @@ GicV3DxeInitialize (
|
|||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Shared code
|
// Shared code
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,7 +230,8 @@ ArmGicSetInterruptPriority (
|
|||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
||||||
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
|
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
|
||||||
SourceIsSpi (Source)) {
|
SourceIsSpi (Source))
|
||||||
|
{
|
||||||
MmioAndThenOr32 (
|
MmioAndThenOr32 (
|
||||||
GicDistributorBase + ARM_GIC_ICDIPR + (4 * RegOffset),
|
GicDistributorBase + ARM_GIC_ICDIPR + (4 * RegOffset),
|
||||||
~(0xff << RegShift),
|
~(0xff << RegShift),
|
||||||
@ -273,7 +274,8 @@ ArmGicEnableInterrupt (
|
|||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
||||||
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
|
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
|
||||||
SourceIsSpi (Source)) {
|
SourceIsSpi (Source))
|
||||||
|
{
|
||||||
// Write set-enable register
|
// Write set-enable register
|
||||||
MmioWrite32 (
|
MmioWrite32 (
|
||||||
GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset),
|
GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset),
|
||||||
@ -317,7 +319,8 @@ ArmGicDisableInterrupt (
|
|||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
||||||
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
|
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
|
||||||
SourceIsSpi (Source)) {
|
SourceIsSpi (Source))
|
||||||
|
{
|
||||||
// Write clear-enable register
|
// Write clear-enable register
|
||||||
MmioWrite32 (
|
MmioWrite32 (
|
||||||
GicDistributorBase + ARM_GIC_ICDICER + (4 * RegOffset),
|
GicDistributorBase + ARM_GIC_ICDICER + (4 * RegOffset),
|
||||||
@ -361,7 +364,8 @@ ArmGicIsInterruptEnabled (
|
|||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
||||||
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
|
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
|
||||||
SourceIsSpi (Source)) {
|
SourceIsSpi (Source))
|
||||||
|
{
|
||||||
Interrupts = ((MmioRead32 (
|
Interrupts = ((MmioRead32 (
|
||||||
GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset)
|
GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset)
|
||||||
)
|
)
|
||||||
|
@ -261,9 +261,13 @@ GicV2SetTriggerType (
|
|||||||
BOOLEAN SourceEnabled;
|
BOOLEAN SourceEnabled;
|
||||||
|
|
||||||
if ( (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING)
|
if ( (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING)
|
||||||
&& (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_LEVEL_HIGH)) {
|
&& (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_LEVEL_HIGH))
|
||||||
DEBUG ((DEBUG_ERROR, "Invalid interrupt trigger type: %d\n", \
|
{
|
||||||
TriggerType));
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"Invalid interrupt trigger type: %d\n", \
|
||||||
|
TriggerType
|
||||||
|
));
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <Library/IoLib.h>
|
#include <Library/IoLib.h>
|
||||||
#include <Library/ArmGicLib.h>
|
#include <Library/ArmGicLib.h>
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicV2EnableInterruptInterface (
|
ArmGicV2EnableInterruptInterface (
|
||||||
|
@ -255,9 +255,13 @@ GicV3SetTriggerType (
|
|||||||
BOOLEAN SourceEnabled;
|
BOOLEAN SourceEnabled;
|
||||||
|
|
||||||
if ( (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING)
|
if ( (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING)
|
||||||
&& (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_LEVEL_HIGH)) {
|
&& (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_LEVEL_HIGH))
|
||||||
DEBUG ((DEBUG_ERROR, "Invalid interrupt trigger type: %d\n", \
|
{
|
||||||
TriggerType));
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"Invalid interrupt trigger type: %d\n", \
|
||||||
|
TriggerType
|
||||||
|
));
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
@ -430,8 +434,8 @@ GicV3DxeInitialize (
|
|||||||
|
|
||||||
if ((MmioRead32 (
|
if ((MmioRead32 (
|
||||||
mGicDistributorBase + ARM_GIC_ICDDCR
|
mGicDistributorBase + ARM_GIC_ICDDCR
|
||||||
) & ARM_GIC_ICDDCR_DS) != 0) {
|
) & ARM_GIC_ICDDCR_DS) != 0)
|
||||||
|
{
|
||||||
// If the Disable Security (DS) control bit is set, we are dealing with a
|
// If the Disable Security (DS) control bit is set, we are dealing with a
|
||||||
// GIC that has only one security state. In this case, let's assume we are
|
// GIC that has only one security state. In this case, let's assume we are
|
||||||
// executing in non-secure state (which is appropriate for DXE modules)
|
// executing in non-secure state (which is appropriate for DXE modules)
|
||||||
|
@ -117,7 +117,7 @@ CpuIoCheckParameter (
|
|||||||
// For FIFO type, the target address won't increase during the access,
|
// For FIFO type, the target address won't increase during the access,
|
||||||
// so treat Count as 1
|
// so treat Count as 1
|
||||||
//
|
//
|
||||||
if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) {
|
if ((Width >= EfiCpuIoWidthFifoUint8) && (Width <= EfiCpuIoWidthFifoUint64)) {
|
||||||
Count = 1;
|
Count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +161,7 @@ CpuIoCheckParameter (
|
|||||||
if (MaxCount < (Count - 1)) {
|
if (MaxCount < (Count - 1)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Address > LShiftU64 (MaxCount - Count + 1, Width)) {
|
if (Address > LShiftU64 (MaxCount - Count + 1, Width)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
@ -254,6 +255,7 @@ CpuMemoryServiceRead (
|
|||||||
*((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address);
|
*((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,6 +337,7 @@ CpuMemoryServiceWrite (
|
|||||||
MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer));
|
MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +524,6 @@ STATIC EFI_CPU_IO2_PROTOCOL mCpuIo2 = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The user Entry Point for module CpuIo2Dxe. The user code starts with this function.
|
The user Entry Point for module CpuIo2Dxe. The user code starts with this function.
|
||||||
|
|
||||||
@ -544,7 +546,8 @@ ArmPciCpuIo2Initialize (
|
|||||||
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiCpuIo2ProtocolGuid);
|
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiCpuIo2ProtocolGuid);
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&mHandle,
|
&mHandle,
|
||||||
&gEfiCpuIo2ProtocolGuid, &mCpuIo2,
|
&gEfiCpuIo2ProtocolGuid,
|
||||||
|
&mCpuIo2,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
@ -53,7 +53,6 @@ typedef struct {
|
|||||||
CLOCK_RATE_DWORD Rate;
|
CLOCK_RATE_DWORD Rate;
|
||||||
} CLOCK_RATE_SET_ATTRIBUTES;
|
} CLOCK_RATE_SET_ATTRIBUTES;
|
||||||
|
|
||||||
|
|
||||||
// Message parameters for CLOCK_CONFIG_SET command.
|
// Message parameters for CLOCK_CONFIG_SET command.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 ClockId;
|
UINT32 ClockId;
|
||||||
|
@ -124,7 +124,9 @@ ScmiCommandExecute (
|
|||||||
Response = (SCMI_MESSAGE_RESPONSE *)MtlGetChannelPayload (Channel);
|
Response = (SCMI_MESSAGE_RESPONSE *)MtlGetChannelPayload (Channel);
|
||||||
|
|
||||||
if (Response->Status != ScmiSuccess) {
|
if (Response->Status != ScmiSuccess) {
|
||||||
DEBUG ((DEBUG_ERROR, "SCMI error: ProtocolId = 0x%x, MessageId = 0x%x, error = %d\n",
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"SCMI error: ProtocolId = 0x%x, MessageId = 0x%x, error = %d\n",
|
||||||
Command->ProtocolId,
|
Command->ProtocolId,
|
||||||
Command->MessageId,
|
Command->MessageId,
|
||||||
Response->Status
|
Response->Status
|
||||||
|
@ -256,7 +256,6 @@ BaseDiscoverListProtocols (
|
|||||||
Skip = 0;
|
Skip = 0;
|
||||||
|
|
||||||
while (Skip < TotalProtocols) {
|
while (Skip < TotalProtocols) {
|
||||||
|
|
||||||
*MessageParams = Skip;
|
*MessageParams = Skip;
|
||||||
|
|
||||||
// Note PayloadLength is a IN/OUT parameter.
|
// Note PayloadLength is a IN/OUT parameter.
|
||||||
|
@ -135,6 +135,7 @@ ClockGetClockAttributes (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRUE if bit 0 of ClockAttributes->Attributes is set.
|
// TRUE if bit 0 of ClockAttributes->Attributes is set.
|
||||||
*Enabled = CLOCK_ENABLED (ClockAttributes->Attributes);
|
*Enabled = CLOCK_ENABLED (ClockAttributes->Attributes);
|
||||||
|
|
||||||
@ -209,7 +210,6 @@ ClockDescribeRates (
|
|||||||
*MessageParams++ = ClockId;
|
*MessageParams++ = ClockId;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
*MessageParams = RateIndex;
|
*MessageParams = RateIndex;
|
||||||
|
|
||||||
// Set Payload length, note PayloadLength is a IN/OUT parameter.
|
// Set Payload length, note PayloadLength is a IN/OUT parameter.
|
||||||
|
@ -88,7 +88,8 @@ ArmScmiDxeEntryPoint (
|
|||||||
|
|
||||||
// Accept any version between SCMI v1.0 and SCMI v2.0
|
// Accept any version between SCMI v1.0 and SCMI v2.0
|
||||||
if ((Version < BASE_PROTOCOL_VERSION_V1) ||
|
if ((Version < BASE_PROTOCOL_VERSION_V1) ||
|
||||||
(Version > BASE_PROTOCOL_VERSION_V2)) {
|
(Version > BASE_PROTOCOL_VERSION_V2))
|
||||||
|
{
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
@ -130,7 +131,8 @@ ArmScmiDxeEntryPoint (
|
|||||||
|
|
||||||
// Install supported protocol on ImageHandle.
|
// Install supported protocol on ImageHandle.
|
||||||
for (ProtocolIndex = 1; ProtocolIndex < ARRAY_SIZE (Protocols);
|
for (ProtocolIndex = 1; ProtocolIndex < ARRAY_SIZE (Protocols);
|
||||||
ProtocolIndex++) {
|
ProtocolIndex++)
|
||||||
|
{
|
||||||
for (Index = 0; Index < NumProtocols; Index++) {
|
for (Index = 0; Index < NumProtocols; Index++) {
|
||||||
if (Protocols[ProtocolIndex].Id == SupportedList[Index]) {
|
if (Protocols[ProtocolIndex].Id == SupportedList[Index]) {
|
||||||
Status = Protocols[ProtocolIndex].InitFn (&ImageHandle);
|
Status = Protocols[ProtocolIndex].InitFn (&ImageHandle);
|
||||||
@ -138,6 +140,7 @@ ArmScmiDxeEntryPoint (
|
|||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
|
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
|
||||||
DEN0056A_System_Control_and_Management_Interface.pdf
|
DEN0056A_System_Control_and_Management_Interface.pdf
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef SCMI_DXE_H_
|
#ifndef SCMI_DXE_H_
|
||||||
#define SCMI_DXE_H_
|
#define SCMI_DXE_H_
|
||||||
|
|
||||||
|
@ -183,7 +183,6 @@ PerformanceDescribeLevels (
|
|||||||
Cmd.MessageId = ScmiMessageIdPerformanceDescribeLevels;
|
Cmd.MessageId = ScmiMessageIdPerformanceDescribeLevels;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
*MessageParams = LevelIndex;
|
*MessageParams = LevelIndex;
|
||||||
|
|
||||||
// Note, PayloadLength is an IN/OUT parameter.
|
// Note, PayloadLength is an IN/OUT parameter.
|
||||||
@ -219,7 +218,6 @@ PerformanceDescribeLevels (
|
|||||||
sizeof (SCMI_PERFORMANCE_LEVEL)
|
sizeof (SCMI_PERFORMANCE_LEVEL)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (ReturnRemainNumLevels != 0);
|
} while (ReturnRemainNumLevels != 0);
|
||||||
|
|
||||||
*LevelArraySize = RequiredSize;
|
*LevelArraySize = RequiredSize;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
|
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
|
||||||
DEN0056A_System_Control_and_Management_Interface.pdf
|
DEN0056A_System_Control_and_Management_Interface.pdf
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef SCMI_PRIVATE_H_
|
#ifndef SCMI_PRIVATE_H_
|
||||||
#define SCMI_PRIVATE_H_
|
#define SCMI_PRIVATE_H_
|
||||||
|
|
||||||
|
@ -52,9 +52,11 @@ PageAttributeToGcdAttribute (
|
|||||||
GcdAttributes = EFI_MEMORY_WB;
|
GcdAttributes = EFI_MEMORY_WB;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"PageAttributeToGcdAttribute: PageAttributes:0x%lX not supported.\n",
|
"PageAttributeToGcdAttribute: PageAttributes:0x%lX not supported.\n",
|
||||||
PageAttributes));
|
PageAttributes
|
||||||
|
));
|
||||||
ASSERT (0);
|
ASSERT (0);
|
||||||
// The Global Coherency Domain (GCD) value is defined as a bit set.
|
// The Global Coherency Domain (GCD) value is defined as a bit set.
|
||||||
// Returning 0 means no attribute has been set.
|
// Returning 0 means no attribute has been set.
|
||||||
@ -63,7 +65,8 @@ PageAttributeToGcdAttribute (
|
|||||||
|
|
||||||
// Determine protection attributes
|
// Determine protection attributes
|
||||||
if (((PageAttributes & TT_AP_MASK) == TT_AP_NO_RO) ||
|
if (((PageAttributes & TT_AP_MASK) == TT_AP_NO_RO) ||
|
||||||
((PageAttributes & TT_AP_MASK) == TT_AP_RO_RO)) {
|
((PageAttributes & TT_AP_MASK) == TT_AP_RO_RO))
|
||||||
|
{
|
||||||
// Read only cases map to write-protect
|
// Read only cases map to write-protect
|
||||||
GcdAttributes |= EFI_MEMORY_RO;
|
GcdAttributes |= EFI_MEMORY_RO;
|
||||||
}
|
}
|
||||||
@ -88,7 +91,7 @@ GetFirstPageAttribute (
|
|||||||
// Get the first entry of the table
|
// Get the first entry of the table
|
||||||
FirstEntry = *FirstLevelTableAddress;
|
FirstEntry = *FirstLevelTableAddress;
|
||||||
|
|
||||||
if ((TableLevel != 3) && (FirstEntry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY) {
|
if ((TableLevel != 3) && ((FirstEntry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY)) {
|
||||||
// Only valid for Levels 0, 1 and 2
|
// Only valid for Levels 0, 1 and 2
|
||||||
|
|
||||||
// Get the attribute of the subsequent table
|
// Get the attribute of the subsequent table
|
||||||
@ -138,14 +141,18 @@ GetNextEntryAttribute (
|
|||||||
|
|
||||||
// If Entry is a Table Descriptor type entry then go through the sub-level table
|
// If Entry is a Table Descriptor type entry then go through the sub-level table
|
||||||
if ((EntryType == TT_TYPE_BLOCK_ENTRY) ||
|
if ((EntryType == TT_TYPE_BLOCK_ENTRY) ||
|
||||||
((TableLevel == 3) && (EntryType == TT_TYPE_BLOCK_ENTRY_LEVEL3))) {
|
((TableLevel == 3) && (EntryType == TT_TYPE_BLOCK_ENTRY_LEVEL3)))
|
||||||
|
{
|
||||||
if ((*PrevEntryAttribute == INVALID_ENTRY) || (EntryAttribute != *PrevEntryAttribute)) {
|
if ((*PrevEntryAttribute == INVALID_ENTRY) || (EntryAttribute != *PrevEntryAttribute)) {
|
||||||
if (*PrevEntryAttribute != INVALID_ENTRY) {
|
if (*PrevEntryAttribute != INVALID_ENTRY) {
|
||||||
// Update GCD with the last region
|
// Update GCD with the last region
|
||||||
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors,
|
SetGcdMemorySpaceAttributes (
|
||||||
|
MemorySpaceMap,
|
||||||
|
NumberOfDescriptors,
|
||||||
*StartGcdRegion,
|
*StartGcdRegion,
|
||||||
(BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel))) - *StartGcdRegion,
|
(BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel))) - *StartGcdRegion,
|
||||||
PageAttributeToGcdAttribute (*PrevEntryAttribute));
|
PageAttributeToGcdAttribute (*PrevEntryAttribute)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start of the new region
|
// Start of the new region
|
||||||
@ -159,17 +166,24 @@ GetNextEntryAttribute (
|
|||||||
ASSERT (TableLevel < 3);
|
ASSERT (TableLevel < 3);
|
||||||
|
|
||||||
// Increase the level number and scan the sub-level table
|
// Increase the level number and scan the sub-level table
|
||||||
GetNextEntryAttribute ((UINT64*)(Entry & TT_ADDRESS_MASK_DESCRIPTION_TABLE),
|
GetNextEntryAttribute (
|
||||||
TT_ENTRY_COUNT, TableLevel + 1,
|
(UINT64 *)(Entry & TT_ADDRESS_MASK_DESCRIPTION_TABLE),
|
||||||
|
TT_ENTRY_COUNT,
|
||||||
|
TableLevel + 1,
|
||||||
(BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel))),
|
(BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel))),
|
||||||
PrevEntryAttribute, StartGcdRegion);
|
PrevEntryAttribute,
|
||||||
|
StartGcdRegion
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if (*PrevEntryAttribute != INVALID_ENTRY) {
|
if (*PrevEntryAttribute != INVALID_ENTRY) {
|
||||||
// Update GCD with the last region
|
// Update GCD with the last region
|
||||||
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors,
|
SetGcdMemorySpaceAttributes (
|
||||||
|
MemorySpaceMap,
|
||||||
|
NumberOfDescriptors,
|
||||||
*StartGcdRegion,
|
*StartGcdRegion,
|
||||||
(BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel))) - *StartGcdRegion,
|
(BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel))) - *StartGcdRegion,
|
||||||
PageAttributeToGcdAttribute (*PrevEntryAttribute));
|
PageAttributeToGcdAttribute (*PrevEntryAttribute)
|
||||||
|
);
|
||||||
|
|
||||||
// Start of the new region
|
// Start of the new region
|
||||||
*StartGcdRegion = BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel));
|
*StartGcdRegion = BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel));
|
||||||
@ -232,17 +246,24 @@ SyncCacheConfig (
|
|||||||
|
|
||||||
// We scan from the start of the memory map (ie: at the address 0x0)
|
// We scan from the start of the memory map (ie: at the address 0x0)
|
||||||
BaseAddressGcdRegion = 0x0;
|
BaseAddressGcdRegion = 0x0;
|
||||||
EndAddressGcdRegion = GetNextEntryAttribute (FirstLevelTableAddress,
|
EndAddressGcdRegion = GetNextEntryAttribute (
|
||||||
TableCount, TableLevel,
|
FirstLevelTableAddress,
|
||||||
|
TableCount,
|
||||||
|
TableLevel,
|
||||||
BaseAddressGcdRegion,
|
BaseAddressGcdRegion,
|
||||||
&PageAttribute, &BaseAddressGcdRegion);
|
&PageAttribute,
|
||||||
|
&BaseAddressGcdRegion
|
||||||
|
);
|
||||||
|
|
||||||
// Update GCD with the last region if valid
|
// Update GCD with the last region if valid
|
||||||
if (PageAttribute != INVALID_ENTRY) {
|
if (PageAttribute != INVALID_ENTRY) {
|
||||||
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors,
|
SetGcdMemorySpaceAttributes (
|
||||||
|
MemorySpaceMap,
|
||||||
|
NumberOfDescriptors,
|
||||||
BaseAddressGcdRegion,
|
BaseAddressGcdRegion,
|
||||||
EndAddressGcdRegion - BaseAddressGcdRegion,
|
EndAddressGcdRegion - BaseAddressGcdRegion,
|
||||||
PageAttributeToGcdAttribute (PageAttribute));
|
PageAttributeToGcdAttribute (PageAttribute)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool (MemorySpaceMap);
|
FreePool (MemorySpaceMap);
|
||||||
@ -264,6 +285,7 @@ EfiAttributeToArmAttribute (
|
|||||||
} else {
|
} else {
|
||||||
ArmAttributes = TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK;
|
ArmAttributes = TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EFI_MEMORY_WC:
|
case EFI_MEMORY_WC:
|
||||||
ArmAttributes = TT_ATTR_INDX_MEMORY_NON_CACHEABLE;
|
ArmAttributes = TT_ATTR_INDX_MEMORY_NON_CACHEABLE;
|
||||||
@ -283,7 +305,7 @@ EfiAttributeToArmAttribute (
|
|||||||
|
|
||||||
// Determine protection attributes
|
// Determine protection attributes
|
||||||
if ((EfiAttributes & EFI_MEMORY_RO) != 0) {
|
if ((EfiAttributes & EFI_MEMORY_RO) != 0) {
|
||||||
ArmAttributes |= TT_AP_RO_RO;
|
ArmAttributes |= TT_AP_NO_RO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process eXecute Never attribute
|
// Process eXecute Never attribute
|
||||||
@ -330,7 +352,10 @@ GetMemoryRegionRec (
|
|||||||
NextTranslationTable, // Address of the next level page table
|
NextTranslationTable, // Address of the next level page table
|
||||||
TableLevel + 1, // Next Page Table level
|
TableLevel + 1, // Next Page Table level
|
||||||
(UINTN *)TT_LAST_BLOCK_ADDRESS (NextTranslationTable, TT_ENTRY_COUNT),
|
(UINTN *)TT_LAST_BLOCK_ADDRESS (NextTranslationTable, TT_ENTRY_COUNT),
|
||||||
BaseAddress, RegionLength, RegionAttributes);
|
BaseAddress,
|
||||||
|
RegionLength,
|
||||||
|
RegionAttributes
|
||||||
|
);
|
||||||
|
|
||||||
// In case of 'Success', it means the end of the block region has been found into the upper
|
// In case of 'Success', it means the end of the block region has been found into the upper
|
||||||
// level translation table
|
// level translation table
|
||||||
@ -358,6 +383,7 @@ GetMemoryRegionRec (
|
|||||||
// In case we have found the end of the region we return success
|
// In case we have found the end of the region we return success
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockEntry++;
|
BlockEntry++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,9 +414,14 @@ GetMemoryRegion (
|
|||||||
// Get the Table info from T0SZ
|
// Get the Table info from T0SZ
|
||||||
GetRootTranslationTableInfo (T0SZ, &TableLevel, &EntryCount);
|
GetRootTranslationTableInfo (T0SZ, &TableLevel, &EntryCount);
|
||||||
|
|
||||||
Status = GetMemoryRegionRec (TranslationTable, TableLevel,
|
Status = GetMemoryRegionRec (
|
||||||
|
TranslationTable,
|
||||||
|
TableLevel,
|
||||||
(UINTN *)TT_LAST_BLOCK_ADDRESS (TranslationTable, EntryCount),
|
(UINTN *)TT_LAST_BLOCK_ADDRESS (TranslationTable, EntryCount),
|
||||||
BaseAddress, RegionLength, RegionAttributes);
|
BaseAddress,
|
||||||
|
RegionLength,
|
||||||
|
RegionAttributes
|
||||||
|
);
|
||||||
|
|
||||||
// If the region continues up to the end of the root table then GetMemoryRegionRec()
|
// If the region continues up to the end of the root table then GetMemoryRegionRec()
|
||||||
// will return EFI_NOT_FOUND
|
// will return EFI_NOT_FOUND
|
||||||
|
@ -206,6 +206,7 @@ SyncCacheConfigPage (
|
|||||||
*NextRegionBase = BaseAddress | (i << TT_DESCRIPTOR_PAGE_BASE_SHIFT);
|
*NextRegionBase = BaseAddress | (i << TT_DESCRIPTOR_PAGE_BASE_SHIFT);
|
||||||
NextPageAttributes = 0;
|
NextPageAttributes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*NextRegionLength += TT_DESCRIPTOR_PAGE_SIZE;
|
*NextRegionLength += TT_DESCRIPTOR_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +234,6 @@ SyncCacheConfig (
|
|||||||
UINTN NumberOfDescriptors;
|
UINTN NumberOfDescriptors;
|
||||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
|
||||||
|
|
||||||
|
|
||||||
DEBUG ((DEBUG_PAGE, "SyncCacheConfig()\n"));
|
DEBUG ((DEBUG_PAGE, "SyncCacheConfig()\n"));
|
||||||
|
|
||||||
// This code assumes MMU is enabled and filed with section translations
|
// This code assumes MMU is enabled and filed with section translations
|
||||||
@ -246,7 +246,6 @@ SyncCacheConfig (
|
|||||||
Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
|
||||||
// The GCD implementation maintains its own copy of the state of memory space attributes. GCD needs
|
// The GCD implementation maintains its own copy of the state of memory space attributes. GCD needs
|
||||||
// to know what the initial memory space attributes are. The CPU Arch. Protocol does not provide a
|
// to know what the initial memory space attributes are. The CPU Arch. Protocol does not provide a
|
||||||
// GetMemoryAttributes function for GCD to get this so we must resort to calling GCD (as if we were
|
// GetMemoryAttributes function for GCD to get this so we must resort to calling GCD (as if we were
|
||||||
@ -284,6 +283,7 @@ SyncCacheConfig (
|
|||||||
NextRegionBase = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (i << TT_DESCRIPTOR_SECTION_BASE_SHIFT);
|
NextRegionBase = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (i << TT_DESCRIPTOR_SECTION_BASE_SHIFT);
|
||||||
NextSectionAttributes = SectionAttributes;
|
NextSectionAttributes = SectionAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
NextRegionLength += TT_DESCRIPTOR_SECTION_SIZE;
|
NextRegionLength += TT_DESCRIPTOR_SECTION_SIZE;
|
||||||
} else if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (FirstLevelTable[i])) {
|
} else if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (FirstLevelTable[i])) {
|
||||||
// In this case any bits set in the 'NextSectionAttributes' are garbage and were set from
|
// In this case any bits set in the 'NextSectionAttributes' are garbage and were set from
|
||||||
@ -292,9 +292,14 @@ SyncCacheConfig (
|
|||||||
// section attributes into page attributes
|
// section attributes into page attributes
|
||||||
NextSectionAttributes = 0;
|
NextSectionAttributes = 0;
|
||||||
Status = SyncCacheConfigPage (
|
Status = SyncCacheConfigPage (
|
||||||
i,FirstLevelTable[i],
|
i,
|
||||||
NumberOfDescriptors, MemorySpaceMap,
|
FirstLevelTable[i],
|
||||||
&NextRegionBase,&NextRegionLength,&NextSectionAttributes);
|
NumberOfDescriptors,
|
||||||
|
MemorySpaceMap,
|
||||||
|
&NextRegionBase,
|
||||||
|
&NextRegionLength,
|
||||||
|
&NextSectionAttributes
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
} else {
|
} else {
|
||||||
// We do not support yet 16MB sections
|
// We do not support yet 16MB sections
|
||||||
@ -313,6 +318,7 @@ SyncCacheConfig (
|
|||||||
NextRegionBase = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (i << TT_DESCRIPTOR_SECTION_BASE_SHIFT);
|
NextRegionBase = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (i << TT_DESCRIPTOR_SECTION_BASE_SHIFT);
|
||||||
NextSectionAttributes = 0;
|
NextSectionAttributes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NextRegionLength += TT_DESCRIPTOR_SECTION_SIZE;
|
NextRegionLength += TT_DESCRIPTOR_SECTION_SIZE;
|
||||||
}
|
}
|
||||||
} // section entry loop
|
} // section entry loop
|
||||||
@ -494,7 +500,8 @@ GetMemoryRegion (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) ||
|
} else if (((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) ||
|
||||||
((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SUPERSECTION)) {
|
((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SUPERSECTION))
|
||||||
|
{
|
||||||
if ((SectionDescriptor & TT_DESCRIPTOR_SECTION_ATTRIBUTE_MASK) != *RegionAttributes) {
|
if ((SectionDescriptor & TT_DESCRIPTOR_SECTION_ATTRIBUTE_MASK) != *RegionAttributes) {
|
||||||
// If the attributes of the section differ from the one targeted then we exit the loop
|
// If the attributes of the section differ from the one targeted then we exit the loop
|
||||||
break;
|
break;
|
||||||
|
@ -49,7 +49,6 @@ CpuFlushCpuDataCache (
|
|||||||
IN EFI_CPU_FLUSH_TYPE FlushType
|
IN EFI_CPU_FLUSH_TYPE FlushType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (FlushType) {
|
switch (FlushType) {
|
||||||
case EfiCpuFlushTypeWriteBack:
|
case EfiCpuFlushTypeWriteBack:
|
||||||
WriteBackDataCacheRange ((VOID *)(UINTN)Start, (UINTN)Length);
|
WriteBackDataCacheRange ((VOID *)(UINTN)Start, (UINTN)Length);
|
||||||
@ -67,7 +66,6 @@ CpuFlushCpuDataCache (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function enables interrupt processing by the processor.
|
This function enables interrupt processing by the processor.
|
||||||
|
|
||||||
@ -88,7 +86,6 @@ CpuEnableInterrupt (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function disables interrupt processing by the processor.
|
This function disables interrupt processing by the processor.
|
||||||
|
|
||||||
@ -109,7 +106,6 @@ CpuDisableInterrupt (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function retrieves the processor's current interrupt state a returns it in
|
This function retrieves the processor's current interrupt state a returns it in
|
||||||
State. If interrupts are currently enabled, then TRUE is returned. If interrupts
|
State. If interrupts are currently enabled, then TRUE is returned. If interrupts
|
||||||
@ -138,7 +134,6 @@ CpuGetInterruptState (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function generates an INIT on the processor. If this function succeeds, then the
|
This function generates an INIT on the processor. If this function succeeds, then the
|
||||||
processor will be reset, and control will not be returned to the caller. If InitType is
|
processor will be reset, and control will not be returned to the caller. If InitType is
|
||||||
@ -247,7 +242,8 @@ CpuDxeInitialize (
|
|||||||
|
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&mCpuHandle,
|
&mCpuHandle,
|
||||||
&gEfiCpuArchProtocolGuid, &mCpu,
|
&gEfiCpuArchProtocolGuid,
|
||||||
|
&mCpu,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ RegisterInterruptHandler (
|
|||||||
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function registers and enables the handler specified by InterruptHandler for a processor
|
This function registers and enables the handler specified by InterruptHandler for a processor
|
||||||
interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
|
interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
|
||||||
@ -86,7 +85,6 @@ RegisterDebuggerInterruptHandler (
|
|||||||
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CpuSetMemoryAttributes (
|
CpuSetMemoryAttributes (
|
||||||
|
@ -43,19 +43,22 @@ SearchGcdMemorySpaces (
|
|||||||
*EndIndex = 0;
|
*EndIndex = 0;
|
||||||
for (Index = 0; Index < NumberOfDescriptors; Index++) {
|
for (Index = 0; Index < NumberOfDescriptors; Index++) {
|
||||||
if ((BaseAddress >= MemorySpaceMap[Index].BaseAddress) &&
|
if ((BaseAddress >= MemorySpaceMap[Index].BaseAddress) &&
|
||||||
(BaseAddress < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length))) {
|
(BaseAddress < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length)))
|
||||||
|
{
|
||||||
*StartIndex = Index;
|
*StartIndex = Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((BaseAddress + Length - 1) >= MemorySpaceMap[Index].BaseAddress) &&
|
if (((BaseAddress + Length - 1) >= MemorySpaceMap[Index].BaseAddress) &&
|
||||||
((BaseAddress + Length - 1) < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length))) {
|
((BaseAddress + Length - 1) < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length)))
|
||||||
|
{
|
||||||
*EndIndex = Index;
|
*EndIndex = Index;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the attributes for a specified range in Gcd Memory Space Map.
|
Sets the attributes for a specified range in Gcd Memory Space Map.
|
||||||
|
|
||||||
@ -88,14 +91,21 @@ SetGcdMemorySpaceAttributes (
|
|||||||
EFI_PHYSICAL_ADDRESS RegionStart;
|
EFI_PHYSICAL_ADDRESS RegionStart;
|
||||||
UINT64 RegionLength;
|
UINT64 RegionLength;
|
||||||
|
|
||||||
DEBUG ((DEBUG_GCD, "SetGcdMemorySpaceAttributes[0x%lX; 0x%lX] = 0x%lX\n",
|
DEBUG ((
|
||||||
BaseAddress, BaseAddress + Length, Attributes));
|
DEBUG_GCD,
|
||||||
|
"SetGcdMemorySpaceAttributes[0x%lX; 0x%lX] = 0x%lX\n",
|
||||||
|
BaseAddress,
|
||||||
|
BaseAddress + Length,
|
||||||
|
Attributes
|
||||||
|
));
|
||||||
|
|
||||||
// We do not support a smaller granularity than 4KB on ARM Architecture
|
// We do not support a smaller granularity than 4KB on ARM Architecture
|
||||||
if ((Length & EFI_PAGE_MASK) != 0) {
|
if ((Length & EFI_PAGE_MASK) != 0) {
|
||||||
DEBUG ((DEBUG_WARN,
|
DEBUG ((
|
||||||
|
DEBUG_WARN,
|
||||||
"Warning: We do not support smaller granularity than 4KB on ARM Architecture (passed length: 0x%lX).\n",
|
"Warning: We do not support smaller granularity than 4KB on ARM Architecture (passed length: 0x%lX).\n",
|
||||||
Length));
|
Length
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -120,6 +130,7 @@ SetGcdMemorySpaceAttributes (
|
|||||||
if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeNonExistent) {
|
if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeNonExistent) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate the start and end address of the overlapping range
|
// Calculate the start and end address of the overlapping range
|
||||||
//
|
//
|
||||||
@ -128,11 +139,13 @@ SetGcdMemorySpaceAttributes (
|
|||||||
} else {
|
} else {
|
||||||
RegionStart = MemorySpaceMap[Index].BaseAddress;
|
RegionStart = MemorySpaceMap[Index].BaseAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((BaseAddress + Length - 1) < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length)) {
|
if ((BaseAddress + Length - 1) < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length)) {
|
||||||
RegionLength = BaseAddress + Length - RegionStart;
|
RegionLength = BaseAddress + Length - RegionStart;
|
||||||
} else {
|
} else {
|
||||||
RegionLength = MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - RegionStart;
|
RegionLength = MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - RegionStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set memory attributes according to MTRR attribute and the original attribute of descriptor
|
// Set memory attributes according to MTRR attribute and the original attribute of descriptor
|
||||||
//
|
//
|
||||||
|
@ -79,7 +79,8 @@ PublishArmProcessorTable (
|
|||||||
|
|
||||||
// Allocate runtime memory for ARM processor Table entries
|
// Allocate runtime memory for ARM processor Table entries
|
||||||
ArmProcessorTable->ArmCpus = (ARM_CORE_INFO *)AllocateRuntimePool (
|
ArmProcessorTable->ArmCpus = (ARM_CORE_INFO *)AllocateRuntimePool (
|
||||||
ArmProcessorTable->NumberOfEntries * sizeof(ARM_CORE_INFO));
|
ArmProcessorTable->NumberOfEntries * sizeof (ARM_CORE_INFO)
|
||||||
|
);
|
||||||
|
|
||||||
// Check if the memory allocation is successful or not
|
// Check if the memory allocation is successful or not
|
||||||
ASSERT (NULL != ArmProcessorTable->ArmCpus);
|
ASSERT (NULL != ArmProcessorTable->ArmCpus);
|
||||||
|
@ -24,7 +24,7 @@ InitializeExceptions (
|
|||||||
|
|
||||||
VectorInfo = (EFI_VECTOR_HANDOFF_INFO *)NULL;
|
VectorInfo = (EFI_VECTOR_HANDOFF_INFO *)NULL;
|
||||||
Status = EfiGetSystemConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID **)&VectorInfoList);
|
Status = EfiGetSystemConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID **)&VectorInfoList);
|
||||||
if (Status == EFI_SUCCESS && VectorInfoList != NULL) {
|
if ((Status == EFI_SUCCESS) && (VectorInfoList != NULL)) {
|
||||||
VectorInfo = VectorInfoList;
|
VectorInfo = VectorInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ Abstract:
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The package level header files this module uses
|
// The package level header files this module uses
|
||||||
//
|
//
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef GENERIC_WATCHDOG_H_
|
#ifndef GENERIC_WATCHDOG_H_
|
||||||
#define GENERIC_WATCHDOG_H_
|
#define GENERIC_WATCHDOG_H_
|
||||||
|
|
||||||
|
@ -119,8 +119,12 @@ WatchdogInterruptHandler (
|
|||||||
mWatchdogNotify (TimerPeriod + 1);
|
mWatchdogNotify (TimerPeriod + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gRT->ResetSystem (EfiResetCold, EFI_TIMEOUT, StrSize (ResetString),
|
gRT->ResetSystem (
|
||||||
(CHAR16 *)ResetString);
|
EfiResetCold,
|
||||||
|
EFI_TIMEOUT,
|
||||||
|
StrSize (ResetString),
|
||||||
|
(CHAR16 *)ResetString
|
||||||
|
);
|
||||||
|
|
||||||
// If we got here then the reset didn't work
|
// If we got here then the reset didn't work
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
@ -158,11 +162,11 @@ WatchdogRegisterHandler (
|
|||||||
IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction
|
IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (mWatchdogNotify == NULL && NotifyFunction == NULL) {
|
if ((mWatchdogNotify == NULL) && (NotifyFunction == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWatchdogNotify != NULL && NotifyFunction != NULL) {
|
if ((mWatchdogNotify != NULL) && (NotifyFunction != NULL)) {
|
||||||
return EFI_ALREADY_STARTED;
|
return EFI_ALREADY_STARTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,8 +311,11 @@ GenericWatchdogEntry (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_HANDLE Handle;
|
EFI_HANDLE Handle;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gHardwareInterrupt2ProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&mInterruptProtocol);
|
&gHardwareInterrupt2ProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&mInterruptProtocol
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
/* Make sure the Watchdog Timer Architectural Protocol has not been installed
|
/* Make sure the Watchdog Timer Architectural Protocol has not been installed
|
||||||
@ -320,33 +327,44 @@ GenericWatchdogEntry (
|
|||||||
ASSERT (mTimerFrequencyHz != 0);
|
ASSERT (mTimerFrequencyHz != 0);
|
||||||
|
|
||||||
// Install interrupt handler
|
// Install interrupt handler
|
||||||
Status = mInterruptProtocol->RegisterInterruptSource (mInterruptProtocol,
|
Status = mInterruptProtocol->RegisterInterruptSource (
|
||||||
|
mInterruptProtocol,
|
||||||
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
|
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
|
||||||
WatchdogInterruptHandler);
|
WatchdogInterruptHandler
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = mInterruptProtocol->SetTriggerType (mInterruptProtocol,
|
Status = mInterruptProtocol->SetTriggerType (
|
||||||
|
mInterruptProtocol,
|
||||||
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
|
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
|
||||||
EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING);
|
EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto UnregisterHandler;
|
goto UnregisterHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install the Timer Architectural Protocol onto a new handle
|
// Install the Timer Architectural Protocol onto a new handle
|
||||||
Handle = NULL;
|
Handle = NULL;
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (&Handle,
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&gEfiWatchdogTimerArchProtocolGuid, &mWatchdogTimer,
|
&Handle,
|
||||||
NULL);
|
&gEfiWatchdogTimerArchProtocolGuid,
|
||||||
|
&mWatchdogTimer,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto UnregisterHandler;
|
goto UnregisterHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register for an ExitBootServicesEvent
|
// Register for an ExitBootServicesEvent
|
||||||
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY,
|
Status = gBS->CreateEvent (
|
||||||
WatchdogExitBootServicesEvent, NULL,
|
EVT_SIGNAL_EXIT_BOOT_SERVICES,
|
||||||
&mEfiExitBootServicesEvent);
|
TPL_NOTIFY,
|
||||||
|
WatchdogExitBootServicesEvent,
|
||||||
|
NULL,
|
||||||
|
&mEfiExitBootServicesEvent
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
mNumTimerTicks = 0;
|
mNumTimerTicks = 0;
|
||||||
@ -356,8 +374,10 @@ GenericWatchdogEntry (
|
|||||||
|
|
||||||
UnregisterHandler:
|
UnregisterHandler:
|
||||||
// Unregister the handler
|
// Unregister the handler
|
||||||
mInterruptProtocol->RegisterInterruptSource (mInterruptProtocol,
|
mInterruptProtocol->RegisterInterruptSource (
|
||||||
|
mInterruptProtocol,
|
||||||
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
|
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
|
||||||
NULL);
|
NULL
|
||||||
|
);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,20 @@ STATIC EFI_HANDLE mMmCommunicateHandle;
|
|||||||
This function provides a service to send and receive messages from a registered UEFI service.
|
This function provides a service to send and receive messages from a registered UEFI service.
|
||||||
|
|
||||||
@param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instance.
|
@param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instance.
|
||||||
@param[in] CommBufferPhysical Physical address of the MM communication buffer
|
@param[in, out] CommBufferPhysical Physical address of the MM communication buffer
|
||||||
@param[in] CommBufferVirtual Virtual address of the MM communication buffer
|
@param[in, out] CommBufferVirtual Virtual address of the MM communication buffer
|
||||||
@param[in] CommSize The size of the data buffer being passed in. On exit, the size of data
|
@param[in, out] CommSize The size of the data buffer being passed in. On input,
|
||||||
being returned. Zero if the handler does not wish to reply with any data.
|
when not omitted, the buffer should cover EFI_MM_COMMUNICATE_HEADER
|
||||||
This parameter is optional and may be NULL.
|
and the value of MessageLength field. On exit, the size
|
||||||
|
of data being returned. Zero if the handler does not
|
||||||
|
wish to reply with any data. This parameter is optional
|
||||||
|
and may be NULL.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The message was successfully posted.
|
@retval EFI_SUCCESS The message was successfully posted.
|
||||||
@retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBufferVirtual was NULL.
|
@retval EFI_INVALID_PARAMETER CommBufferPhysical or CommBufferVirtual was NULL, or
|
||||||
|
integer value pointed by CommSize does not cover
|
||||||
|
EFI_MM_COMMUNICATE_HEADER and the value of MessageLength
|
||||||
|
field.
|
||||||
@retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implementation.
|
@retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implementation.
|
||||||
If this error is returned, the MessageLength field
|
If this error is returned, the MessageLength field
|
||||||
in the CommBuffer header or the integer pointed by
|
in the CommBuffer header or the integer pointed by
|
||||||
@ -82,10 +88,11 @@ MmCommunication2Communicate (
|
|||||||
//
|
//
|
||||||
// Check parameters
|
// Check parameters
|
||||||
//
|
//
|
||||||
if (CommBufferVirtual == NULL) {
|
if ((CommBufferVirtual == NULL) || (CommBufferPhysical == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
CommunicateHeader = CommBufferVirtual;
|
CommunicateHeader = CommBufferVirtual;
|
||||||
// CommBuffer is a mandatory parameter. Hence, Rely on
|
// CommBuffer is a mandatory parameter. Hence, Rely on
|
||||||
// MessageLength + Header to ascertain the
|
// MessageLength + Header to ascertain the
|
||||||
@ -95,33 +102,41 @@ MmCommunication2Communicate (
|
|||||||
sizeof (CommunicateHeader->HeaderGuid) +
|
sizeof (CommunicateHeader->HeaderGuid) +
|
||||||
sizeof (CommunicateHeader->MessageLength);
|
sizeof (CommunicateHeader->MessageLength);
|
||||||
|
|
||||||
// If the length of the CommBuffer is 0 then return the expected length.
|
// If CommSize is not omitted, perform size inspection before proceeding.
|
||||||
if (CommSize != 0) {
|
if (CommSize != NULL) {
|
||||||
// This case can be used by the consumer of this driver to find out the
|
// This case can be used by the consumer of this driver to find out the
|
||||||
// max size that can be used for allocating CommBuffer.
|
// max size that can be used for allocating CommBuffer.
|
||||||
if ((*CommSize == 0) ||
|
if ((*CommSize == 0) ||
|
||||||
(*CommSize > mNsCommBuffMemRegion.Length)) {
|
(*CommSize > mNsCommBuffMemRegion.Length))
|
||||||
|
{
|
||||||
*CommSize = mNsCommBuffMemRegion.Length;
|
*CommSize = mNsCommBuffMemRegion.Length;
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// CommSize must match MessageLength + sizeof (EFI_MM_COMMUNICATE_HEADER);
|
// CommSize should cover at least MessageLength + sizeof (EFI_MM_COMMUNICATE_HEADER);
|
||||||
//
|
//
|
||||||
if (*CommSize != BufferSize) {
|
if (*CommSize < BufferSize) {
|
||||||
return EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If the buffer size is 0 or greater than what can be tolerated by the MM
|
// If the message length is 0 or greater than what can be tolerated by the MM
|
||||||
// environment then return the expected size.
|
// environment then return the expected size.
|
||||||
//
|
//
|
||||||
if ((BufferSize == 0) ||
|
if ((CommunicateHeader->MessageLength == 0) ||
|
||||||
(BufferSize > mNsCommBuffMemRegion.Length)) {
|
(BufferSize > mNsCommBuffMemRegion.Length))
|
||||||
|
{
|
||||||
CommunicateHeader->MessageLength = mNsCommBuffMemRegion.Length -
|
CommunicateHeader->MessageLength = mNsCommBuffMemRegion.Length -
|
||||||
sizeof (CommunicateHeader->HeaderGuid) -
|
sizeof (CommunicateHeader->HeaderGuid) -
|
||||||
sizeof (CommunicateHeader->MessageLength);
|
sizeof (CommunicateHeader->MessageLength);
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MessageLength or CommSize check has failed, return here.
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SMC Function ID
|
// SMC Function ID
|
||||||
@ -219,15 +234,19 @@ NotifySetVirtualAddressMap (
|
|||||||
(VOID **)&mNsCommBuffMemRegion.VirtualBase
|
(VOID **)&mNsCommBuffMemRegion.VirtualBase
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "NotifySetVirtualAddressMap():"
|
DEBUG ((
|
||||||
" Unable to convert MM runtime pointer. Status:0x%r\n", Status));
|
DEBUG_ERROR,
|
||||||
|
"NotifySetVirtualAddressMap():"
|
||||||
|
" Unable to convert MM runtime pointer. Status:0x%r\n",
|
||||||
|
Status
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetMmCompatibility ()
|
GetMmCompatibility (
|
||||||
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT32 MmVersion;
|
UINT32 MmVersion;
|
||||||
@ -241,13 +260,24 @@ GetMmCompatibility ()
|
|||||||
MmVersion = MmVersionArgs.Arg0;
|
MmVersion = MmVersionArgs.Arg0;
|
||||||
|
|
||||||
if ((MM_MAJOR_VER (MmVersion) == MM_CALLER_MAJOR_VER) &&
|
if ((MM_MAJOR_VER (MmVersion) == MM_CALLER_MAJOR_VER) &&
|
||||||
(MM_MINOR_VER(MmVersion) >= MM_CALLER_MINOR_VER)) {
|
(MM_MINOR_VER (MmVersion) >= MM_CALLER_MINOR_VER))
|
||||||
DEBUG ((DEBUG_INFO, "MM Version: Major=0x%x, Minor=0x%x\n",
|
{
|
||||||
MM_MAJOR_VER(MmVersion), MM_MINOR_VER(MmVersion)));
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"MM Version: Major=0x%x, Minor=0x%x\n",
|
||||||
|
MM_MAJOR_VER (MmVersion),
|
||||||
|
MM_MINOR_VER (MmVersion)
|
||||||
|
));
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR, "Incompatible MM Versions.\n Current Version: Major=0x%x, Minor=0x%x.\n Expected: Major=0x%x, Minor>=0x%x.\n",
|
DEBUG ((
|
||||||
MM_MAJOR_VER(MmVersion), MM_MINOR_VER(MmVersion), MM_CALLER_MAJOR_VER, MM_CALLER_MINOR_VER));
|
DEBUG_ERROR,
|
||||||
|
"Incompatible MM Versions.\n Current Version: Major=0x%x, Minor=0x%x.\n Expected: Major=0x%x, Minor>=0x%x.\n",
|
||||||
|
MM_MAJOR_VER (MmVersion),
|
||||||
|
MM_MINOR_VER (MmVersion),
|
||||||
|
MM_CALLER_MAJOR_VER,
|
||||||
|
MM_CALLER_MINOR_VER
|
||||||
|
));
|
||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,8 +369,11 @@ MmCommunication2Initialize (
|
|||||||
EFI_MEMORY_RUNTIME
|
EFI_MEMORY_RUNTIME
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: "
|
DEBUG ((
|
||||||
"Failed to add MM-NS Buffer Memory Space\n"));
|
DEBUG_ERROR,
|
||||||
|
"MmCommunicateInitialize: "
|
||||||
|
"Failed to add MM-NS Buffer Memory Space\n"
|
||||||
|
));
|
||||||
goto ReturnErrorStatus;
|
goto ReturnErrorStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,8 +383,11 @@ MmCommunication2Initialize (
|
|||||||
EFI_MEMORY_WB | EFI_MEMORY_XP | EFI_MEMORY_RUNTIME
|
EFI_MEMORY_WB | EFI_MEMORY_XP | EFI_MEMORY_RUNTIME
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: "
|
DEBUG ((
|
||||||
"Failed to set MM-NS Buffer Memory attributes\n"));
|
DEBUG_ERROR,
|
||||||
|
"MmCommunicateInitialize: "
|
||||||
|
"Failed to set MM-NS Buffer Memory attributes\n"
|
||||||
|
));
|
||||||
goto CleanAddedMemorySpace;
|
goto CleanAddedMemorySpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,8 +399,11 @@ MmCommunication2Initialize (
|
|||||||
&mMmCommunication2
|
&mMmCommunication2
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: "
|
DEBUG ((
|
||||||
"Failed to install MM communication protocol\n"));
|
DEBUG_ERROR,
|
||||||
|
"MmCommunicationInitialize: "
|
||||||
|
"Failed to install MM communication protocol\n"
|
||||||
|
));
|
||||||
goto CleanAddedMemorySpace;
|
goto CleanAddedMemorySpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,17 +420,24 @@ MmCommunication2Initialize (
|
|||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
for (Index = 0; Index < ARRAY_SIZE (mGuidedEventGuid); Index++) {
|
for (Index = 0; Index < ARRAY_SIZE (mGuidedEventGuid); Index++) {
|
||||||
Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
|
Status = gBS->CreateEventEx (
|
||||||
MmGuidedEventNotify, mGuidedEventGuid[Index],
|
EVT_NOTIFY_SIGNAL,
|
||||||
mGuidedEventGuid[Index], &mGuidedEvent[Index]);
|
TPL_CALLBACK,
|
||||||
|
MmGuidedEventNotify,
|
||||||
|
mGuidedEventGuid[Index],
|
||||||
|
mGuidedEventGuid[Index],
|
||||||
|
&mGuidedEvent[Index]
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
while (Index-- > 0) {
|
while (Index-- > 0) {
|
||||||
gBS->CloseEvent (mGuidedEvent[Index]);
|
gBS->CloseEvent (mGuidedEvent[Index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
goto UninstallProtocol;
|
goto UninstallProtocol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
UninstallProtocol:
|
UninstallProtocol:
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <PiDxe.h>
|
#include <PiDxe.h>
|
||||||
|
|
||||||
#include <Library/ArmLib.h>
|
#include <Library/ArmLib.h>
|
||||||
@ -306,7 +305,6 @@ TimerInterruptHandler (
|
|||||||
|
|
||||||
// Check if the timer interrupt is active
|
// Check if the timer interrupt is active
|
||||||
if ((ArmGenericTimerGetTimerCtrlReg ()) & ARM_ARCH_TIMER_ISTATUS) {
|
if ((ArmGenericTimerGetTimerCtrlReg ()) & ARM_ARCH_TIMER_ISTATUS) {
|
||||||
|
|
||||||
if (mTimerNotifyFunction != 0) {
|
if (mTimerNotifyFunction != 0) {
|
||||||
mTimerNotifyFunction (mTimerPeriod * mElapsedPeriod);
|
mTimerNotifyFunction (mTimerPeriod * mElapsedPeriod);
|
||||||
}
|
}
|
||||||
@ -338,7 +336,6 @@ TimerInterruptHandler (
|
|||||||
gBS->RestoreTPL (OriginalTPL);
|
gBS->RestoreTPL (OriginalTPL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the state information for the Timer Architectural Protocol and
|
Initialize the state information for the Timer Architectural Protocol and
|
||||||
the Timer Debug support protocol that allows the debugger to break into a
|
the Timer Debug support protocol that allows the debugger to break into a
|
||||||
@ -412,7 +409,8 @@ TimerInitialize (
|
|||||||
// Install the Timer Architectural Protocol onto a new handle
|
// Install the Timer Architectural Protocol onto a new handle
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&Handle,
|
&Handle,
|
||||||
&gEfiTimerArchProtocolGuid, &gTimer,
|
&gEfiTimerArchProtocolGuid,
|
||||||
|
&gTimer,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
@ -60,10 +60,12 @@ typedef struct {
|
|||||||
|
|
||||||
SEMIHOST_DEVICE_PATH gDevicePath = {
|
SEMIHOST_DEVICE_PATH gDevicePath = {
|
||||||
{
|
{
|
||||||
{ HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0 } },
|
{ HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0 }
|
||||||
|
},
|
||||||
EFI_CALLER_ID_GUID
|
EFI_CALLER_ID_GUID
|
||||||
},
|
},
|
||||||
{ END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } }
|
{ END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -115,8 +117,6 @@ FreeFCB (
|
|||||||
FreePool (Fcb);
|
FreePool (Fcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
VolumeOpen (
|
VolumeOpen (
|
||||||
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
|
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
|
||||||
@ -193,12 +193,14 @@ FileOpen (
|
|||||||
|
|
||||||
if ((OpenMode != EFI_FILE_MODE_READ) &&
|
if ((OpenMode != EFI_FILE_MODE_READ) &&
|
||||||
(OpenMode != (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE)) &&
|
(OpenMode != (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE)) &&
|
||||||
(OpenMode != (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE)) ) {
|
(OpenMode != (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE)))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((OpenMode & EFI_FILE_MODE_CREATE) != 0) &&
|
if (((OpenMode & EFI_FILE_MODE_CREATE) != 0) &&
|
||||||
((Attributes & EFI_FILE_DIRECTORY) != 0)) {
|
((Attributes & EFI_FILE_DIRECTORY) != 0))
|
||||||
|
{
|
||||||
return EFI_WRITE_PROTECTED;
|
return EFI_WRITE_PROTECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,13 +209,15 @@ FileOpen (
|
|||||||
if (AsciiFileName == NULL) {
|
if (AsciiFileName == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnicodeStrToAsciiStrS (FileName, AsciiFileName, Length);
|
UnicodeStrToAsciiStrS (FileName, AsciiFileName, Length);
|
||||||
|
|
||||||
// Opening '/', '\', '.', or the NULL pathname is trying to open the root directory
|
// Opening '/', '\', '.', or the NULL pathname is trying to open the root directory
|
||||||
if ((AsciiStrCmp (AsciiFileName, "\\") == 0) ||
|
if ((AsciiStrCmp (AsciiFileName, "\\") == 0) ||
|
||||||
(AsciiStrCmp (AsciiFileName, "/") == 0) ||
|
(AsciiStrCmp (AsciiFileName, "/") == 0) ||
|
||||||
(AsciiStrCmp (AsciiFileName, "") == 0) ||
|
(AsciiStrCmp (AsciiFileName, "") == 0) ||
|
||||||
(AsciiStrCmp (AsciiFileName, ".") == 0) ) {
|
(AsciiStrCmp (AsciiFileName, ".") == 0))
|
||||||
|
{
|
||||||
FreePool (AsciiFileName);
|
FreePool (AsciiFileName);
|
||||||
return (VolumeOpen (&gSemihostFs, NewHandle));
|
return (VolumeOpen (&gSemihostFs, NewHandle));
|
||||||
}
|
}
|
||||||
@ -232,6 +236,7 @@ FileOpen (
|
|||||||
} else {
|
} else {
|
||||||
SemihostMode = SEMIHOST_FILE_MODE_READ | SEMIHOST_FILE_MODE_BINARY | SEMIHOST_FILE_MODE_UPDATE;
|
SemihostMode = SEMIHOST_FILE_MODE_READ | SEMIHOST_FILE_MODE_BINARY | SEMIHOST_FILE_MODE_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Return = SemihostFileOpen (AsciiFileName, SemihostMode, &SemihostHandle);
|
Return = SemihostFileOpen (AsciiFileName, SemihostMode, &SemihostHandle);
|
||||||
|
|
||||||
if (RETURN_ERROR (Return)) {
|
if (RETURN_ERROR (Return)) {
|
||||||
@ -346,6 +351,7 @@ TruncateFile (
|
|||||||
if (RETURN_ERROR (Return)) {
|
if (RETURN_ERROR (Return)) {
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
Remaining -= ToRead;
|
Remaining -= ToRead;
|
||||||
Read += ToRead;
|
Read += ToRead;
|
||||||
}
|
}
|
||||||
@ -379,12 +385,12 @@ Error:
|
|||||||
if (FileHandle != 0) {
|
if (FileHandle != 0) {
|
||||||
SemihostFileClose (FileHandle);
|
SemihostFileClose (FileHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Buffer != NULL) {
|
if (Buffer != NULL) {
|
||||||
FreePool (Buffer);
|
FreePool (Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -420,6 +426,7 @@ FileClose (
|
|||||||
if (Fcb->Info.FileSize < Fcb->Info.PhysicalSize) {
|
if (Fcb->Info.FileSize < Fcb->Info.PhysicalSize) {
|
||||||
TruncateFile (Fcb->FileName, Fcb->Info.FileSize);
|
TruncateFile (Fcb->FileName, Fcb->Info.FileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool (Fcb->FileName);
|
FreePool (Fcb->FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,6 +478,7 @@ FileDelete (
|
|||||||
if (RETURN_ERROR (Return)) {
|
if (RETURN_ERROR (Return)) {
|
||||||
return EFI_WARN_DELETE_FAILURE;
|
return EFI_WARN_DELETE_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return EFI_WARN_DELETE_FAILURE;
|
return EFI_WARN_DELETE_FAILURE;
|
||||||
@ -574,6 +582,7 @@ ExtendFile (
|
|||||||
if (RETURN_ERROR (Return)) {
|
if (RETURN_ERROR (Return)) {
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Remaining -= WriteNb;
|
Remaining -= WriteNb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,7 +627,8 @@ FileWrite (
|
|||||||
|
|
||||||
// We cannot write a read-only file
|
// We cannot write a read-only file
|
||||||
if ( (Fcb->Info.Attribute & EFI_FILE_READ_ONLY)
|
if ( (Fcb->Info.Attribute & EFI_FILE_READ_ONLY)
|
||||||
|| !(Fcb->OpenMode & EFI_FILE_MODE_WRITE)) {
|
|| !(Fcb->OpenMode & EFI_FILE_MODE_WRITE))
|
||||||
|
{
|
||||||
return EFI_ACCESS_DENIED;
|
return EFI_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,6 +642,7 @@ FileWrite (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fcb->Info.FileSize = Fcb->Position;
|
Fcb->Info.FileSize = Fcb->Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,6 +661,7 @@ FileWrite (
|
|||||||
if (RETURN_ERROR (Return)) {
|
if (RETURN_ERROR (Return)) {
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fcb->Info.PhysicalSize = Length;
|
Fcb->Info.PhysicalSize = Length;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -718,8 +730,7 @@ FileSetPosition (
|
|||||||
if (Position != 0) {
|
if (Position != 0) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//
|
//
|
||||||
// UEFI Spec section 12.5:
|
// UEFI Spec section 12.5:
|
||||||
// "Seeking to position 0xFFFFFFFFFFFFFFFF causes the current position to
|
// "Seeking to position 0xFFFFFFFFFFFFFFFF causes the current position to
|
||||||
@ -728,6 +739,7 @@ FileSetPosition (
|
|||||||
if (Position == 0xFFFFFFFFFFFFFFFF) {
|
if (Position == 0xFFFFFFFFFFFFFFFF) {
|
||||||
Position = Fcb->Info.FileSize;
|
Position = Fcb->Info.FileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Return = SemihostFileSeek (Fcb->SemihostHandle, MIN (Position, Fcb->Info.FileSize));
|
Return = SemihostFileSeek (Fcb->SemihostHandle, MIN (Position, Fcb->Info.FileSize));
|
||||||
if (RETURN_ERROR (Return)) {
|
if (RETURN_ERROR (Return)) {
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
@ -889,7 +901,8 @@ FileGetInfo (
|
|||||||
if ((This == NULL) ||
|
if ((This == NULL) ||
|
||||||
(InformationType == NULL) ||
|
(InformationType == NULL) ||
|
||||||
(BufferSize == NULL) ||
|
(BufferSize == NULL) ||
|
||||||
((Buffer == NULL) && (*BufferSize > 0)) ) {
|
((Buffer == NULL) && (*BufferSize > 0)))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,6 +981,7 @@ SetFileInfo (
|
|||||||
if (AsciiFileName == NULL) {
|
if (AsciiFileName == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnicodeStrToAsciiStrS (Info->FileName, AsciiFileName, Length);
|
UnicodeStrToAsciiStrS (Info->FileName, AsciiFileName, Length);
|
||||||
|
|
||||||
FileSizeIsDifferent = (Info->FileSize != Fcb->Info.FileSize);
|
FileSizeIsDifferent = (Info->FileSize != Fcb->Info.FileSize);
|
||||||
@ -985,7 +999,8 @@ SetFileInfo (
|
|||||||
// description.
|
// description.
|
||||||
//
|
//
|
||||||
if ((Fcb->OpenMode == EFI_FILE_MODE_READ) ||
|
if ((Fcb->OpenMode == EFI_FILE_MODE_READ) ||
|
||||||
(Fcb->Info.Attribute & EFI_FILE_READ_ONLY) ) {
|
(Fcb->Info.Attribute & EFI_FILE_READ_ONLY))
|
||||||
|
{
|
||||||
if (FileSizeIsDifferent || FileNameIsDifferent || ReadOnlyIsDifferent) {
|
if (FileSizeIsDifferent || FileNameIsDifferent || ReadOnlyIsDifferent) {
|
||||||
Status = EFI_ACCESS_DENIED;
|
Status = EFI_ACCESS_DENIED;
|
||||||
goto Error;
|
goto Error;
|
||||||
@ -1006,6 +1021,7 @@ SetFileInfo (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// The read/write position from the host file system point of view
|
// The read/write position from the host file system point of view
|
||||||
// is at the end of the file. If the position from this module
|
// is at the end of the file. If the position from this module
|
||||||
@ -1016,12 +1032,14 @@ SetFileInfo (
|
|||||||
FileSetPosition (&Fcb->File, Fcb->Position);
|
FileSetPosition (&Fcb->File, Fcb->Position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Fcb->Info.FileSize = FileSize;
|
Fcb->Info.FileSize = FileSize;
|
||||||
|
|
||||||
Return = SemihostFileLength (Fcb->SemihostHandle, &Length);
|
Return = SemihostFileLength (Fcb->SemihostHandle, &Length);
|
||||||
if (RETURN_ERROR (Return)) {
|
if (RETURN_ERROR (Return)) {
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fcb->Info.PhysicalSize = Length;
|
Fcb->Info.PhysicalSize = Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,6 +1066,7 @@ SetFileInfo (
|
|||||||
if (RETURN_ERROR (Return)) {
|
if (RETURN_ERROR (Return)) {
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool (Fcb->FileName);
|
FreePool (Fcb->FileName);
|
||||||
Fcb->FileName = AsciiFileName;
|
Fcb->FileName = AsciiFileName;
|
||||||
AsciiFileName = NULL;
|
AsciiFileName = NULL;
|
||||||
@ -1119,19 +1138,24 @@ FileSetInfo (
|
|||||||
if (Info->Size < (SIZE_OF_EFI_FILE_INFO + StrSize (Info->FileName))) {
|
if (Info->Size < (SIZE_OF_EFI_FILE_INFO + StrSize (Info->FileName))) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BufferSize < Info->Size) {
|
if (BufferSize < Info->Size) {
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
return EFI_BAD_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SetFileInfo (Fcb, Info);
|
return SetFileInfo (Fcb, Info);
|
||||||
} else if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
|
} else if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
|
||||||
SystemInfo = Buffer;
|
SystemInfo = Buffer;
|
||||||
if (SystemInfo->Size <
|
if (SystemInfo->Size <
|
||||||
(SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (SystemInfo->VolumeLabel))) {
|
(SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (SystemInfo->VolumeLabel)))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BufferSize < SystemInfo->Size) {
|
if (BufferSize < SystemInfo->Size) {
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
return EFI_BAD_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer = SystemInfo->VolumeLabel;
|
Buffer = SystemInfo->VolumeLabel;
|
||||||
|
|
||||||
if (StrSize (Buffer) > 0) {
|
if (StrSize (Buffer) > 0) {
|
||||||
@ -1166,7 +1190,8 @@ FileFlush (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
if ( (Fcb->Info.Attribute & EFI_FILE_READ_ONLY)
|
if ( (Fcb->Info.Attribute & EFI_FILE_READ_ONLY)
|
||||||
|| !(Fcb->OpenMode & EFI_FILE_MODE_WRITE)) {
|
|| !(Fcb->OpenMode & EFI_FILE_MODE_WRITE))
|
||||||
|
{
|
||||||
return EFI_ACCESS_DENIED;
|
return EFI_ACCESS_DENIED;
|
||||||
} else {
|
} else {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -1192,8 +1217,10 @@ SemihostFsEntryPoint (
|
|||||||
|
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&gInstallHandle,
|
&gInstallHandle,
|
||||||
&gEfiSimpleFileSystemProtocolGuid, &gSemihostFs,
|
&gEfiSimpleFileSystemProtocolGuid,
|
||||||
&gEfiDevicePathProtocolGuid, &gDevicePath,
|
&gSemihostFs,
|
||||||
|
&gEfiDevicePathProtocolGuid,
|
||||||
|
&gDevicePath,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -243,4 +243,3 @@ FileFlush (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif // SEMIHOST_FS_H_
|
#endif // SEMIHOST_FS_H_
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASM_MACRO_IO_LIB_H_
|
#ifndef ASM_MACRO_IO_LIB_H_
|
||||||
#define ASM_MACRO_IO_LIB_H_
|
#define ASM_MACRO_IO_LIB_H_
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASM_MACRO_IO_LIBV8_H_
|
#ifndef ASM_MACRO_IO_LIBV8_H_
|
||||||
#define ASM_MACRO_IO_LIBV8_H_
|
#define ASM_MACRO_IO_LIBV8_H_
|
||||||
|
|
||||||
@ -24,7 +23,6 @@
|
|||||||
cbnz SAFE_XREG, 1f ;\
|
cbnz SAFE_XREG, 1f ;\
|
||||||
b . ;// We should never get here
|
b . ;// We should never get here
|
||||||
|
|
||||||
|
|
||||||
// CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
|
// CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
|
||||||
// This only selects between EL1 and EL2 and EL3, else we die.
|
// This only selects between EL1 and EL2 and EL3, else we die.
|
||||||
// Provide the Macro with a safe temp xreg to use.
|
// Provide the Macro with a safe temp xreg to use.
|
||||||
|
@ -152,7 +152,6 @@
|
|||||||
#define TCR_EL1_TBI0_MASK (0x01UL << TCR_EL1_TBI0_FIELD)
|
#define TCR_EL1_TBI0_MASK (0x01UL << TCR_EL1_TBI0_FIELD)
|
||||||
#define TCR_EL1_TBI1_MASK (0x01UL << TCR_EL1_TBI1_FIELD)
|
#define TCR_EL1_TBI1_MASK (0x01UL << TCR_EL1_TBI1_FIELD)
|
||||||
|
|
||||||
|
|
||||||
#define TCR_EL23_T0SZ_FIELD (0)
|
#define TCR_EL23_T0SZ_FIELD (0)
|
||||||
#define TCR_EL23_IRGN0_FIELD (8)
|
#define TCR_EL23_IRGN0_FIELD (8)
|
||||||
#define TCR_EL23_ORGN0_FIELD (10)
|
#define TCR_EL23_ORGN0_FIELD (10)
|
||||||
@ -166,7 +165,6 @@
|
|||||||
#define TCR_EL23_TG0_MASK (0x01UL << TCR_EL23_TG0_FIELD)
|
#define TCR_EL23_TG0_MASK (0x01UL << TCR_EL23_TG0_FIELD)
|
||||||
#define TCR_EL23_PS_MASK (0x07UL << TCR_EL23_PS_FIELD)
|
#define TCR_EL23_PS_MASK (0x07UL << TCR_EL23_PS_FIELD)
|
||||||
|
|
||||||
|
|
||||||
#define TCR_RGN_OUTER_NON_CACHEABLE (0x0UL << 10)
|
#define TCR_RGN_OUTER_NON_CACHEABLE (0x0UL << 10)
|
||||||
#define TCR_RGN_OUTER_WRITE_BACK_ALLOC (0x1UL << 10)
|
#define TCR_RGN_OUTER_WRITE_BACK_ALLOC (0x1UL << 10)
|
||||||
#define TCR_RGN_OUTER_WRITE_THROUGH (0x2UL << 10)
|
#define TCR_RGN_OUTER_WRITE_THROUGH (0x2UL << 10)
|
||||||
@ -195,4 +193,3 @@
|
|||||||
// Uses LPAE Page Table format
|
// Uses LPAE Page Table format
|
||||||
|
|
||||||
#endif // AARCH64_MMU_H_
|
#endif // AARCH64_MMU_H_
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
#define A9_SCU_SACR_OFFSET 0x50
|
#define A9_SCU_SACR_OFFSET 0x50
|
||||||
#define A9_SCU_SSACR_OFFSET 0x54
|
#define A9_SCU_SSACR_OFFSET 0x54
|
||||||
|
|
||||||
|
|
||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGetScuBaseAddress (
|
ArmGetScuBaseAddress (
|
||||||
@ -56,4 +55,3 @@ ArmGetScuBaseAddress (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif // ARM_CORTEX_A9_H_
|
#endif // ARM_CORTEX_A9_H_
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#define CPSR_IRQ (1 << 7)
|
#define CPSR_IRQ (1 << 7)
|
||||||
#define CPSR_FIQ (1 << 6)
|
#define CPSR_FIQ (1 << 6)
|
||||||
|
|
||||||
|
|
||||||
// CPACR - Coprocessor Access Control Register definitions
|
// CPACR - Coprocessor Access Control Register definitions
|
||||||
#define CPACR_CP_DENIED(cp) 0x00
|
#define CPACR_CP_DENIED(cp) 0x00
|
||||||
#define CPACR_CP_PRIV(cp) ((0x1 << ((cp) << 1)) & 0x0FFFFFFF)
|
#define CPACR_CP_PRIV(cp) ((0x1 << ((cp) << 1)) & 0x0FFFFFFF)
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#define TTBR_MP_NON_CACHEABLE ( TTBR_RGN_OUTER_NON_CACHEABLE | TTBR_RGN_INNER_NON_CACHEABLE )
|
#define TTBR_MP_NON_CACHEABLE ( TTBR_RGN_OUTER_NON_CACHEABLE | TTBR_RGN_INNER_NON_CACHEABLE )
|
||||||
#define TTBR_MP_WRITE_BACK_ALLOC ( TTBR_RGN_OUTER_WRITE_BACK_ALLOC | TTBR_RGN_INNER_WRITE_BACK_ALLOC | TTBR_SHAREABLE)
|
#define TTBR_MP_WRITE_BACK_ALLOC ( TTBR_RGN_OUTER_WRITE_BACK_ALLOC | TTBR_RGN_INNER_WRITE_BACK_ALLOC | TTBR_SHAREABLE)
|
||||||
|
|
||||||
|
|
||||||
#define TRANSLATION_TABLE_SECTION_COUNT 4096
|
#define TRANSLATION_TABLE_SECTION_COUNT 4096
|
||||||
#define TRANSLATION_TABLE_SECTION_SIZE (sizeof(UINT32) * TRANSLATION_TABLE_SECTION_COUNT)
|
#define TRANSLATION_TABLE_SECTION_SIZE (sizeof(UINT32) * TRANSLATION_TABLE_SECTION_COUNT)
|
||||||
#define TRANSLATION_TABLE_SECTION_ALIGNMENT (sizeof(UINT32) * TRANSLATION_TABLE_SECTION_COUNT)
|
#define TRANSLATION_TABLE_SECTION_ALIGNMENT (sizeof(UINT32) * TRANSLATION_TABLE_SECTION_COUNT)
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
#define MPIDR_U_BIT_MASK 0x40000000
|
#define MPIDR_U_BIT_MASK 0x40000000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 ClusterId;
|
UINT64 Mpidr;
|
||||||
UINT32 CoreId;
|
|
||||||
|
|
||||||
// MP Core Mailbox
|
// MP Core Mailbox
|
||||||
EFI_PHYSICAL_ADDRESS MailboxSetAddress;
|
EFI_PHYSICAL_ADDRESS MailboxSetAddress;
|
||||||
@ -43,7 +42,6 @@ typedef struct {
|
|||||||
ARM_CORE_INFO *ArmCpus;
|
ARM_CORE_INFO *ArmCpus;
|
||||||
} ARM_PROCESSOR_TABLE;
|
} ARM_PROCESSOR_TABLE;
|
||||||
|
|
||||||
|
|
||||||
#define ARM_MP_CORE_INFO_GUID \
|
#define ARM_MP_CORE_INFO_GUID \
|
||||||
{ 0xa4ee0728, 0xe5d7, 0x4ac5, {0xb2, 0x1e, 0x65, 0x8e, 0xd8, 0x57, 0xe8, 0x34} }
|
{ 0xa4ee0728, 0xe5d7, 0x4ac5, {0xb2, 0x1e, 0x65, 0x8e, 0xd8, 0x57, 0xe8, 0x34} }
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@ typedef union {
|
|||||||
} CSSELR_DATA;
|
} CSSELR_DATA;
|
||||||
|
|
||||||
/// The cache type values for the InD field of the CSSELR register
|
/// The cache type values for the InD field of the CSSELR register
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
/// Select the data or unified cache
|
/// Select the data or unified cache
|
||||||
CsselrCacheTypeDataOrUnified = 0,
|
CsselrCacheTypeDataOrUnified = 0,
|
||||||
/// Select the instruction cache
|
/// Select the instruction cache
|
||||||
|
@ -17,7 +17,6 @@ typedef enum {
|
|||||||
ARM_GIC_ARCH_REVISION_3
|
ARM_GIC_ARCH_REVISION_3
|
||||||
} ARM_GIC_ARCH_REVISION;
|
} ARM_GIC_ARCH_REVISION;
|
||||||
|
|
||||||
|
|
||||||
ARM_GIC_ARCH_REVISION
|
ARM_GIC_ARCH_REVISION
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicGetSupportedArchRevision (
|
ArmGicGetSupportedArchRevision (
|
||||||
|
@ -52,7 +52,6 @@
|
|||||||
#define ARM_GIC_ICDICFR_LEVEL_TRIGGERED 0x0 // Level triggered interrupt
|
#define ARM_GIC_ICDICFR_LEVEL_TRIGGERED 0x0 // Level triggered interrupt
|
||||||
#define ARM_GIC_ICDICFR_EDGE_TRIGGERED 0x1 // Edge triggered interrupt
|
#define ARM_GIC_ICDICFR_EDGE_TRIGGERED 0x1 // Edge triggered interrupt
|
||||||
|
|
||||||
|
|
||||||
// GIC Redistributor
|
// GIC Redistributor
|
||||||
#define ARM_GICR_CTLR_FRAME_SIZE SIZE_64KB
|
#define ARM_GICR_CTLR_FRAME_SIZE SIZE_64KB
|
||||||
#define ARM_GICR_SGI_PPI_FRAME_SIZE SIZE_64KB
|
#define ARM_GICR_SGI_PPI_FRAME_SIZE SIZE_64KB
|
||||||
|
@ -59,8 +59,12 @@ typedef struct {
|
|||||||
ARM_MEMORY_REGION_ATTRIBUTES Attributes;
|
ARM_MEMORY_REGION_ATTRIBUTES Attributes;
|
||||||
} ARM_MEMORY_REGION_DESCRIPTOR;
|
} ARM_MEMORY_REGION_DESCRIPTOR;
|
||||||
|
|
||||||
typedef VOID (*CACHE_OPERATION)(VOID);
|
typedef VOID (*CACHE_OPERATION)(
|
||||||
typedef VOID (*LINE_OPERATION)(UINTN);
|
VOID
|
||||||
|
);
|
||||||
|
typedef VOID (*LINE_OPERATION)(
|
||||||
|
UINTN
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// ARM Processor Mode
|
// ARM Processor Mode
|
||||||
@ -107,6 +111,10 @@ typedef enum {
|
|||||||
#define GET_CORE_ID(MpId) ((MpId) & ARM_CORE_MASK)
|
#define GET_CORE_ID(MpId) ((MpId) & ARM_CORE_MASK)
|
||||||
#define GET_CLUSTER_ID(MpId) (((MpId) & ARM_CLUSTER_MASK) >> 8)
|
#define GET_CLUSTER_ID(MpId) (((MpId) & ARM_CLUSTER_MASK) >> 8)
|
||||||
#define GET_MPID(ClusterId, CoreId) (((ClusterId) << 8) | (CoreId))
|
#define GET_MPID(ClusterId, CoreId) (((ClusterId) << 8) | (CoreId))
|
||||||
|
#define GET_MPIDR_AFF0(MpId) ((MpId) & ARM_CORE_AFF0)
|
||||||
|
#define GET_MPIDR_AFF1(MpId) (((MpId) & ARM_CORE_AFF1) >> 8)
|
||||||
|
#define GET_MPIDR_AFF2(MpId) (((MpId) & ARM_CORE_AFF2) >> 16)
|
||||||
|
#define GET_MPIDR_AFF3(MpId) (((MpId) & ARM_CORE_AFF3) >> 32)
|
||||||
#define PRIMARY_CORE_ID (PcdGet32(PcdArmPrimaryCore) & ARM_CORE_MASK)
|
#define PRIMARY_CORE_ID (PcdGet32(PcdArmPrimaryCore) & ARM_CORE_MASK)
|
||||||
|
|
||||||
/** Reads the CCSIDR register for the specified cache.
|
/** Reads the CCSIDR register for the specified cache.
|
||||||
@ -183,7 +191,6 @@ ArmInvalidateDataCache (
|
|||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmCleanInvalidateDataCache (
|
ArmCleanInvalidateDataCache (
|
||||||
@ -573,7 +580,6 @@ ArmWriteHVBar (
|
|||||||
IN UINTN HypModeVectorBase
|
IN UINTN HypModeVectorBase
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Helper functions for accessing CPU ACTLR
|
// Helper functions for accessing CPU ACTLR
|
||||||
//
|
//
|
||||||
@ -736,7 +742,6 @@ ArmGetPhysicalAddressBits (
|
|||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// ID Register Helper functions
|
/// ID Register Helper functions
|
||||||
///
|
///
|
||||||
@ -768,6 +773,7 @@ ArmHasCcidx (
|
|||||||
///
|
///
|
||||||
/// AArch32-only ID Register Helper functions
|
/// AArch32-only ID Register Helper functions
|
||||||
///
|
///
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check whether the CPU supports the Security extensions
|
Check whether the CPU supports the Security extensions
|
||||||
|
|
||||||
@ -779,6 +785,7 @@ EFIAPI
|
|||||||
ArmHasSecurityExtensions (
|
ArmHasSecurityExtensions (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif // MDE_CPU_ARM
|
#endif // MDE_CPU_ARM
|
||||||
|
|
||||||
#endif // ARM_LIB_H_
|
#endif // ARM_LIB_H_
|
||||||
|
@ -128,4 +128,3 @@ MtlReceiveMessage (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif /* ARM_MTL_LIB_H_ */
|
#endif /* ARM_MTL_LIB_H_ */
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
|
* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
||||||
* Copyright (c) 2012-2014, ARM Limited. All rights reserved.
|
* Copyright (c) 2012-2014, ARM Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
@ -37,4 +38,76 @@ ArmCallSmc (
|
|||||||
IN OUT ARM_SMC_ARGS *Args
|
IN OUT ARM_SMC_ARGS *Args
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 3 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Argument/result.
|
||||||
|
@param Arg3 Argument/result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc3 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg3 OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 2 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Argument/result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc2 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 1 argument.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc1 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 0 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Result.
|
||||||
|
@param Arg2 Result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc0 (
|
||||||
|
IN UINTN Function,
|
||||||
|
OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
#endif // ARM_SMC_LIB_H_
|
#endif // ARM_SMC_LIB_H_
|
||||||
|
@ -8,15 +8,13 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#ifndef OEM_MISC_LIB_H_
|
#ifndef OEM_MISC_LIB_H_
|
||||||
#define OEM_MISC_LIB_H_
|
#define OEM_MISC_LIB_H_
|
||||||
|
|
||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
#include <IndustryStandard/SmBios.h>
|
#include <IndustryStandard/SmBios.h>
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
CpuCacheL1 = 1,
|
CpuCacheL1 = 1,
|
||||||
CpuCacheL2,
|
CpuCacheL2,
|
||||||
CpuCacheL3,
|
CpuCacheL3,
|
||||||
@ -27,8 +25,7 @@ typedef enum
|
|||||||
CpuCacheLevelMax
|
CpuCacheLevelMax
|
||||||
} OEM_MISC_CPU_CACHE_LEVEL;
|
} OEM_MISC_CPU_CACHE_LEVEL;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
UINT8 Voltage; ///< Processor voltage
|
UINT8 Voltage; ///< Processor voltage
|
||||||
UINT16 CurrentSpeed; ///< Current clock speed in MHz
|
UINT16 CurrentSpeed; ///< Current clock speed in MHz
|
||||||
UINT16 MaxSpeed; ///< Maximum clock speed in MHz
|
UINT16 MaxSpeed; ///< Maximum clock speed in MHz
|
||||||
@ -38,17 +35,19 @@ typedef struct
|
|||||||
UINT16 ThreadCount; ///< Number of threads per processor
|
UINT16 ThreadCount; ///< Number of threads per processor
|
||||||
} OEM_MISC_PROCESSOR_DATA;
|
} OEM_MISC_PROCESSOR_DATA;
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
ProductNameType01,
|
ProductNameType01,
|
||||||
SerialNumType01,
|
SerialNumType01,
|
||||||
UuidType01,
|
UuidType01,
|
||||||
SystemManufacturerType01,
|
SystemManufacturerType01,
|
||||||
|
VersionType01,
|
||||||
SkuNumberType01,
|
SkuNumberType01,
|
||||||
FamilyType01,
|
FamilyType01,
|
||||||
AssertTagType02,
|
AssertTagType02,
|
||||||
SerialNumberType02,
|
SerialNumberType02,
|
||||||
BoardManufacturerType02,
|
BoardManufacturerType02,
|
||||||
|
ProductNameType02,
|
||||||
|
VersionType02,
|
||||||
SkuNumberType02,
|
SkuNumberType02,
|
||||||
ChassisLocationType02,
|
ChassisLocationType02,
|
||||||
AssetTagType03,
|
AssetTagType03,
|
||||||
@ -57,6 +56,8 @@ typedef enum
|
|||||||
ChassisTypeType03,
|
ChassisTypeType03,
|
||||||
ManufacturerType03,
|
ManufacturerType03,
|
||||||
SkuNumberType03,
|
SkuNumberType03,
|
||||||
|
ProcessorPartNumType04,
|
||||||
|
ProcessorSerialNumType04,
|
||||||
SmbiosHiiStringFieldMax
|
SmbiosHiiStringFieldMax
|
||||||
} OEM_MISC_SMBIOS_HII_STRING_FIELD;
|
} OEM_MISC_SMBIOS_HII_STRING_FIELD;
|
||||||
|
|
||||||
|
@ -18,4 +18,3 @@
|
|||||||
#define SCMI_MAX_STR_LEN 16
|
#define SCMI_MAX_STR_LEN 16
|
||||||
|
|
||||||
#endif /* ARM_SCMI_H_ */
|
#endif /* ARM_SCMI_H_ */
|
||||||
|
|
||||||
|
@ -215,4 +215,3 @@ typedef struct _SCMI_CLOCK_PROTOCOL {
|
|||||||
} SCMI_CLOCK_PROTOCOL;
|
} SCMI_CLOCK_PROTOCOL;
|
||||||
|
|
||||||
#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */
|
#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */
|
||||||
|
|
||||||
|
@ -256,4 +256,3 @@ typedef enum {
|
|||||||
} SCMI_MESSAGE_ID_PERFORMANCE;
|
} SCMI_MESSAGE_ID_PERFORMANCE;
|
||||||
|
|
||||||
#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */
|
#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
#include <Library/ArmLib.h>
|
#include <Library/ArmLib.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
@ -25,7 +24,6 @@
|
|||||||
#define MULT_U64_X_N MultU64x64
|
#define MULT_U64_X_N MultU64x64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
TimerConstructor (
|
TimerConstructor (
|
||||||
@ -36,7 +34,6 @@ TimerConstructor (
|
|||||||
// Check if the ARM Generic Timer Extension is implemented.
|
// Check if the ARM Generic Timer Extension is implemented.
|
||||||
//
|
//
|
||||||
if (ArmIsArchTimerImplemented ()) {
|
if (ArmIsArchTimerImplemented ()) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if Architectural Timer frequency is pre-determined by the platform
|
// Check if Architectural Timer frequency is pre-determined by the platform
|
||||||
// (ie. nonzero).
|
// (ie. nonzero).
|
||||||
@ -59,6 +56,7 @@ TimerConstructor (
|
|||||||
if (ArmHasSecurityExtensions ()) {
|
if (ArmHasSecurityExtensions ()) {
|
||||||
ArmGenericTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
|
ArmGenericTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,9 +66,8 @@ TimerConstructor (
|
|||||||
// If the reset value (0) is returned, just ASSERT.
|
// If the reset value (0) is returned, just ASSERT.
|
||||||
//
|
//
|
||||||
ASSERT (ArmGenericTimerGetTimerFreq () != 0);
|
ASSERT (ArmGenericTimerGetTimerFreq () != 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((EFI_D_ERROR, "ARM Architectural Timer is not available in the CPU, hence this library cannot be used.\n"));
|
DEBUG ((DEBUG_ERROR, "ARM Architectural Timer is not available in the CPU, hence this library cannot be used.\n"));
|
||||||
ASSERT (0);
|
ASSERT (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,10 +93,10 @@ GetPlatformTimerFreq (
|
|||||||
if (TimerFreq == 0) {
|
if (TimerFreq == 0) {
|
||||||
TimerFreq = ArmGenericTimerGetTimerFreq ();
|
TimerFreq = ArmGenericTimerGetTimerFreq ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return TimerFreq;
|
return TimerFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Stalls the CPU for the number of microseconds specified by MicroSeconds.
|
Stalls the CPU for the number of microseconds specified by MicroSeconds.
|
||||||
|
|
||||||
@ -141,7 +138,6 @@ MicroSecondDelay (
|
|||||||
return MicroSeconds;
|
return MicroSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Stalls the CPU for at least the given number of nanoseconds.
|
Stalls the CPU for at least the given number of nanoseconds.
|
||||||
|
|
||||||
@ -219,7 +215,7 @@ GetPerformanceCounter (
|
|||||||
UINT64
|
UINT64
|
||||||
EFIAPI
|
EFIAPI
|
||||||
GetPerformanceCounterProperties (
|
GetPerformanceCounterProperties (
|
||||||
OUT UINT64 *StartValue, OPTIONAL
|
OUT UINT64 *StartValue OPTIONAL,
|
||||||
OUT UINT64 *EndValue OPTIONAL
|
OUT UINT64 *EndValue OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -267,7 +263,8 @@ GetTimeInNanoSecond (
|
|||||||
DivU64x32Remainder (
|
DivU64x32Remainder (
|
||||||
Ticks,
|
Ticks,
|
||||||
TimerFreq,
|
TimerFreq,
|
||||||
&Remainder),
|
&Remainder
|
||||||
|
),
|
||||||
1000000000U
|
1000000000U
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -278,7 +275,8 @@ GetTimeInNanoSecond (
|
|||||||
NanoSeconds += DivU64x32 (
|
NanoSeconds += DivU64x32 (
|
||||||
MULT_U64_X_N (
|
MULT_U64_X_N (
|
||||||
(UINT64)Remainder,
|
(UINT64)Remainder,
|
||||||
1000000000U),
|
1000000000U
|
||||||
|
),
|
||||||
TimerFreq
|
TimerFreq
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ CacheRangeOperation (
|
|||||||
LineOperation (AlignedAddress);
|
LineOperation (AlignedAddress);
|
||||||
AlignedAddress += LineLength;
|
AlignedAddress += LineLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArmDataSynchronizationBarrier ();
|
ArmDataSynchronizationBarrier ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,11 +63,18 @@ InvalidateInstructionCacheRange (
|
|||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CacheRangeOperation (Address, Length, ArmCleanDataCacheEntryToPoUByMVA,
|
CacheRangeOperation (
|
||||||
ArmDataCacheLineLength ());
|
Address,
|
||||||
CacheRangeOperation (Address, Length,
|
Length,
|
||||||
|
ArmCleanDataCacheEntryToPoUByMVA,
|
||||||
|
ArmDataCacheLineLength ()
|
||||||
|
);
|
||||||
|
CacheRangeOperation (
|
||||||
|
Address,
|
||||||
|
Length,
|
||||||
ArmInvalidateInstructionCacheEntryToPoUByMVA,
|
ArmInvalidateInstructionCacheEntryToPoUByMVA,
|
||||||
ArmInstructionCacheLineLength ());
|
ArmInstructionCacheLineLength ()
|
||||||
|
);
|
||||||
|
|
||||||
ArmInstructionSynchronizationBarrier ();
|
ArmInstructionSynchronizationBarrier ();
|
||||||
|
|
||||||
@ -89,8 +97,12 @@ WriteBackInvalidateDataCacheRange (
|
|||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CacheRangeOperation(Address, Length, ArmCleanInvalidateDataCacheEntryByMVA,
|
CacheRangeOperation (
|
||||||
ArmDataCacheLineLength ());
|
Address,
|
||||||
|
Length,
|
||||||
|
ArmCleanInvalidateDataCacheEntryByMVA,
|
||||||
|
ArmDataCacheLineLength ()
|
||||||
|
);
|
||||||
return Address;
|
return Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +122,12 @@ WriteBackDataCacheRange (
|
|||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CacheRangeOperation(Address, Length, ArmCleanDataCacheEntryByMVA,
|
CacheRangeOperation (
|
||||||
ArmDataCacheLineLength ());
|
Address,
|
||||||
|
Length,
|
||||||
|
ArmCleanDataCacheEntryByMVA,
|
||||||
|
ArmDataCacheLineLength ()
|
||||||
|
);
|
||||||
return Address;
|
return Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +138,11 @@ InvalidateDataCacheRange (
|
|||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CacheRangeOperation(Address, Length, ArmInvalidateDataCacheEntryByMVA,
|
CacheRangeOperation (
|
||||||
ArmDataCacheLineLength ());
|
Address,
|
||||||
|
Length,
|
||||||
|
ArmInvalidateDataCacheEntryByMVA,
|
||||||
|
ArmDataCacheLineLength ()
|
||||||
|
);
|
||||||
return Address;
|
return Address;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,6 @@ CHAR8 *gLdmStack[] = {
|
|||||||
|
|
||||||
#define LDM_EXT(_reg, _off) ((_reg == 13) ? gLdmStack[(_off)] : gLdmAdr[(_off)])
|
#define LDM_EXT(_reg, _off) ((_reg == 13) ? gLdmStack[(_off)] : gLdmAdr[(_off)])
|
||||||
|
|
||||||
|
|
||||||
#define SIGN(_U) ((_U) ? "" : "-")
|
#define SIGN(_U) ((_U) ? "" : "-")
|
||||||
#define WRITE(_Write) ((_Write) ? "!" : "")
|
#define WRITE(_Write) ((_Write) ? "!" : "")
|
||||||
#define BYTE(_B) ((_B) ? "B":"")
|
#define BYTE(_B) ((_B) ? "B":"")
|
||||||
@ -110,9 +109,11 @@ MRegList (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (First) {
|
if (First) {
|
||||||
AsciiStrCatS (mMregListStr, sizeof mMregListStr, "ERROR");
|
AsciiStrCatS (mMregListStr, sizeof mMregListStr, "ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiStrCatS (mMregListStr, sizeof mMregListStr, "}");
|
AsciiStrCatS (mMregListStr, sizeof mMregListStr, "}");
|
||||||
|
|
||||||
// BugBug: Make caller pass in buffer it is cleaner
|
// BugBug: Make caller pass in buffer it is cleaner
|
||||||
@ -136,7 +137,6 @@ RotateRight (
|
|||||||
return (Op >> Shift) | (Op << (32 - Shift));
|
return (Op >> Shift) | (Op << (32 - Shift));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Place a disassembly of **OpCodePtr into buffer, and update OpCodePtr to
|
Place a disassembly of **OpCodePtr into buffer, and update OpCodePtr to
|
||||||
point to next instruction.
|
point to next instruction.
|
||||||
@ -181,7 +181,6 @@ DisassembleArmInstruction (
|
|||||||
Rd = (OpCode >> 12) & 0xf;
|
Rd = (OpCode >> 12) & 0xf;
|
||||||
Rm = (OpCode & 0xf);
|
Rm = (OpCode & 0xf);
|
||||||
|
|
||||||
|
|
||||||
if (Extended) {
|
if (Extended) {
|
||||||
Index = AsciiSPrint (Buf, Size, "0x%08x ", OpCode);
|
Index = AsciiSPrint (Buf, Size, "0x%08x ", OpCode);
|
||||||
Buf += Index;
|
Buf += Index;
|
||||||
@ -197,6 +196,7 @@ DisassembleArmInstruction (
|
|||||||
// A4.1.103 STREX{<cond>} <Rd>, <Rm>, [<Rn>]
|
// A4.1.103 STREX{<cond>} <Rd>, <Rm>, [<Rn>]
|
||||||
AsciiSPrint (Buf, Size, "STREX%a %a, %a, [%a]", COND (OpCode), gReg[Rd], gReg[Rn], gReg[Rn]);
|
AsciiSPrint (Buf, Size, "STREX%a %a, %a, [%a]", COND (OpCode), gReg[Rd], gReg[Rn], gReg[Rn]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +212,7 @@ DisassembleArmInstruction (
|
|||||||
// A4.1.98 STM{<cond>}<addressing_mode> <Rn>, <registers>^
|
// A4.1.98 STM{<cond>}<addressing_mode> <Rn>, <registers>^
|
||||||
AsciiSPrint (Buf, Size, "STM%a%a, %a%a, %a", COND (OpCode), LDM_EXT (Rn, (OpCode >> 23) & 3), gReg[Rn], WRITE (Write), MRegList (OpCode), USER (WriteBack));
|
AsciiSPrint (Buf, Size, "STM%a%a, %a%a, %a", COND (OpCode), LDM_EXT (Rn, (OpCode >> 23) & 3), gReg[Rn], WRITE (Write), MRegList (OpCode), USER (WriteBack));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,6 +224,7 @@ DisassembleArmInstruction (
|
|||||||
} else {
|
} else {
|
||||||
Index = AsciiSPrint (Buf, Size, "%a%a%a%a %a, ", Load ? "LDR" : "STR", COND (OpCode), BYTE (WriteBack), (!(Pre) && Write) ? "T" : "", gReg[Rd]);
|
Index = AsciiSPrint (Buf, Size, "%a%a%a%a %a, ", Load ? "LDR" : "STR", COND (OpCode), BYTE (WriteBack), (!(Pre) && Write) ? "T" : "", gReg[Rd]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pre) {
|
if (Pre) {
|
||||||
if (!Imm) {
|
if (!Imm) {
|
||||||
// A5.2.2 [<Rn>, #+/-<offset_12>]
|
// A5.2.2 [<Rn>, #+/-<offset_12>]
|
||||||
@ -255,7 +257,8 @@ DisassembleArmInstruction (
|
|||||||
|
|
||||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a%a, %a, #%d]%a", gReg[Rn], SIGN (Up), gReg[Rm], Type, ShiftImm, WRITE (Write));
|
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a%a, %a, #%d]%a", gReg[Rn], SIGN (Up), gReg[Rm], Type, ShiftImm, WRITE (Write));
|
||||||
}
|
}
|
||||||
} else { // !Pre
|
} else {
|
||||||
|
// !Pre
|
||||||
if (!Imm) {
|
if (!Imm) {
|
||||||
// A5.2.8 [<Rn>], #+/-<offset_12>
|
// A5.2.8 [<Rn>], #+/-<offset_12>
|
||||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a0x%x", gReg[Rn], SIGN (Up), Offset12);
|
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a0x%x", gReg[Rn], SIGN (Up), Offset12);
|
||||||
@ -287,6 +290,7 @@ DisassembleArmInstruction (
|
|||||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%a, %a, #%d", gReg[Rn], SIGN (Up), gReg[Rm], Type, ShiftImm);
|
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%a, %a, #%d", gReg[Rn], SIGN (Up), gReg[Rm], Type, ShiftImm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,6 +341,7 @@ DisassembleArmInstruction (
|
|||||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%a", gReg[Rn], SIGN (Up), gReg[Rm]);
|
AsciiSPrint (&Buf[Index], Size - Index, "[%a], #%a%a", gReg[Rn], SIGN (Up), gReg[Rm]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,15 +376,20 @@ DisassembleArmInstruction (
|
|||||||
AsciiSPrint (Buf, Size, "CPS #0x%x", (OpCode & 0x2f));
|
AsciiSPrint (Buf, Size, "CPS #0x%x", (OpCode & 0x2f));
|
||||||
} else {
|
} else {
|
||||||
IMod = (OpCode >> 18) & 0x3;
|
IMod = (OpCode >> 18) & 0x3;
|
||||||
Index = AsciiSPrint (Buf, Size, "CPS%a %a%a%a",
|
Index = AsciiSPrint (
|
||||||
|
Buf,
|
||||||
|
Size,
|
||||||
|
"CPS%a %a%a%a",
|
||||||
(IMod == 3) ? "ID" : "IE",
|
(IMod == 3) ? "ID" : "IE",
|
||||||
((OpCode & BIT8) != 0) ? "A" : "",
|
((OpCode & BIT8) != 0) ? "A" : "",
|
||||||
((OpCode & BIT7) != 0) ? "I" : "",
|
((OpCode & BIT7) != 0) ? "I" : "",
|
||||||
((OpCode & BIT6) != 0) ? "F":"");
|
((OpCode & BIT6) != 0) ? "F" : ""
|
||||||
|
);
|
||||||
if ((OpCode & BIT17) != 0) {
|
if ((OpCode & BIT17) != 0) {
|
||||||
AsciiSPrint (&Buf[Index], Size - Index, ", #0x%x", OpCode & 0x1f);
|
AsciiSPrint (&Buf[Index], Size - Index, ", #0x%x", OpCode & 0x1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +405,6 @@ DisassembleArmInstruction (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((OpCode & 0x0db00000) == 0x01200000) {
|
if ((OpCode & 0x0db00000) == 0x01200000) {
|
||||||
// A4.1.38 MSR{<cond>} CPSR_<fields>, #<immediate> MSR{<cond>} CPSR_<fields>, <Rm>
|
// A4.1.38 MSR{<cond>} CPSR_<fields>, #<immediate> MSR{<cond>} CPSR_<fields>, <Rm>
|
||||||
if (Imm) {
|
if (Imm) {
|
||||||
@ -405,6 +414,7 @@ DisassembleArmInstruction (
|
|||||||
// MSR{<cond>} CPSR_<fields>, <Rm>
|
// MSR{<cond>} CPSR_<fields>, <Rm>
|
||||||
AsciiSPrint (Buf, Size, "MRS%a %a_%a, %a", COND (OpCode), WriteBack ? "SPSR" : "CPSR", gReg[Rd]);
|
AsciiSPrint (Buf, Size, "MRS%a %a_%a, %a", COND (OpCode), WriteBack ? "SPSR" : "CPSR", gReg[Rd]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +444,6 @@ DisassembleArmInstruction (
|
|||||||
// A5.5.5.2 [<Rn>, #+/-<offset_8>*4 ]!
|
// A5.5.5.2 [<Rn>, #+/-<offset_8>*4 ]!
|
||||||
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a0x%x*4]%a", gReg[Rn], SIGN (Up), OpCode & 0xff, WRITE (Write));
|
AsciiSPrint (&Buf[Index], Size - Index, "[%a, #%a0x%x*4]%a", gReg[Rn], SIGN (Up), OpCode & 0xff, WRITE (Write));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((OpCode & 0x0f000010) == 0x0e000010) {
|
if ((OpCode & 0x0f000010) == 0x0e000010) {
|
||||||
@ -454,4 +463,3 @@ DisassembleArmInstruction (
|
|||||||
*OpCodePtr += 1;
|
*OpCodePtr += 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +93,6 @@ extern CHAR8 *gReg[];
|
|||||||
#define THUMB2_MRS 235
|
#define THUMB2_MRS 235
|
||||||
#define THUMB2_MSR 236
|
#define THUMB2_MSR 236
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CHAR8 *Start;
|
CHAR8 *Start;
|
||||||
UINT32 OpCode;
|
UINT32 OpCode;
|
||||||
@ -202,7 +199,6 @@ THUMB_INSTRUCTIONS gOpThumb[] = {
|
|||||||
{ "UXTH", 0xb280, 0xffc0, DATA_FORMAT5 },
|
{ "UXTH", 0xb280, 0xffc0, DATA_FORMAT5 },
|
||||||
|
|
||||||
{ "IT", 0xbf00, 0xff00, IT_BLOCK }
|
{ "IT", 0xbf00, 0xff00, IT_BLOCK }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
THUMB_INSTRUCTIONS gOpThumb2[] = {
|
THUMB_INSTRUCTIONS gOpThumb2[] = {
|
||||||
@ -281,7 +277,6 @@ THUMB_INSTRUCTIONS gOpThumb2[] = {
|
|||||||
{ "MLA", 0xfb000000, 0xfff000f0, THUMB2_4REGS }, // MLA <Rd>, <Rn>, <Rm>, <Ra>
|
{ "MLA", 0xfb000000, 0xfff000f0, THUMB2_4REGS }, // MLA <Rd>, <Rn>, <Rm>, <Ra>
|
||||||
{ "MLS", 0xfb000010, 0xfff000f0, THUMB2_4REGS }, // MLA <Rd>, <Rn>, <Rm>, <Ra>
|
{ "MLS", 0xfb000010, 0xfff000f0, THUMB2_4REGS }, // MLA <Rd>, <Rn>, <Rm>, <Ra>
|
||||||
|
|
||||||
|
|
||||||
{ "SMLABB", 0xfb100000, 0xfff000f0, THUMB2_4REGS }, // SMLABB <Rd>, <Rn>, <Rm>, <Ra>
|
{ "SMLABB", 0xfb100000, 0xfff000f0, THUMB2_4REGS }, // SMLABB <Rd>, <Rn>, <Rm>, <Ra>
|
||||||
{ "SMLABT", 0xfb100010, 0xfff000f0, THUMB2_4REGS }, // SMLABT <Rd>, <Rn>, <Rm>, <Ra>
|
{ "SMLABT", 0xfb100010, 0xfff000f0, THUMB2_4REGS }, // SMLABT <Rd>, <Rn>, <Rm>, <Ra>
|
||||||
{ "SMLABB", 0xfb100020, 0xfff000f0, THUMB2_4REGS }, // SMLATB <Rd>, <Rn>, <Rm>, <Ra>
|
{ "SMLABB", 0xfb100020, 0xfff000f0, THUMB2_4REGS }, // SMLATB <Rd>, <Rn>, <Rm>, <Ra>
|
||||||
@ -298,7 +293,6 @@ THUMB_INSTRUCTIONS gOpThumb2[] = {
|
|||||||
{ "SMLAD", 0xfb200000, 0xfff000f0, THUMB2_4REGS }, // SMLAD <Rd>, <Rn>, <Rm>, <Ra>
|
{ "SMLAD", 0xfb200000, 0xfff000f0, THUMB2_4REGS }, // SMLAD <Rd>, <Rn>, <Rm>, <Ra>
|
||||||
{ "SMLADX", 0xfb200010, 0xfff000f0, THUMB2_4REGS }, // SMLADX <Rd>, <Rn>, <Rm>, <Ra>
|
{ "SMLADX", 0xfb200010, 0xfff000f0, THUMB2_4REGS }, // SMLADX <Rd>, <Rn>, <Rm>, <Ra>
|
||||||
|
|
||||||
|
|
||||||
{ "B", 0xf0008000, 0xf800d000, B_T3 }, // B<c> <label>
|
{ "B", 0xf0008000, 0xf800d000, B_T3 }, // B<c> <label>
|
||||||
{ "B", 0xf0009000, 0xf800d000, B_T4 }, // B<c> <label>
|
{ "B", 0xf0009000, 0xf800d000, B_T4 }, // B<c> <label>
|
||||||
{ "BL", 0xf000d000, 0xf800d000, B_T4 }, // BL<c> <label>
|
{ "BL", 0xf000d000, 0xf800d000, B_T4 }, // BL<c> <label>
|
||||||
@ -419,9 +413,11 @@ ThumbMRegList (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (First) {
|
if (First) {
|
||||||
AsciiStrCatS (mThumbMregListStr, sizeof mThumbMregListStr, "ERROR");
|
AsciiStrCatS (mThumbMregListStr, sizeof mThumbMregListStr, "ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiStrCatS (mThumbMregListStr, sizeof mThumbMregListStr, "}");
|
AsciiStrCatS (mThumbMregListStr, sizeof mThumbMregListStr, "}");
|
||||||
|
|
||||||
// BugBug: Make caller pass in buffer it is cleaner
|
// BugBug: Make caller pass in buffer it is cleaner
|
||||||
@ -521,6 +517,7 @@ DisassembleThumbInstruction (
|
|||||||
*OpCodePtrPtr += 1;
|
*OpCodePtrPtr += 1;
|
||||||
|
|
||||||
// Manage IT Block ItFlag TRUE means we are in an IT block
|
// Manage IT Block ItFlag TRUE means we are in an IT block
|
||||||
|
|
||||||
/*if (*ItBlock != 0) {
|
/*if (*ItBlock != 0) {
|
||||||
ItFlag = TRUE;
|
ItFlag = TRUE;
|
||||||
*ItBlock -= 1;
|
*ItBlock -= 1;
|
||||||
@ -535,6 +532,7 @@ DisassembleThumbInstruction (
|
|||||||
} else {
|
} else {
|
||||||
Offset = AsciiSPrint (Buf, Size, "%-6a", gOpThumb[Index].Start);
|
Offset = AsciiSPrint (Buf, Size, "%-6a", gOpThumb[Index].Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (gOpThumb[Index].AddressMode) {
|
switch (gOpThumb[Index].AddressMode) {
|
||||||
case LOAD_STORE_FORMAT1:
|
case LOAD_STORE_FORMAT1:
|
||||||
// A6.5.1 <Rd>, [<Rn>, #<5_bit_offset>]
|
// A6.5.1 <Rd>, [<Rn>, #<5_bit_offset>]
|
||||||
@ -579,7 +577,6 @@ DisassembleThumbInstruction (
|
|||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a", ThumbMRegList ((OpCode & 0xff) | ((OpCode & BIT8) == BIT8 ? BIT14 : 0)));
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a", ThumbMRegList ((OpCode & 0xff) | ((OpCode & BIT8) == BIT8 ? BIT14 : 0)));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
case IMMED_8:
|
case IMMED_8:
|
||||||
// A6.7 <immed_8>
|
// A6.7 <immed_8>
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " 0x%x", OpCode & 0xff);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " 0x%x", OpCode & 0xff);
|
||||||
@ -684,13 +681,13 @@ DisassembleThumbInstruction (
|
|||||||
} else if ((OpCode & 0xf) == 0x8) {
|
} else if ((OpCode & 0xf) == 0x8) {
|
||||||
*ItBlock = 1;
|
*ItBlock = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a", gCondition[(OpCode >> 4) & 0xf]);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a", gCondition[(OpCode >> 4) & 0xf]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Thumb2 are 32-bit instructions
|
// Thumb2 are 32-bit instructions
|
||||||
*OpCodePtrPtr += 1;
|
*OpCodePtrPtr += 1;
|
||||||
Rt = (OpCode32 >> 12) & 0xf;
|
Rt = (OpCode32 >> 12) & 0xf;
|
||||||
@ -705,6 +702,7 @@ DisassembleThumbInstruction (
|
|||||||
} else {
|
} else {
|
||||||
Offset = AsciiSPrint (Buf, Size, " %-6a", gOpThumb2[Index].Start);
|
Offset = AsciiSPrint (Buf, Size, " %-6a", gOpThumb2[Index].Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (gOpThumb2[Index].AddressMode) {
|
switch (gOpThumb2[Index].AddressMode) {
|
||||||
case B_T3:
|
case B_T3:
|
||||||
Cond = gCondition[(OpCode32 >> 22) & 0xf];
|
Cond = gCondition[(OpCode32 >> 22) & 0xf];
|
||||||
@ -767,6 +765,7 @@ DisassembleThumbInstruction (
|
|||||||
// U == 0 means subtrack, U == 1 means add
|
// U == 0 means subtrack, U == 1 means add
|
||||||
Target = -Target;
|
Target = -Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a", gReg[(OpCode32 >> 12) & 0xf], PcAlign4 (Pc) + Target);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a", gReg[(OpCode32 >> 12) & 0xf], PcAlign4 (Pc) + Target);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -778,6 +777,7 @@ DisassembleThumbInstruction (
|
|||||||
} else {
|
} else {
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, ", LSL #%d]", (OpCode32 >> 4) & 3);
|
AsciiSPrint (&Buf[Offset], Size - Offset, ", LSL #%d]", (OpCode32 >> 4) & 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case LDM_REG_IMM12:
|
case LDM_REG_IMM12:
|
||||||
@ -788,6 +788,7 @@ DisassembleThumbInstruction (
|
|||||||
} else {
|
} else {
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, ", #0x%x]", OpCode32 & 0xfff);
|
AsciiSPrint (&Buf[Offset], Size - Offset, ", #0x%x]", OpCode32 & 0xfff);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case LDM_REG_IMM8:
|
case LDM_REG_IMM8:
|
||||||
@ -805,6 +806,7 @@ DisassembleThumbInstruction (
|
|||||||
} else {
|
} else {
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, "], #%a0x%x", UAdd ? "" : "-", OpCode32 & 0xff);
|
AsciiSPrint (&Buf[Offset], Size - Offset, "], #%a0x%x", UAdd ? "" : "-", OpCode32 & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case LDRD_REG_IMM8_SIGNED:
|
case LDRD_REG_IMM8_SIGNED:
|
||||||
@ -824,6 +826,7 @@ DisassembleThumbInstruction (
|
|||||||
AsciiSPrint (&Buf[Offset], Size - Offset, ", #%a0x%x", UAdd ? "" : "-", (OpCode32 & 0xff) << 2);
|
AsciiSPrint (&Buf[Offset], Size - Offset, ", #%a0x%x", UAdd ? "" : "-", (OpCode32 & 0xff) << 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case LDRD_REG_IMM8:
|
case LDRD_REG_IMM8:
|
||||||
@ -833,6 +836,7 @@ DisassembleThumbInstruction (
|
|||||||
// U == 0 means subtrack, U == 1 means add
|
// U == 0 means subtrack, U == 1 means add
|
||||||
Target = -Target;
|
Target = -Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a, %a", gReg[Rt], gReg[Rt2], Pc + 4 + Target);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a, %a", gReg[Rt], gReg[Rt2], Pc + 4 + Target);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -863,6 +867,7 @@ DisassembleThumbInstruction (
|
|||||||
if ((OpCode32 & BIT20) == BIT20) {
|
if ((OpCode32 & BIT20) == BIT20) {
|
||||||
Buf[Offset - 3] = 'S'; // assume %-6a
|
Buf[Offset - 3] = 'S'; // assume %-6a
|
||||||
}
|
}
|
||||||
|
|
||||||
Target = (OpCode32 & 0xff) | ((OpCode32 >> 4) & 0x700) | ((OpCode & BIT26) == BIT26 ? BIT11 : 0);
|
Target = (OpCode32 & 0xff) | ((OpCode32 >> 4) & 0x700) | ((OpCode & BIT26) == BIT26 ? BIT11 : 0);
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a, #0x%x", gReg[Rd], gReg[Rn], Target);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a, #0x%x", gReg[Rd], gReg[Rn], Target);
|
||||||
return;
|
return;
|
||||||
@ -872,6 +877,7 @@ DisassembleThumbInstruction (
|
|||||||
if ((OpCode32 & BIT20) == BIT20) {
|
if ((OpCode32 & BIT20) == BIT20) {
|
||||||
Buf[Offset - 3] = 'S'; // assume %-6a
|
Buf[Offset - 3] = 'S'; // assume %-6a
|
||||||
}
|
}
|
||||||
|
|
||||||
Target = (OpCode32 & 0xff) | ((OpCode32 >> 4) & 0x700) | ((OpCode & BIT26) == BIT26 ? BIT11 : 0);
|
Target = (OpCode32 & 0xff) | ((OpCode32 >> 4) & 0x700) | ((OpCode & BIT26) == BIT26 ? BIT11 : 0);
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, #0x%x", gReg[Rd], Target);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, #0x%x", gReg[Rd], Target);
|
||||||
return;
|
return;
|
||||||
@ -888,11 +894,13 @@ DisassembleThumbInstruction (
|
|||||||
if ((OpCode32 & BIT20) == BIT20) {
|
if ((OpCode32 & BIT20) == BIT20) {
|
||||||
Buf[Offset - 3] = 'S'; // assume %-6a
|
Buf[Offset - 3] = 'S'; // assume %-6a
|
||||||
}
|
}
|
||||||
|
|
||||||
Target = ((OpCode32 >> 6) & 3) | ((OpCode32 >> 10) & 0x1c0);
|
Target = ((OpCode32 >> 6) & 3) | ((OpCode32 >> 10) & 0x1c0);
|
||||||
Offset += AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a, %a", gReg[Rd], gReg[Rn], gReg[Rm]);
|
Offset += AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a, %a", gReg[Rd], gReg[Rn], gReg[Rm]);
|
||||||
if (Target != 0) {
|
if (Target != 0) {
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, ", LSL %d", gShiftType[(OpCode >> 5) & 3], Target);
|
AsciiSPrint (&Buf[Offset], Size - Offset, ", LSL %d", gShiftType[(OpCode >> 5) & 3], Target);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ADD_IMM5_2REG:
|
case ADD_IMM5_2REG:
|
||||||
@ -903,12 +911,12 @@ DisassembleThumbInstruction (
|
|||||||
AsciiSPrint (&Buf[Offset], Size - Offset, ", LSL %d", gShiftType[(OpCode >> 5) & 3], Target);
|
AsciiSPrint (&Buf[Offset], Size - Offset, ", LSL %d", gShiftType[(OpCode >> 5) & 3], Target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case ASR_IMM5:
|
case ASR_IMM5:
|
||||||
// ARS <Rd>, <Rm> #<const>} imm3:imm2
|
// ARS <Rd>, <Rm> #<const>} imm3:imm2
|
||||||
if ((OpCode32 & BIT20) == BIT20) {
|
if ((OpCode32 & BIT20) == BIT20) {
|
||||||
Buf[Offset - 3] = 'S'; // assume %-6a
|
Buf[Offset - 3] = 'S'; // assume %-6a
|
||||||
}
|
}
|
||||||
|
|
||||||
Target = ((OpCode32 >> 6) & 3) | ((OpCode32 >> 10) & 0x1c0);
|
Target = ((OpCode32 >> 6) & 3) | ((OpCode32 >> 10) & 0x1c0);
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a #%d", gReg[Rd], gReg[Rm], Target);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a #%d", gReg[Rd], gReg[Rm], Target);
|
||||||
return;
|
return;
|
||||||
@ -918,6 +926,7 @@ DisassembleThumbInstruction (
|
|||||||
if ((OpCode32 & BIT20) == BIT20) {
|
if ((OpCode32 & BIT20) == BIT20) {
|
||||||
Buf[Offset - 3] = 'S'; // assume %-6a
|
Buf[Offset - 3] = 'S'; // assume %-6a
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a %a", gReg[Rd], gReg[Rn], gReg[Rm]);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a %a", gReg[Rd], gReg[Rn], gReg[Rm]);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -929,6 +938,7 @@ DisassembleThumbInstruction (
|
|||||||
} else {
|
} else {
|
||||||
Target = PcAlign4 (Pc) + Target;
|
Target = PcAlign4 (Pc) + Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, 0x%08x", gReg[Rd], Target);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, 0x%08x", gReg[Rd], Target);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -950,6 +960,7 @@ DisassembleThumbInstruction (
|
|||||||
} else {
|
} else {
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a, #%d, #%d", gReg[Rd], gReg[Rn], LsBit, MsBit + 1);
|
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %a, #%d, #%d", gReg[Rd], gReg[Rn], LsBit, MsBit + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case CPD_THUMB2:
|
case CPD_THUMB2:
|
||||||
@ -964,6 +975,7 @@ DisassembleThumbInstruction (
|
|||||||
if (Opc2 != 0) {
|
if (Opc2 != 0) {
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, ",#%d,", Opc2);
|
AsciiSPrint (&Buf[Offset], Size - Offset, ",#%d,", Opc2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MRC_THUMB2:
|
case MRC_THUMB2:
|
||||||
@ -977,6 +989,7 @@ DisassembleThumbInstruction (
|
|||||||
if (Opc2 != 0) {
|
if (Opc2 != 0) {
|
||||||
AsciiSPrint (&Buf[Offset], Size - Offset, ",#%d,", Opc2);
|
AsciiSPrint (&Buf[Offset], Size - Offset, ",#%d,", Opc2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MRRC_THUMB2:
|
case MRRC_THUMB2:
|
||||||
@ -1019,8 +1032,6 @@ DisassembleThumbInstruction (
|
|||||||
AsciiSPrint (Buf, Size, "0x%08x", OpCode32);
|
AsciiSPrint (Buf, Size, "0x%08x", OpCode32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
DisassembleArmInstruction (
|
DisassembleArmInstruction (
|
||||||
IN UINT32 **OpCodePtr,
|
IN UINT32 **OpCodePtr,
|
||||||
@ -1029,7 +1040,6 @@ DisassembleArmInstruction (
|
|||||||
IN BOOLEAN Extended
|
IN BOOLEAN Extended
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Place a disassembly of **OpCodePtr into buffer, and update OpCodePtr to
|
Place a disassembly of **OpCodePtr into buffer, and update OpCodePtr to
|
||||||
point to next instruction.
|
point to next instruction.
|
||||||
@ -1061,4 +1071,3 @@ DisassembleInstruction (
|
|||||||
DisassembleArmInstruction ((UINT32 **)OpCodePtr, Buf, Size, Extended);
|
DisassembleArmInstruction ((UINT32 **)OpCodePtr, Buf, Size, Extended);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,8 +35,7 @@ ArchVectorConfig (
|
|||||||
if (VectorBaseAddress == 0xFFFF0000) {
|
if (VectorBaseAddress == 0xFFFF0000) {
|
||||||
// set SCTLR.V to enable high vectors
|
// set SCTLR.V to enable high vectors
|
||||||
ArmSetHighVectors ();
|
ArmSetHighVectors ();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Set SCTLR.V to 0 to enable VBAR to be used
|
// Set SCTLR.V to 0 to enable VBAR to be used
|
||||||
ArmSetLowVectors ();
|
ArmSetLowVectors ();
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,8 @@ ExceptionHandlersEnd(
|
|||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
RETURN_STATUS ArchVectorConfig(
|
RETURN_STATUS
|
||||||
|
ArchVectorConfig (
|
||||||
IN UINTN VectorBaseAddress
|
IN UINTN VectorBaseAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -66,7 +67,6 @@ STATIC CONST BOOLEAN gArmRelocateVectorTable = TRUE;
|
|||||||
STATIC CONST BOOLEAN gArmRelocateVectorTable = FALSE;
|
STATIC CONST BOOLEAN gArmRelocateVectorTable = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes all CPU exceptions entries and provides the default exception handlers.
|
Initializes all CPU exceptions entries and provides the default exception handlers.
|
||||||
|
|
||||||
@ -96,12 +96,10 @@ InitializeCpuExceptionHandlers(
|
|||||||
|
|
||||||
// if we are requested to copy exception handlers to another location
|
// if we are requested to copy exception handlers to another location
|
||||||
if (gArmRelocateVectorTable) {
|
if (gArmRelocateVectorTable) {
|
||||||
|
|
||||||
VectorBase = PcdGet64 (PcdCpuVectorBaseAddress);
|
VectorBase = PcdGet64 (PcdCpuVectorBaseAddress);
|
||||||
Status = CopyExceptionHandlers (VectorBase);
|
Status = CopyExceptionHandlers (VectorBase);
|
||||||
|
} else {
|
||||||
}
|
// use VBAR to point to where our exception handlers are
|
||||||
else { // use VBAR to point to where our exception handlers are
|
|
||||||
|
|
||||||
// The vector table must be aligned for the architecture. If this
|
// The vector table must be aligned for the architecture. If this
|
||||||
// assertion fails ensure the appropriate FFS alignment is in effect,
|
// assertion fails ensure the appropriate FFS alignment is in effect,
|
||||||
@ -180,12 +178,11 @@ CopyExceptionHandlers(
|
|||||||
//
|
//
|
||||||
for (Index = 0; Index <= gMaxExceptionNumber; Index++) {
|
for (Index = 0; Index <= gMaxExceptionNumber; Index++) {
|
||||||
if (!FeaturePcdGet (PcdDebuggerExceptionSupport) ||
|
if (!FeaturePcdGet (PcdDebuggerExceptionSupport) ||
|
||||||
(gDebuggerExceptionHandlers[Index] == 0) || (gDebuggerExceptionHandlers[Index] == (VOID *)gDebuggerNoHandlerValue)) {
|
(gDebuggerExceptionHandlers[Index] == 0) || (gDebuggerExceptionHandlers[Index] == (VOID *)gDebuggerNoHandlerValue))
|
||||||
|
{
|
||||||
Status = RegisterExceptionHandler (Index, NULL);
|
Status = RegisterExceptionHandler (Index, NULL);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// If the debugger has already hooked put its vector back
|
// If the debugger has already hooked put its vector back
|
||||||
VectorBase[Index] = (UINT32)(UINTN)gDebuggerExceptionHandlers[Index];
|
VectorBase[Index] = (UINT32)(UINTN)gDebuggerExceptionHandlers[Index];
|
||||||
}
|
}
|
||||||
@ -197,7 +194,6 @@ CopyExceptionHandlers(
|
|||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
|
Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
|
||||||
|
|
||||||
@ -307,9 +303,8 @@ CommonCExceptionHandler(
|
|||||||
gExceptionHandlers[ExceptionType](ExceptionType, SystemContext);
|
gExceptionHandlers[ExceptionType](ExceptionType, SystemContext);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
DEBUG ((DEBUG_ERROR, "Unknown exception type %d\n", ExceptionType));
|
||||||
DEBUG((EFI_D_ERROR, "Unknown exception type %d\n", ExceptionType));
|
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,4 +342,3 @@ InitializeCpuExceptionHandlersEx (
|
|||||||
{
|
{
|
||||||
return InitializeCpuExceptionHandlers (VectorInfo);
|
return InitializeCpuExceptionHandlers (VectorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,6 @@ ArmGenericTimerGetTimerVal (
|
|||||||
return ArmReadCntpTval ();
|
return ArmReadCntpTval ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGenericTimerSetTimerVal (
|
ArmGenericTimerSetTimerVal (
|
||||||
|
@ -71,7 +71,6 @@ ArmGenericTimerGetTimerVal (
|
|||||||
return ArmReadCntvTval ();
|
return ArmReadCntvTval ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGenericTimerSetTimerVal (
|
ArmGenericTimerSetTimerVal (
|
||||||
|
@ -38,6 +38,7 @@ ArmGicArchLibInitialize (
|
|||||||
ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
|
ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
|
||||||
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IccSre & ICC_SRE_EL2_SRE) {
|
if (IccSre & ICC_SRE_EL2_SRE) {
|
||||||
mGicArchRevision = ARM_GIC_ARCH_REVISION_3;
|
mGicArchRevision = ARM_GIC_ARCH_REVISION_3;
|
||||||
goto Done;
|
goto Done;
|
||||||
|
@ -36,6 +36,7 @@ ArmGicGetSupportedArchRevision (
|
|||||||
ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
|
ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
|
||||||
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IccSre & ICC_SRE_EL2_SRE) {
|
if (IccSre & ICC_SRE_EL2_SRE) {
|
||||||
return ARM_GIC_ARCH_REVISION_3;
|
return ARM_GIC_ARCH_REVISION_3;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
#ifndef AARCH64_LIB_H_
|
#ifndef AARCH64_LIB_H_
|
||||||
#define AARCH64_LIB_H_
|
#define AARCH64_LIB_H_
|
||||||
|
|
||||||
typedef VOID (*AARCH64_CACHE_OPERATION)(UINTN);
|
typedef VOID (*AARCH64_CACHE_OPERATION)(
|
||||||
|
UINTN
|
||||||
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
AArch64AllDataCachesOperation (
|
AArch64AllDataCachesOperation (
|
||||||
@ -53,4 +55,3 @@ ArmReadIdAA64Mmfr2 (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif // AARCH64_LIB_H_
|
#endif // AARCH64_LIB_H_
|
||||||
|
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
#define ID_MMFR0_SHR_IMP_HW_COHERENT 1
|
#define ID_MMFR0_SHR_IMP_HW_COHERENT 1
|
||||||
#define ID_MMFR0_SHR_IGNORED 0xf
|
#define ID_MMFR0_SHR_IGNORED 0xf
|
||||||
|
|
||||||
typedef VOID (*ARM_V7_CACHE_OPERATION)(UINT32);
|
typedef VOID (*ARM_V7_CACHE_OPERATION)(
|
||||||
|
UINT32
|
||||||
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
ArmV7AllDataCachesOperation (
|
ArmV7AllDataCachesOperation (
|
||||||
@ -65,4 +67,3 @@ ArmReadIdPfr1 (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif // ARM_V7_LIB_H_
|
#endif // ARM_V7_LIB_H_
|
||||||
|
|
||||||
|
@ -47,12 +47,13 @@ ArmMemoryAttributeToPageAttribute (
|
|||||||
ASSERT (0);
|
ASSERT (0);
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:
|
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:
|
||||||
if (ArmReadCurrentEL () == AARCH64_EL2)
|
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
||||||
return TT_ATTR_INDX_DEVICE_MEMORY | TT_XN_MASK;
|
return TT_ATTR_INDX_DEVICE_MEMORY | TT_XN_MASK;
|
||||||
else
|
} else {
|
||||||
return TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK;
|
return TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define MIN_T0SZ 16
|
#define MIN_T0SZ 16
|
||||||
#define BITS_PER_LEVEL 9
|
#define BITS_PER_LEVEL 9
|
||||||
@ -107,12 +108,15 @@ FreePageTablesRecursive (
|
|||||||
if (Level < 3) {
|
if (Level < 3) {
|
||||||
for (Index = 0; Index < TT_ENTRY_COUNT; Index++) {
|
for (Index = 0; Index < TT_ENTRY_COUNT; Index++) {
|
||||||
if ((TranslationTable[Index] & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY) {
|
if ((TranslationTable[Index] & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY) {
|
||||||
FreePageTablesRecursive ((VOID *)(UINTN)(TranslationTable[Index] &
|
FreePageTablesRecursive (
|
||||||
|
(VOID *)(UINTN)(TranslationTable[Index] &
|
||||||
TT_ADDRESS_MASK_BLOCK_ENTRY),
|
TT_ADDRESS_MASK_BLOCK_ENTRY),
|
||||||
Level + 1);
|
Level + 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePages (TranslationTable, 1);
|
FreePages (TranslationTable, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +130,7 @@ IsBlockEntry (
|
|||||||
if (Level == 3) {
|
if (Level == 3) {
|
||||||
return (Entry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY_LEVEL3;
|
return (Entry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY_LEVEL3;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Entry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY;
|
return (Entry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +148,7 @@ IsTableEntry (
|
|||||||
//
|
//
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Entry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY;
|
return (Entry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,8 +176,16 @@ UpdateRegionMappingRecursive (
|
|||||||
BlockShift = (Level + 1) * BITS_PER_LEVEL + MIN_T0SZ;
|
BlockShift = (Level + 1) * BITS_PER_LEVEL + MIN_T0SZ;
|
||||||
BlockMask = MAX_UINT64 >> BlockShift;
|
BlockMask = MAX_UINT64 >> BlockShift;
|
||||||
|
|
||||||
DEBUG ((DEBUG_VERBOSE, "%a(%d): %llx - %llx set %lx clr %lx\n", __FUNCTION__,
|
DEBUG ((
|
||||||
Level, RegionStart, RegionEnd, AttributeSetMask, AttributeClearMask));
|
DEBUG_VERBOSE,
|
||||||
|
"%a(%d): %llx - %llx set %lx clr %lx\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Level,
|
||||||
|
RegionStart,
|
||||||
|
RegionEnd,
|
||||||
|
AttributeSetMask,
|
||||||
|
AttributeClearMask
|
||||||
|
));
|
||||||
|
|
||||||
for ( ; RegionStart < RegionEnd; RegionStart = BlockEnd) {
|
for ( ; RegionStart < RegionEnd; RegionStart = BlockEnd) {
|
||||||
BlockEnd = MIN (RegionEnd, (RegionStart | BlockMask) + 1);
|
BlockEnd = MIN (RegionEnd, (RegionStart | BlockMask) + 1);
|
||||||
@ -187,8 +201,9 @@ UpdateRegionMappingRecursive (
|
|||||||
// we cannot replace it with a block entry without potentially losing
|
// we cannot replace it with a block entry without potentially losing
|
||||||
// attribute information, so keep the table entry in that case.
|
// attribute information, so keep the table entry in that case.
|
||||||
//
|
//
|
||||||
if (Level == 0 || ((RegionStart | BlockEnd) & BlockMask) != 0 ||
|
if ((Level == 0) || (((RegionStart | BlockEnd) & BlockMask) != 0) ||
|
||||||
(IsTableEntry (*Entry, Level) && AttributeClearMask != 0)) {
|
(IsTableEntry (*Entry, Level) && (AttributeClearMask != 0)))
|
||||||
|
{
|
||||||
ASSERT (Level < 3);
|
ASSERT (Level < 3);
|
||||||
|
|
||||||
if (!IsTableEntry (*Entry, Level)) {
|
if (!IsTableEntry (*Entry, Level)) {
|
||||||
@ -216,9 +231,14 @@ UpdateRegionMappingRecursive (
|
|||||||
// We are splitting an existing block entry, so we have to populate
|
// We are splitting an existing block entry, so we have to populate
|
||||||
// the new table with the attributes of the block entry it replaces.
|
// the new table with the attributes of the block entry it replaces.
|
||||||
//
|
//
|
||||||
Status = UpdateRegionMappingRecursive (RegionStart & ~BlockMask,
|
Status = UpdateRegionMappingRecursive (
|
||||||
(RegionStart | BlockMask) + 1, *Entry & TT_ATTRIBUTES_MASK,
|
RegionStart & ~BlockMask,
|
||||||
0, TranslationTable, Level + 1);
|
(RegionStart | BlockMask) + 1,
|
||||||
|
*Entry & TT_ATTRIBUTES_MASK,
|
||||||
|
0,
|
||||||
|
TranslationTable,
|
||||||
|
Level + 1
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// The range we passed to UpdateRegionMappingRecursive () is block
|
// The range we passed to UpdateRegionMappingRecursive () is block
|
||||||
@ -236,9 +256,14 @@ UpdateRegionMappingRecursive (
|
|||||||
//
|
//
|
||||||
// Recurse to the next level
|
// Recurse to the next level
|
||||||
//
|
//
|
||||||
Status = UpdateRegionMappingRecursive (RegionStart, BlockEnd,
|
Status = UpdateRegionMappingRecursive (
|
||||||
AttributeSetMask, AttributeClearMask, TranslationTable,
|
RegionStart,
|
||||||
Level + 1);
|
BlockEnd,
|
||||||
|
AttributeSetMask,
|
||||||
|
AttributeClearMask,
|
||||||
|
TranslationTable,
|
||||||
|
Level + 1
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
if (!IsTableEntry (*Entry, Level)) {
|
if (!IsTableEntry (*Entry, Level)) {
|
||||||
//
|
//
|
||||||
@ -250,13 +275,18 @@ UpdateRegionMappingRecursive (
|
|||||||
//
|
//
|
||||||
FreePageTablesRecursive (TranslationTable, Level + 1);
|
FreePageTablesRecursive (TranslationTable, Level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsTableEntry (*Entry, Level)) {
|
if (!IsTableEntry (*Entry, Level)) {
|
||||||
EntryValue = (UINTN)TranslationTable | TT_TYPE_TABLE_ENTRY;
|
EntryValue = (UINTN)TranslationTable | TT_TYPE_TABLE_ENTRY;
|
||||||
ReplaceTableEntry (Entry, EntryValue, RegionStart,
|
ReplaceTableEntry (
|
||||||
IsBlockEntry (*Entry, Level));
|
Entry,
|
||||||
|
EntryValue,
|
||||||
|
RegionStart,
|
||||||
|
IsBlockEntry (*Entry, Level)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EntryValue = (*Entry & AttributeClearMask) | AttributeSetMask;
|
EntryValue = (*Entry & AttributeClearMask) | AttributeSetMask;
|
||||||
@ -280,6 +310,7 @@ UpdateRegionMappingRecursive (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,9 +331,14 @@ UpdateRegionMapping (
|
|||||||
|
|
||||||
T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;
|
T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;
|
||||||
|
|
||||||
return UpdateRegionMappingRecursive (RegionStart, RegionStart + RegionLength,
|
return UpdateRegionMappingRecursive (
|
||||||
AttributeSetMask, AttributeClearMask, ArmGetTTBR0BaseAddress (),
|
RegionStart,
|
||||||
GetRootTableLevel (T0SZ));
|
RegionStart + RegionLength,
|
||||||
|
AttributeSetMask,
|
||||||
|
AttributeClearMask,
|
||||||
|
ArmGetTTBR0BaseAddress (),
|
||||||
|
GetRootTableLevel (T0SZ)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
@ -346,8 +382,9 @@ GcdAttributeToPageAttribute (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((GcdAttributes & EFI_MEMORY_XP) != 0 ||
|
if (((GcdAttributes & EFI_MEMORY_XP) != 0) ||
|
||||||
(GcdAttributes & EFI_MEMORY_CACHETYPE_MASK) == EFI_MEMORY_UC) {
|
((GcdAttributes & EFI_MEMORY_CACHETYPE_MASK) == EFI_MEMORY_UC))
|
||||||
|
{
|
||||||
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
||||||
PageAttributes |= TT_XN_MASK;
|
PageAttributes |= TT_XN_MASK;
|
||||||
} else {
|
} else {
|
||||||
@ -356,7 +393,7 @@ GcdAttributeToPageAttribute (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((GcdAttributes & EFI_MEMORY_RO) != 0) {
|
if ((GcdAttributes & EFI_MEMORY_RO) != 0) {
|
||||||
PageAttributes |= TT_AP_RO_RO;
|
PageAttributes |= TT_AP_NO_RO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PageAttributes | TT_AF;
|
return PageAttributes | TT_AF;
|
||||||
@ -385,8 +422,12 @@ ArmSetMemoryAttributes (
|
|||||||
TT_PXN_MASK | TT_XN_MASK);
|
TT_PXN_MASK | TT_XN_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UpdateRegionMapping (BaseAddress, Length, PageAttributes,
|
return UpdateRegionMapping (
|
||||||
PageAttributeMask);
|
BaseAddress,
|
||||||
|
Length,
|
||||||
|
PageAttributes,
|
||||||
|
PageAttributeMask
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
@ -419,7 +460,8 @@ ArmSetMemoryRegionNoExec (
|
|||||||
BaseAddress,
|
BaseAddress,
|
||||||
Length,
|
Length,
|
||||||
Val,
|
Val,
|
||||||
~TT_ADDRESS_MASK_BLOCK_ENTRY);
|
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -437,7 +479,8 @@ ArmClearMemoryRegionNoExec (
|
|||||||
BaseAddress,
|
BaseAddress,
|
||||||
Length,
|
Length,
|
||||||
0,
|
0,
|
||||||
Mask);
|
Mask
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -449,8 +492,9 @@ ArmSetMemoryRegionReadOnly (
|
|||||||
return SetMemoryRegionAttribute (
|
return SetMemoryRegionAttribute (
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
Length,
|
Length,
|
||||||
TT_AP_RO_RO,
|
TT_AP_NO_RO,
|
||||||
~TT_ADDRESS_MASK_BLOCK_ENTRY);
|
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -462,8 +506,9 @@ ArmClearMemoryRegionReadOnly (
|
|||||||
return SetMemoryRegionAttribute (
|
return SetMemoryRegionAttribute (
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
Length,
|
Length,
|
||||||
TT_AP_RW_RW,
|
TT_AP_NO_RW,
|
||||||
~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK));
|
~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -523,9 +568,11 @@ ArmConfigureMmu (
|
|||||||
} else if (MaxAddress < SIZE_256TB) {
|
} else if (MaxAddress < SIZE_256TB) {
|
||||||
TCR |= TCR_PS_256TB;
|
TCR |= TCR_PS_256TB;
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU configuration.\n",
|
"ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU configuration.\n",
|
||||||
MaxAddress));
|
MaxAddress
|
||||||
|
));
|
||||||
ASSERT (0); // Bigger than 48-bit memory space are not supported
|
ASSERT (0); // Bigger than 48-bit memory space are not supported
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
@ -547,9 +594,11 @@ ArmConfigureMmu (
|
|||||||
} else if (MaxAddress < SIZE_256TB) {
|
} else if (MaxAddress < SIZE_256TB) {
|
||||||
TCR |= TCR_IPS_256TB;
|
TCR |= TCR_IPS_256TB;
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU configuration.\n",
|
"ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU configuration.\n",
|
||||||
MaxAddress));
|
MaxAddress
|
||||||
|
));
|
||||||
ASSERT (0); // Bigger than 48-bit memory space are not supported
|
ASSERT (0); // Bigger than 48-bit memory space are not supported
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
@ -579,6 +628,7 @@ ArmConfigureMmu (
|
|||||||
if (TranslationTable == NULL) {
|
if (TranslationTable == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// We set TTBR0 just after allocating the table to retrieve its location from
|
// We set TTBR0 just after allocating the table to retrieve its location from
|
||||||
// the subsequent functions without needing to pass this value across the
|
// the subsequent functions without needing to pass this value across the
|
||||||
@ -599,8 +649,10 @@ ArmConfigureMmu (
|
|||||||
// Make sure we are not inadvertently hitting in the caches
|
// Make sure we are not inadvertently hitting in the caches
|
||||||
// when populating the page tables.
|
// when populating the page tables.
|
||||||
//
|
//
|
||||||
InvalidateDataCacheRange (TranslationTable,
|
InvalidateDataCacheRange (
|
||||||
RootTableEntryCount * sizeof (UINT64));
|
TranslationTable,
|
||||||
|
RootTableEntryCount * sizeof (UINT64)
|
||||||
|
);
|
||||||
ZeroMem (TranslationTable, RootTableEntryCount * sizeof (UINT64));
|
ZeroMem (TranslationTable, RootTableEntryCount * sizeof (UINT64));
|
||||||
|
|
||||||
while (MemoryTable->Length != 0) {
|
while (MemoryTable->Length != 0) {
|
||||||
@ -608,6 +660,7 @@ ArmConfigureMmu (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto FreeTranslationTable;
|
goto FreeTranslationTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryTable++;
|
MemoryTable++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,8 +702,10 @@ ArmMmuBaseLibConstructor (
|
|||||||
// The ArmReplaceLiveTranslationEntry () helper function may be invoked
|
// The ArmReplaceLiveTranslationEntry () helper function may be invoked
|
||||||
// with the MMU off so we have to ensure that it gets cleaned to the PoC
|
// with the MMU off so we have to ensure that it gets cleaned to the PoC
|
||||||
//
|
//
|
||||||
WriteBackDataCacheRange ((VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
WriteBackDataCacheRange (
|
||||||
ArmReplaceLiveTranslationEntrySize);
|
(VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
||||||
|
ArmReplaceLiveTranslationEntrySize
|
||||||
|
);
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -37,18 +37,21 @@ ArmMmuPeiLibConstructor (
|
|||||||
// is executing from DRAM, we only need to perform the cache maintenance
|
// is executing from DRAM, we only need to perform the cache maintenance
|
||||||
// when not executing in place.
|
// when not executing in place.
|
||||||
//
|
//
|
||||||
if ((UINTN)FileInfo.Buffer <= (UINTN)ArmReplaceLiveTranslationEntry &&
|
if (((UINTN)FileInfo.Buffer <= (UINTN)ArmReplaceLiveTranslationEntry) &&
|
||||||
((UINTN)FileInfo.Buffer + FileInfo.BufferSize >=
|
((UINTN)FileInfo.Buffer + FileInfo.BufferSize >=
|
||||||
(UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize)) {
|
(UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize))
|
||||||
DEBUG ((EFI_D_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));
|
{
|
||||||
|
DEBUG ((DEBUG_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((EFI_D_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));
|
DEBUG ((DEBUG_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));
|
||||||
//
|
//
|
||||||
// The ArmReplaceLiveTranslationEntry () helper function may be invoked
|
// The ArmReplaceLiveTranslationEntry () helper function may be invoked
|
||||||
// with the MMU off so we have to ensure that it gets cleaned to the PoC
|
// with the MMU off so we have to ensure that it gets cleaned to the PoC
|
||||||
//
|
//
|
||||||
WriteBackDataCacheRange ((VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
WriteBackDataCacheRange (
|
||||||
ArmReplaceLiveTranslationEntrySize);
|
(VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
||||||
|
ArmReplaceLiveTranslationEntrySize
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
|
@ -76,6 +76,7 @@ PreferNonshareableMemory (
|
|||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Val != ID_MMFR0_SHR_IMP_HW_COHERENT;
|
return Val != ID_MMFR0_SHR_IMP_HW_COHERENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +141,8 @@ PopulateLevel2PageTable (
|
|||||||
// Allocate a Level2 Page Table for this Section
|
// Allocate a Level2 Page Table for this Section
|
||||||
TranslationTable = (UINTN)AllocateAlignedPages (
|
TranslationTable = (UINTN)AllocateAlignedPages (
|
||||||
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_PAGE_SIZE),
|
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_PAGE_SIZE),
|
||||||
TRANSLATION_TABLE_PAGE_ALIGNMENT);
|
TRANSLATION_TABLE_PAGE_ALIGNMENT
|
||||||
|
);
|
||||||
|
|
||||||
// Translate the Section Descriptor into Page Descriptor
|
// Translate the Section Descriptor into Page Descriptor
|
||||||
SectionDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (*SectionEntry, FALSE);
|
SectionDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (*SectionEntry, FALSE);
|
||||||
@ -151,8 +153,10 @@ PopulateLevel2PageTable (
|
|||||||
// Make sure we are not inadvertently hitting in the caches
|
// Make sure we are not inadvertently hitting in the caches
|
||||||
// when populating the page tables
|
// when populating the page tables
|
||||||
//
|
//
|
||||||
InvalidateDataCacheRange ((VOID *)TranslationTable,
|
InvalidateDataCacheRange (
|
||||||
TRANSLATION_TABLE_PAGE_SIZE);
|
(VOID *)TranslationTable,
|
||||||
|
TRANSLATION_TABLE_PAGE_SIZE
|
||||||
|
);
|
||||||
|
|
||||||
// Populate the new Level2 Page Table for the section
|
// Populate the new Level2 Page Table for the section
|
||||||
PageEntry = (UINT32 *)TranslationTable;
|
PageEntry = (UINT32 *)TranslationTable;
|
||||||
@ -172,13 +176,16 @@ PopulateLevel2PageTable (
|
|||||||
} else {
|
} else {
|
||||||
TranslationTable = (UINTN)AllocateAlignedPages (
|
TranslationTable = (UINTN)AllocateAlignedPages (
|
||||||
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_PAGE_SIZE),
|
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_PAGE_SIZE),
|
||||||
TRANSLATION_TABLE_PAGE_ALIGNMENT);
|
TRANSLATION_TABLE_PAGE_ALIGNMENT
|
||||||
|
);
|
||||||
//
|
//
|
||||||
// Make sure we are not inadvertently hitting in the caches
|
// Make sure we are not inadvertently hitting in the caches
|
||||||
// when populating the page tables
|
// when populating the page tables
|
||||||
//
|
//
|
||||||
InvalidateDataCacheRange ((VOID *)TranslationTable,
|
InvalidateDataCacheRange (
|
||||||
TRANSLATION_TABLE_PAGE_SIZE);
|
(VOID *)TranslationTable,
|
||||||
|
TRANSLATION_TABLE_PAGE_SIZE
|
||||||
|
);
|
||||||
ZeroMem ((VOID *)TranslationTable, TRANSLATION_TABLE_PAGE_SIZE);
|
ZeroMem ((VOID *)TranslationTable, TRANSLATION_TABLE_PAGE_SIZE);
|
||||||
|
|
||||||
*SectionEntry = (TranslationTable & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |
|
*SectionEntry = (TranslationTable & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |
|
||||||
@ -202,8 +209,10 @@ PopulateLevel2PageTable (
|
|||||||
// [speculatively] since the previous invalidate are evicted again.
|
// [speculatively] since the previous invalidate are evicted again.
|
||||||
//
|
//
|
||||||
ArmDataMemoryBarrier ();
|
ArmDataMemoryBarrier ();
|
||||||
InvalidateDataCacheRange ((UINT32 *)TranslationTable + FirstPageOffset,
|
InvalidateDataCacheRange (
|
||||||
RemainLength / TT_DESCRIPTOR_PAGE_SIZE * sizeof (*PageEntry));
|
(UINT32 *)TranslationTable + FirstPageOffset,
|
||||||
|
RemainLength / TT_DESCRIPTOR_PAGE_SIZE * sizeof (*PageEntry)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
@ -274,8 +283,9 @@ FillTranslationTable (
|
|||||||
SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS (TranslationTable, MemoryRegion->VirtualBase);
|
SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS (TranslationTable, MemoryRegion->VirtualBase);
|
||||||
|
|
||||||
while (RemainLength != 0) {
|
while (RemainLength != 0) {
|
||||||
if (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE == 0 &&
|
if ((PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE == 0) &&
|
||||||
RemainLength >= TT_DESCRIPTOR_SECTION_SIZE) {
|
(RemainLength >= TT_DESCRIPTOR_SECTION_SIZE))
|
||||||
|
{
|
||||||
// Case: Physical address aligned on the Section Size (1MB) && the length
|
// Case: Physical address aligned on the Section Size (1MB) && the length
|
||||||
// is greater than the Section Size
|
// is greater than the Section Size
|
||||||
*SectionEntry = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (PhysicalBase) | Attributes;
|
*SectionEntry = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (PhysicalBase) | Attributes;
|
||||||
@ -291,14 +301,21 @@ FillTranslationTable (
|
|||||||
PhysicalBase += TT_DESCRIPTOR_SECTION_SIZE;
|
PhysicalBase += TT_DESCRIPTOR_SECTION_SIZE;
|
||||||
RemainLength -= TT_DESCRIPTOR_SECTION_SIZE;
|
RemainLength -= TT_DESCRIPTOR_SECTION_SIZE;
|
||||||
} else {
|
} else {
|
||||||
PageMapLength = MIN ((UINT32)RemainLength, TT_DESCRIPTOR_SECTION_SIZE -
|
PageMapLength = MIN (
|
||||||
(PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE));
|
(UINT32)RemainLength,
|
||||||
|
TT_DESCRIPTOR_SECTION_SIZE -
|
||||||
|
(PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE)
|
||||||
|
);
|
||||||
|
|
||||||
// Case: Physical address aligned on the Section Size (1MB) && the length
|
// Case: Physical address aligned on the Section Size (1MB) && the length
|
||||||
// does not fill a section
|
// does not fill a section
|
||||||
// Case: Physical address NOT aligned on the Section Size (1MB)
|
// Case: Physical address NOT aligned on the Section Size (1MB)
|
||||||
PopulateLevel2PageTable (SectionEntry, PhysicalBase, PageMapLength,
|
PopulateLevel2PageTable (
|
||||||
MemoryRegion->Attributes);
|
SectionEntry,
|
||||||
|
PhysicalBase,
|
||||||
|
PageMapLength,
|
||||||
|
MemoryRegion->Attributes
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Issue a DMB to ensure that the page table entry update made it to
|
// Issue a DMB to ensure that the page table entry update made it to
|
||||||
@ -332,7 +349,8 @@ ArmConfigureMmu (
|
|||||||
|
|
||||||
TranslationTable = AllocateAlignedPages (
|
TranslationTable = AllocateAlignedPages (
|
||||||
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_SECTION_SIZE),
|
EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_SECTION_SIZE),
|
||||||
TRANSLATION_TABLE_SECTION_ALIGNMENT);
|
TRANSLATION_TABLE_SECTION_ALIGNMENT
|
||||||
|
);
|
||||||
if (TranslationTable == NULL) {
|
if (TranslationTable == NULL) {
|
||||||
return RETURN_OUT_OF_RESOURCES;
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -389,7 +407,8 @@ ArmConfigureMmu (
|
|||||||
//
|
//
|
||||||
ArmSetTTBCR (0);
|
ArmSetTTBCR (0);
|
||||||
|
|
||||||
ArmSetDomainAccessControl (DOMAIN_ACCESS_CONTROL_NONE(15) |
|
ArmSetDomainAccessControl (
|
||||||
|
DOMAIN_ACCESS_CONTROL_NONE (15) |
|
||||||
DOMAIN_ACCESS_CONTROL_NONE (14) |
|
DOMAIN_ACCESS_CONTROL_NONE (14) |
|
||||||
DOMAIN_ACCESS_CONTROL_NONE (13) |
|
DOMAIN_ACCESS_CONTROL_NONE (13) |
|
||||||
DOMAIN_ACCESS_CONTROL_NONE (12) |
|
DOMAIN_ACCESS_CONTROL_NONE (12) |
|
||||||
@ -404,7 +423,8 @@ ArmConfigureMmu (
|
|||||||
DOMAIN_ACCESS_CONTROL_NONE (3) |
|
DOMAIN_ACCESS_CONTROL_NONE (3) |
|
||||||
DOMAIN_ACCESS_CONTROL_NONE (2) |
|
DOMAIN_ACCESS_CONTROL_NONE (2) |
|
||||||
DOMAIN_ACCESS_CONTROL_NONE (1) |
|
DOMAIN_ACCESS_CONTROL_NONE (1) |
|
||||||
DOMAIN_ACCESS_CONTROL_CLIENT(0));
|
DOMAIN_ACCESS_CONTROL_CLIENT (0)
|
||||||
|
);
|
||||||
|
|
||||||
ArmEnableInstructionCache ();
|
ArmEnableInstructionCache ();
|
||||||
ArmEnableDataCache ();
|
ArmEnableDataCache ();
|
||||||
|
@ -206,7 +206,6 @@ UpdatePageEntries (
|
|||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
Offset += TT_DESCRIPTOR_PAGE_SIZE;
|
Offset += TT_DESCRIPTOR_PAGE_SIZE;
|
||||||
|
|
||||||
} // End first level translation table loop
|
} // End first level translation table loop
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
@ -303,7 +302,8 @@ UpdateSectionEntries (
|
|||||||
(FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT,
|
(FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT,
|
||||||
TT_DESCRIPTOR_SECTION_SIZE,
|
TT_DESCRIPTOR_SECTION_SIZE,
|
||||||
Attributes,
|
Attributes,
|
||||||
NULL);
|
NULL
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// still a section entry
|
// still a section entry
|
||||||
|
|
||||||
@ -355,19 +355,22 @@ ArmSetMemoryAttributes (
|
|||||||
FlushTlbs = FALSE;
|
FlushTlbs = FALSE;
|
||||||
while (Length > 0) {
|
while (Length > 0) {
|
||||||
if ((BaseAddress % TT_DESCRIPTOR_SECTION_SIZE == 0) &&
|
if ((BaseAddress % TT_DESCRIPTOR_SECTION_SIZE == 0) &&
|
||||||
Length >= TT_DESCRIPTOR_SECTION_SIZE) {
|
(Length >= TT_DESCRIPTOR_SECTION_SIZE))
|
||||||
|
{
|
||||||
ChunkLength = Length - Length % TT_DESCRIPTOR_SECTION_SIZE;
|
ChunkLength = Length - Length % TT_DESCRIPTOR_SECTION_SIZE;
|
||||||
|
|
||||||
DEBUG ((DEBUG_PAGE,
|
DEBUG ((
|
||||||
|
DEBUG_PAGE,
|
||||||
"SetMemoryAttributes(): MMU section 0x%lx length 0x%lx to %lx\n",
|
"SetMemoryAttributes(): MMU section 0x%lx length 0x%lx to %lx\n",
|
||||||
BaseAddress, ChunkLength, Attributes));
|
BaseAddress,
|
||||||
|
ChunkLength,
|
||||||
|
Attributes
|
||||||
|
));
|
||||||
|
|
||||||
Status = UpdateSectionEntries (BaseAddress, ChunkLength, Attributes);
|
Status = UpdateSectionEntries (BaseAddress, ChunkLength, Attributes);
|
||||||
|
|
||||||
FlushTlbs = TRUE;
|
FlushTlbs = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Process page by page until the next section boundary, but only if
|
// Process page by page until the next section boundary, but only if
|
||||||
// we have more than a section's worth of area to deal with after that.
|
// we have more than a section's worth of area to deal with after that.
|
||||||
@ -378,12 +381,20 @@ ArmSetMemoryAttributes (
|
|||||||
ChunkLength = Length;
|
ChunkLength = Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_PAGE,
|
DEBUG ((
|
||||||
|
DEBUG_PAGE,
|
||||||
"SetMemoryAttributes(): MMU page 0x%lx length 0x%lx to %lx\n",
|
"SetMemoryAttributes(): MMU page 0x%lx length 0x%lx to %lx\n",
|
||||||
BaseAddress, ChunkLength, Attributes));
|
BaseAddress,
|
||||||
|
ChunkLength,
|
||||||
|
Attributes
|
||||||
|
));
|
||||||
|
|
||||||
Status = UpdatePageEntries (BaseAddress, ChunkLength, Attributes,
|
Status = UpdatePageEntries (
|
||||||
&FlushTlbs);
|
BaseAddress,
|
||||||
|
ChunkLength,
|
||||||
|
Attributes,
|
||||||
|
&FlushTlbs
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -397,6 +408,7 @@ ArmSetMemoryAttributes (
|
|||||||
if (FlushTlbs) {
|
if (FlushTlbs) {
|
||||||
ArmInvalidateTlb ();
|
ArmInvalidateTlb ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ LibResetSystem (
|
|||||||
ArmCallSmc (&ArmSmcArgs);
|
ArmCallSmc (&ArmSmcArgs);
|
||||||
|
|
||||||
// We should never be here
|
// We should never be here
|
||||||
DEBUG ((EFI_D_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
129
ArmPkg/Library/ArmSmcLib/ArmSmc.c
Normal file
129
ArmPkg/Library/ArmSmcLib/ArmSmc.c
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/** @file
|
||||||
|
SMC helper functions.
|
||||||
|
|
||||||
|
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <Library/ArmSmcLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
|
||||||
|
/** Triggers an SMC call with 3 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Argument/result.
|
||||||
|
@param Arg3 Argument/result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc3 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg3 OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ARM_SMC_ARGS Args;
|
||||||
|
UINTN ErrorCode;
|
||||||
|
|
||||||
|
ZeroMem (&Args, sizeof (ARM_SMC_ARGS));
|
||||||
|
|
||||||
|
Args.Arg0 = Function;
|
||||||
|
|
||||||
|
if (Arg1 != NULL) {
|
||||||
|
Args.Arg1 = *Arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Arg2 != NULL) {
|
||||||
|
Args.Arg2 = *Arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Arg3 != NULL) {
|
||||||
|
Args.Arg3 = *Arg3;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArmCallSmc (&Args);
|
||||||
|
|
||||||
|
ErrorCode = Args.Arg0;
|
||||||
|
|
||||||
|
if (Arg1 != NULL) {
|
||||||
|
*Arg1 = Args.Arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Arg2 != NULL) {
|
||||||
|
*Arg2 = Args.Arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Arg3 != NULL) {
|
||||||
|
*Arg3 = Args.Arg3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 2 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Argument/result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc2 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 1 argument.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc1 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 0 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Result.
|
||||||
|
@param Arg2 Result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc0 (
|
||||||
|
IN UINTN Function,
|
||||||
|
OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
|
||||||
|
}
|
@ -20,6 +20,9 @@
|
|||||||
[Sources.AARCH64]
|
[Sources.AARCH64]
|
||||||
AArch64/ArmSmc.S
|
AArch64/ArmSmc.S
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
ArmSmc.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
ArmPkg/ArmPkg.dec
|
ArmPkg/ArmPkg.dec
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
//
|
//
|
||||||
|
// Copyright (c) 2021, NUVIA Inc. All rights reserved.
|
||||||
// Copyright (c) 2016, Linaro Limited. All rights reserved.
|
// Copyright (c) 2016, Linaro Limited. All rights reserved.
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
@ -7,6 +8,7 @@
|
|||||||
|
|
||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
#include <Library/ArmSmcLib.h>
|
#include <Library/ArmSmcLib.h>
|
||||||
|
#include <IndustryStandard/ArmStdSmc.h>
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
ArmCallSmc (
|
ArmCallSmc (
|
||||||
@ -14,3 +16,86 @@ ArmCallSmc (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Triggers an SMC call with 3 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Argument/result.
|
||||||
|
@param Arg3 Argument/result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc3 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg3 OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return SMC_ARCH_CALL_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 2 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Argument/result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc2 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
IN OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return SMC_ARCH_CALL_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 1 argument.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Argument/result.
|
||||||
|
@param Arg2 Result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc1 (
|
||||||
|
IN UINTN Function,
|
||||||
|
IN OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return SMC_ARCH_CALL_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Trigger an SMC call with 0 arguments.
|
||||||
|
|
||||||
|
@param Function The SMC function.
|
||||||
|
@param Arg1 Result.
|
||||||
|
@param Arg2 Result.
|
||||||
|
@param Arg3 Result.
|
||||||
|
|
||||||
|
@return The SMC error code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
ArmCallSmc0 (
|
||||||
|
IN UINTN Function,
|
||||||
|
OUT UINTN *Arg1 OPTIONAL,
|
||||||
|
OUT UINTN *Arg2 OPTIONAL,
|
||||||
|
OUT UINTN *Arg3 OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return SMC_ARCH_CALL_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
@ -31,11 +31,8 @@ ResetCold (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_SMC_ARGS ArmSmcArgs;
|
|
||||||
|
|
||||||
// Send a PSCI 0.2 SYSTEM_RESET command
|
// Send a PSCI 0.2 SYSTEM_RESET command
|
||||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
ArmCallSmc0 (ARM_SMC_ID_PSCI_SYSTEM_RESET, NULL, NULL, NULL);
|
||||||
ArmCallSmc (&ArmSmcArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,11 +63,8 @@ ResetShutdown (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_SMC_ARGS ArmSmcArgs;
|
|
||||||
|
|
||||||
// Send a PSCI 0.2 SYSTEM_OFF command
|
// Send a PSCI 0.2 SYSTEM_OFF command
|
||||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
ArmCallSmc0 (ARM_SMC_ID_PSCI_SYSTEM_OFF, NULL, NULL, NULL);
|
||||||
ArmCallSmc (&ArmSmcArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,12 +25,18 @@ typedef uint64_t aeabi_double_t;
|
|||||||
* Helpers to convert between float32 and aeabi_float_t, and float64 and
|
* Helpers to convert between float32 and aeabi_float_t, and float64 and
|
||||||
* aeabi_double_t used by the AEABI functions below.
|
* aeabi_double_t used by the AEABI functions below.
|
||||||
*/
|
*/
|
||||||
static aeabi_float_t f32_to_f(float32_t val)
|
static aeabi_float_t
|
||||||
|
f32_to_f (
|
||||||
|
float32_t val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return val.v;
|
return val.v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float32_t f32_from_f(aeabi_float_t val)
|
static float32_t
|
||||||
|
f32_from_f (
|
||||||
|
aeabi_float_t val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
float32_t res;
|
float32_t res;
|
||||||
|
|
||||||
@ -39,12 +45,18 @@ static float32_t f32_from_f(aeabi_float_t val)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static aeabi_double_t f64_to_d(float64_t val)
|
static aeabi_double_t
|
||||||
|
f64_to_d (
|
||||||
|
float64_t val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return val.v;
|
return val.v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float64_t f64_from_d(aeabi_double_t val)
|
static float64_t
|
||||||
|
f64_from_d (
|
||||||
|
aeabi_double_t val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
float64_t res;
|
float64_t res;
|
||||||
|
|
||||||
@ -64,29 +76,47 @@ static float64_t f64_from_d(aeabi_double_t val)
|
|||||||
* Table 2, Standard aeabi_double_t precision floating-point arithmetic helper
|
* Table 2, Standard aeabi_double_t precision floating-point arithmetic helper
|
||||||
* functions
|
* functions
|
||||||
*/
|
*/
|
||||||
|
aeabi_double_t
|
||||||
aeabi_double_t __aeabi_dadd(aeabi_double_t a, aeabi_double_t b)
|
__aeabi_dadd (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (f64_add (f64_from_d (a), f64_from_d (b)));
|
return f64_to_d (f64_add (f64_from_d (a), f64_from_d (b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_double_t __aeabi_ddiv(aeabi_double_t a, aeabi_double_t b)
|
aeabi_double_t
|
||||||
|
__aeabi_ddiv (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (f64_div (f64_from_d (a), f64_from_d (b)));
|
return f64_to_d (f64_div (f64_from_d (a), f64_from_d (b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_double_t __aeabi_dmul(aeabi_double_t a, aeabi_double_t b)
|
aeabi_double_t
|
||||||
|
__aeabi_dmul (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (f64_mul (f64_from_d (a), f64_from_d (b)));
|
return f64_to_d (f64_mul (f64_from_d (a), f64_from_d (b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aeabi_double_t
|
||||||
aeabi_double_t __aeabi_drsub(aeabi_double_t a, aeabi_double_t b)
|
__aeabi_drsub (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (f64_sub (f64_from_d (b), f64_from_d (a)));
|
return f64_to_d (f64_sub (f64_from_d (b), f64_from_d (a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_double_t __aeabi_dsub(aeabi_double_t a, aeabi_double_t b)
|
aeabi_double_t
|
||||||
|
__aeabi_dsub (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (f64_sub (f64_from_d (a), f64_from_d (b)));
|
return f64_to_d (f64_sub (f64_from_d (a), f64_from_d (b)));
|
||||||
}
|
}
|
||||||
@ -94,28 +124,47 @@ aeabi_double_t __aeabi_dsub(aeabi_double_t a, aeabi_double_t b)
|
|||||||
/*
|
/*
|
||||||
* Table 3, double precision floating-point comparison helper functions
|
* Table 3, double precision floating-point comparison helper functions
|
||||||
*/
|
*/
|
||||||
|
int
|
||||||
int __aeabi_dcmpeq(aeabi_double_t a, aeabi_double_t b)
|
__aeabi_dcmpeq (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_eq (f64_from_d (a), f64_from_d (b));
|
return f64_eq (f64_from_d (a), f64_from_d (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_dcmplt(aeabi_double_t a, aeabi_double_t b)
|
int
|
||||||
|
__aeabi_dcmplt (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_lt (f64_from_d (a), f64_from_d (b));
|
return f64_lt (f64_from_d (a), f64_from_d (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_dcmple(aeabi_double_t a, aeabi_double_t b)
|
int
|
||||||
|
__aeabi_dcmple (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_le (f64_from_d (a), f64_from_d (b));
|
return f64_le (f64_from_d (a), f64_from_d (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_dcmpge(aeabi_double_t a, aeabi_double_t b)
|
int
|
||||||
|
__aeabi_dcmpge (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_le (f64_from_d (b), f64_from_d (a));
|
return f64_le (f64_from_d (b), f64_from_d (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_dcmpgt(aeabi_double_t a, aeabi_double_t b)
|
int
|
||||||
|
__aeabi_dcmpgt (
|
||||||
|
aeabi_double_t a,
|
||||||
|
aeabi_double_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_lt (f64_from_d (b), f64_from_d (a));
|
return f64_lt (f64_from_d (b), f64_from_d (a));
|
||||||
}
|
}
|
||||||
@ -124,28 +173,47 @@ int __aeabi_dcmpgt(aeabi_double_t a, aeabi_double_t b)
|
|||||||
* Table 4, Standard single precision floating-point arithmetic helper
|
* Table 4, Standard single precision floating-point arithmetic helper
|
||||||
* functions
|
* functions
|
||||||
*/
|
*/
|
||||||
|
aeabi_float_t
|
||||||
aeabi_float_t __aeabi_fadd(aeabi_float_t a, aeabi_float_t b)
|
__aeabi_fadd (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (f32_add (f32_from_f (a), f32_from_f (b)));
|
return f32_to_f (f32_add (f32_from_f (a), f32_from_f (b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_float_t __aeabi_fdiv(aeabi_float_t a, aeabi_float_t b)
|
aeabi_float_t
|
||||||
|
__aeabi_fdiv (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (f32_div (f32_from_f (a), f32_from_f (b)));
|
return f32_to_f (f32_div (f32_from_f (a), f32_from_f (b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_float_t __aeabi_fmul(aeabi_float_t a, aeabi_float_t b)
|
aeabi_float_t
|
||||||
|
__aeabi_fmul (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (f32_mul (f32_from_f (a), f32_from_f (b)));
|
return f32_to_f (f32_mul (f32_from_f (a), f32_from_f (b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_float_t __aeabi_frsub(aeabi_float_t a, aeabi_float_t b)
|
aeabi_float_t
|
||||||
|
__aeabi_frsub (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (f32_sub (f32_from_f (b), f32_from_f (a)));
|
return f32_to_f (f32_sub (f32_from_f (b), f32_from_f (a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_float_t __aeabi_fsub(aeabi_float_t a, aeabi_float_t b)
|
aeabi_float_t
|
||||||
|
__aeabi_fsub (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (f32_sub (f32_from_f (a), f32_from_f (b)));
|
return f32_to_f (f32_sub (f32_from_f (a), f32_from_f (b)));
|
||||||
}
|
}
|
||||||
@ -154,28 +222,47 @@ aeabi_float_t __aeabi_fsub(aeabi_float_t a, aeabi_float_t b)
|
|||||||
* Table 5, Standard single precision floating-point comparison helper
|
* Table 5, Standard single precision floating-point comparison helper
|
||||||
* functions
|
* functions
|
||||||
*/
|
*/
|
||||||
|
int
|
||||||
int __aeabi_fcmpeq(aeabi_float_t a, aeabi_float_t b)
|
__aeabi_fcmpeq (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_eq (f32_from_f (a), f32_from_f (b));
|
return f32_eq (f32_from_f (a), f32_from_f (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_fcmplt(aeabi_float_t a, aeabi_float_t b)
|
int
|
||||||
|
__aeabi_fcmplt (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_lt (f32_from_f (a), f32_from_f (b));
|
return f32_lt (f32_from_f (a), f32_from_f (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_fcmple(aeabi_float_t a, aeabi_float_t b)
|
int
|
||||||
|
__aeabi_fcmple (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_le (f32_from_f (a), f32_from_f (b));
|
return f32_le (f32_from_f (a), f32_from_f (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_fcmpge(aeabi_float_t a, aeabi_float_t b)
|
int
|
||||||
|
__aeabi_fcmpge (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_le (f32_from_f (b), f32_from_f (a));
|
return f32_le (f32_from_f (b), f32_from_f (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_fcmpgt(aeabi_float_t a, aeabi_float_t b)
|
int
|
||||||
|
__aeabi_fcmpgt (
|
||||||
|
aeabi_float_t a,
|
||||||
|
aeabi_float_t b
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_lt (f32_from_f (b), f32_from_f (a));
|
return f32_lt (f32_from_f (b), f32_from_f (a));
|
||||||
}
|
}
|
||||||
@ -183,43 +270,66 @@ int __aeabi_fcmpgt(aeabi_float_t a, aeabi_float_t b)
|
|||||||
/*
|
/*
|
||||||
* Table 6, Standard floating-point to integer conversions
|
* Table 6, Standard floating-point to integer conversions
|
||||||
*/
|
*/
|
||||||
|
int
|
||||||
int __aeabi_d2iz(aeabi_double_t a)
|
__aeabi_d2iz (
|
||||||
|
aeabi_double_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_i32_r_minMag (f64_from_d (a), false);
|
return f64_to_i32_r_minMag (f64_from_d (a), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned __aeabi_d2uiz(aeabi_double_t a)
|
unsigned
|
||||||
|
__aeabi_d2uiz (
|
||||||
|
aeabi_double_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_ui32_r_minMag (f64_from_d (a), false);
|
return f64_to_ui32_r_minMag (f64_from_d (a), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
long long __aeabi_d2lz(aeabi_double_t a)
|
long long
|
||||||
|
__aeabi_d2lz (
|
||||||
|
aeabi_double_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_i64_r_minMag (f64_from_d (a), false);
|
return f64_to_i64_r_minMag (f64_from_d (a), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long __aeabi_d2ulz(aeabi_double_t a)
|
unsigned long long
|
||||||
|
__aeabi_d2ulz (
|
||||||
|
aeabi_double_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_ui64_r_minMag (f64_from_d (a), false);
|
return f64_to_ui64_r_minMag (f64_from_d (a), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __aeabi_f2iz(aeabi_float_t a)
|
int
|
||||||
|
__aeabi_f2iz (
|
||||||
|
aeabi_float_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_i32_r_minMag (f32_from_f (a), false);
|
return f32_to_i32_r_minMag (f32_from_f (a), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned __aeabi_f2uiz(aeabi_float_t a)
|
unsigned
|
||||||
|
__aeabi_f2uiz (
|
||||||
|
aeabi_float_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_ui32_r_minMag (f32_from_f (a), false);
|
return f32_to_ui32_r_minMag (f32_from_f (a), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
long long __aeabi_f2lz(aeabi_float_t a)
|
long long
|
||||||
|
__aeabi_f2lz (
|
||||||
|
aeabi_float_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_i64_r_minMag (f32_from_f (a), false);
|
return f32_to_i64_r_minMag (f32_from_f (a), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long __aeabi_f2ulz(aeabi_float_t a)
|
unsigned long long
|
||||||
|
__aeabi_f2ulz (
|
||||||
|
aeabi_float_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_ui64_r_minMag (f32_from_f (a), false);
|
return f32_to_ui64_r_minMag (f32_from_f (a), false);
|
||||||
}
|
}
|
||||||
@ -227,13 +337,18 @@ unsigned long long __aeabi_f2ulz(aeabi_float_t a)
|
|||||||
/*
|
/*
|
||||||
* Table 7, Standard conversions between floating types
|
* Table 7, Standard conversions between floating types
|
||||||
*/
|
*/
|
||||||
|
aeabi_float_t
|
||||||
aeabi_float_t __aeabi_d2f(aeabi_double_t a)
|
__aeabi_d2f (
|
||||||
|
aeabi_double_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (f64_to_f32 (f64_from_d (a)));
|
return f32_to_f (f64_to_f32 (f64_from_d (a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_double_t __aeabi_f2d(aeabi_float_t a)
|
aeabi_double_t
|
||||||
|
__aeabi_f2d (
|
||||||
|
aeabi_float_t a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (f32_to_f64 (f32_from_f (a)));
|
return f64_to_d (f32_to_f64 (f32_from_f (a)));
|
||||||
}
|
}
|
||||||
@ -241,43 +356,66 @@ aeabi_double_t __aeabi_f2d(aeabi_float_t a)
|
|||||||
/*
|
/*
|
||||||
* Table 8, Standard integer to floating-point conversions
|
* Table 8, Standard integer to floating-point conversions
|
||||||
*/
|
*/
|
||||||
|
aeabi_double_t
|
||||||
aeabi_double_t __aeabi_i2d(int a)
|
__aeabi_i2d (
|
||||||
|
int a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (i32_to_f64 (a));
|
return f64_to_d (i32_to_f64 (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_double_t __aeabi_ui2d(unsigned a)
|
aeabi_double_t
|
||||||
|
__aeabi_ui2d (
|
||||||
|
unsigned a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (ui32_to_f64 (a));
|
return f64_to_d (ui32_to_f64 (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_double_t __aeabi_l2d(long long a)
|
aeabi_double_t
|
||||||
|
__aeabi_l2d (
|
||||||
|
long long a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (i64_to_f64 (a));
|
return f64_to_d (i64_to_f64 (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_double_t __aeabi_ul2d(unsigned long long a)
|
aeabi_double_t
|
||||||
|
__aeabi_ul2d (
|
||||||
|
unsigned long long a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f64_to_d (ui64_to_f64 (a));
|
return f64_to_d (ui64_to_f64 (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_float_t __aeabi_i2f(int a)
|
aeabi_float_t
|
||||||
|
__aeabi_i2f (
|
||||||
|
int a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (i32_to_f32 (a));
|
return f32_to_f (i32_to_f32 (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_float_t __aeabi_ui2f(unsigned a)
|
aeabi_float_t
|
||||||
|
__aeabi_ui2f (
|
||||||
|
unsigned a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (ui32_to_f32 (a));
|
return f32_to_f (ui32_to_f32 (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_float_t __aeabi_l2f(long long a)
|
aeabi_float_t
|
||||||
|
__aeabi_l2f (
|
||||||
|
long long a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (i64_to_f32 (a));
|
return f32_to_f (i64_to_f32 (a));
|
||||||
}
|
}
|
||||||
|
|
||||||
aeabi_float_t __aeabi_ul2f(unsigned long long a)
|
aeabi_float_t
|
||||||
|
__aeabi_ul2f (
|
||||||
|
unsigned long long a
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return f32_to_f (ui64_to_f32 (a));
|
return f32_to_f (ui64_to_f32 (a));
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,21 @@ typedef unsigned __int64 size_t;
|
|||||||
typedef unsigned __int32 size_t;
|
typedef unsigned __int32 size_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int memcmp(void *, void *, size_t);
|
int
|
||||||
|
memcmp (
|
||||||
|
void *,
|
||||||
|
void *,
|
||||||
|
size_t
|
||||||
|
);
|
||||||
|
|
||||||
#pragma intrinsic(memcmp)
|
#pragma intrinsic(memcmp)
|
||||||
#pragma function(memcmp)
|
#pragma function(memcmp)
|
||||||
int memcmp(const void *s1, const void *s2, size_t n)
|
int
|
||||||
|
memcmp (
|
||||||
|
const void *s1,
|
||||||
|
const void *s2,
|
||||||
|
size_t n
|
||||||
|
)
|
||||||
{
|
{
|
||||||
unsigned char const *t1;
|
unsigned char const *t1;
|
||||||
unsigned char const *t2;
|
unsigned char const *t2;
|
||||||
@ -25,8 +36,10 @@ int memcmp(const void *s1, const void *s2, size_t n)
|
|||||||
t2 = s2;
|
t2 = s2;
|
||||||
|
|
||||||
while (n-- != 0) {
|
while (n-- != 0) {
|
||||||
if (*t1 != *t2)
|
if (*t1 != *t2) {
|
||||||
return (int)*t1 - (int)*t2;
|
return (int)*t1 - (int)*t2;
|
||||||
|
}
|
||||||
|
|
||||||
t1++;
|
t1++;
|
||||||
t2++;
|
t2++;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,12 @@
|
|||||||
|
|
||||||
typedef __SIZE_TYPE__ size_t;
|
typedef __SIZE_TYPE__ size_t;
|
||||||
|
|
||||||
static void __memcpy(void *dest, const void *src, size_t n)
|
static void
|
||||||
|
__memcpy (
|
||||||
|
void *dest,
|
||||||
|
const void *src,
|
||||||
|
size_t n
|
||||||
|
)
|
||||||
{
|
{
|
||||||
unsigned char *d;
|
unsigned char *d;
|
||||||
unsigned char const *s;
|
unsigned char const *s;
|
||||||
@ -22,7 +27,12 @@ static void __memcpy(void *dest, const void *src, size_t n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *memcpy(void *dest, const void *src, size_t n)
|
void *
|
||||||
|
memcpy (
|
||||||
|
void *dest,
|
||||||
|
const void *src,
|
||||||
|
size_t n
|
||||||
|
)
|
||||||
{
|
{
|
||||||
__memcpy (dest, src, n);
|
__memcpy (dest, src, n);
|
||||||
return dest;
|
return dest;
|
||||||
@ -31,12 +41,27 @@ void *memcpy(void *dest, const void *src, size_t n)
|
|||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
|
|
||||||
__attribute__ ((__alias__ ("__memcpy")))
|
__attribute__ ((__alias__ ("__memcpy")))
|
||||||
void __aeabi_memcpy(void *dest, const void *src, size_t n);
|
void
|
||||||
|
__aeabi_memcpy (
|
||||||
|
void *dest,
|
||||||
|
const void *src,
|
||||||
|
size_t n
|
||||||
|
);
|
||||||
|
|
||||||
__attribute__ ((__alias__ ("__memcpy")))
|
__attribute__ ((__alias__ ("__memcpy")))
|
||||||
void __aeabi_memcpy4(void *dest, const void *src, size_t n);
|
void
|
||||||
|
__aeabi_memcpy4 (
|
||||||
|
void *dest,
|
||||||
|
const void *src,
|
||||||
|
size_t n
|
||||||
|
);
|
||||||
|
|
||||||
__attribute__ ((__alias__ ("__memcpy")))
|
__attribute__ ((__alias__ ("__memcpy")))
|
||||||
void __aeabi_memcpy8(void *dest, const void *src, size_t n);
|
void
|
||||||
|
__aeabi_memcpy8 (
|
||||||
|
void *dest,
|
||||||
|
const void *src,
|
||||||
|
size_t n
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,10 +13,21 @@ typedef unsigned __int64 size_t;
|
|||||||
typedef unsigned __int32 size_t;
|
typedef unsigned __int32 size_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void* memcpy(void *, const void *, size_t);
|
void *
|
||||||
|
memcpy (
|
||||||
|
void *,
|
||||||
|
const void *,
|
||||||
|
size_t
|
||||||
|
);
|
||||||
|
|
||||||
#pragma intrinsic(memcpy)
|
#pragma intrinsic(memcpy)
|
||||||
#pragma function(memcpy)
|
#pragma function(memcpy)
|
||||||
void* memcpy(void *dest, const void *src, size_t n)
|
void *
|
||||||
|
memcpy (
|
||||||
|
void *dest,
|
||||||
|
const void *src,
|
||||||
|
size_t n
|
||||||
|
)
|
||||||
{
|
{
|
||||||
unsigned char *d;
|
unsigned char *d;
|
||||||
unsigned char const *s;
|
unsigned char const *s;
|
||||||
|
@ -13,10 +13,21 @@ typedef unsigned __int64 size_t;
|
|||||||
typedef unsigned __int32 size_t;
|
typedef unsigned __int32 size_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void* memmove(void *, const void *, size_t);
|
void *
|
||||||
|
memmove (
|
||||||
|
void *,
|
||||||
|
const void *,
|
||||||
|
size_t
|
||||||
|
);
|
||||||
|
|
||||||
#pragma intrinsic(memmove)
|
#pragma intrinsic(memmove)
|
||||||
#pragma function(memmove)
|
#pragma function(memmove)
|
||||||
void* memmove(void *dest, const void *src, size_t n)
|
void *
|
||||||
|
memmove (
|
||||||
|
void *dest,
|
||||||
|
const void *src,
|
||||||
|
size_t n
|
||||||
|
)
|
||||||
{
|
{
|
||||||
unsigned char *d;
|
unsigned char *d;
|
||||||
unsigned char const *s;
|
unsigned char const *s;
|
||||||
|
@ -10,7 +10,12 @@
|
|||||||
typedef __SIZE_TYPE__ size_t;
|
typedef __SIZE_TYPE__ size_t;
|
||||||
|
|
||||||
static __attribute__ ((__used__))
|
static __attribute__ ((__used__))
|
||||||
void *__memset(void *s, int c, size_t n)
|
void *
|
||||||
|
__memset (
|
||||||
|
void *s,
|
||||||
|
int c,
|
||||||
|
size_t n
|
||||||
|
)
|
||||||
{
|
{
|
||||||
unsigned char *d;
|
unsigned char *d;
|
||||||
|
|
||||||
@ -30,30 +35,62 @@ void *__memset(void *s, int c, size_t n)
|
|||||||
// our memset() 'weak' to let the other implementation take precedence.
|
// our memset() 'weak' to let the other implementation take precedence.
|
||||||
//
|
//
|
||||||
__attribute__ ((__weak__, __alias__ ("__memset")))
|
__attribute__ ((__weak__, __alias__ ("__memset")))
|
||||||
void *memset(void *dest, int c, size_t n);
|
void *
|
||||||
|
memset (
|
||||||
|
void *dest,
|
||||||
|
int c,
|
||||||
|
size_t n
|
||||||
|
);
|
||||||
|
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
|
|
||||||
void __aeabi_memset(void *dest, size_t n, int c)
|
void
|
||||||
|
__aeabi_memset (
|
||||||
|
void *dest,
|
||||||
|
size_t n,
|
||||||
|
int c
|
||||||
|
)
|
||||||
{
|
{
|
||||||
__memset (dest, c, n);
|
__memset (dest, c, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__ ((__alias__ ("__aeabi_memset")))
|
__attribute__ ((__alias__ ("__aeabi_memset")))
|
||||||
void __aeabi_memset4(void *dest, size_t n, int c);
|
void
|
||||||
|
__aeabi_memset4 (
|
||||||
|
void *dest,
|
||||||
|
size_t n,
|
||||||
|
int c
|
||||||
|
);
|
||||||
|
|
||||||
__attribute__ ((__alias__ ("__aeabi_memset")))
|
__attribute__ ((__alias__ ("__aeabi_memset")))
|
||||||
void __aeabi_memset8(void *dest, size_t n, int c);
|
void
|
||||||
|
__aeabi_memset8 (
|
||||||
|
void *dest,
|
||||||
|
size_t n,
|
||||||
|
int c
|
||||||
|
);
|
||||||
|
|
||||||
void __aeabi_memclr(void *dest, size_t n)
|
void
|
||||||
|
__aeabi_memclr (
|
||||||
|
void *dest,
|
||||||
|
size_t n
|
||||||
|
)
|
||||||
{
|
{
|
||||||
__memset (dest, 0, n);
|
__memset (dest, 0, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__ ((__alias__ ("__aeabi_memclr")))
|
__attribute__ ((__alias__ ("__aeabi_memclr")))
|
||||||
void __aeabi_memclr4(void *dest, size_t n);
|
void
|
||||||
|
__aeabi_memclr4 (
|
||||||
|
void *dest,
|
||||||
|
size_t n
|
||||||
|
);
|
||||||
|
|
||||||
__attribute__ ((__alias__ ("__aeabi_memclr")))
|
__attribute__ ((__alias__ ("__aeabi_memclr")))
|
||||||
void __aeabi_memclr8(void *dest, size_t n);
|
void
|
||||||
|
__aeabi_memclr8 (
|
||||||
|
void *dest,
|
||||||
|
size_t n
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,10 +13,21 @@ typedef unsigned __int64 size_t;
|
|||||||
typedef unsigned __int32 size_t;
|
typedef unsigned __int32 size_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void* memset(void *, int, size_t);
|
void *
|
||||||
|
memset (
|
||||||
|
void *,
|
||||||
|
int,
|
||||||
|
size_t
|
||||||
|
);
|
||||||
|
|
||||||
#pragma intrinsic(memset)
|
#pragma intrinsic(memset)
|
||||||
#pragma function(memset)
|
#pragma function(memset)
|
||||||
void *memset(void *s, int c, size_t n)
|
void *
|
||||||
|
memset (
|
||||||
|
void *s,
|
||||||
|
int c,
|
||||||
|
size_t n
|
||||||
|
)
|
||||||
{
|
{
|
||||||
unsigned char *d;
|
unsigned char *d;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
|
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
|
||||||
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
|
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
|
||||||
|
|
||||||
|
|
||||||
// Vector Table for Sec Phase
|
// Vector Table for Sec Phase
|
||||||
VOID
|
VOID
|
||||||
DebugAgentVectorTable (
|
DebugAgentVectorTable (
|
||||||
@ -125,7 +124,6 @@ GetFfsFile (
|
|||||||
FileState = GetFileState (ErasePolarity, FfsFileHeader);
|
FileState = GetFileState (ErasePolarity, FfsFileHeader);
|
||||||
|
|
||||||
switch (FileState) {
|
switch (FileState) {
|
||||||
|
|
||||||
case EFI_FILE_HEADER_INVALID:
|
case EFI_FILE_HEADER_INVALID:
|
||||||
FileOffset += sizeof (EFI_FFS_FILE_HEADER);
|
FileOffset += sizeof (EFI_FFS_FILE_HEADER);
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
|
||||||
@ -161,6 +159,7 @@ GetFfsFile (
|
|||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +267,7 @@ VOID
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
InitializeDebugAgent (
|
InitializeDebugAgent (
|
||||||
IN UINT32 InitFlag,
|
IN UINT32 InitFlag,
|
||||||
IN VOID *Context, OPTIONAL
|
IN VOID *Context OPTIONAL,
|
||||||
IN DEBUG_AGENT_CONTINUE Function OPTIONAL
|
IN DEBUG_AGENT_CONTINUE Function OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -335,4 +334,3 @@ SaveAndSetDebugTimerInterrupt (
|
|||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
#include <Library/PeCoffExtraActionLib.h>
|
#include <Library/PeCoffExtraActionLib.h>
|
||||||
#include <Library/PrintLib.h>
|
#include <Library/PrintLib.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
If the build is done on cygwin the paths are cygpaths.
|
If the build is done on cygwin the paths are cygpaths.
|
||||||
/cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
|
/cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
|
||||||
@ -57,7 +56,6 @@ DeCygwinPathIfNeeded (
|
|||||||
return Temp;
|
return Temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
||||||
|
|
||||||
@ -81,24 +79,22 @@ PeCoffLoaderRelocateImageExtraAction (
|
|||||||
#ifdef __CC_ARM
|
#ifdef __CC_ARM
|
||||||
#if (__ARMCC_VERSION < 500000)
|
#if (__ARMCC_VERSION < 500000)
|
||||||
// Print out the command for the RVD debugger to load symbols for this image
|
// Print out the command for the RVD debugger to load symbols for this image
|
||||||
DEBUG ((EFI_D_LOAD | EFI_D_INFO, "load /a /ni /np %a &0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "load /a /ni /np %a &0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
||||||
#else
|
#else
|
||||||
// Print out the command for the DS-5 to load symbols for this image
|
// Print out the command for the DS-5 to load symbols for this image
|
||||||
DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
||||||
#endif
|
#endif
|
||||||
#elif __GNUC__
|
#elif __GNUC__
|
||||||
// This may not work correctly if you generate PE/COFF directly as then the Offset would not be required
|
// This may not work correctly if you generate PE/COFF directly as then the Offset would not be required
|
||||||
DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
|
||||||
#else
|
#else
|
||||||
DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
|
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
|
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
||||||
|
@ -48,43 +48,75 @@ DescribeInstructionOrDataAbort (
|
|||||||
CHAR8 *AbortCause;
|
CHAR8 *AbortCause;
|
||||||
|
|
||||||
switch (Iss & 0x3f) {
|
switch (Iss & 0x3f) {
|
||||||
case 0x0: AbortCause = "Address size fault, zeroth level of translation or translation table base register"; break;
|
case 0x0: AbortCause = "Address size fault, zeroth level of translation or translation table base register";
|
||||||
case 0x1: AbortCause = "Address size fault, first level"; break;
|
break;
|
||||||
case 0x2: AbortCause = "Address size fault, second level"; break;
|
case 0x1: AbortCause = "Address size fault, first level";
|
||||||
case 0x3: AbortCause = "Address size fault, third level"; break;
|
break;
|
||||||
case 0x4: AbortCause = "Translation fault, zeroth level"; break;
|
case 0x2: AbortCause = "Address size fault, second level";
|
||||||
case 0x5: AbortCause = "Translation fault, first level"; break;
|
break;
|
||||||
case 0x6: AbortCause = "Translation fault, second level"; break;
|
case 0x3: AbortCause = "Address size fault, third level";
|
||||||
case 0x7: AbortCause = "Translation fault, third level"; break;
|
break;
|
||||||
case 0x9: AbortCause = "Access flag fault, first level"; break;
|
case 0x4: AbortCause = "Translation fault, zeroth level";
|
||||||
case 0xa: AbortCause = "Access flag fault, second level"; break;
|
break;
|
||||||
case 0xb: AbortCause = "Access flag fault, third level"; break;
|
case 0x5: AbortCause = "Translation fault, first level";
|
||||||
case 0xd: AbortCause = "Permission fault, first level"; break;
|
break;
|
||||||
case 0xe: AbortCause = "Permission fault, second level"; break;
|
case 0x6: AbortCause = "Translation fault, second level";
|
||||||
case 0xf: AbortCause = "Permission fault, third level"; break;
|
break;
|
||||||
case 0x10: AbortCause = "Synchronous external abort"; break;
|
case 0x7: AbortCause = "Translation fault, third level";
|
||||||
case 0x18: AbortCause = "Synchronous parity error on memory access"; break;
|
break;
|
||||||
case 0x11: AbortCause = "Asynchronous external abort"; break;
|
case 0x9: AbortCause = "Access flag fault, first level";
|
||||||
case 0x19: AbortCause = "Asynchronous parity error on memory access"; break;
|
break;
|
||||||
case 0x14: AbortCause = "Synchronous external abort on translation table walk, zeroth level"; break;
|
case 0xa: AbortCause = "Access flag fault, second level";
|
||||||
case 0x15: AbortCause = "Synchronous external abort on translation table walk, first level"; break;
|
break;
|
||||||
case 0x16: AbortCause = "Synchronous external abort on translation table walk, second level"; break;
|
case 0xb: AbortCause = "Access flag fault, third level";
|
||||||
case 0x17: AbortCause = "Synchronous external abort on translation table walk, third level"; break;
|
break;
|
||||||
case 0x1c: AbortCause = "Synchronous parity error on memory access on translation table walk, zeroth level"; break;
|
case 0xd: AbortCause = "Permission fault, first level";
|
||||||
case 0x1d: AbortCause = "Synchronous parity error on memory access on translation table walk, first level"; break;
|
break;
|
||||||
case 0x1e: AbortCause = "Synchronous parity error on memory access on translation table walk, second level"; break;
|
case 0xe: AbortCause = "Permission fault, second level";
|
||||||
case 0x1f: AbortCause = "Synchronous parity error on memory access on translation table walk, third level"; break;
|
break;
|
||||||
case 0x21: AbortCause = "Alignment fault"; break;
|
case 0xf: AbortCause = "Permission fault, third level";
|
||||||
case 0x22: AbortCause = "Debug event"; break;
|
break;
|
||||||
case 0x30: AbortCause = "TLB conflict abort"; break;
|
case 0x10: AbortCause = "Synchronous external abort";
|
||||||
|
break;
|
||||||
|
case 0x18: AbortCause = "Synchronous parity error on memory access";
|
||||||
|
break;
|
||||||
|
case 0x11: AbortCause = "Asynchronous external abort";
|
||||||
|
break;
|
||||||
|
case 0x19: AbortCause = "Asynchronous parity error on memory access";
|
||||||
|
break;
|
||||||
|
case 0x14: AbortCause = "Synchronous external abort on translation table walk, zeroth level";
|
||||||
|
break;
|
||||||
|
case 0x15: AbortCause = "Synchronous external abort on translation table walk, first level";
|
||||||
|
break;
|
||||||
|
case 0x16: AbortCause = "Synchronous external abort on translation table walk, second level";
|
||||||
|
break;
|
||||||
|
case 0x17: AbortCause = "Synchronous external abort on translation table walk, third level";
|
||||||
|
break;
|
||||||
|
case 0x1c: AbortCause = "Synchronous parity error on memory access on translation table walk, zeroth level";
|
||||||
|
break;
|
||||||
|
case 0x1d: AbortCause = "Synchronous parity error on memory access on translation table walk, first level";
|
||||||
|
break;
|
||||||
|
case 0x1e: AbortCause = "Synchronous parity error on memory access on translation table walk, second level";
|
||||||
|
break;
|
||||||
|
case 0x1f: AbortCause = "Synchronous parity error on memory access on translation table walk, third level";
|
||||||
|
break;
|
||||||
|
case 0x21: AbortCause = "Alignment fault";
|
||||||
|
break;
|
||||||
|
case 0x22: AbortCause = "Debug event";
|
||||||
|
break;
|
||||||
|
case 0x30: AbortCause = "TLB conflict abort";
|
||||||
|
break;
|
||||||
case 0x33:
|
case 0x33:
|
||||||
case 0x34: AbortCause = "IMPLEMENTATION DEFINED"; break;
|
case 0x34: AbortCause = "IMPLEMENTATION DEFINED";
|
||||||
|
break;
|
||||||
case 0x35:
|
case 0x35:
|
||||||
case 0x36: AbortCause = "Domain fault"; break;
|
case 0x36: AbortCause = "Domain fault";
|
||||||
default: AbortCause = ""; break;
|
break;
|
||||||
|
default: AbortCause = "";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR, "\n%a: %a\n", AbortType, AbortCause));
|
DEBUG ((DEBUG_ERROR, "\n%a: %a\n", AbortType, AbortCause));
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
@ -101,17 +133,22 @@ DescribeExceptionSyndrome (
|
|||||||
Iss = Esr & 0x00ffffff;
|
Iss = Esr & 0x00ffffff;
|
||||||
|
|
||||||
switch (Ec) {
|
switch (Ec) {
|
||||||
case 0x15: Message = "SVC executed in AArch64"; break;
|
case 0x15: Message = "SVC executed in AArch64";
|
||||||
|
break;
|
||||||
case 0x20:
|
case 0x20:
|
||||||
case 0x21: DescribeInstructionOrDataAbort ("Instruction abort", Iss); return;
|
case 0x21: DescribeInstructionOrDataAbort ("Instruction abort", Iss);
|
||||||
case 0x22: Message = "PC alignment fault"; break;
|
return;
|
||||||
case 0x23: Message = "SP alignment fault"; break;
|
case 0x22: Message = "PC alignment fault";
|
||||||
|
break;
|
||||||
|
case 0x23: Message = "SP alignment fault";
|
||||||
|
break;
|
||||||
case 0x24:
|
case 0x24:
|
||||||
case 0x25: DescribeInstructionOrDataAbort ("Data abort", Iss); return;
|
case 0x25: DescribeInstructionOrDataAbort ("Data abort", Iss);
|
||||||
|
return;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR, "\n %a \n", Message));
|
DEBUG ((DEBUG_ERROR, "\n %a \n", Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MDEPKG_NDEBUG
|
#ifndef MDEPKG_NDEBUG
|
||||||
@ -126,12 +163,14 @@ BaseName (
|
|||||||
Str = FullName + AsciiStrLen (FullName);
|
Str = FullName + AsciiStrLen (FullName);
|
||||||
|
|
||||||
while (--Str > FullName) {
|
while (--Str > FullName) {
|
||||||
if (*Str == '/' || *Str == '\\') {
|
if ((*Str == '/') || (*Str == '\\')) {
|
||||||
return Str + 1;
|
return Str + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Str;
|
return Str;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,8 +199,10 @@ DefaultExceptionHandler (
|
|||||||
if (gST->ConOut != NULL) {
|
if (gST->ConOut != NULL) {
|
||||||
AsciiPrint (Message);
|
AsciiPrint (Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
mRecursiveException = TRUE;
|
mRecursiveException = TRUE;
|
||||||
|
|
||||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR);
|
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR);
|
||||||
@ -180,11 +221,16 @@ DefaultExceptionHandler (
|
|||||||
|
|
||||||
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
|
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
|
||||||
if (Pdb != NULL) {
|
if (Pdb != NULL) {
|
||||||
DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n",
|
DEBUG ((
|
||||||
SystemContext.SystemContextAArch64->ELR, ImageBase,
|
DEBUG_ERROR,
|
||||||
SystemContext.SystemContextAArch64->ELR - ImageBase, BaseName (Pdb)));
|
"PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n",
|
||||||
|
SystemContext.SystemContextAArch64->ELR,
|
||||||
|
ImageBase,
|
||||||
|
SystemContext.SystemContextAArch64->ELR - ImageBase,
|
||||||
|
BaseName (Pdb)
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((EFI_D_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR));
|
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {
|
if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {
|
||||||
@ -196,6 +242,7 @@ DefaultExceptionHandler (
|
|||||||
RootFp[0] = SystemContext.SystemContextAArch64->FP;
|
RootFp[0] = SystemContext.SystemContextAArch64->FP;
|
||||||
RootFp[1] = SystemContext.SystemContextAArch64->LR;
|
RootFp[1] = SystemContext.SystemContextAArch64->LR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
|
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
|
||||||
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
|
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
|
||||||
if (Pdb != NULL) {
|
if (Pdb != NULL) {
|
||||||
@ -203,71 +250,84 @@ DefaultExceptionHandler (
|
|||||||
Idx++;
|
Idx++;
|
||||||
PrevPdb = Pdb;
|
PrevPdb = Pdb;
|
||||||
}
|
}
|
||||||
DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n",
|
|
||||||
Fp[1], ImageBase, Fp[1] - ImageBase, Idx, BaseName (Pdb)));
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n",
|
||||||
|
Fp[1],
|
||||||
|
ImageBase,
|
||||||
|
Fp[1] - ImageBase,
|
||||||
|
Idx,
|
||||||
|
BaseName (Pdb)
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((EFI_D_ERROR, "PC 0x%012lx\n", Fp[1]));
|
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", Fp[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
|
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
|
||||||
if (Pdb != NULL) {
|
if (Pdb != NULL) {
|
||||||
DEBUG ((EFI_D_ERROR, "\n[ 0] %a\n", Pdb));
|
DEBUG ((DEBUG_ERROR, "\n[ 0] %a\n", Pdb));
|
||||||
}
|
}
|
||||||
|
|
||||||
Idx = 0;
|
Idx = 0;
|
||||||
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
|
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
|
||||||
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
|
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
|
||||||
if (Pdb != NULL && Pdb != PrevPdb) {
|
if ((Pdb != NULL) && (Pdb != PrevPdb)) {
|
||||||
DEBUG ((EFI_D_ERROR, "[% 2d] %a\n", ++Idx, Pdb));
|
DEBUG ((DEBUG_ERROR, "[% 2d] %a\n", ++Idx, Pdb));
|
||||||
PrevPdb = Pdb;
|
PrevPdb = Pdb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_CODE_END ();
|
DEBUG_CODE_END ();
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR, "\n X0 0x%016lx X1 0x%016lx X2 0x%016lx X3 0x%016lx\n", SystemContext.SystemContextAArch64->X0, SystemContext.SystemContextAArch64->X1, SystemContext.SystemContextAArch64->X2, SystemContext.SystemContextAArch64->X3));
|
DEBUG ((DEBUG_ERROR, "\n X0 0x%016lx X1 0x%016lx X2 0x%016lx X3 0x%016lx\n", SystemContext.SystemContextAArch64->X0, SystemContext.SystemContextAArch64->X1, SystemContext.SystemContextAArch64->X2, SystemContext.SystemContextAArch64->X3));
|
||||||
DEBUG ((EFI_D_ERROR, " X4 0x%016lx X5 0x%016lx X6 0x%016lx X7 0x%016lx\n", SystemContext.SystemContextAArch64->X4, SystemContext.SystemContextAArch64->X5, SystemContext.SystemContextAArch64->X6, SystemContext.SystemContextAArch64->X7));
|
DEBUG ((DEBUG_ERROR, " X4 0x%016lx X5 0x%016lx X6 0x%016lx X7 0x%016lx\n", SystemContext.SystemContextAArch64->X4, SystemContext.SystemContextAArch64->X5, SystemContext.SystemContextAArch64->X6, SystemContext.SystemContextAArch64->X7));
|
||||||
DEBUG ((EFI_D_ERROR, " X8 0x%016lx X9 0x%016lx X10 0x%016lx X11 0x%016lx\n", SystemContext.SystemContextAArch64->X8, SystemContext.SystemContextAArch64->X9, SystemContext.SystemContextAArch64->X10, SystemContext.SystemContextAArch64->X11));
|
DEBUG ((DEBUG_ERROR, " X8 0x%016lx X9 0x%016lx X10 0x%016lx X11 0x%016lx\n", SystemContext.SystemContextAArch64->X8, SystemContext.SystemContextAArch64->X9, SystemContext.SystemContextAArch64->X10, SystemContext.SystemContextAArch64->X11));
|
||||||
DEBUG ((EFI_D_ERROR, " X12 0x%016lx X13 0x%016lx X14 0x%016lx X15 0x%016lx\n", SystemContext.SystemContextAArch64->X12, SystemContext.SystemContextAArch64->X13, SystemContext.SystemContextAArch64->X14, SystemContext.SystemContextAArch64->X15));
|
DEBUG ((DEBUG_ERROR, " X12 0x%016lx X13 0x%016lx X14 0x%016lx X15 0x%016lx\n", SystemContext.SystemContextAArch64->X12, SystemContext.SystemContextAArch64->X13, SystemContext.SystemContextAArch64->X14, SystemContext.SystemContextAArch64->X15));
|
||||||
DEBUG ((EFI_D_ERROR, " X16 0x%016lx X17 0x%016lx X18 0x%016lx X19 0x%016lx\n", SystemContext.SystemContextAArch64->X16, SystemContext.SystemContextAArch64->X17, SystemContext.SystemContextAArch64->X18, SystemContext.SystemContextAArch64->X19));
|
DEBUG ((DEBUG_ERROR, " X16 0x%016lx X17 0x%016lx X18 0x%016lx X19 0x%016lx\n", SystemContext.SystemContextAArch64->X16, SystemContext.SystemContextAArch64->X17, SystemContext.SystemContextAArch64->X18, SystemContext.SystemContextAArch64->X19));
|
||||||
DEBUG ((EFI_D_ERROR, " X20 0x%016lx X21 0x%016lx X22 0x%016lx X23 0x%016lx\n", SystemContext.SystemContextAArch64->X20, SystemContext.SystemContextAArch64->X21, SystemContext.SystemContextAArch64->X22, SystemContext.SystemContextAArch64->X23));
|
DEBUG ((DEBUG_ERROR, " X20 0x%016lx X21 0x%016lx X22 0x%016lx X23 0x%016lx\n", SystemContext.SystemContextAArch64->X20, SystemContext.SystemContextAArch64->X21, SystemContext.SystemContextAArch64->X22, SystemContext.SystemContextAArch64->X23));
|
||||||
DEBUG ((EFI_D_ERROR, " X24 0x%016lx X25 0x%016lx X26 0x%016lx X27 0x%016lx\n", SystemContext.SystemContextAArch64->X24, SystemContext.SystemContextAArch64->X25, SystemContext.SystemContextAArch64->X26, SystemContext.SystemContextAArch64->X27));
|
DEBUG ((DEBUG_ERROR, " X24 0x%016lx X25 0x%016lx X26 0x%016lx X27 0x%016lx\n", SystemContext.SystemContextAArch64->X24, SystemContext.SystemContextAArch64->X25, SystemContext.SystemContextAArch64->X26, SystemContext.SystemContextAArch64->X27));
|
||||||
DEBUG ((EFI_D_ERROR, " X28 0x%016lx FP 0x%016lx LR 0x%016lx \n", SystemContext.SystemContextAArch64->X28, SystemContext.SystemContextAArch64->FP, SystemContext.SystemContextAArch64->LR));
|
DEBUG ((DEBUG_ERROR, " X28 0x%016lx FP 0x%016lx LR 0x%016lx \n", SystemContext.SystemContextAArch64->X28, SystemContext.SystemContextAArch64->FP, SystemContext.SystemContextAArch64->LR));
|
||||||
|
|
||||||
/* We save these as 128bit numbers, but have to print them as two 64bit numbers,
|
/* We save these as 128bit numbers, but have to print them as two 64bit numbers,
|
||||||
so swap the 64bit words to correctly represent a 128bit number. */
|
so swap the 64bit words to correctly represent a 128bit number. */
|
||||||
DEBUG ((EFI_D_ERROR, "\n V0 0x%016lx %016lx V1 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V0[1], SystemContext.SystemContextAArch64->V0[0], SystemContext.SystemContextAArch64->V1[1], SystemContext.SystemContextAArch64->V1[0]));
|
DEBUG ((DEBUG_ERROR, "\n V0 0x%016lx %016lx V1 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V0[1], SystemContext.SystemContextAArch64->V0[0], SystemContext.SystemContextAArch64->V1[1], SystemContext.SystemContextAArch64->V1[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V2 0x%016lx %016lx V3 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V2[1], SystemContext.SystemContextAArch64->V2[0], SystemContext.SystemContextAArch64->V3[1], SystemContext.SystemContextAArch64->V3[0]));
|
DEBUG ((DEBUG_ERROR, " V2 0x%016lx %016lx V3 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V2[1], SystemContext.SystemContextAArch64->V2[0], SystemContext.SystemContextAArch64->V3[1], SystemContext.SystemContextAArch64->V3[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V4 0x%016lx %016lx V5 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V4[1], SystemContext.SystemContextAArch64->V4[0], SystemContext.SystemContextAArch64->V5[1], SystemContext.SystemContextAArch64->V5[0]));
|
DEBUG ((DEBUG_ERROR, " V4 0x%016lx %016lx V5 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V4[1], SystemContext.SystemContextAArch64->V4[0], SystemContext.SystemContextAArch64->V5[1], SystemContext.SystemContextAArch64->V5[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V6 0x%016lx %016lx V7 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V6[1], SystemContext.SystemContextAArch64->V6[0], SystemContext.SystemContextAArch64->V7[1], SystemContext.SystemContextAArch64->V7[0]));
|
DEBUG ((DEBUG_ERROR, " V6 0x%016lx %016lx V7 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V6[1], SystemContext.SystemContextAArch64->V6[0], SystemContext.SystemContextAArch64->V7[1], SystemContext.SystemContextAArch64->V7[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V8 0x%016lx %016lx V9 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V8[1], SystemContext.SystemContextAArch64->V8[0], SystemContext.SystemContextAArch64->V9[1], SystemContext.SystemContextAArch64->V9[0]));
|
DEBUG ((DEBUG_ERROR, " V8 0x%016lx %016lx V9 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V8[1], SystemContext.SystemContextAArch64->V8[0], SystemContext.SystemContextAArch64->V9[1], SystemContext.SystemContextAArch64->V9[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V10 0x%016lx %016lx V11 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V10[1], SystemContext.SystemContextAArch64->V10[0], SystemContext.SystemContextAArch64->V11[1], SystemContext.SystemContextAArch64->V11[0]));
|
DEBUG ((DEBUG_ERROR, " V10 0x%016lx %016lx V11 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V10[1], SystemContext.SystemContextAArch64->V10[0], SystemContext.SystemContextAArch64->V11[1], SystemContext.SystemContextAArch64->V11[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V12 0x%016lx %016lx V13 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V12[1], SystemContext.SystemContextAArch64->V12[0], SystemContext.SystemContextAArch64->V13[1], SystemContext.SystemContextAArch64->V13[0]));
|
DEBUG ((DEBUG_ERROR, " V12 0x%016lx %016lx V13 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V12[1], SystemContext.SystemContextAArch64->V12[0], SystemContext.SystemContextAArch64->V13[1], SystemContext.SystemContextAArch64->V13[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V14 0x%016lx %016lx V15 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V14[1], SystemContext.SystemContextAArch64->V14[0], SystemContext.SystemContextAArch64->V15[1], SystemContext.SystemContextAArch64->V15[0]));
|
DEBUG ((DEBUG_ERROR, " V14 0x%016lx %016lx V15 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V14[1], SystemContext.SystemContextAArch64->V14[0], SystemContext.SystemContextAArch64->V15[1], SystemContext.SystemContextAArch64->V15[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V16 0x%016lx %016lx V17 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V16[1], SystemContext.SystemContextAArch64->V16[0], SystemContext.SystemContextAArch64->V17[1], SystemContext.SystemContextAArch64->V17[0]));
|
DEBUG ((DEBUG_ERROR, " V16 0x%016lx %016lx V17 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V16[1], SystemContext.SystemContextAArch64->V16[0], SystemContext.SystemContextAArch64->V17[1], SystemContext.SystemContextAArch64->V17[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V18 0x%016lx %016lx V19 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V18[1], SystemContext.SystemContextAArch64->V18[0], SystemContext.SystemContextAArch64->V19[1], SystemContext.SystemContextAArch64->V19[0]));
|
DEBUG ((DEBUG_ERROR, " V18 0x%016lx %016lx V19 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V18[1], SystemContext.SystemContextAArch64->V18[0], SystemContext.SystemContextAArch64->V19[1], SystemContext.SystemContextAArch64->V19[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V20 0x%016lx %016lx V21 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V20[1], SystemContext.SystemContextAArch64->V20[0], SystemContext.SystemContextAArch64->V21[1], SystemContext.SystemContextAArch64->V21[0]));
|
DEBUG ((DEBUG_ERROR, " V20 0x%016lx %016lx V21 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V20[1], SystemContext.SystemContextAArch64->V20[0], SystemContext.SystemContextAArch64->V21[1], SystemContext.SystemContextAArch64->V21[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V22 0x%016lx %016lx V23 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V22[1], SystemContext.SystemContextAArch64->V22[0], SystemContext.SystemContextAArch64->V23[1], SystemContext.SystemContextAArch64->V23[0]));
|
DEBUG ((DEBUG_ERROR, " V22 0x%016lx %016lx V23 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V22[1], SystemContext.SystemContextAArch64->V22[0], SystemContext.SystemContextAArch64->V23[1], SystemContext.SystemContextAArch64->V23[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V24 0x%016lx %016lx V25 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V24[1], SystemContext.SystemContextAArch64->V24[0], SystemContext.SystemContextAArch64->V25[1], SystemContext.SystemContextAArch64->V25[0]));
|
DEBUG ((DEBUG_ERROR, " V24 0x%016lx %016lx V25 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V24[1], SystemContext.SystemContextAArch64->V24[0], SystemContext.SystemContextAArch64->V25[1], SystemContext.SystemContextAArch64->V25[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V26 0x%016lx %016lx V27 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V26[1], SystemContext.SystemContextAArch64->V26[0], SystemContext.SystemContextAArch64->V27[1], SystemContext.SystemContextAArch64->V27[0]));
|
DEBUG ((DEBUG_ERROR, " V26 0x%016lx %016lx V27 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V26[1], SystemContext.SystemContextAArch64->V26[0], SystemContext.SystemContextAArch64->V27[1], SystemContext.SystemContextAArch64->V27[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V28 0x%016lx %016lx V29 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V28[1], SystemContext.SystemContextAArch64->V28[0], SystemContext.SystemContextAArch64->V29[1], SystemContext.SystemContextAArch64->V29[0]));
|
DEBUG ((DEBUG_ERROR, " V28 0x%016lx %016lx V29 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V28[1], SystemContext.SystemContextAArch64->V28[0], SystemContext.SystemContextAArch64->V29[1], SystemContext.SystemContextAArch64->V29[0]));
|
||||||
DEBUG ((EFI_D_ERROR, " V30 0x%016lx %016lx V31 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V30[1], SystemContext.SystemContextAArch64->V30[0], SystemContext.SystemContextAArch64->V31[1], SystemContext.SystemContextAArch64->V31[0]));
|
DEBUG ((DEBUG_ERROR, " V30 0x%016lx %016lx V31 0x%016lx %016lx\n", SystemContext.SystemContextAArch64->V30[1], SystemContext.SystemContextAArch64->V30[0], SystemContext.SystemContextAArch64->V31[1], SystemContext.SystemContextAArch64->V31[0]));
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR, "\n SP 0x%016lx ELR 0x%016lx SPSR 0x%08lx FPSR 0x%08lx\n ESR 0x%08lx FAR 0x%016lx\n", SystemContext.SystemContextAArch64->SP, SystemContext.SystemContextAArch64->ELR, SystemContext.SystemContextAArch64->SPSR, SystemContext.SystemContextAArch64->FPSR, SystemContext.SystemContextAArch64->ESR, SystemContext.SystemContextAArch64->FAR));
|
DEBUG ((DEBUG_ERROR, "\n SP 0x%016lx ELR 0x%016lx SPSR 0x%08lx FPSR 0x%08lx\n ESR 0x%08lx FAR 0x%016lx\n", SystemContext.SystemContextAArch64->SP, SystemContext.SystemContextAArch64->ELR, SystemContext.SystemContextAArch64->SPSR, SystemContext.SystemContextAArch64->FPSR, SystemContext.SystemContextAArch64->ESR, SystemContext.SystemContextAArch64->FAR));
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR, "\n ESR : EC 0x%02x IL 0x%x ISS 0x%08x\n", (SystemContext.SystemContextAArch64->ESR & 0xFC000000) >> 26, (SystemContext.SystemContextAArch64->ESR >> 25) & 0x1, SystemContext.SystemContextAArch64->ESR & 0x1FFFFFF ));
|
DEBUG ((DEBUG_ERROR, "\n ESR : EC 0x%02x IL 0x%x ISS 0x%08x\n", (SystemContext.SystemContextAArch64->ESR & 0xFC000000) >> 26, (SystemContext.SystemContextAArch64->ESR >> 25) & 0x1, SystemContext.SystemContextAArch64->ESR & 0x1FFFFFF));
|
||||||
|
|
||||||
DescribeExceptionSyndrome (SystemContext.SystemContextAArch64->ESR);
|
DescribeExceptionSyndrome (SystemContext.SystemContextAArch64->ESR);
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR, "\nStack dump:\n"));
|
DEBUG ((DEBUG_ERROR, "\nStack dump:\n"));
|
||||||
for (Offset = -256; Offset < 256; Offset += 32) {
|
for (Offset = -256; Offset < 256; Offset += 32) {
|
||||||
DEBUG ((EFI_D_ERROR, "%c %013lx: %016lx %016lx %016lx %016lx\n",
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"%c %013lx: %016lx %016lx %016lx %016lx\n",
|
||||||
Offset == 0 ? '>' : ' ',
|
Offset == 0 ? '>' : ' ',
|
||||||
SystemContext.SystemContextAArch64->SP + Offset,
|
SystemContext.SystemContextAArch64->SP + Offset,
|
||||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset),
|
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset),
|
||||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 8),
|
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 8),
|
||||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 16),
|
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 16),
|
||||||
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24)));
|
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
|
@ -134,22 +134,38 @@ FaultStatusToString (
|
|||||||
CHAR8 *FaultSource;
|
CHAR8 *FaultSource;
|
||||||
|
|
||||||
switch (Status) {
|
switch (Status) {
|
||||||
case 0x01: FaultSource = "Alignment fault"; break;
|
case 0x01: FaultSource = "Alignment fault";
|
||||||
case 0x02: FaultSource = "Debug event fault"; break;
|
break;
|
||||||
case 0x03: FaultSource = "Access Flag fault on Section"; break;
|
case 0x02: FaultSource = "Debug event fault";
|
||||||
case 0x04: FaultSource = "Cache maintenance operation fault[2]"; break;
|
break;
|
||||||
case 0x05: FaultSource = "Translation fault on Section"; break;
|
case 0x03: FaultSource = "Access Flag fault on Section";
|
||||||
case 0x06: FaultSource = "Access Flag fault on Page"; break;
|
break;
|
||||||
case 0x07: FaultSource = "Translation fault on Page"; break;
|
case 0x04: FaultSource = "Cache maintenance operation fault[2]";
|
||||||
case 0x08: FaultSource = "Precise External Abort"; break;
|
break;
|
||||||
case 0x09: FaultSource = "Domain fault on Section"; break;
|
case 0x05: FaultSource = "Translation fault on Section";
|
||||||
case 0x0b: FaultSource = "Domain fault on Page"; break;
|
break;
|
||||||
case 0x0c: FaultSource = "External abort on translation, first level"; break;
|
case 0x06: FaultSource = "Access Flag fault on Page";
|
||||||
case 0x0d: FaultSource = "Permission fault on Section"; break;
|
break;
|
||||||
case 0x0e: FaultSource = "External abort on translation, second level"; break;
|
case 0x07: FaultSource = "Translation fault on Page";
|
||||||
case 0x0f: FaultSource = "Permission fault on Page"; break;
|
break;
|
||||||
case 0x16: FaultSource = "Imprecise External Abort"; break;
|
case 0x08: FaultSource = "Precise External Abort";
|
||||||
default: FaultSource = "No function"; break;
|
break;
|
||||||
|
case 0x09: FaultSource = "Domain fault on Section";
|
||||||
|
break;
|
||||||
|
case 0x0b: FaultSource = "Domain fault on Page";
|
||||||
|
break;
|
||||||
|
case 0x0c: FaultSource = "External abort on translation, first level";
|
||||||
|
break;
|
||||||
|
case 0x0d: FaultSource = "Permission fault on Section";
|
||||||
|
break;
|
||||||
|
case 0x0e: FaultSource = "External abort on translation, second level";
|
||||||
|
break;
|
||||||
|
case 0x0f: FaultSource = "Permission fault on Page";
|
||||||
|
break;
|
||||||
|
case 0x16: FaultSource = "Imprecise External Abort";
|
||||||
|
break;
|
||||||
|
default: FaultSource = "No function";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FaultSource;
|
return FaultSource;
|
||||||
@ -191,8 +207,14 @@ DefaultExceptionHandler (
|
|||||||
|
|
||||||
PcAdjust = 0;
|
PcAdjust = 0;
|
||||||
|
|
||||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x CPSR 0x%08x ",
|
CharCount = AsciiSPrint (
|
||||||
gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);
|
Buffer,
|
||||||
|
sizeof (Buffer),
|
||||||
|
"\n%a Exception PC at 0x%08x CPSR 0x%08x ",
|
||||||
|
gExceptionTypeString[ExceptionType],
|
||||||
|
SystemContext.SystemContextArm->PC,
|
||||||
|
SystemContext.SystemContextArm->CPSR
|
||||||
|
);
|
||||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||||
if (gST->ConOut != NULL) {
|
if (gST->ConOut != NULL) {
|
||||||
AsciiPrint (Buffer);
|
AsciiPrint (Buffer);
|
||||||
@ -210,12 +232,12 @@ DefaultExceptionHandler (
|
|||||||
UINT32 ItBlock;
|
UINT32 ItBlock;
|
||||||
|
|
||||||
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
|
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
|
||||||
DEBUG ((EFI_D_ERROR, "%a\n", CpsrStr));
|
DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));
|
||||||
|
|
||||||
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);
|
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);
|
||||||
Offset = SystemContext.SystemContextArm->PC - ImageBase;
|
Offset = SystemContext.SystemContextArm->PC - ImageBase;
|
||||||
if (Pdb != NULL) {
|
if (Pdb != NULL) {
|
||||||
DEBUG ((EFI_D_ERROR, "%a\n", Pdb));
|
DEBUG ((DEBUG_ERROR, "%a\n", Pdb));
|
||||||
|
|
||||||
//
|
//
|
||||||
// A PE/COFF image loads its headers into memory so the headers are
|
// A PE/COFF image loads its headers into memory so the headers are
|
||||||
@ -225,13 +247,13 @@ DefaultExceptionHandler (
|
|||||||
// you need to subtract out the size of the PE/COFF header to get
|
// you need to subtract out the size of the PE/COFF header to get
|
||||||
// get the offset that matches the link map.
|
// get the offset that matches the link map.
|
||||||
//
|
//
|
||||||
DEBUG ((EFI_D_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));
|
DEBUG ((DEBUG_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));
|
||||||
|
|
||||||
// If we come from an image it is safe to show the instruction. We know it should not fault
|
// If we come from an image it is safe to show the instruction. We know it should not fault
|
||||||
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
|
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
|
||||||
ItBlock = 0;
|
ItBlock = 0;
|
||||||
DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));
|
DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));
|
||||||
DEBUG ((EFI_D_ERROR, "\n%a", Buffer));
|
DEBUG ((DEBUG_ERROR, "\n%a", Buffer));
|
||||||
|
|
||||||
switch (ExceptionType) {
|
switch (ExceptionType) {
|
||||||
case EXCEPT_ARM_UNDEFINED_INSTRUCTION:
|
case EXCEPT_ARM_UNDEFINED_INSTRUCTION:
|
||||||
@ -245,28 +267,28 @@ DefaultExceptionHandler (
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_CODE_END ();
|
DEBUG_CODE_END ();
|
||||||
DEBUG ((EFI_D_ERROR, "\n R0 0x%08x R1 0x%08x R2 0x%08x R3 0x%08x\n", SystemContext.SystemContextArm->R0, SystemContext.SystemContextArm->R1, SystemContext.SystemContextArm->R2, SystemContext.SystemContextArm->R3));
|
DEBUG ((DEBUG_ERROR, "\n R0 0x%08x R1 0x%08x R2 0x%08x R3 0x%08x\n", SystemContext.SystemContextArm->R0, SystemContext.SystemContextArm->R1, SystemContext.SystemContextArm->R2, SystemContext.SystemContextArm->R3));
|
||||||
DEBUG ((EFI_D_ERROR, " R4 0x%08x R5 0x%08x R6 0x%08x R7 0x%08x\n", SystemContext.SystemContextArm->R4, SystemContext.SystemContextArm->R5, SystemContext.SystemContextArm->R6, SystemContext.SystemContextArm->R7));
|
DEBUG ((DEBUG_ERROR, " R4 0x%08x R5 0x%08x R6 0x%08x R7 0x%08x\n", SystemContext.SystemContextArm->R4, SystemContext.SystemContextArm->R5, SystemContext.SystemContextArm->R6, SystemContext.SystemContextArm->R7));
|
||||||
DEBUG ((EFI_D_ERROR, " R8 0x%08x R9 0x%08x R10 0x%08x R11 0x%08x\n", SystemContext.SystemContextArm->R8, SystemContext.SystemContextArm->R9, SystemContext.SystemContextArm->R10, SystemContext.SystemContextArm->R11));
|
DEBUG ((DEBUG_ERROR, " R8 0x%08x R9 0x%08x R10 0x%08x R11 0x%08x\n", SystemContext.SystemContextArm->R8, SystemContext.SystemContextArm->R9, SystemContext.SystemContextArm->R10, SystemContext.SystemContextArm->R11));
|
||||||
DEBUG ((EFI_D_ERROR, " R12 0x%08x SP 0x%08x LR 0x%08x PC 0x%08x\n", SystemContext.SystemContextArm->R12, SystemContext.SystemContextArm->SP, SystemContext.SystemContextArm->LR, SystemContext.SystemContextArm->PC));
|
DEBUG ((DEBUG_ERROR, " R12 0x%08x SP 0x%08x LR 0x%08x PC 0x%08x\n", SystemContext.SystemContextArm->R12, SystemContext.SystemContextArm->SP, SystemContext.SystemContextArm->LR, SystemContext.SystemContextArm->PC));
|
||||||
DEBUG ((EFI_D_ERROR, "DFSR 0x%08x DFAR 0x%08x IFSR 0x%08x IFAR 0x%08x\n", SystemContext.SystemContextArm->DFSR, SystemContext.SystemContextArm->DFAR, SystemContext.SystemContextArm->IFSR, SystemContext.SystemContextArm->IFAR));
|
DEBUG ((DEBUG_ERROR, "DFSR 0x%08x DFAR 0x%08x IFSR 0x%08x IFAR 0x%08x\n", SystemContext.SystemContextArm->DFSR, SystemContext.SystemContextArm->DFAR, SystemContext.SystemContextArm->IFSR, SystemContext.SystemContextArm->IFAR));
|
||||||
|
|
||||||
// Bit10 is Status[4] Bit3:0 is Status[3:0]
|
// Bit10 is Status[4] Bit3:0 is Status[3:0]
|
||||||
DfsrStatus = (SystemContext.SystemContextArm->DFSR & 0xf) | ((SystemContext.SystemContextArm->DFSR >> 6) & 0x10);
|
DfsrStatus = (SystemContext.SystemContextArm->DFSR & 0xf) | ((SystemContext.SystemContextArm->DFSR >> 6) & 0x10);
|
||||||
DfsrWrite = (SystemContext.SystemContextArm->DFSR & BIT11) != 0;
|
DfsrWrite = (SystemContext.SystemContextArm->DFSR & BIT11) != 0;
|
||||||
if (DfsrStatus != 0x00) {
|
if (DfsrStatus != 0x00) {
|
||||||
DEBUG ((EFI_D_ERROR, " %a: %a 0x%08x\n", FaultStatusToString (DfsrStatus), DfsrWrite ? "write to" : "read from", SystemContext.SystemContextArm->DFAR));
|
DEBUG ((DEBUG_ERROR, " %a: %a 0x%08x\n", FaultStatusToString (DfsrStatus), DfsrWrite ? "write to" : "read from", SystemContext.SystemContextArm->DFAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
IfsrStatus = (SystemContext.SystemContextArm->IFSR & 0xf) | ((SystemContext.SystemContextArm->IFSR >> 6) & 0x10);
|
IfsrStatus = (SystemContext.SystemContextArm->IFSR & 0xf) | ((SystemContext.SystemContextArm->IFSR >> 6) & 0x10);
|
||||||
if (IfsrStatus != 0) {
|
if (IfsrStatus != 0) {
|
||||||
DEBUG ((EFI_D_ERROR, " Instruction %a at 0x%08x\n", FaultStatusToString (SystemContext.SystemContextArm->IFSR & 0xf), SystemContext.SystemContextArm->IFAR));
|
DEBUG ((DEBUG_ERROR, " Instruction %a at 0x%08x\n", FaultStatusToString (SystemContext.SystemContextArm->IFSR & 0xf), SystemContext.SystemContextArm->IFAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR, "\n"));
|
DEBUG ((DEBUG_ERROR, "\n"));
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
|
|
||||||
CpuDeadLoop (); // may return if executing under a debugger
|
CpuDeadLoop (); // may return if executing under a debugger
|
||||||
|
@ -53,9 +53,11 @@ GetImageName (
|
|||||||
for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
|
for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
|
||||||
if (DebugTable->NormalImage != NULL) {
|
if (DebugTable->NormalImage != NULL) {
|
||||||
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
|
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
|
||||||
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
|
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL))
|
||||||
|
{
|
||||||
if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
|
if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
|
||||||
(Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {
|
(Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize)))
|
||||||
|
{
|
||||||
*ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
|
*ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
|
||||||
*PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);
|
*PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);
|
||||||
return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
|
return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
|
||||||
@ -66,4 +68,3 @@ GetImageName (
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ PlatformRegisterFvBootOption (
|
|||||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
EfiBootManagerFreeLoadOption (&NewOption);
|
EfiBootManagerFreeLoadOption (&NewOption);
|
||||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@ IsOpteePresent (
|
|||||||
if ((ArmSmcArgs.Arg0 == OPTEE_OS_UID0) &&
|
if ((ArmSmcArgs.Arg0 == OPTEE_OS_UID0) &&
|
||||||
(ArmSmcArgs.Arg1 == OPTEE_OS_UID1) &&
|
(ArmSmcArgs.Arg1 == OPTEE_OS_UID1) &&
|
||||||
(ArmSmcArgs.Arg2 == OPTEE_OS_UID2) &&
|
(ArmSmcArgs.Arg2 == OPTEE_OS_UID2) &&
|
||||||
(ArmSmcArgs.Arg3 == OPTEE_OS_UID3)) {
|
(ArmSmcArgs.Arg3 == OPTEE_OS_UID3))
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -441,7 +442,8 @@ OpteeInvokeFunction (
|
|||||||
InvokeFunctionArg->Params,
|
InvokeFunctionArg->Params,
|
||||||
OPTEE_MAX_CALL_PARAMS,
|
OPTEE_MAX_CALL_PARAMS,
|
||||||
MessageArg->Params
|
MessageArg->Params
|
||||||
) != 0) {
|
) != 0)
|
||||||
|
{
|
||||||
MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
|
MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
|
||||||
MessageArg->ReturnOrigin = OPTEE_ORIGIN_COMMUNICATION;
|
MessageArg->ReturnOrigin = OPTEE_ORIGIN_COMMUNICATION;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,6 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#pragma pack (1)
|
#pragma pack (1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
USB_CLASS_DEVICE_PATH Keyboard;
|
USB_CLASS_DEVICE_PATH Keyboard;
|
||||||
@ -124,7 +123,6 @@ STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check if the handle satisfies a particular condition.
|
Check if the handle satisfies a particular condition.
|
||||||
|
|
||||||
@ -143,7 +141,6 @@ BOOLEAN
|
|||||||
IN CONST CHAR16 *ReportText
|
IN CONST CHAR16 *ReportText
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Process a handle.
|
Process a handle.
|
||||||
|
|
||||||
@ -184,14 +181,24 @@ FilterAndProcess (
|
|||||||
UINTN NoHandles;
|
UINTN NoHandles;
|
||||||
UINTN Idx;
|
UINTN Idx;
|
||||||
|
|
||||||
Status = gBS->LocateHandleBuffer (ByProtocol, ProtocolGuid,
|
Status = gBS->LocateHandleBuffer (
|
||||||
NULL /* SearchKey */, &NoHandles, &Handles);
|
ByProtocol,
|
||||||
|
ProtocolGuid,
|
||||||
|
NULL /* SearchKey */,
|
||||||
|
&NoHandles,
|
||||||
|
&Handles
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// This is not an error, just an informative condition.
|
// This is not an error, just an informative condition.
|
||||||
//
|
//
|
||||||
DEBUG ((EFI_D_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid,
|
DEBUG ((
|
||||||
Status));
|
DEBUG_VERBOSE,
|
||||||
|
"%a: %g: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ProtocolGuid,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +219,7 @@ FilterAndProcess (
|
|||||||
DevicePathText = Fallback;
|
DevicePathText = Fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Filter == NULL || Filter (Handles[Idx], DevicePathText)) {
|
if ((Filter == NULL) || Filter (Handles[Idx], DevicePathText)) {
|
||||||
Process (Handles[Idx], DevicePathText);
|
Process (Handles[Idx], DevicePathText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,10 +227,10 @@ FilterAndProcess (
|
|||||||
FreePool (DevicePathText);
|
FreePool (DevicePathText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (Handles);
|
gBS->FreePool (Handles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This FILTER_FUNCTION checks if a handle corresponds to a PCI display device.
|
This FILTER_FUNCTION checks if a handle corresponds to a PCI display device.
|
||||||
**/
|
**/
|
||||||
@ -239,8 +246,11 @@ IsPciDisplay (
|
|||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
PCI_TYPE00 Pci;
|
PCI_TYPE00 Pci;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (Handle, &gEfiPciIoProtocolGuid,
|
Status = gBS->HandleProtocol (
|
||||||
(VOID**)&PciIo);
|
Handle,
|
||||||
|
&gEfiPciIoProtocolGuid,
|
||||||
|
(VOID **)&PciIo
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// This is not an error worth reporting.
|
// This is not an error worth reporting.
|
||||||
@ -248,17 +258,21 @@ IsPciDisplay (
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0 /* Offset */,
|
Status = PciIo->Pci.Read (
|
||||||
sizeof Pci / sizeof (UINT32), &Pci);
|
PciIo,
|
||||||
|
EfiPciIoWidthUint32,
|
||||||
|
0 /* Offset */,
|
||||||
|
sizeof Pci / sizeof (UINT32),
|
||||||
|
&Pci
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((EFI_D_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));
|
DEBUG ((DEBUG_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return IS_PCI_DISPLAY (&Pci);
|
return IS_PCI_DISPLAY (&Pci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This FILTER_FUNCTION checks if a handle corresponds to a non-discoverable
|
This FILTER_FUNCTION checks if a handle corresponds to a non-discoverable
|
||||||
USB host controller.
|
USB host controller.
|
||||||
@ -274,22 +288,25 @@ IsUsbHost (
|
|||||||
NON_DISCOVERABLE_DEVICE *Device;
|
NON_DISCOVERABLE_DEVICE *Device;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (Handle,
|
Status = gBS->HandleProtocol (
|
||||||
|
Handle,
|
||||||
&gEdkiiNonDiscoverableDeviceProtocolGuid,
|
&gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||||
(VOID **)&Device);
|
(VOID **)&Device
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CompareGuid (Device->Type, &gEdkiiNonDiscoverableUhciDeviceGuid) ||
|
if (CompareGuid (Device->Type, &gEdkiiNonDiscoverableUhciDeviceGuid) ||
|
||||||
CompareGuid (Device->Type, &gEdkiiNonDiscoverableEhciDeviceGuid) ||
|
CompareGuid (Device->Type, &gEdkiiNonDiscoverableEhciDeviceGuid) ||
|
||||||
CompareGuid (Device->Type, &gEdkiiNonDiscoverableXhciDeviceGuid)) {
|
CompareGuid (Device->Type, &gEdkiiNonDiscoverableXhciDeviceGuid))
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
|
This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
|
||||||
the matching driver to produce all first-level child handles.
|
the matching driver to produce all first-level child handles.
|
||||||
@ -310,11 +327,15 @@ Connect (
|
|||||||
NULL, // RemainingDevicePath -- produce all children
|
NULL, // RemainingDevicePath -- produce all children
|
||||||
FALSE // Recursive
|
FALSE // Recursive
|
||||||
);
|
);
|
||||||
DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE, "%a: %s: %r\n",
|
DEBUG ((
|
||||||
__FUNCTION__, ReportText, Status));
|
EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,
|
||||||
|
"%a: %s: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText,
|
||||||
|
Status
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
|
This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
|
||||||
handle, and adds it to ConOut and ErrOut.
|
handle, and adds it to ConOut and ErrOut.
|
||||||
@ -332,27 +353,46 @@ AddOutput (
|
|||||||
|
|
||||||
DevicePath = DevicePathFromHandle (Handle);
|
DevicePath = DevicePathFromHandle (Handle);
|
||||||
if (DevicePath == NULL) {
|
if (DevicePath == NULL) {
|
||||||
DEBUG ((EFI_D_ERROR, "%a: %s: handle %p: device path not found\n",
|
DEBUG ((
|
||||||
__FUNCTION__, ReportText, Handle));
|
DEBUG_ERROR,
|
||||||
|
"%a: %s: handle %p: device path not found\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText,
|
||||||
|
Handle
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
|
Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((EFI_D_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,
|
DEBUG ((
|
||||||
ReportText, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: %s: adding to ConOut: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
|
Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((EFI_D_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,
|
DEBUG ((
|
||||||
ReportText, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: %s: adding to ErrOut: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((EFI_D_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,
|
DEBUG ((
|
||||||
ReportText));
|
DEBUG_VERBOSE,
|
||||||
|
"%a: %s: added to ConOut and ErrOut\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
@ -403,25 +443,33 @@ PlatformRegisterFvBootOption (
|
|||||||
FreePool (DevicePath);
|
FreePool (DevicePath);
|
||||||
|
|
||||||
BootOptions = EfiBootManagerGetLoadOptions (
|
BootOptions = EfiBootManagerGetLoadOptions (
|
||||||
&BootOptionCount, LoadOptionTypeBoot
|
&BootOptionCount,
|
||||||
|
LoadOptionTypeBoot
|
||||||
);
|
);
|
||||||
|
|
||||||
OptionIndex = EfiBootManagerFindLoadOption (
|
OptionIndex = EfiBootManagerFindLoadOption (
|
||||||
&NewOption, BootOptions, BootOptionCount
|
&NewOption,
|
||||||
|
BootOptions,
|
||||||
|
BootOptionCount
|
||||||
);
|
);
|
||||||
|
|
||||||
if (OptionIndex == -1) {
|
if (OptionIndex == -1) {
|
||||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
Status = EfiBootManagerAddKeyOptionVariable (NULL,
|
Status = EfiBootManagerAddKeyOptionVariable (
|
||||||
(UINT16)NewOption.OptionNumber, 0, Key, NULL);
|
NULL,
|
||||||
|
(UINT16)NewOption.OptionNumber,
|
||||||
|
0,
|
||||||
|
Key,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
EfiBootManagerFreeLoadOption (&NewOption);
|
EfiBootManagerFreeLoadOption (&NewOption);
|
||||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
GetPlatformOptions (
|
GetPlatformOptions (
|
||||||
@ -437,11 +485,15 @@ GetPlatformOptions (
|
|||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINTN BootCount;
|
UINTN BootCount;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gPlatformBootManagerProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&PlatformBootManager);
|
&gPlatformBootManagerProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&PlatformBootManager
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = PlatformBootManager->GetPlatformBootOptionsAndKeys (
|
Status = PlatformBootManager->GetPlatformBootOptionsAndKeys (
|
||||||
&BootCount,
|
&BootCount,
|
||||||
&BootOptions,
|
&BootOptions,
|
||||||
@ -450,6 +502,7 @@ GetPlatformOptions (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fetch the existent boot options. If there are none, CurrentBootCount
|
// Fetch the existent boot options. If there are none, CurrentBootCount
|
||||||
// will be zeroed.
|
// will be zeroed.
|
||||||
@ -491,10 +544,16 @@ GetPlatformOptions (
|
|||||||
MAX_UINTN
|
MAX_UINTN
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: failed to register \"%s\": %r\n",
|
DEBUG ((
|
||||||
__FUNCTION__, BootOptions[Index].Description, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: failed to register \"%s\": %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
BootOptions[Index].Description,
|
||||||
|
Status
|
||||||
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BootOptionNumber = BootOptions[Index].OptionNumber;
|
BootOptionNumber = BootOptions[Index].OptionNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,10 +572,16 @@ GetPlatformOptions (
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: failed to register hotkey for \"%s\": %r\n",
|
DEBUG ((
|
||||||
__FUNCTION__, BootOptions[Index].Description, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: failed to register hotkey for \"%s\": %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
BootOptions[Index].Description,
|
||||||
|
Status
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EfiBootManagerFreeLoadOptions (CurrentBootOptions, CurrentBootOptionCount);
|
EfiBootManagerFreeLoadOptions (CurrentBootOptions, CurrentBootOptionCount);
|
||||||
EfiBootManagerFreeLoadOptions (BootOptions, BootCount);
|
EfiBootManagerFreeLoadOptions (BootOptions, BootCount);
|
||||||
FreePool (BootKeys);
|
FreePool (BootKeys);
|
||||||
@ -554,19 +619,27 @@ PlatformRegisterOptionsAndKeys (
|
|||||||
Status = EfiBootManagerGetBootManagerMenu (&BootOption);
|
Status = EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
Status = EfiBootManagerAddKeyOptionVariable (
|
Status = EfiBootManagerAddKeyOptionVariable (
|
||||||
NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
|
NULL,
|
||||||
|
(UINT16)BootOption.OptionNumber,
|
||||||
|
0,
|
||||||
|
&F2,
|
||||||
|
NULL
|
||||||
);
|
);
|
||||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||||
Status = EfiBootManagerAddKeyOptionVariable (
|
Status = EfiBootManagerAddKeyOptionVariable (
|
||||||
NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
|
NULL,
|
||||||
|
(UINT16)BootOption.OptionNumber,
|
||||||
|
0,
|
||||||
|
&Esc,
|
||||||
|
NULL
|
||||||
);
|
);
|
||||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// BDS Platform Functions
|
// BDS Platform Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Do the platform init, can be customized by OEM/IBV
|
Do the platform init, can be customized by OEM/IBV
|
||||||
Possible things that can be done in PlatformBootManagerBeforeConsole:
|
Possible things that can be done in PlatformBootManagerBeforeConsole:
|
||||||
@ -626,27 +699,45 @@ PlatformBootManagerBeforeConsole (
|
|||||||
//
|
//
|
||||||
// Add the hardcoded short-form USB keyboard device path to ConIn.
|
// Add the hardcoded short-form USB keyboard device path to ConIn.
|
||||||
//
|
//
|
||||||
EfiBootManagerUpdateConsoleVariable (ConIn,
|
EfiBootManagerUpdateConsoleVariable (
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard, NULL);
|
ConIn,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
|
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
|
||||||
//
|
//
|
||||||
STATIC_ASSERT (FixedPcdGet8 (PcdDefaultTerminalType) == 4,
|
STATIC_ASSERT (
|
||||||
"PcdDefaultTerminalType must be TTYTERM");
|
FixedPcdGet8 (PcdDefaultTerminalType) == 4,
|
||||||
STATIC_ASSERT (FixedPcdGet8 (PcdUartDefaultParity) != 0,
|
"PcdDefaultTerminalType must be TTYTERM"
|
||||||
"PcdUartDefaultParity must be set to an actual value, not 'default'");
|
);
|
||||||
STATIC_ASSERT (FixedPcdGet8 (PcdUartDefaultStopBits) != 0,
|
STATIC_ASSERT (
|
||||||
"PcdUartDefaultStopBits must be set to an actual value, not 'default'");
|
FixedPcdGet8 (PcdUartDefaultParity) != 0,
|
||||||
|
"PcdUartDefaultParity must be set to an actual value, not 'default'"
|
||||||
|
);
|
||||||
|
STATIC_ASSERT (
|
||||||
|
FixedPcdGet8 (PcdUartDefaultStopBits) != 0,
|
||||||
|
"PcdUartDefaultStopBits must be set to an actual value, not 'default'"
|
||||||
|
);
|
||||||
|
|
||||||
CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);
|
CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);
|
||||||
|
|
||||||
EfiBootManagerUpdateConsoleVariable (ConIn,
|
EfiBootManagerUpdateConsoleVariable (
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
ConIn,
|
||||||
EfiBootManagerUpdateConsoleVariable (ConOut,
|
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
NULL
|
||||||
EfiBootManagerUpdateConsoleVariable (ErrOut,
|
);
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
EfiBootManagerUpdateConsoleVariable (
|
||||||
|
ConOut,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
EfiBootManagerUpdateConsoleVariable (
|
||||||
|
ErrOut,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register platform-specific boot options and keyboard shortcuts.
|
// Register platform-specific boot options and keyboard shortcuts.
|
||||||
@ -668,8 +759,11 @@ HandleCapsules (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__));
|
DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__));
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&EsrtManagement);
|
&gEsrtManagementProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&EsrtManagement
|
||||||
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
EsrtManagement->SyncEsrtFmp ();
|
EsrtManagement->SyncEsrtFmp ();
|
||||||
}
|
}
|
||||||
@ -679,14 +773,22 @@ HandleCapsules (
|
|||||||
//
|
//
|
||||||
HobPointer.Raw = GetHobList ();
|
HobPointer.Raw = GetHobList ();
|
||||||
NeedReset = FALSE;
|
NeedReset = FALSE;
|
||||||
while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE,
|
while ((HobPointer.Raw = GetNextHob (
|
||||||
HobPointer.Raw)) != NULL) {
|
EFI_HOB_TYPE_UEFI_CAPSULE,
|
||||||
|
HobPointer.Raw
|
||||||
|
)) != NULL)
|
||||||
|
{
|
||||||
CapsuleHeader = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress;
|
CapsuleHeader = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress;
|
||||||
|
|
||||||
Status = ProcessCapsuleImage (CapsuleHeader);
|
Status = ProcessCapsuleImage (CapsuleHeader);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: failed to process capsule %p - %r\n",
|
DEBUG ((
|
||||||
__FUNCTION__, CapsuleHeader, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: failed to process capsule %p - %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
CapsuleHeader,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,15 +797,17 @@ HandleCapsules (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (NeedReset) {
|
if (NeedReset) {
|
||||||
DEBUG ((DEBUG_WARN, "%a: capsule update successful, resetting ...\n",
|
DEBUG ((
|
||||||
__FUNCTION__));
|
DEBUG_WARN,
|
||||||
|
"%a: capsule update successful, resetting ...\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
|
|
||||||
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define VERSION_STRING_PREFIX L"Tianocore/EDK2 firmware version "
|
#define VERSION_STRING_PREFIX L"Tianocore/EDK2 firmware version "
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -776,8 +880,12 @@ BootDiscoveryPolicyHandler (
|
|||||||
(VOID **)&BMPolicy
|
(VOID **)&BMPolicy
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_INFO, "%a - Failed to locate gEfiBootManagerPolicyProtocolGuid."
|
DEBUG ((
|
||||||
"Driver connect will be skipped.\n", __FUNCTION__));
|
DEBUG_INFO,
|
||||||
|
"%a - Failed to locate gEfiBootManagerPolicyProtocolGuid."
|
||||||
|
"Driver connect will be skipped.\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -845,21 +953,33 @@ PlatformBootManagerAfterConsole (
|
|||||||
Status = BootLogoEnableLogo ();
|
Status = BootLogoEnableLogo ();
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
if (FirmwareVerLength > 0) {
|
if (FirmwareVerLength > 0) {
|
||||||
Print (VERSION_STRING_PREFIX L"%s\n",
|
Print (
|
||||||
PcdGetPtr (PcdFirmwareVersionString));
|
VERSION_STRING_PREFIX L"%s\n",
|
||||||
|
PcdGetPtr (PcdFirmwareVersionString)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Print (L"Press ESCAPE for boot options ");
|
Print (L"Press ESCAPE for boot options ");
|
||||||
} else if (FirmwareVerLength > 0) {
|
} else if (FirmwareVerLength > 0) {
|
||||||
Status = gBS->HandleProtocol (gST->ConsoleOutHandle,
|
Status = gBS->HandleProtocol (
|
||||||
&gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
|
gST->ConsoleOutHandle,
|
||||||
|
&gEfiGraphicsOutputProtocolGuid,
|
||||||
|
(VOID **)&GraphicsOutput
|
||||||
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
PosX = (GraphicsOutput->Mode->Info->HorizontalResolution -
|
PosX = (GraphicsOutput->Mode->Info->HorizontalResolution -
|
||||||
(StrLen (VERSION_STRING_PREFIX) + FirmwareVerLength) *
|
(StrLen (VERSION_STRING_PREFIX) + FirmwareVerLength) *
|
||||||
EFI_GLYPH_WIDTH) / 2;
|
EFI_GLYPH_WIDTH) / 2;
|
||||||
PosY = 0;
|
PosY = 0;
|
||||||
|
|
||||||
PrintXY (PosX, PosY, NULL, NULL, VERSION_STRING_PREFIX L"%s",
|
PrintXY (
|
||||||
PcdGetPtr (PcdFirmwareVersionString));
|
PosX,
|
||||||
|
PosY,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
VERSION_STRING_PREFIX L"%s",
|
||||||
|
PcdGetPtr (PcdFirmwareVersionString)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -943,8 +1063,10 @@ PlatformBootManagerUnableToBoot (
|
|||||||
//
|
//
|
||||||
// Record the total number of boot configured boot options
|
// Record the total number of boot configured boot options
|
||||||
//
|
//
|
||||||
BootOptions = EfiBootManagerGetLoadOptions (&OldBootOptionCount,
|
BootOptions = EfiBootManagerGetLoadOptions (
|
||||||
LoadOptionTypeBoot);
|
&OldBootOptionCount,
|
||||||
|
LoadOptionTypeBoot
|
||||||
|
);
|
||||||
EfiBootManagerFreeLoadOptions (BootOptions, OldBootOptionCount);
|
EfiBootManagerFreeLoadOptions (BootOptions, OldBootOptionCount);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -956,8 +1078,10 @@ PlatformBootManagerUnableToBoot (
|
|||||||
//
|
//
|
||||||
// Record the updated number of boot configured boot options
|
// Record the updated number of boot configured boot options
|
||||||
//
|
//
|
||||||
BootOptions = EfiBootManagerGetLoadOptions (&NewBootOptionCount,
|
BootOptions = EfiBootManagerGetLoadOptions (
|
||||||
LoadOptionTypeBoot);
|
&NewBootOptionCount,
|
||||||
|
LoadOptionTypeBoot
|
||||||
|
);
|
||||||
EfiBootManagerFreeLoadOptions (BootOptions, NewBootOptionCount);
|
EfiBootManagerFreeLoadOptions (BootOptions, NewBootOptionCount);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -969,8 +1093,11 @@ PlatformBootManagerUnableToBoot (
|
|||||||
//
|
//
|
||||||
if (!PcdGetBool (PcdEmuVariableNvModeEnable)) {
|
if (!PcdGetBool (PcdEmuVariableNvModeEnable)) {
|
||||||
if (NewBootOptionCount != OldBootOptionCount) {
|
if (NewBootOptionCount != OldBootOptionCount) {
|
||||||
DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot options\n",
|
DEBUG ((
|
||||||
__FUNCTION__));
|
DEBUG_WARN,
|
||||||
|
"%a: rebooting after refreshing all boot options\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ WriteStringToFile (
|
|||||||
// This gets you all the symbols except for SEC. To get SEC symbols you need to copy the
|
// This gets you all the symbols except for SEC. To get SEC symbols you need to copy the
|
||||||
// debug print in the SEC into the debugger manually
|
// debug print in the SEC into the debugger manually
|
||||||
SemihostWriteString (Buffer);
|
SemihostWriteString (Buffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
I'm currently having issues with this code crashing the debugger. Seems like it should work.
|
I'm currently having issues with this code crashing the debugger. Seems like it should work.
|
||||||
|
|
||||||
@ -51,7 +52,6 @@ WriteStringToFile (
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
If the build is done on cygwin the paths are cygpaths.
|
If the build is done on cygwin the paths are cygpaths.
|
||||||
/cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
|
/cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
|
||||||
@ -95,7 +95,6 @@ DeCygwinPathIfNeeded (
|
|||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
||||||
|
|
||||||
@ -123,8 +122,6 @@ PeCoffLoaderRelocateImageExtraAction (
|
|||||||
WriteStringToFile (Buffer, AsciiStrSize (Buffer));
|
WriteStringToFile (Buffer, AsciiStrSize (Buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/PrintLib.h>
|
#include <Library/PrintLib.h>
|
||||||
@ -56,7 +55,6 @@ DebugPrint (
|
|||||||
VA_END (Marker);
|
VA_END (Marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Prints a debug message to the debug output device if the specified
|
Prints a debug message to the debug output device if the specified
|
||||||
error level is enabled base on Null-terminated format string and a
|
error level is enabled base on Null-terminated format string and a
|
||||||
@ -108,7 +106,6 @@ DebugPrintMarker (
|
|||||||
SemihostWriteString (AsciiBuffer);
|
SemihostWriteString (AsciiBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Prints a debug message to the debug output device if the specified
|
Prints a debug message to the debug output device if the specified
|
||||||
error level is enabled.
|
error level is enabled.
|
||||||
@ -135,7 +132,6 @@ DebugVPrint (
|
|||||||
DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
|
DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Prints a debug message to the debug output device if the specified
|
Prints a debug message to the debug output device if the specified
|
||||||
error level is enabled.
|
error level is enabled.
|
||||||
@ -164,7 +160,6 @@ DebugBPrint (
|
|||||||
DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
|
DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Prints an assert message containing a filename, line number, and description.
|
Prints an assert message containing a filename, line number, and description.
|
||||||
@ -215,7 +210,6 @@ DebugAssert (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
|
Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
|
||||||
@ -251,7 +245,6 @@ DebugClearMemory (
|
|||||||
return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
|
return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Returns TRUE if ASSERT() macros are enabled.
|
Returns TRUE if ASSERT() macros are enabled.
|
||||||
@ -272,7 +265,6 @@ DebugAssertEnabled (
|
|||||||
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
|
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Returns TRUE if DEBUG()macros are enabled.
|
Returns TRUE if DEBUG()macros are enabled.
|
||||||
@ -293,7 +285,6 @@ DebugPrintEnabled (
|
|||||||
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
|
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Returns TRUE if DEBUG_CODE()macros are enabled.
|
Returns TRUE if DEBUG_CODE()macros are enabled.
|
||||||
@ -314,7 +305,6 @@ DebugCodeEnabled (
|
|||||||
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
|
return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.
|
Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include <Library/SemihostLib.h>
|
#include <Library/SemihostLib.h>
|
||||||
#include <Library/SerialPortLib.h>
|
#include <Library/SerialPortLib.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Programmed hardware of Serial port.
|
Programmed hardware of Serial port.
|
||||||
@ -63,12 +62,10 @@ SerialPortWrite (
|
|||||||
SourceIndex = 0;
|
SourceIndex = 0;
|
||||||
DestinationIndex = 0;
|
DestinationIndex = 0;
|
||||||
|
|
||||||
while (SourceIndex < NumberOfBytes)
|
while (SourceIndex < NumberOfBytes) {
|
||||||
{
|
|
||||||
CurrentCharacter = Buffer[SourceIndex++];
|
CurrentCharacter = Buffer[SourceIndex++];
|
||||||
|
|
||||||
switch (CurrentCharacter)
|
switch (CurrentCharacter) {
|
||||||
{
|
|
||||||
case '\r':
|
case '\r':
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -81,8 +78,7 @@ SerialPortWrite (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DestinationIndex > PRINT_BUFFER_THRESHOLD)
|
if (DestinationIndex > PRINT_BUFFER_THRESHOLD) {
|
||||||
{
|
|
||||||
PrintBuffer[DestinationIndex] = '\0';
|
PrintBuffer[DestinationIndex] = '\0';
|
||||||
SemihostWriteString ((CHAR8 *)PrintBuffer);
|
SemihostWriteString ((CHAR8 *)PrintBuffer);
|
||||||
|
|
||||||
@ -90,8 +86,7 @@ SerialPortWrite (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DestinationIndex > 0)
|
if (DestinationIndex > 0) {
|
||||||
{
|
|
||||||
PrintBuffer[DestinationIndex] = '\0';
|
PrintBuffer[DestinationIndex] = '\0';
|
||||||
SemihostWriteString ((CHAR8 *)PrintBuffer);
|
SemihostWriteString ((CHAR8 *)PrintBuffer);
|
||||||
}
|
}
|
||||||
@ -99,7 +94,6 @@ SerialPortWrite (
|
|||||||
return NumberOfBytes;
|
return NumberOfBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read data from serial device and save the datas in buffer.
|
Read data from serial device and save the datas in buffer.
|
||||||
|
|
||||||
@ -121,8 +115,6 @@ SerialPortRead (
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if any data is available to be read from the debug device.
|
Check to see if any data is available to be read from the debug device.
|
||||||
|
|
||||||
@ -139,4 +131,3 @@ SerialPortPoll (
|
|||||||
// Since SemiHosting read character is blocking always say we have a char ready?
|
// Since SemiHosting read character is blocking always say we have a char ready?
|
||||||
return SemihostConnectionSupported ();
|
return SemihostConnectionSupported ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,11 +124,12 @@ SemihostFileWrite (
|
|||||||
|
|
||||||
*Length = SEMIHOST_SYS_WRITE (&WriteBlock);
|
*Length = SEMIHOST_SYS_WRITE (&WriteBlock);
|
||||||
|
|
||||||
if (*Length != 0)
|
if (*Length != 0) {
|
||||||
return RETURN_ABORTED;
|
return RETURN_ABORTED;
|
||||||
else
|
} else {
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
SemihostFileClose (
|
SemihostFileClose (
|
||||||
|
@ -256,6 +256,7 @@ ArmSetMemoryRegionNoExec (
|
|||||||
MemoryAttributes | CodePermission
|
MemoryAttributes | CodePermission
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +279,7 @@ ArmClearMemoryRegionNoExec (
|
|||||||
MemoryAttributes & ~CodePermission
|
MemoryAttributes & ~CodePermission
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,6 +302,7 @@ ArmSetMemoryRegionReadOnly (
|
|||||||
MemoryAttributes | DataPermission
|
MemoryAttributes | DataPermission
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,13 +318,16 @@ ArmClearMemoryRegionReadOnly (
|
|||||||
|
|
||||||
Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
|
Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
PermissionRequest = SET_MEM_ATTR_MAKE_PERM_REQUEST (SET_MEM_ATTR_DATA_PERM_RW,
|
PermissionRequest = SET_MEM_ATTR_MAKE_PERM_REQUEST (
|
||||||
MemoryAttributes);
|
SET_MEM_ATTR_DATA_PERM_RW,
|
||||||
|
MemoryAttributes
|
||||||
|
);
|
||||||
return RequestMemoryPermissionChange (
|
return RequestMemoryPermissionChange (
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
Length,
|
Length,
|
||||||
PermissionRequest
|
PermissionRequest
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user