Compare commits
1320 Commits
edk2-stabl
...
edk2-stabl
Author | SHA1 | Date | |
---|---|---|---|
|
819cfc6b42 | ||
|
00b51e0d78 | ||
|
48089f3a7c | ||
|
eaffa1d7ff | ||
|
1d76560146 | ||
|
98e9d29e06 | ||
|
055c7bd1a7 | ||
|
991515a058 | ||
|
e91bfffd4f | ||
|
46226fb5d3 | ||
|
c0aeb92663 | ||
|
dfa6147a79 | ||
|
2bead79cfc | ||
|
b2ff8e45db | ||
|
4b5faa5775 | ||
|
43e0ede26b | ||
|
f0d3e59754 | ||
|
bdf3142eb7 | ||
|
20193b20b5 | ||
|
bf1ff73c8c | ||
|
cea8e3b513 | ||
|
ea7a37d352 | ||
|
9b9b331e0f | ||
|
5e1900f266 | ||
|
174a306ccd | ||
|
3af00aec7f | ||
|
c638d1f672 | ||
|
eac38f74c4 | ||
|
2a6dc1211f | ||
|
63c8d160ae | ||
|
84158d0ebe | ||
|
ac492c3ead | ||
|
81f5aa0700 | ||
|
7cede6d5f4 | ||
|
49a113a7a4 | ||
|
9d6d237c3c | ||
|
136931c4db | ||
|
3c274c0d83 | ||
|
107ddf1de9 | ||
|
2d8c17a9b6 | ||
|
bae848ee25 | ||
|
744c42bfd8 | ||
|
01ad4134c3 | ||
|
ef05145136 | ||
|
7672d1cca5 | ||
|
fa789cc68a | ||
|
5cadb8ce21 | ||
|
d11968fcc5 | ||
|
c7c1170a45 | ||
|
677f2c6f15 | ||
|
3f49462558 | ||
|
0f9fd06919 | ||
|
8543840cfd | ||
|
70f3e62dc7 | ||
|
f284981506 | ||
|
1c923b9f25 | ||
|
c7a7f09c1d | ||
|
25a6745fe8 | ||
|
dcf05f958e | ||
|
5309ddc83b | ||
|
925c445fd3 | ||
|
7427dd3fc0 | ||
|
c6b512962e | ||
|
b2de9ec5a7 | ||
|
6510dcf6f7 | ||
|
a52044a9e6 | ||
|
08aacbf056 | ||
|
4d1014093f | ||
|
39ded59c09 | ||
|
3399f64588 | ||
|
dd49d448b0 | ||
|
f220dcbba8 | ||
|
cc13dcc576 | ||
|
33d0a3cc92 | ||
|
a8a72fc1ff | ||
|
a9fc9bb466 | ||
|
fbec9aec00 | ||
|
7178047402 | ||
|
e674096acc | ||
|
ff3382a51c | ||
|
5e400d22a0 | ||
|
fc0d5922f1 | ||
|
8dab4eebe4 | ||
|
964a4f032d | ||
|
629c1dacc9 | ||
|
8bb018afaf | ||
|
243212b0d0 | ||
|
88f436883b | ||
|
63923a5642 | ||
|
96d691166f | ||
|
60475162a6 | ||
|
b164b6d149 | ||
|
98ab6e8718 | ||
|
af8859bce2 | ||
|
1fadd18d0c | ||
|
6c744465b6 | ||
|
3b74b0394d | ||
|
1b25a7049c | ||
|
cdbdd12460 | ||
|
f2188fe5d1 | ||
|
fbb6f18e1c | ||
|
065fa2dcc2 | ||
|
867851dc30 | ||
|
11dae72d3f | ||
|
775b337c78 | ||
|
4f3ddc6e15 | ||
|
8d34c7afb3 | ||
|
ad7d3ace1a | ||
|
5a13f5c2fa | ||
|
f5c987fcac | ||
|
4ceefd6dd1 | ||
|
b4394cca2d | ||
|
7132df94ac | ||
|
b4dde1ae6a | ||
|
701b5797b2 | ||
|
d706d9c64a | ||
|
ef64ae06f8 | ||
|
7b6e7d0098 | ||
|
f51967280b | ||
|
6585ced558 | ||
|
2d212083d0 | ||
|
8c99839776 | ||
|
a78938f274 | ||
|
6607062e91 | ||
|
01ac3d8b69 | ||
|
4416bf3383 | ||
|
44a3d93af3 | ||
|
1a39bdf2c5 | ||
|
ea7a3015a2 | ||
|
2f8b51d6af | ||
|
8a1f540596 | ||
|
7054f1a54e | ||
|
28eb51dd54 | ||
|
8ef7e222ae | ||
|
ab85db3260 | ||
|
81cb0371f9 | ||
|
638dfb4135 | ||
|
5542e528cd | ||
|
a21a994f55 | ||
|
4249829cf2 | ||
|
8f5ad634ad | ||
|
9df2c0a555 | ||
|
dfacaab57e | ||
|
9eb8f2c99f | ||
|
ac33eee8b8 | ||
|
5779671137 | ||
|
c301291dc3 | ||
|
5a118a61d1 | ||
|
0f612c1443 | ||
|
ea88df6b26 | ||
|
f5d851673d | ||
|
8f63f4143d | ||
|
6ee981c858 | ||
|
7c703f0a8a | ||
|
e7667b7b9a | ||
|
49f06b6640 | ||
|
37423fa344 | ||
|
420cd54993 | ||
|
f6c4b0a78e | ||
|
fcd71642df | ||
|
56f65e4bad | ||
|
a87f5fdb3d | ||
|
2d3974a351 | ||
|
92759eeb0c | ||
|
0c136bbba0 | ||
|
e4ff852136 | ||
|
ad6c8540cc | ||
|
0da3df78ff | ||
|
4a0642ad27 | ||
|
ea55bd8f66 | ||
|
4dba2a9d08 | ||
|
aad98d915a | ||
|
51bb8eb76c | ||
|
6250124de8 | ||
|
e5b515f832 | ||
|
530f5b0912 | ||
|
8314a85893 | ||
|
69abcf1e78 | ||
|
8d238f1433 | ||
|
aa3ea84407 | ||
|
c082da89cf | ||
|
67fc78d026 | ||
|
ded0b489af | ||
|
d189de3b0a | ||
|
cdd20638bc | ||
|
4bd0849d81 | ||
|
1288c5415c | ||
|
f211292711 | ||
|
c1dd400a13 | ||
|
8fbf857a0b | ||
|
4354c22f38 | ||
|
0364ccfead | ||
|
a8acc12dfd | ||
|
78262899d2 | ||
|
41abf00bf9 | ||
|
77fee3a9d8 | ||
|
07c7e68360 | ||
|
069d403587 | ||
|
b26359c176 | ||
|
d85b84e201 | ||
|
bc59ede170 | ||
|
f5137e1a54 | ||
|
2bc46e67b6 | ||
|
82b81c6464 | ||
|
897a2b447e | ||
|
5e8958472c | ||
|
ded1d5414b | ||
|
8bcddbcce2 | ||
|
8da2b97392 | ||
|
cfb4a10d76 | ||
|
08a08129ae | ||
|
7f198321ee | ||
|
937fbe4878 | ||
|
ed132ef8ae | ||
|
ea522a12b3 | ||
|
a44fef7de3 | ||
|
4ec9a6f6cd | ||
|
b38068f9f6 | ||
|
15f83fa364 | ||
|
aaf546879a | ||
|
a196b04926 | ||
|
6925150feb | ||
|
1df6658bcb | ||
|
6101bd125a | ||
|
c15941a643 | ||
|
fdc6288f81 | ||
|
ff52068d92 | ||
|
26d6ef38e7 | ||
|
69ac88cabd | ||
|
6a07d9cacf | ||
|
140e4422b1 | ||
|
bd035a066f | ||
|
7ffc433c2e | ||
|
c1e8537690 | ||
|
578a715cfc | ||
|
4e5a804222 | ||
|
9f12d6b6ec | ||
|
5bb7bfbe81 | ||
|
d15d2667d5 | ||
|
d8e5d35ede | ||
|
55bee4a9de | ||
|
0d382976c2 | ||
|
56ad09ba75 | ||
|
b4d3b77973 | ||
|
0f9283429d | ||
|
d064a6f790 | ||
|
0fba57da65 | ||
|
c19e3f578f | ||
|
cc62b85a4a | ||
|
48c53994e6 | ||
|
69e10f0211 | ||
|
9d9761af50 | ||
|
1034d223f8 | ||
|
03663c4319 | ||
|
8e934ab956 | ||
|
84d0b21d18 | ||
|
0e5aecfed1 | ||
|
86cc274941 | ||
|
0b4263a2c2 | ||
|
647cd40cf6 | ||
|
04c5b3023e | ||
|
b63e17d746 | ||
|
d4d24001f7 | ||
|
27727338b2 | ||
|
9181782c30 | ||
|
098c557023 | ||
|
c0bce66068 | ||
|
e1f5c6249a | ||
|
5258c4186f | ||
|
ba2300f97b | ||
|
0f8323b44b | ||
|
ba91d0292e | ||
|
5ce29ae84d | ||
|
c5cf7f69c9 | ||
|
0abfb0be6c | ||
|
45da4e3135 | ||
|
2900e75511 | ||
|
cafb4f3f36 | ||
|
80bc13db83 | ||
|
d322557712 | ||
|
e2607d3a78 | ||
|
0b37723186 | ||
|
2d4c76f783 | ||
|
c08a3a96fd | ||
|
083b029538 | ||
|
dea6c7dc2a | ||
|
0a0e60caf2 | ||
|
0f0422cedc | ||
|
3d50fdc5c6 | ||
|
c6bb7d54be | ||
|
782948c1a7 | ||
|
6dd64168ed | ||
|
c6382ba0f2 | ||
|
77f75c7fb8 | ||
|
b9bbb4ae93 | ||
|
dd246227d6 | ||
|
f47415e031 | ||
|
6fb2760dc8 | ||
|
81dc0d8b4c | ||
|
63887e272d | ||
|
41d7832db0 | ||
|
e6447d2a08 | ||
|
373a95532a | ||
|
ecbc394365 | ||
|
11f62f4cc0 | ||
|
c6f47e678f | ||
|
9165a7e95e | ||
|
e97b9b4e5a | ||
|
25c9d44315 | ||
|
bee67e0c14 | ||
|
ae0be176a8 | ||
|
5215cd5baf | ||
|
e6de6052a0 | ||
|
11ec5161fa | ||
|
db7e6291c0 | ||
|
6eeb58ece3 | ||
|
665fca9ee7 | ||
|
a1f6485a9b | ||
|
05762bd2e0 | ||
|
c580e27efc | ||
|
d89492456f | ||
|
8dbf868e02 | ||
|
293b97d0c4 | ||
|
4dea9e4a0e | ||
|
8e985ac3fd | ||
|
66494e5324 | ||
|
eabaeb0613 | ||
|
8bca1bb977 | ||
|
b65c0eed6b | ||
|
757f502a3b | ||
|
050d6e9434 | ||
|
128547b081 | ||
|
4ef4b81c9b | ||
|
98edce75fa | ||
|
0fc07b1c6a | ||
|
01225075db | ||
|
66803cafcf | ||
|
d7c6030a47 | ||
|
8b441847e3 | ||
|
ba634ce82b | ||
|
c844d86bee | ||
|
c3ac3301e9 | ||
|
0363584ac9 | ||
|
94c802e108 | ||
|
ff7cb2d7c9 | ||
|
5d586606c7 | ||
|
10416bf46e | ||
|
d992a05ade | ||
|
4b02045f86 | ||
|
c6c4362051 | ||
|
4d1452c599 | ||
|
1694b00511 | ||
|
92da8a154f | ||
|
a818a873e5 | ||
|
8d59bbf47e | ||
|
5de2a54b2c | ||
|
d6b42ed7ed | ||
|
832fbc6e32 | ||
|
23c71536ef | ||
|
56e9828380 | ||
|
83d77fa311 | ||
|
01b31b585e | ||
|
02990e2558 | ||
|
78f088b5a7 | ||
|
ecbcff0f49 | ||
|
d226811a66 | ||
|
95ef765839 | ||
|
e5e1cd1a83 | ||
|
04f8371cdd | ||
|
9688e231d7 | ||
|
edacc551e6 | ||
|
ce781cf8bb | ||
|
e5c7d0b017 | ||
|
f384303dc5 | ||
|
ede0bd1496 | ||
|
61e2c83424 | ||
|
5a349b96b1 | ||
|
18f463edba | ||
|
6127bf1f30 | ||
|
2c2cb23528 | ||
|
a7c8969d03 | ||
|
ed2ff315db | ||
|
3163f34a42 | ||
|
697e594fad | ||
|
9bf79303ae | ||
|
67b5dba791 | ||
|
45f5341f6d | ||
|
8f4ec0cc43 | ||
|
f433fa59d2 | ||
|
e3d2c08322 | ||
|
b16284e2a0 | ||
|
6ded9f50c3 | ||
|
797f526ae2 | ||
|
c9fb11f92f | ||
|
55b67b6950 | ||
|
d795fb571b | ||
|
42b0443599 | ||
|
5430f7f60d | ||
|
f9278458b6 | ||
|
89520115b8 | ||
|
dc5f2905eb | ||
|
b991aec050 | ||
|
51734dfc48 | ||
|
61652efd04 | ||
|
33f30cfec2 | ||
|
66f6a64dd9 | ||
|
457b4e42f7 | ||
|
84f553cb63 | ||
|
74ce342f18 | ||
|
f1d31a6ec7 | ||
|
9e7b042ecb | ||
|
1295e37d4b | ||
|
f20e35982b | ||
|
997419d16f | ||
|
ccbbb4b1c5 | ||
|
dd0b33e3e5 | ||
|
7b82da70ed | ||
|
8ba392687b | ||
|
089013a697 | ||
|
1639b6bf07 | ||
|
f2cc962cd2 | ||
|
cf4af503fb | ||
|
b27b897369 | ||
|
eb20c21fcc | ||
|
358e23c1be | ||
|
0657e74116 | ||
|
c28c16e7c4 | ||
|
1a24843ecb | ||
|
09458c2b0b | ||
|
e4af282e9f | ||
|
d0252b8fc1 | ||
|
caa389625f | ||
|
0c6d851d25 | ||
|
6405cd0304 | ||
|
d6457b3090 | ||
|
b62d7ac97b | ||
|
6c299acf48 | ||
|
cdf6ff1719 | ||
|
3e3be2cbc2 | ||
|
68c89b987f | ||
|
e5fcaeb133 | ||
|
4764aa50ef | ||
|
95f0330953 | ||
|
a257988f59 | ||
|
8d185dfb66 | ||
|
2bb6938949 | ||
|
a56ee36c49 | ||
|
728ff1da33 | ||
|
206168e83f | ||
|
cdd79996c2 | ||
|
7df447930c | ||
|
af98f1fb03 | ||
|
fb89f62d27 | ||
|
56e70968e9 | ||
|
26997800c9 | ||
|
0734975824 | ||
|
e03657dca8 | ||
|
11dd44dfbe | ||
|
7dc182ed1e | ||
|
3fab32d41d | ||
|
321240b135 | ||
|
07251f3c6a | ||
|
84d77d9bf5 | ||
|
dbe820d5fa | ||
|
4693b325e8 | ||
|
33f517445b | ||
|
fc00ff286a | ||
|
b4af23aaab | ||
|
4ca4d2b9df | ||
|
12d3d60f51 | ||
|
495809a614 | ||
|
836042ffd8 | ||
|
24e6daa2bc | ||
|
583f1aba8b | ||
|
67a6f414aa | ||
|
3323359a81 | ||
|
54051768cd | ||
|
71210053fa | ||
|
bb40c3836f | ||
|
f2f526e074 | ||
|
263782f667 | ||
|
bb5c115fa6 | ||
|
24f57f9648 | ||
|
2f499c36db | ||
|
4dca07ff0f | ||
|
eb6a748272 | ||
|
66f4b1b0d2 | ||
|
b08a19eae2 | ||
|
e9e6167123 | ||
|
6f0c65cdb0 | ||
|
53eb26b238 | ||
|
3b4d1b38ea | ||
|
e701a4d51e | ||
|
f484427d10 | ||
|
77ea6b547e | ||
|
48d642a310 | ||
|
f8b1854b92 | ||
|
35318c2eb9 | ||
|
0ee255f50a | ||
|
c4c7fb2174 | ||
|
e504b3917e | ||
|
ea1312a5b4 | ||
|
c5cd360277 | ||
|
6521e4d202 | ||
|
e3e88d90e8 | ||
|
f92a9dce10 | ||
|
6f415f8af4 | ||
|
47b1d61169 | ||
|
cc6a0cff99 | ||
|
31f0af7964 | ||
|
b697a31a8d | ||
|
8f8e4fa3f3 | ||
|
e3aba976f6 | ||
|
0cd7542a69 | ||
|
c2abf77116 | ||
|
5eb3d1bcc1 | ||
|
07e17188df | ||
|
e4b3fd905a | ||
|
82c1aa87f9 | ||
|
5eab38ad03 | ||
|
71fd87e98a | ||
|
144028626e | ||
|
c8e631588b | ||
|
2bc8545883 | ||
|
aea5930c40 | ||
|
aad9a30144 | ||
|
878cbd871d | ||
|
f7686f2727 | ||
|
aa3153b872 | ||
|
2e01a5c128 | ||
|
8727cc9a8e | ||
|
c8c6cf149d | ||
|
3b2661d247 | ||
|
cecf279c32 | ||
|
ecfe6382c1 | ||
|
661a669c81 | ||
|
14ef21e559 | ||
|
a926c6c49e | ||
|
96e8676577 | ||
|
c90cb726f8 | ||
|
b6b54367c3 | ||
|
4904a2b1ec | ||
|
563a2d2695 | ||
|
c18fbd2c31 | ||
|
da3dad181e | ||
|
d55d73152e | ||
|
b1db096575 | ||
|
1bfc89414d | ||
|
69e59545b1 | ||
|
2c93253c95 | ||
|
07fa6d1841 | ||
|
f6bd3286ed | ||
|
1f26a9e62e | ||
|
b4e2cf092a | ||
|
cf6a0a52b0 | ||
|
4f441d024b | ||
|
2e71876081 | ||
|
494127613b | ||
|
b7a8264ae4 | ||
|
f077bff840 | ||
|
f8fb208a3e | ||
|
b17a3a133b | ||
|
d6107c593b | ||
|
410ca0ff94 | ||
|
0e57170097 | ||
|
16e0969ef7 | ||
|
b05523a4e9 | ||
|
852227a9d5 | ||
|
1c4dfadb46 | ||
|
b977956a6c | ||
|
f4a6f63999 | ||
|
ae2c904c3d | ||
|
f07a9df9af | ||
|
6b821be140 | ||
|
041c7a31c2 | ||
|
28dce5b130 | ||
|
699372d388 | ||
|
3b76284883 | ||
|
82ccaaf8e7 | ||
|
997c6967b0 | ||
|
7cfe9048e3 | ||
|
961792c9d6 | ||
|
a1386bb252 | ||
|
e4c1d8d231 | ||
|
d2bfe28966 | ||
|
4ad7ea9c84 | ||
|
9b94ebb0c8 | ||
|
a4c9c2b0f0 | ||
|
c20408163f | ||
|
16bd7aa076 | ||
|
866d3b9fd5 | ||
|
cd81e8e030 | ||
|
fa78edc57e | ||
|
b294633c68 | ||
|
bf0c14a562 | ||
|
fd1820b7ea | ||
|
4ca4041b0d | ||
|
8820767fb3 | ||
|
a0f9628705 | ||
|
2fccd1f153 | ||
|
69da506c92 | ||
|
5ad2592ab3 | ||
|
db0a3087a5 | ||
|
6ceaef4804 | ||
|
5bd2e5dfe6 | ||
|
dc5880d02f | ||
|
7fa4692636 | ||
|
75fb0cfc82 | ||
|
bfb574db11 | ||
|
aa1cd447b3 | ||
|
f335d91a3b | ||
|
5a6455e04c | ||
|
7fc183df71 | ||
|
437ed29f27 | ||
|
c7c2599759 | ||
|
0d1ad06c27 | ||
|
facf52aeb8 | ||
|
6bc74286e7 | ||
|
c6e655743f | ||
|
e9782e6907 | ||
|
a6f799e7fd | ||
|
0c3f8766b0 | ||
|
46f51898ff | ||
|
a1d595fc9c | ||
|
f6b86eec5a | ||
|
ec07fd0e35 | ||
|
7b8c5a8eb4 | ||
|
85c6c14c4c | ||
|
cb4820b6c1 | ||
|
5a0932b7d4 | ||
|
fc14c809cb | ||
|
f80f052277 | ||
|
1eeca0750a | ||
|
bc82574de4 | ||
|
2c5961cccf | ||
|
02fcfdce1e | ||
|
5c551d6d91 | ||
|
92b27c2e6a | ||
|
e1aaef001f | ||
|
a43a62f9b0 | ||
|
6d5ae344cd | ||
|
c126e3588d | ||
|
6720b8e46f | ||
|
d78df93863 | ||
|
f13264b340 | ||
|
09cd17b0de | ||
|
a7dec790dc | ||
|
c27cdc941d | ||
|
98fa877efd | ||
|
705c3469b5 | ||
|
cbac2c74e8 | ||
|
d6017bca19 | ||
|
76e956547e | ||
|
550f196e82 | ||
|
8aeb405466 | ||
|
38da9606f7 | ||
|
419c0aafa6 | ||
|
77d6772708 | ||
|
68c1bedbf2 | ||
|
090642db7a | ||
|
f9c6b5134e | ||
|
1b5420e807 | ||
|
f67ec87704 | ||
|
540522fec0 | ||
|
b3f321f2d7 | ||
|
93a21b465b | ||
|
069703228c | ||
|
39254d922e | ||
|
289d93b79c | ||
|
173a7a7daa | ||
|
f6ce1a5cd8 | ||
|
b59e6fdae2 | ||
|
5db84c85c3 | ||
|
96192ba5bd | ||
|
8a763b533b | ||
|
aef0061ac2 | ||
|
aea8a9c954 | ||
|
b98e2113b5 | ||
|
9d669016d9 | ||
|
ff8485179c | ||
|
cc18c503e0 | ||
|
f6e4824533 | ||
|
566cdfc675 | ||
|
7c138e4008 | ||
|
4d37059d8e | ||
|
1f9bd937b3 | ||
|
6ea50514c1 | ||
|
d92db8a086 | ||
|
019621d078 | ||
|
c0984d1ff2 | ||
|
852ae4cd80 | ||
|
f41acc651f | ||
|
d59279f8ce | ||
|
d09c1d4b88 | ||
|
d3109e5f18 | ||
|
6ba931bebf | ||
|
935343cf16 | ||
|
7623b4bf6a | ||
|
13b97736c8 | ||
|
11f0014c0e | ||
|
ae6e470252 | ||
|
558b37b49b | ||
|
d375273c89 | ||
|
bda715bf6d | ||
|
2f2fd79fc4 | ||
|
3509103132 | ||
|
c5ef1f01a1 | ||
|
620cddb1e0 | ||
|
c59230bce1 | ||
|
8c170ad491 | ||
|
15f98047d2 | ||
|
cdcee3d17b | ||
|
4b384c21ad | ||
|
bb13762548 | ||
|
e7aac7fc13 | ||
|
d1855afc6e | ||
|
0d129ef7c3 | ||
|
466d8f65e3 | ||
|
26847fb6be | ||
|
a00e2e5513 | ||
|
ca573b8615 | ||
|
0eda253317 | ||
|
ed1806b2c0 | ||
|
01a06884a1 | ||
|
619f077252 | ||
|
6c8a08bd8a | ||
|
d0ff1cae3a | ||
|
f25ee54763 | ||
|
37d3eb026a | ||
|
7afef31b2b | ||
|
e96a5734f6 | ||
|
bf5678b580 | ||
|
c3e128a4cd | ||
|
3beb8c9654 | ||
|
51411435d5 | ||
|
0826808d4f | ||
|
18df11da8c | ||
|
ae55e9fca6 | ||
|
bde407db51 | ||
|
426efcc374 | ||
|
663e70851c | ||
|
cabcc6851b | ||
|
998ebe5ca0 | ||
|
5c7a611353 | ||
|
e0dcfb31fb | ||
|
e05132aaa0 | ||
|
c01622057c | ||
|
70d1481b55 | ||
|
c3f4f5a949 | ||
|
066d3c8004 | ||
|
c673216f53 | ||
|
6c1988af76 | ||
|
ea382b3b21 | ||
|
7edf120150 | ||
|
5f8b749c73 | ||
|
7e88204fe1 | ||
|
84cb35232d | ||
|
5d25638e1b | ||
|
7fab007f33 | ||
|
32c76a8cd4 | ||
|
7cddfae1e8 | ||
|
ef09160098 | ||
|
36d7626a37 | ||
|
becff4f473 | ||
|
65cc189414 | ||
|
7d62df623f | ||
|
89ed7e4795 | ||
|
3579551734 | ||
|
015a001b03 | ||
|
c0a0b9bc35 | ||
|
328076cfdf | ||
|
124b765051 | ||
|
e037530468 | ||
|
a107ad0f62 | ||
|
021930d7c2 | ||
|
e974064303 | ||
|
096cd41ce7 | ||
|
d05739a3ff | ||
|
987cc09c7c | ||
|
47ab397011 | ||
|
be8d6ef385 | ||
|
8147fe090f | ||
|
7cd55f3009 | ||
|
66f18fde49 | ||
|
2ef0ff39e5 | ||
|
165f1e4936 | ||
|
f81273f7fb | ||
|
43b3ca6b7f | ||
|
ba08910df1 | ||
|
9d70d8f20d | ||
|
82b0ee8354 | ||
|
59aa48bb7d | ||
|
e5ec3ba409 | ||
|
85fd05ab97 | ||
|
fe405f08a0 | ||
|
ec54ce1f1a | ||
|
5ee17c5418 | ||
|
717f35a9f2 | ||
|
82dd766f25 | ||
|
2cc6d4c8ed | ||
|
33a3408fbb | ||
|
ae80fe997d | ||
|
5ef3990735 | ||
|
cbcf0cd65e | ||
|
d8d829b89d | ||
|
5386c9e6da | ||
|
5654ce1d2c | ||
|
0aca5901e3 | ||
|
8c2357809e | ||
|
c32e733151 | ||
|
9ce09870e7 | ||
|
ff379e1b48 | ||
|
d452feedf2 | ||
|
12e4043bd6 | ||
|
992d5451d1 | ||
|
89c5d90003 | ||
|
6bb00aa484 | ||
|
3701f105fa | ||
|
b670700ddf | ||
|
bbd30066e1 | ||
|
3a872dac7b | ||
|
c5d68ef6e7 | ||
|
a086f4a63b | ||
|
a24fbd6061 | ||
|
9bf473da4c | ||
|
bf65d7ee88 | ||
|
16acacf24c | ||
|
d8d4abdff9 | ||
|
538ac013d6 | ||
|
8cb4b429a2 | ||
|
ec87305f90 | ||
|
129404f6e4 | ||
|
3e8b7e1055 | ||
|
62031335bd | ||
|
72a9386f67 | ||
|
0426115b67 | ||
|
b822be1a20 | ||
|
0b633b1494 | ||
|
451521ccbc | ||
|
c55cf3f795 | ||
|
0547ffbf6d | ||
|
4d8651c2fb | ||
|
b21fe5a8a6 | ||
|
a00b71b009 | ||
|
b2d76fdd42 | ||
|
3c16e6fb97 | ||
|
a7e722941c | ||
|
4bdc41cf17 | ||
|
ec25e904c7 | ||
|
01c2fb0d22 | ||
|
3f378450df | ||
|
4a86424224 | ||
|
73ccde8f6d | ||
|
7bda8c6481 | ||
|
6937fc8338 | ||
|
259e1e0462 | ||
|
2846c19da9 | ||
|
ceb52713b0 | ||
|
560f9bb063 | ||
|
39ba0f8dfc | ||
|
5fb3f5723a | ||
|
05da2d24b0 | ||
|
8bd2028f9a | ||
|
6acf72901a | ||
|
4dd7b86556 | ||
|
47b9521513 | ||
|
09f01d4efb | ||
|
c4e76d2fba | ||
|
316e6df435 | ||
|
7a548f3ea9 | ||
|
30697b94fd | ||
|
f70f493d1b | ||
|
0e3e62fc2b | ||
|
e254c71e9e | ||
|
57162cb62d | ||
|
e03b0d0672 | ||
|
0adc35fccd | ||
|
3e3f5bb21c | ||
|
01c0d3c0d5 | ||
|
fb91d6cbd0 | ||
|
19f7c63ea9 | ||
|
44fc90eb0e | ||
|
cda98df162 | ||
|
81bbc1452c | ||
|
e59747bd82 | ||
|
f6a196c7eb | ||
|
862614e254 | ||
|
4bc2c74851 | ||
|
7dbb8a24d1 | ||
|
cc6efda777 | ||
|
27874a382c | ||
|
00743d144b | ||
|
9d9d15b42a | ||
|
78c373f2a5 | ||
|
916825b84f | ||
|
d103840cfb | ||
|
1cd902f1f4 | ||
|
e986f4ce96 | ||
|
804e8c6566 | ||
|
592bf33a29 | ||
|
1fd8d08970 | ||
|
aa65bb4020 | ||
|
11ce7a2de7 | ||
|
5890a18409 | ||
|
a654289439 | ||
|
4cb94f20b0 | ||
|
1ef86f1201 | ||
|
5eb973eb62 | ||
|
5c25f6c67b | ||
|
127e2c5315 | ||
|
54d81d06fc | ||
|
8a485e4bb8 | ||
|
2c284027b2 | ||
|
22f73b6d2d | ||
|
1c75bf3c21 | ||
|
c14c4719f9 | ||
|
4e17aba4b5 | ||
|
2280af5ff8 | ||
|
cf3d4508b2 | ||
|
d9e7f6fe49 | ||
|
ca33daafc6 | ||
|
a639248bd0 | ||
|
7bee249891 | ||
|
a121165e35 | ||
|
d2842bb6ec | ||
|
735a7496cb | ||
|
7de1c71dd2 | ||
|
5d5be45bd1 | ||
|
47d988387e | ||
|
a1d5723914 | ||
|
a8a78ef194 | ||
|
beb0f8d483 | ||
|
dd3ba82d31 | ||
|
8aff08c817 | ||
|
b92e049522 | ||
|
c8c978d328 | ||
|
ae3bc559f9 | ||
|
d992163da6 | ||
|
85d805ed32 | ||
|
6ae2b6648e | ||
|
fff6d81270 | ||
|
2ddc8e1b67 | ||
|
93629f2c7c | ||
|
0cb30c3f5e | ||
|
765ba5bf05 | ||
|
a89f558d3c | ||
|
b9e702c3c9 | ||
|
6d55ad9a59 | ||
|
31377aba8f | ||
|
80f097711b | ||
|
d4586fe3ae | ||
|
cef0c5c684 | ||
|
c1b073a9dc | ||
|
933b4c333c | ||
|
3182843f3b | ||
|
c8fb724046 | ||
|
3b1f3414f2 | ||
|
c17c3c24d8 | ||
|
342813a3f7 | ||
|
b0fd309719 | ||
|
179efe5d69 | ||
|
0be81a4d83 | ||
|
6032b46dce | ||
|
6c1a4a376e | ||
|
c7aecf2a4f | ||
|
50bee4cc12 | ||
|
239bcf7805 | ||
|
6e8b0b6913 | ||
|
82e70d9ac0 | ||
|
35043a5ec0 | ||
|
b556f2445c | ||
|
9eb5ccda50 | ||
|
ff29cdb968 | ||
|
6cdddccf00 | ||
|
863fe9e191 | ||
|
4b3e9d80be | ||
|
199031b2b0 | ||
|
922bf317f1 | ||
|
aade3b93fe | ||
|
8a89747844 | ||
|
e00ec499c5 | ||
|
351fe77666 | ||
|
ef4cf3d88d | ||
|
cbce5a1a93 | ||
|
3d480a93de | ||
|
9d8ed9c8ee | ||
|
aa0f522471 | ||
|
9a50990cdb | ||
|
dcf8c79056 | ||
|
cc650a0378 | ||
|
eff44c008d | ||
|
2695e49219 | ||
|
ee3da09bb2 | ||
|
eae9e51d98 | ||
|
b84f32ae5b | ||
|
cab1f02565 | ||
|
c46204e25f | ||
|
957a15adaf | ||
|
ae62a6e44d | ||
|
ed8bfada03 | ||
|
8487ec0ee7 | ||
|
b5dbf8267b | ||
|
85dba961c7 | ||
|
720c25ab41 | ||
|
7dcc2f3870 | ||
|
2af33db365 | ||
|
d1e41c620f | ||
|
6ca9f410d1 | ||
|
43e306806e | ||
|
502c01c502 | ||
|
9b648112a5 | ||
|
32c5a470ad | ||
|
00bbb1e584 | ||
|
df7ce74e6c | ||
|
66772bc852 | ||
|
e9a3613ce0 | ||
|
c9a4df88fd | ||
|
1729fb8a82 | ||
|
8405b1480f | ||
|
dab7bac94c | ||
|
a5672d43a6 | ||
|
5acd6489df | ||
|
0bcd3cc06e | ||
|
2ef32f914a | ||
|
a64cc43552 | ||
|
3bcc2e22ef | ||
|
44b7a856f0 | ||
|
48c6e7dbcd | ||
|
020891f173 | ||
|
52199bf532 | ||
|
d98efb4682 | ||
|
99338ef81e | ||
|
b92298af82 | ||
|
789a723285 | ||
|
25589c4a76 | ||
|
ca01e6216a | ||
|
83f11f9572 | ||
|
68d234989b | ||
|
0a64106c56 | ||
|
c1ff81f799 | ||
|
16bf588b60 | ||
|
115cebbe4d | ||
|
b6efc505e4 | ||
|
7136d5491e | ||
|
fead469a3b | ||
|
75d2be4a37 | ||
|
07be1d34d9 | ||
|
a26050f74d | ||
|
2eff4ddc77 | ||
|
9ca2dc7bec | ||
|
2997ae3873 | ||
|
9e2c88b16e | ||
|
9670f79937 | ||
|
26638d2aa3 | ||
|
7464db4474 | ||
|
56035d1c8b | ||
|
db2c22633f | ||
|
fb493ac84e | ||
|
b28acb22e0 | ||
|
f4213fed34 | ||
|
acb2acccfd | ||
|
4fcd5d2620 | ||
|
0882d6a32d | ||
|
d79295b5c5 | ||
|
3b46a1e243 | ||
|
244ce33bdd | ||
|
584b246e88 | ||
|
0c9744787e | ||
|
dfc7c3dc8c | ||
|
a57b4c11a5 | ||
|
e75951ca89 | ||
|
ea6d859b50 | ||
|
dd00f92b2f | ||
|
961fadf60c | ||
|
8f8372439d | ||
|
8437368c69 | ||
|
d7d9866ef4 | ||
|
4d29da411f | ||
|
6fd754ec0f | ||
|
2355f0c09c | ||
|
913a308df9 | ||
|
c6720db5dd | ||
|
31b1638468 | ||
|
999c53e2ca | ||
|
0487cac09f | ||
|
ab644cfac5 | ||
|
0f6eccdbf7 | ||
|
1d0ff11526 | ||
|
d23eb3aa99 | ||
|
0a29933ea9 | ||
|
225810a182 | ||
|
81aeb94648 | ||
|
09e74b81ba | ||
|
0e6db46b1b | ||
|
b03dceb87f | ||
|
c4663e7277 | ||
|
9d6915ca91 | ||
|
6f1bb567aa | ||
|
012e424601 | ||
|
055eaacc34 | ||
|
beabde5875 | ||
|
b8e54e15de | ||
|
a7e070808c | ||
|
d618fe05bf | ||
|
8fc06b6e19 | ||
|
4aa7e66c06 | ||
|
e0200cc47a | ||
|
2ce4bfb843 | ||
|
380821a949 | ||
|
dad7fc29d9 | ||
|
ced203c3d5 | ||
|
104df6136f | ||
|
f89815a125 | ||
|
dbbb045ff1 | ||
|
10d291f746 | ||
|
264e930de0 | ||
|
cd24eb578b | ||
|
f0a704f9b5 | ||
|
76bf716a7a | ||
|
b1b5177a0c | ||
|
ab9768cd46 | ||
|
bcdafe1179 | ||
|
114e6075b6 | ||
|
c53807cb7b | ||
|
cb4f1dfcc1 | ||
|
1aa311d175 | ||
|
082b563fc4 | ||
|
10daf3ee24 | ||
|
23d873f4cf | ||
|
6e1ddbab8d | ||
|
78b081334e | ||
|
711ee4103a | ||
|
d2c0d52ed6 | ||
|
c5f4b4fd03 | ||
|
ee2ea7868a | ||
|
ad8f2b7251 | ||
|
2067672ded | ||
|
d8c073c89b | ||
|
e25963d458 | ||
|
0371178d0b | ||
|
5bd2dbc698 | ||
|
e7d7f02c8e | ||
|
22745df666 | ||
|
8ecae3d641 | ||
|
190f77f8f4 | ||
|
0371032289 | ||
|
69a50a249b | ||
|
f21a1d48fe | ||
|
f80580f56b | ||
|
8db4e9f9a0 | ||
|
bb78d969b7 | ||
|
cafc573ac0 | ||
|
3c9e2f239a | ||
|
de103f1981 | ||
|
4364d66168 | ||
|
a670f12a74 | ||
|
406ad0582a | ||
|
3361336607 | ||
|
8916a4f67f | ||
|
9e6b552b4c | ||
|
ecb778d0ac | ||
|
bbda386d25 | ||
|
8f9ef9c9a0 | ||
|
5ff7d712d4 | ||
|
710f83b79d | ||
|
cf01fdd5d7 | ||
|
d6d4a81f8a | ||
|
1bd2ff1866 | ||
|
f054beec54 | ||
|
f931506815 | ||
|
b3d379d188 | ||
|
769879e2a6 | ||
|
9ecab62d40 | ||
|
7c424c28b0 | ||
|
28b16c01cf | ||
|
a62bd922aa | ||
|
629709a51d | ||
|
12973359d0 | ||
|
43c1111530 | ||
|
51e0599536 | ||
|
f01d3ee12c | ||
|
b6d324e06b | ||
|
4e1133b946 | ||
|
c24328ca62 | ||
|
8be33c6544 | ||
|
9fc029ee62 | ||
|
6a2b20ff97 | ||
|
7aa06237b8 | ||
|
b7213bbd59 | ||
|
d63242bd69 | ||
|
2a0bd3bffc | ||
|
3c0d567c37 | ||
|
f4d539007c | ||
|
b3dd9cb836 | ||
|
96f3efbd99 | ||
|
d97ee3244d | ||
|
2157a23a86 | ||
|
3b382f5b38 | ||
|
988e4d8f5e | ||
|
0e7aa6bf9e | ||
|
582a7c9995 | ||
|
ef9974b298 | ||
|
2500ce1011 | ||
|
58350c0055 | ||
|
09c90532e7 | ||
|
953438e466 | ||
|
e5eb0e3347 | ||
|
7d74ea141e | ||
|
130b649a8b | ||
|
11b5093ce4 | ||
|
8467a263f9 | ||
|
a8e8c43a0e | ||
|
4102950a21 | ||
|
03f708090b | ||
|
0c9d4ad788 | ||
|
42951543dd | ||
|
fd0ad0c346 | ||
|
5f403cdc6a | ||
|
022787f806 | ||
|
a23f76e184 | ||
|
acbc5747bc | ||
|
b19793a2ec | ||
|
e919c390e8 | ||
|
11b24ef0d7 | ||
|
1336476233 | ||
|
f3c69cb5a1 | ||
|
3f77ccb9c8 | ||
|
cbb3b6b950 | ||
|
0b1a1bdc30 | ||
|
7bb42e3249 | ||
|
238f5f9544 | ||
|
6f340acfb1 | ||
|
dd1e20b3c2 | ||
|
62f00dad22 | ||
|
2c17d676e4 | ||
|
415fc406d6 | ||
|
3184e44df1 | ||
|
f46c7d1e36 | ||
|
981bf66d5a | ||
|
8c92a9508e | ||
|
45297e6c9b | ||
|
1dccbd1a38 | ||
|
838c730fe6 | ||
|
db7afaee91 | ||
|
970e262949 | ||
|
d933ec115b | ||
|
477b5b7d55 | ||
|
34969dd260 | ||
|
cdb80a281f | ||
|
8fdb4de628 | ||
|
e8a537d28d | ||
|
e495b1009a | ||
|
c403de7bd4 | ||
|
1096a9b04b | ||
|
b4036b52b1 | ||
|
917a7e3f34 | ||
|
7b8f69d7e1 | ||
|
d82ec90f51 | ||
|
8465fd59d3 | ||
|
54c8d5e432 | ||
|
11a04bb4a6 | ||
|
512042eba8 | ||
|
314799a926 | ||
|
3d35a6c243 | ||
|
5eeb088ad6 | ||
|
db463e8e9d | ||
|
dba79765c4 | ||
|
520ba8e306 | ||
|
18b5b14932 | ||
|
f7da805b50 | ||
|
39596c41c8 | ||
|
3abaa281d3 | ||
|
70165fa6e2 | ||
|
ee91d9ef24 | ||
|
58eb8517ad | ||
|
4f173db8b4 | ||
|
0e72e8762a | ||
|
fb008dbe01 | ||
|
7cc7c52670 | ||
|
1b1c58ab32 | ||
|
c4bc1a9498 | ||
|
c05a218a97 | ||
|
b5d1dc94d0 | ||
|
1a24f5fb12 | ||
|
a4037690d9 | ||
|
05db766bee | ||
|
1926702c95 | ||
|
6dc4ac1347 | ||
|
e87ac5ef49 | ||
|
0ccf955674 | ||
|
22c45b7c52 | ||
|
52bf4eba45 | ||
|
aefcc91805 | ||
|
165b5bcd68 | ||
|
e61f3f4ef1 | ||
|
08522341c4 | ||
|
ec87181192 | ||
|
6edd257861 | ||
|
ac55fcb051 | ||
|
7719bc3f71 | ||
|
0a4079ad86 | ||
|
b9bb27e1ff | ||
|
033ba8bb29 | ||
|
5236d47854 | ||
|
d9c8a9cf11 | ||
|
b18c0905ee | ||
|
2081054636 | ||
|
9ca7ece8b3 | ||
|
31a94f7fba | ||
|
df25a5457f | ||
|
4b7bd4c591 | ||
|
9ab2b34dd4 | ||
|
76cf3d35e6 | ||
|
d1abb876f4 | ||
|
76ec17526b | ||
|
367604b2f4 | ||
|
3c06953fd7 | ||
|
04ecdc38cd | ||
|
383d34159d | ||
|
227a133a0a |
@@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
||||||
|
# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
##
|
##
|
||||||
trigger:
|
trigger:
|
||||||
@@ -12,10 +13,14 @@ pr:
|
|||||||
- master
|
- master
|
||||||
- stable/*
|
- stable/*
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- template: templates/defaults.yml
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- template: templates/pr-gate-build-job.yml
|
- template: templates/pr-gate-build-job.yml
|
||||||
parameters:
|
parameters:
|
||||||
tool_chain_tag: 'GCC5'
|
tool_chain_tag: 'GCC5'
|
||||||
vm_image: 'ubuntu-latest'
|
vm_image: 'ubuntu-22.04'
|
||||||
arch_list: "IA32,X64,ARM,AARCH64,RISCV64"
|
container: ${{ variables.default_linux_image }}
|
||||||
|
arch_list: "IA32,X64,ARM,AARCH64,RISCV64,LOONGARCH64"
|
||||||
|
usePythonVersion: '' # use Python from the container image
|
||||||
|
@@ -27,7 +27,7 @@ steps:
|
|||||||
|
|
||||||
- task: UsePythonVersion@0
|
- task: UsePythonVersion@0
|
||||||
inputs:
|
inputs:
|
||||||
versionSpec: '3.8.x'
|
versionSpec: '>=3.10.6'
|
||||||
architecture: 'x64'
|
architecture: 'x64'
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
|
@@ -12,9 +12,18 @@ pr:
|
|||||||
- master
|
- master
|
||||||
- stable/*
|
- stable/*
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- template: templates/defaults.yml
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- template: templates/pr-gate-build-job.yml
|
- template: templates/pr-gate-build-job.yml
|
||||||
parameters:
|
parameters:
|
||||||
tool_chain_tag: 'VS2019'
|
tool_chain_tag: 'VS2019'
|
||||||
vm_image: 'windows-2019'
|
vm_image: 'windows-2019'
|
||||||
arch_list: "IA32,X64"
|
arch_list: "IA32,X64"
|
||||||
|
usePythonVersion: ${{ variables.default_python_version }}
|
||||||
|
extra_install_step:
|
||||||
|
- powershell: choco install opencppcoverage; Write-Host "##vso[task.prependpath]C:\Program Files\OpenCppCoverage"
|
||||||
|
displayName: Install Code Coverage Tool
|
||||||
|
condition: and(gt(variables.pkg_count, 0), succeeded())
|
||||||
|
|
||||||
|
@@ -10,15 +10,6 @@ parameters:
|
|||||||
tool_chain_tag: ''
|
tool_chain_tag: ''
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- ${{ if contains(parameters.tool_chain_tag, 'GCC') }}:
|
|
||||||
- bash: sudo apt-get update
|
|
||||||
displayName: Update apt
|
|
||||||
condition: and(gt(variables.pkg_count, 0), succeeded())
|
|
||||||
|
|
||||||
- bash: sudo apt-get install gcc g++ make uuid-dev
|
|
||||||
displayName: Install required tools
|
|
||||||
condition: and(gt(variables.pkg_count, 0), succeeded())
|
|
||||||
|
|
||||||
- task: CmdLine@1
|
- task: CmdLine@1
|
||||||
displayName: Build Base Tools from source
|
displayName: Build Base Tools from source
|
||||||
inputs:
|
inputs:
|
||||||
|
12
.azurepipelines/templates/defaults.yml
Normal file
12
.azurepipelines/templates/defaults.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
## @file
|
||||||
|
# File templates/default.yml
|
||||||
|
#
|
||||||
|
# template file containing common default values
|
||||||
|
#
|
||||||
|
# Copyright (c) Red Hat, Inc.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
variables:
|
||||||
|
default_python_version: ">=3.10.6"
|
||||||
|
default_linux_image: "ghcr.io/tianocore/containers/fedora-37-test:a0dd931"
|
@@ -34,16 +34,26 @@ parameters:
|
|||||||
- name: extra_install_step
|
- name: extra_install_step
|
||||||
type: stepList
|
type: stepList
|
||||||
default: []
|
default: []
|
||||||
|
- name: usePythonVersion
|
||||||
|
type: string
|
||||||
|
default: ''
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- bash: |
|
||||||
|
echo "##vso[task.prependpath]${HOME}/.local/bin"
|
||||||
|
echo "new PATH=${PATH}"
|
||||||
|
displayName: Set PATH
|
||||||
|
condition: eq('${{ parameters.tool_chain_tag }}', 'GCC5')
|
||||||
|
|
||||||
- checkout: self
|
- checkout: self
|
||||||
clean: true
|
clean: true
|
||||||
fetchDepth: 1
|
fetchDepth: 1
|
||||||
|
|
||||||
- task: UsePythonVersion@0
|
- task: UsePythonVersion@0
|
||||||
inputs:
|
inputs:
|
||||||
versionSpec: "3.8.x"
|
versionSpec: ${{ parameters.usePythonVersion }}
|
||||||
architecture: "x64"
|
architecture: "x64"
|
||||||
|
condition: ne('${{ parameters.usePythonVersion }}', '')
|
||||||
|
|
||||||
- script: pip install -r pip-requirements.txt --upgrade
|
- script: pip install -r pip-requirements.txt --upgrade
|
||||||
displayName: 'Install/Upgrade pip modules'
|
displayName: 'Install/Upgrade pip modules'
|
||||||
@@ -106,7 +116,7 @@ steps:
|
|||||||
filename: stuart_build
|
filename: stuart_build
|
||||||
arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}} ${{ parameters.run_flags }} --FlashOnly
|
arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}} ${{ parameters.run_flags }} --FlashOnly
|
||||||
condition: and(and(gt(variables.pkg_count, 0), succeeded()), eq(variables['Run'], true))
|
condition: and(and(gt(variables.pkg_count, 0), succeeded()), eq(variables['Run'], true))
|
||||||
timeoutInMinutes: 1
|
timeoutInMinutes: 2
|
||||||
|
|
||||||
# Copy the build logs to the artifact staging directory
|
# Copy the build logs to the artifact staging directory
|
||||||
- task: CopyFiles@2
|
- task: CopyFiles@2
|
||||||
|
@@ -12,6 +12,9 @@ parameters:
|
|||||||
tool_chain_tag: ''
|
tool_chain_tag: ''
|
||||||
vm_image: ''
|
vm_image: ''
|
||||||
arch_list: ''
|
arch_list: ''
|
||||||
|
extra_install_step: []
|
||||||
|
usePythonVersion: ''
|
||||||
|
container: ''
|
||||||
|
|
||||||
# Build step
|
# Build step
|
||||||
jobs:
|
jobs:
|
||||||
@@ -21,6 +24,10 @@ jobs:
|
|||||||
#Use matrix to speed up the build process
|
#Use matrix to speed up the build process
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
${{ if eq(parameters.tool_chain_tag, 'GCC5') }}:
|
||||||
|
TARGET_GCC_ONLY:
|
||||||
|
Build.Pkgs: 'EmbeddedPkg'
|
||||||
|
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
||||||
TARGET_ARM_ARMPLATFORM:
|
TARGET_ARM_ARMPLATFORM:
|
||||||
Build.Pkgs: 'ArmPkg,ArmPlatformPkg'
|
Build.Pkgs: 'ArmPkg,ArmPlatformPkg'
|
||||||
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
||||||
@@ -37,13 +44,19 @@ jobs:
|
|||||||
Build.Pkgs: 'NetworkPkg,RedfishPkg'
|
Build.Pkgs: 'NetworkPkg,RedfishPkg'
|
||||||
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
||||||
TARGET_OTHER:
|
TARGET_OTHER:
|
||||||
Build.Pkgs: 'PcAtChipsetPkg,PrmPkg,ShellPkg,StandaloneMmPkg'
|
Build.Pkgs: 'PcAtChipsetPkg,PrmPkg,ShellPkg,SourceLevelDebugPkg,StandaloneMmPkg,SignedCapsulePkg'
|
||||||
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
||||||
TARGET_FMP_FAT_TEST:
|
TARGET_FMP_FAT_TEST:
|
||||||
Build.Pkgs: 'FmpDevicePkg,FatPkg,UnitTestFrameworkPkg,DynamicTablesPkg'
|
Build.Pkgs: 'FmpDevicePkg,FatPkg,UnitTestFrameworkPkg,DynamicTablesPkg'
|
||||||
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
||||||
TARGET_CRYPTO:
|
TARGET_CRYPTO_DEBUG:
|
||||||
Build.Pkgs: 'CryptoPkg'
|
Build.Pkgs: 'CryptoPkg'
|
||||||
|
Build.Targets: 'DEBUG,NOOPT'
|
||||||
|
TARGET_CRYPTO_RELEASE:
|
||||||
|
Build.Pkgs: 'CryptoPkg'
|
||||||
|
Build.Targets: 'RELEASE,NO-TARGET'
|
||||||
|
TARGET_FSP:
|
||||||
|
Build.Pkgs: 'IntelFsp2Pkg,IntelFsp2WrapperPkg'
|
||||||
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
Build.Targets: 'DEBUG,RELEASE,NO-TARGET,NOOPT'
|
||||||
TARGET_SECURITY:
|
TARGET_SECURITY:
|
||||||
Build.Pkgs: 'SecurityPkg'
|
Build.Pkgs: 'SecurityPkg'
|
||||||
@@ -63,6 +76,9 @@ jobs:
|
|||||||
pool:
|
pool:
|
||||||
vmImage: ${{ parameters.vm_image }}
|
vmImage: ${{ parameters.vm_image }}
|
||||||
|
|
||||||
|
${{ if not(eq(parameters.container, '')) }}:
|
||||||
|
container: ${{ parameters.container }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- template: pr-gate-steps.yml
|
- template: pr-gate-steps.yml
|
||||||
parameters:
|
parameters:
|
||||||
@@ -70,3 +86,47 @@ jobs:
|
|||||||
build_pkgs: $(Build.Pkgs)
|
build_pkgs: $(Build.Pkgs)
|
||||||
build_targets: $(Build.Targets)
|
build_targets: $(Build.Targets)
|
||||||
build_archs: ${{ parameters.arch_list }}
|
build_archs: ${{ parameters.arch_list }}
|
||||||
|
usePythonVersion: ${{ parameters.usePythonVersion }}
|
||||||
|
extra_install_step: ${{ parameters.extra_install_step }}
|
||||||
|
|
||||||
|
- job: Build_${{ parameters.tool_chain_tag }}_TARGET_CODE_COVERAGE
|
||||||
|
dependsOn: Build_${{ parameters.tool_chain_tag }}
|
||||||
|
workspace:
|
||||||
|
clean: all
|
||||||
|
|
||||||
|
pool:
|
||||||
|
vmImage: 'windows-2019'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- checkout: self
|
||||||
|
clean: true
|
||||||
|
fetchDepth: 1
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- task: DownloadPipelineArtifact@2
|
||||||
|
displayName: 'Download Build Artifacts'
|
||||||
|
inputs:
|
||||||
|
buildType: 'current'
|
||||||
|
targetPath: '$(Build.ArtifactStagingDirectory)'
|
||||||
|
|
||||||
|
- powershell: Write-Host "##vso[task.setvariable variable=is_code_coverage]0"
|
||||||
|
displayName: Give default value for whether CodeCoverage or not
|
||||||
|
|
||||||
|
- powershell: if (Test-Path -Path $(Build.ArtifactStagingDirectory)/**/coverage.xml) {Write-Host "##vso[task.setvariable variable=is_code_coverage]1"}
|
||||||
|
displayName: Check coverage.xml exist or not
|
||||||
|
|
||||||
|
- task: CmdLine@2
|
||||||
|
displayName: Create code coverage report
|
||||||
|
inputs:
|
||||||
|
script: |
|
||||||
|
dotnet tool install -g dotnet-reportgenerator-globaltool
|
||||||
|
reportgenerator -reports:$(Build.ArtifactStagingDirectory)/**/coverage.xml -targetdir:$(Build.ArtifactStagingDirectory)/Coverage -reporttypes:Cobertura -filefilters:-*Build*;-*UnitTest*;-*Mock*;-*usr*
|
||||||
|
condition: eq(variables.is_code_coverage, 1)
|
||||||
|
|
||||||
|
- task: PublishCodeCoverageResults@1
|
||||||
|
displayName: 'Publish code coverage'
|
||||||
|
inputs:
|
||||||
|
codeCoverageTool: Cobertura
|
||||||
|
summaryFileLocation: '$(Build.ArtifactStagingDirectory)/Coverage/Cobertura.xml'
|
||||||
|
condition: eq(variables.is_code_coverage, 1)
|
||||||
|
|
||||||
|
@@ -12,16 +12,25 @@ parameters:
|
|||||||
build_pkgs: ''
|
build_pkgs: ''
|
||||||
build_targets: ''
|
build_targets: ''
|
||||||
build_archs: ''
|
build_archs: ''
|
||||||
|
usePythonVersion: ''
|
||||||
|
extra_install_step: []
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- bash: |
|
||||||
|
echo "##vso[task.prependpath]${HOME}/.local/bin"
|
||||||
|
echo "new PATH=${PATH}"
|
||||||
|
displayName: Set PATH
|
||||||
|
condition: eq('${{ parameters.tool_chain_tag }}', 'GCC5')
|
||||||
|
|
||||||
- checkout: self
|
- checkout: self
|
||||||
clean: true
|
clean: true
|
||||||
fetchDepth: 1
|
fetchDepth: 1
|
||||||
|
|
||||||
- task: UsePythonVersion@0
|
- task: UsePythonVersion@0
|
||||||
inputs:
|
inputs:
|
||||||
versionSpec: '3.8.x'
|
versionSpec: ${{ parameters.usePythonVersion }}
|
||||||
architecture: 'x64'
|
architecture: "x64"
|
||||||
|
condition: ne('${{ parameters.usePythonVersion }}', '')
|
||||||
|
|
||||||
- script: pip install -r pip-requirements.txt --upgrade
|
- script: pip install -r pip-requirements.txt --upgrade
|
||||||
displayName: 'Install/Upgrade pip modules'
|
displayName: 'Install/Upgrade pip modules'
|
||||||
@@ -37,6 +46,8 @@ steps:
|
|||||||
displayName: fetch target branch
|
displayName: fetch target branch
|
||||||
condition: eq(variables['Build.Reason'], 'PullRequest')
|
condition: eq(variables['Build.Reason'], 'PullRequest')
|
||||||
|
|
||||||
|
- ${{ parameters.extra_install_step }}
|
||||||
|
|
||||||
# trim the package list if this is a PR
|
# trim the package list if this is a PR
|
||||||
- task: CmdLine@1
|
- task: CmdLine@1
|
||||||
displayName: Check if ${{ parameters.build_pkgs }} need testing
|
displayName: Check if ${{ parameters.build_pkgs }} need testing
|
||||||
@@ -125,6 +136,7 @@ steps:
|
|||||||
TestSuites.xml
|
TestSuites.xml
|
||||||
**/BUILD_TOOLS_REPORT.html
|
**/BUILD_TOOLS_REPORT.html
|
||||||
**/OVERRIDELOG.TXT
|
**/OVERRIDELOG.TXT
|
||||||
|
coverage.xml
|
||||||
flattenFolders: true
|
flattenFolders: true
|
||||||
condition: succeededOrFailed()
|
condition: succeededOrFailed()
|
||||||
|
|
||||||
|
16
.devcontainer/devcontainer.json
Normal file
16
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"image": "ghcr.io/tianocore/containers/fedora-35-dev:latest",
|
||||||
|
"postCreateCommand": "git config --global --add safe.directory * && pip install --upgrade -r pip-requirements.txt",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"DavidAnson.vscode-markdownlint",
|
||||||
|
"ms-azuretools.vscode-docker",
|
||||||
|
"ms-vscode-remote.remote-containers",
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"walonli.edk2-vscode",
|
||||||
|
"zachflower.uncrustify"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
.git-blame-ignore-revs
Normal file
52
.git-blame-ignore-revs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# PrmPkg: Apply uncrustify changes
|
||||||
|
a298a84478053872ed9da660a75f182ce81b8ddc
|
||||||
|
# UnitTestFrameworkPkg: Apply uncrustify changes
|
||||||
|
7c0ad2c33810ead45b7919f8f8d0e282dae52e71
|
||||||
|
# UefiPayloadPkg: Apply uncrustify changes
|
||||||
|
e5efcf8be8a1bf59aa98875787475e3144ee4cef
|
||||||
|
# UefiCpuPkg: Apply uncrustify changes
|
||||||
|
053e878bfb5c9d5eca779789b62891add30b14ba
|
||||||
|
# StandaloneMmPkg: Apply uncrustify changes
|
||||||
|
91415a36ae7aaeabb2bbab3762f39544f9aed683
|
||||||
|
# SourceLevelDebugPkg: Apply uncrustify changes
|
||||||
|
c1e126b1196de75e0a4cda21e4551ea9bb05e059
|
||||||
|
# SignedCapsulePkg: Apply uncrustify changes
|
||||||
|
b87864896714cf3062a7bc6d577d8fbd62d105e5
|
||||||
|
# ShellPkg: Apply uncrustify changes
|
||||||
|
47d20b54f9a65b08aa602a1866c1b59a69088dfc
|
||||||
|
# SecurityPkg: Apply uncrustify changes
|
||||||
|
c411b485b63a671a1e276700cff025c73997233c
|
||||||
|
# RedfishPkg: Apply uncrustify changes
|
||||||
|
39de741e2dcb8f11e9b4438e37224797643d8451
|
||||||
|
# PcAtChipsetPkg: Apply uncrustify changes
|
||||||
|
5220bd211df890f2672c23c050082862cd1e82d6
|
||||||
|
# OvmfPkg: Apply uncrustify changes
|
||||||
|
ac0a286f4d747a4c6c603a7b225917293cbe1e9f
|
||||||
|
# NetworkPkg: Apply uncrustify changes
|
||||||
|
d1050b9dff1cace252aff86630bfdb59dff5f507
|
||||||
|
# MdePkg: Apply uncrustify changes
|
||||||
|
2f88bd3a1296c522317f1c21377876de63de5be7
|
||||||
|
# MdeModulePkg: Apply uncrustify changes
|
||||||
|
1436aea4d5707e672672a11bda72be2c63c936c3
|
||||||
|
# IntelFsp2WrapperPkg: Apply uncrustify changes
|
||||||
|
7c7184e201a90a1d2376e615e55e3f4074731468
|
||||||
|
# IntelFsp2Pkg: Apply uncrustify changes
|
||||||
|
111f2228ddf487b0ac3491e416bb3dcdcfa4f979
|
||||||
|
# FmpDevicePkg: Apply uncrustify changes
|
||||||
|
45ce0a67bb4ee80f27da93777c623f51f344f23b
|
||||||
|
# FatPkg: Apply uncrustify changes
|
||||||
|
bcdcc4160d7460c46c08c9395aae81be44ef23a9
|
||||||
|
# EmulatorPkg: Apply uncrustify changes
|
||||||
|
a550d468a6ca577d9e9c57a0eafcf2fc9fbb8c97
|
||||||
|
# EmbeddedPkg: Apply uncrustify changes
|
||||||
|
e7108d0e9655b1795c94ac372b0449f28dd907df
|
||||||
|
# DynamicTablesPkg: Apply uncrustify changes
|
||||||
|
731c67e1d77b7741a91762d17659fc9fbcb9e305
|
||||||
|
# CryptoPkg: Apply uncrustify changes
|
||||||
|
7c342378317039e632d9a1a5d4cf7c21aec8cb7a
|
||||||
|
# ArmVirtPkg: Apply uncrustify changes
|
||||||
|
2b16a4fb91b9b31c0d152588f5ac51080c6c0763
|
||||||
|
# ArmPlatformPkg: Apply uncrustify changes
|
||||||
|
40b0b23ed34f48c26d711d3e4613a4bb35eeadff
|
||||||
|
# ArmPkg: Apply uncrustify changes
|
||||||
|
429309e0c6b74792d679681a8edd0d5ae0ff850c
|
24
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
24
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
## @file
|
||||||
|
# GitHub issue configuration file.
|
||||||
|
#
|
||||||
|
# This file is meant to direct contributors familiar with GitHub's issue tracker
|
||||||
|
# to the external resources used by TianoCore.
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Bugs and Feature Requests
|
||||||
|
url: https://bugzilla.tianocore.org/
|
||||||
|
about: Submit bug reports and feature requests here
|
||||||
|
- name: Reporting Security Issues
|
||||||
|
url: https://github.com/tianocore/tianocore.github.io/wiki/Reporting-Security-Issues
|
||||||
|
about: Read the wiki page that describes the process here
|
||||||
|
- name: EDK II Development Mailing List
|
||||||
|
url: https://edk2.groups.io/g/devel
|
||||||
|
about: Submit code patches and ask questions on the mailing list (devel@edk2.groups.io)
|
||||||
|
- name: EDK II Discussions
|
||||||
|
url: https://github.com/tianocore/edk2/discussions
|
||||||
|
about: You can also reach out on the Discussion section of this repository
|
29
.github/codeql/codeql-config.yml
vendored
Normal file
29
.github/codeql/codeql-config.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## @file
|
||||||
|
# CodeQL configuration file for edk2.
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
name: "CodeQL config"
|
||||||
|
|
||||||
|
# The following line disables the default queries. This is used because we want to enable on query at a time by
|
||||||
|
# explicitly specifying each query in a "queries" array as they are enabled.
|
||||||
|
#
|
||||||
|
# See the following for more information about adding custom queries:
|
||||||
|
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-a-custom-configuration-file
|
||||||
|
|
||||||
|
#disable-default-queries: true
|
||||||
|
|
||||||
|
queries:
|
||||||
|
- name: EDK2 CodeQL Query List
|
||||||
|
uses: ./.github/codeql/edk2.qls
|
||||||
|
|
||||||
|
# We must specify a query for CodeQL to run. Until the first query is enabled, enable the security query suite but
|
||||||
|
# exclude all problem levels from impacting the results. After the first query is enabled, this filter can be relaxed
|
||||||
|
# to find the level of problems desired from the query.
|
||||||
|
query-filters:
|
||||||
|
- exclude:
|
||||||
|
problem.severity:
|
||||||
|
- warning
|
||||||
|
- recommendation
|
24
.github/codeql/edk2.qls
vendored
Normal file
24
.github/codeql/edk2.qls
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- description: EDK2 (C++) queries
|
||||||
|
|
||||||
|
# Bring in all queries from the official cpp-queries suite so individual queries can be explicitly enabled.
|
||||||
|
|
||||||
|
- queries: '.'
|
||||||
|
from: codeql/cpp-queries
|
||||||
|
|
||||||
|
# Enable individual queries below.
|
||||||
|
|
||||||
|
- include:
|
||||||
|
id: cpp/conditionallyuninitializedvariable
|
||||||
|
- include:
|
||||||
|
id: cpp/infinite-loop-with-unsatisfiable-exit-condition
|
||||||
|
- include:
|
||||||
|
id: cpp/overflow-buffer
|
||||||
|
- include:
|
||||||
|
id: cpp/overrunning-write
|
||||||
|
- include:
|
||||||
|
id: cpp/overrunning-write-with-float
|
||||||
|
- include:
|
||||||
|
id: cpp/pointer-overflow-check
|
||||||
|
- include:
|
||||||
|
id: cpp/very-likely-overrunning-write
|
36
.github/dependabot.yml
vendored
Normal file
36
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
## @file
|
||||||
|
# Dependabot configuration file to enable GitHub services for managing and updating
|
||||||
|
# dependencies.
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
##
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
commit-message:
|
||||||
|
prefix: "pip"
|
||||||
|
reviewers:
|
||||||
|
- "makubacki"
|
||||||
|
- "mdkinney"
|
||||||
|
- "spbrogan"
|
||||||
|
rebase-strategy: "disabled"
|
||||||
|
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "monday"
|
||||||
|
commit-message:
|
||||||
|
prefix: "GitHub Action"
|
||||||
|
reviewers:
|
||||||
|
- "makubacki"
|
||||||
|
- "mdkinney"
|
||||||
|
- "spbrogan"
|
||||||
|
rebase-strategy: "disabled"
|
118
.github/workflows/codeql-analysis.yml
vendored
Normal file
118
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
# @file
|
||||||
|
# GitHub Workflow for CodeQL Analysis
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths-ignore:
|
||||||
|
- '**/*.bat'
|
||||||
|
- '**/*.md'
|
||||||
|
- '**/*.py'
|
||||||
|
- '**/*.rst'
|
||||||
|
- '**/*.sh'
|
||||||
|
- '**/*.txt'
|
||||||
|
|
||||||
|
schedule:
|
||||||
|
# https://crontab.guru/#20_23_*_*_4
|
||||||
|
- cron: '20 23 * * 4'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: windows-2019
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- Package: "ArmPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "CryptoPkg"
|
||||||
|
ArchList: "IA32"
|
||||||
|
- Package: "CryptoPkg"
|
||||||
|
ArchList: "X64"
|
||||||
|
- Package: "DynamicTablesPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "FatPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "FmpDevicePkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "IntelFsp2Pkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "IntelFsp2WrapperPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "MdeModulePkg"
|
||||||
|
ArchList: "IA32"
|
||||||
|
- Package: "MdeModulePkg"
|
||||||
|
ArchList: "X64"
|
||||||
|
- Package: "MdePkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "PcAtChipsetPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "PrmPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "SecurityPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "ShellPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "SourceLevelDebugPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "StandaloneMmPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "UefiCpuPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
- Package: "UnitTestFrameworkPkg"
|
||||||
|
ArchList: "IA32,X64"
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.10.6'
|
||||||
|
cache: 'pip'
|
||||||
|
cache-dependency-path: 'pip-requirements.txt'
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v2
|
||||||
|
with:
|
||||||
|
languages: 'cpp'
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||||
|
# Learn more about CodeQL language support at https://codeql.github.com/docs/codeql-overview/supported-languages-and-frameworks/
|
||||||
|
config-file: ./.github/codeql/codeql-config.yml
|
||||||
|
# Note: Add new queries to codeql-config.yml file as they are enabled.
|
||||||
|
|
||||||
|
- name: Install/Upgrade pip Modules
|
||||||
|
run: pip install -r pip-requirements.txt --upgrade
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
run: stuart_setup -c .pytool/CISettings.py -t DEBUG -a ${{ matrix.ArchList }} TOOL_CHAIN_TAG=VS2019
|
||||||
|
|
||||||
|
- name: Update
|
||||||
|
run: stuart_update -c .pytool/CISettings.py -t DEBUG -a ${{ matrix.ArchList }} TOOL_CHAIN_TAG=VS2019
|
||||||
|
|
||||||
|
- name: Build Tools From Source
|
||||||
|
run: python BaseTools/Edk2ToolsBuild.py -t VS2019
|
||||||
|
|
||||||
|
- name: CI Build
|
||||||
|
run: stuart_ci_build -c .pytool/CISettings.py -p ${{ matrix.Package }} -t DEBUG -a ${{ matrix.ArchList }} TOOL_CHAIN_TAG=VS2019
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
12
.gitmodules
vendored
12
.gitmodules
vendored
@@ -20,3 +20,15 @@
|
|||||||
[submodule "RedfishPkg/Library/JsonLib/jansson"]
|
[submodule "RedfishPkg/Library/JsonLib/jansson"]
|
||||||
path = RedfishPkg/Library/JsonLib/jansson
|
path = RedfishPkg/Library/JsonLib/jansson
|
||||||
url = https://github.com/akheron/jansson
|
url = https://github.com/akheron/jansson
|
||||||
|
[submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"]
|
||||||
|
path = UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
|
||||||
|
url = https://github.com/google/googletest.git
|
||||||
|
[submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"]
|
||||||
|
path = UnitTestFrameworkPkg/Library/SubhookLib/subhook
|
||||||
|
url = https://github.com/Zeex/subhook.git
|
||||||
|
[submodule "MdePkg/Library/BaseFdtLib/libfdt"]
|
||||||
|
path = MdePkg/Library/BaseFdtLib/libfdt
|
||||||
|
url = https://github.com/devicetree-org/pylibfdt.git
|
||||||
|
[submodule "MdePkg/Library/MipiSysTLib/mipisyst"]
|
||||||
|
path = MdePkg/Library/MipiSysTLib/mipisyst
|
||||||
|
url = https://github.com/MIPI-Alliance/public-mipi-sys-t.git
|
||||||
|
@@ -38,7 +38,6 @@ pull_request_rules:
|
|||||||
actions:
|
actions:
|
||||||
queue:
|
queue:
|
||||||
method: rebase
|
method: rebase
|
||||||
rebase_fallback: none
|
|
||||||
name: default
|
name: default
|
||||||
|
|
||||||
- name: Post a comment on a PR that can not be merged due to a merge conflict
|
- name: Post a comment on a PR that can not be merged due to a merge conflict
|
||||||
|
@@ -53,7 +53,10 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag
|
|||||||
"ArmPlatformPkg",
|
"ArmPlatformPkg",
|
||||||
"ArmVirtPkg",
|
"ArmVirtPkg",
|
||||||
"DynamicTablesPkg",
|
"DynamicTablesPkg",
|
||||||
|
"EmbeddedPkg",
|
||||||
"EmulatorPkg",
|
"EmulatorPkg",
|
||||||
|
"IntelFsp2Pkg",
|
||||||
|
"IntelFsp2WrapperPkg",
|
||||||
"MdePkg",
|
"MdePkg",
|
||||||
"MdeModulePkg",
|
"MdeModulePkg",
|
||||||
"NetworkPkg",
|
"NetworkPkg",
|
||||||
@@ -62,6 +65,7 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag
|
|||||||
"UefiCpuPkg",
|
"UefiCpuPkg",
|
||||||
"FmpDevicePkg",
|
"FmpDevicePkg",
|
||||||
"ShellPkg",
|
"ShellPkg",
|
||||||
|
"SignedCapsulePkg",
|
||||||
"StandaloneMmPkg",
|
"StandaloneMmPkg",
|
||||||
"FatPkg",
|
"FatPkg",
|
||||||
"CryptoPkg",
|
"CryptoPkg",
|
||||||
@@ -69,6 +73,7 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag
|
|||||||
"UnitTestFrameworkPkg",
|
"UnitTestFrameworkPkg",
|
||||||
"OvmfPkg",
|
"OvmfPkg",
|
||||||
"RedfishPkg",
|
"RedfishPkg",
|
||||||
|
"SourceLevelDebugPkg",
|
||||||
"UefiPayloadPkg"
|
"UefiPayloadPkg"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -79,7 +84,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag
|
|||||||
"X64",
|
"X64",
|
||||||
"ARM",
|
"ARM",
|
||||||
"AARCH64",
|
"AARCH64",
|
||||||
"RISCV64")
|
"RISCV64",
|
||||||
|
"LOONGARCH64")
|
||||||
|
|
||||||
def GetTargetsSupported(self):
|
def GetTargetsSupported(self):
|
||||||
''' return iterable of edk2 target tags supported by this build '''
|
''' return iterable of edk2 target tags supported by this build '''
|
||||||
@@ -163,13 +169,6 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag
|
|||||||
else:
|
else:
|
||||||
logging.warning("Falling back to using in-tree BaseTools")
|
logging.warning("Falling back to using in-tree BaseTools")
|
||||||
|
|
||||||
if is_linux and self.ActualToolChainTag.upper().startswith("GCC"):
|
|
||||||
if "AARCH64" in self.ActualArchitectures:
|
|
||||||
scopes += ("gcc_aarch64_linux",)
|
|
||||||
if "ARM" in self.ActualArchitectures:
|
|
||||||
scopes += ("gcc_arm_linux",)
|
|
||||||
if "RISCV64" in self.ActualArchitectures:
|
|
||||||
scopes += ("gcc_riscv64_unknown",)
|
|
||||||
self.ActualScopes = scopes
|
self.ActualScopes = scopes
|
||||||
return self.ActualScopes
|
return self.ActualScopes
|
||||||
|
|
||||||
@@ -184,6 +183,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag
|
|||||||
"CryptoPkg/Library/OpensslLib/openssl", False))
|
"CryptoPkg/Library/OpensslLib/openssl", False))
|
||||||
rs.append(RequiredSubmodule(
|
rs.append(RequiredSubmodule(
|
||||||
"UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))
|
"UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))
|
||||||
|
rs.append(RequiredSubmodule(
|
||||||
|
"UnitTestFrameworkPkg/Library/GoogleTestLib/googletest", False))
|
||||||
rs.append(RequiredSubmodule(
|
rs.append(RequiredSubmodule(
|
||||||
"MdeModulePkg/Universal/RegularExpressionDxe/oniguruma", False))
|
"MdeModulePkg/Universal/RegularExpressionDxe/oniguruma", False))
|
||||||
rs.append(RequiredSubmodule(
|
rs.append(RequiredSubmodule(
|
||||||
@@ -192,6 +193,12 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag
|
|||||||
"BaseTools/Source/C/BrotliCompress/brotli", False))
|
"BaseTools/Source/C/BrotliCompress/brotli", False))
|
||||||
rs.append(RequiredSubmodule(
|
rs.append(RequiredSubmodule(
|
||||||
"RedfishPkg/Library/JsonLib/jansson", False))
|
"RedfishPkg/Library/JsonLib/jansson", False))
|
||||||
|
rs.append(RequiredSubmodule(
|
||||||
|
"UnitTestFrameworkPkg/Library/SubhookLib/subhook", False))
|
||||||
|
rs.append(RequiredSubmodule(
|
||||||
|
"MdePkg/Library/BaseFdtLib/libfdt", False))
|
||||||
|
rs.append(RequiredSubmodule(
|
||||||
|
"MdePkg/Library/MipiSysTLib/mipisyst", False))
|
||||||
return rs
|
return rs
|
||||||
|
|
||||||
def GetName(self):
|
def GetName(self):
|
||||||
|
@@ -93,9 +93,7 @@ class CharEncodingCheck(ICiBuildPlugin):
|
|||||||
files = [Edk2pathObj.GetAbsolutePathOnThisSystemFromEdk2RelativePath(x) for x in files]
|
files = [Edk2pathObj.GetAbsolutePathOnThisSystemFromEdk2RelativePath(x) for x in files]
|
||||||
for a in files:
|
for a in files:
|
||||||
files_tested += 1
|
files_tested += 1
|
||||||
if(self.TestEncodingOk(a, enc)):
|
if not self.TestEncodingOk(a, enc):
|
||||||
logging.debug("File {0} Passed Encoding Check {1}".format(a, enc))
|
|
||||||
else:
|
|
||||||
tc.LogStdError("Encoding Failure in {0}. Not {1}".format(a, enc))
|
tc.LogStdError("Encoding Failure in {0}. Not {1}".format(a, enc))
|
||||||
overall_status += 1
|
overall_status += 1
|
||||||
|
|
||||||
|
@@ -69,6 +69,13 @@ class EccCheck(ICiBuildPlugin):
|
|||||||
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
|
||||||
|
|
||||||
|
abs_pkg_path = Edk2pathObj.GetAbsolutePathOnThisSystemFromEdk2RelativePath(packagename)
|
||||||
|
|
||||||
|
if abs_pkg_path is None:
|
||||||
|
tc.SetSkipped()
|
||||||
|
tc.LogStdError("No Package folder {0}".format(abs_pkg_path))
|
||||||
|
return 0
|
||||||
|
|
||||||
# Create temp directory
|
# Create temp directory
|
||||||
temp_path = os.path.join(workspace_path, 'Build', '.pytool', 'Plugin', 'EccCheck')
|
temp_path = os.path.join(workspace_path, 'Build', '.pytool', 'Plugin', 'EccCheck')
|
||||||
try:
|
try:
|
||||||
@@ -77,7 +84,7 @@ class EccCheck(ICiBuildPlugin):
|
|||||||
shutil.rmtree(temp_path)
|
shutil.rmtree(temp_path)
|
||||||
# Copy package being scanned to temp_path
|
# Copy package being scanned to temp_path
|
||||||
shutil.copytree (
|
shutil.copytree (
|
||||||
os.path.join(workspace_path, packagename),
|
abs_pkg_path,
|
||||||
os.path.join(temp_path, packagename),
|
os.path.join(temp_path, packagename),
|
||||||
symlinks=True
|
symlinks=True
|
||||||
)
|
)
|
||||||
|
@@ -289,6 +289,8 @@
|
|||||||
"unrecovered",
|
"unrecovered",
|
||||||
"cmocka",
|
"cmocka",
|
||||||
"unenrolling",
|
"unenrolling",
|
||||||
"unconfigure"
|
"unconfigure",
|
||||||
|
"Loongson",
|
||||||
|
"LOONGARCH"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,12 @@
|
|||||||
# Edk2 Continuous Integration
|
# Edk2 Continuous Integration
|
||||||
|
|
||||||
|
This file focuses on information for those working with the `.pytools` directory
|
||||||
|
directly or interested in lower-level details about how CI works.
|
||||||
|
|
||||||
|
If you just want to get started building code, visit
|
||||||
|
[Build Instructions](https://github.com/tianocore/tianocore.github.io/wiki/Build-Instruction)
|
||||||
|
on the TianoCore wiki.
|
||||||
|
|
||||||
## Basic Status
|
## Basic Status
|
||||||
|
|
||||||
| Package | Windows VS2019 (IA32/X64)| Ubuntu GCC (IA32/X64/ARM/AARCH64) | Known Issues |
|
| Package | Windows VS2019 (IA32/X64)| Ubuntu GCC (IA32/X64/ARM/AARCH64) | Known Issues |
|
||||||
@@ -82,43 +89,18 @@ easily and consistently running locally and in a cloud ci environment. To do
|
|||||||
that a few steps should be followed. Details of EDKII Tools can be found in the
|
that a few steps should be followed. Details of EDKII Tools can be found in the
|
||||||
[docs folder here](https://github.com/tianocore/edk2-pytool-extensions/tree/master/docs)
|
[docs folder here](https://github.com/tianocore/edk2-pytool-extensions/tree/master/docs)
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
1. A supported toolchain (others might work but this is what is tested and validated)
|
|
||||||
* Windows 10:
|
|
||||||
* VS 2017 or VS 2019
|
|
||||||
* Windows SDK (for rc)
|
|
||||||
* Windows WDK (for capsules)
|
|
||||||
* Ubuntu 18.04 or Fedora
|
|
||||||
* GCC5
|
|
||||||
* Easy to add more but this is the current state
|
|
||||||
2. Python 3.7.x or newer on path
|
|
||||||
3. git on path
|
|
||||||
4. Recommended to setup and activate a python virtual environment
|
|
||||||
5. Install the requirements `pip install --upgrade -r pip-requirements.txt`
|
|
||||||
|
|
||||||
### Running CI
|
### Running CI
|
||||||
|
|
||||||
1. clone your edk2 repo
|
Quick notes:
|
||||||
2. Activate your python virtual environment in cmd window
|
|
||||||
3. Get code dependencies (done only when submodules change)
|
* By default all CI plugins are opted in.
|
||||||
* `stuart_setup -c .pytool/CISettings.py TOOL_CHAIN_TAG=<your tag here>`
|
* Setting the plugin to `skip` as an argument will skip running the plugin.
|
||||||
4. Update other dependencies (done more often)
|
Examples:
|
||||||
* `stuart_update -c .pytool/CISettings.py TOOL_CHAIN_TAG=<your tag here>`
|
|
||||||
5. Run CI build (--help will give you options)
|
|
||||||
* `stuart_ci_build -c .pytool/CISettings.py TOOL_CHAIN_TAG=<your tag here>`
|
|
||||||
* -p <pkg1,pkg2,pkg3> : To build only certain packages use a CSV list
|
|
||||||
* -a <arch1,arch2,arch3>: To run only certain architectures use a CSV list
|
|
||||||
* -t <target1,target2>: To run only tests related to certain targets use a
|
|
||||||
CSV list
|
|
||||||
* By default all tests are opted in. Then given a package.ci.yaml file those
|
|
||||||
tests can be configured for a package. Finally setting the check to the
|
|
||||||
value `skip` will skip that plugin. Examples:
|
|
||||||
* `CompilerPlugin=skip` skip the build test
|
* `CompilerPlugin=skip` skip the build test
|
||||||
* `GuidCheck=skip` skip the Guid check
|
* `GuidCheck=skip` skip the Guid check
|
||||||
* `SpellCheck=skip` skip the spell checker
|
* `SpellCheck=skip` skip the spell checker
|
||||||
* etc
|
* etc.
|
||||||
6. Detailed reports and logs per package are captured in the `Build` directory
|
* Detailed reports and logs per package are captured in the `Build` directory.
|
||||||
|
|
||||||
## Current PyTool Test Capabilities
|
## Current PyTool Test Capabilities
|
||||||
|
|
||||||
|
2430
ArmPkg/Application/ArmCpuInfo/ArmCpuInfo.c
Normal file
2430
ArmPkg/Application/ArmCpuInfo/ArmCpuInfo.c
Normal file
File diff suppressed because it is too large
Load Diff
31
ArmPkg/Application/ArmCpuInfo/ArmCpuInfo.inf
Normal file
31
ArmPkg/Application/ArmCpuInfo/ArmCpuInfo.inf
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
## @file
|
||||||
|
# Application to present AArch64 cpu information.
|
||||||
|
#
|
||||||
|
# Based on HelloWorld:
|
||||||
|
# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
|
# Copyright (c) 2023, Linaro Ltd. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010019
|
||||||
|
BASE_NAME = ArmCpuInfo
|
||||||
|
FILE_GUID = b3134491-6502-4faf-a9da-007184e32163
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = UefiMain
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
ArmCpuInfo.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
ArmPkg/ArmPkg.dec
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
ArmLib
|
||||||
|
UefiApplicationEntryPoint
|
||||||
|
UefiLib
|
@@ -87,7 +87,7 @@
|
|||||||
|
|
||||||
## options defined .pytool/Plugin/SpellCheck
|
## options defined .pytool/Plugin/SpellCheck
|
||||||
"SpellCheck": {
|
"SpellCheck": {
|
||||||
"AuditOnly": False,
|
"AuditOnly": True,
|
||||||
"IgnoreFiles": [
|
"IgnoreFiles": [
|
||||||
"Library/ArmSoftFloatLib/berkeley-softfloat-3/**"
|
"Library/ArmSoftFloatLib/berkeley-softfloat-3/**"
|
||||||
], # use gitignore syntax to ignore errors
|
], # use gitignore syntax to ignore errors
|
||||||
@@ -239,5 +239,10 @@
|
|||||||
],
|
],
|
||||||
"AdditionalIncludePaths": [] # Additional paths to spell check
|
"AdditionalIncludePaths": [] # Additional paths to spell check
|
||||||
# (wildcards supported)
|
# (wildcards supported)
|
||||||
|
},
|
||||||
|
|
||||||
|
# options defined in .pytool/Plugin/UncrustifyCheck
|
||||||
|
"UncrustifyCheck": {
|
||||||
|
"AuditOnly": True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
# ARM processor package.
|
# ARM processor package.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
|
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
|
||||||
# Copyright (c) 2011 - 2021, ARM Limited. All rights reserved.
|
# Copyright (c) 2011 - 2023, ARM Limited. All rights reserved.
|
||||||
# Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
|
# Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
@@ -71,6 +71,11 @@
|
|||||||
#
|
#
|
||||||
ArmSvcLib|Include/Library/ArmSvcLib.h
|
ArmSvcLib|Include/Library/ArmSvcLib.h
|
||||||
|
|
||||||
|
## @libraryclass Provides a Monitor Call interface that will use the
|
||||||
|
# default conduit (HVC or SMC).
|
||||||
|
#
|
||||||
|
ArmMonitorLib|Include/Library/ArmMonitorLib.h
|
||||||
|
|
||||||
## @libraryclass Provides a default exception handler.
|
## @libraryclass Provides a default exception handler.
|
||||||
#
|
#
|
||||||
DefaultExceptionHandlerLib|Include/Library/DefaultExceptionHandlerLib.h
|
DefaultExceptionHandlerLib|Include/Library/DefaultExceptionHandlerLib.h
|
||||||
@@ -99,6 +104,8 @@
|
|||||||
# Include/Guid/ArmMpCoreInfo.h
|
# Include/Guid/ArmMpCoreInfo.h
|
||||||
gArmMpCoreInfoGuid = { 0xa4ee0728, 0xe5d7, 0x4ac5, {0xb2, 0x1e, 0x65, 0x8e, 0xd8, 0x57, 0xe8, 0x34} }
|
gArmMpCoreInfoGuid = { 0xa4ee0728, 0xe5d7, 0x4ac5, {0xb2, 0x1e, 0x65, 0x8e, 0xd8, 0x57, 0xe8, 0x34} }
|
||||||
|
|
||||||
|
gArmMmuReplaceLiveTranslationEntryFuncGuid = { 0xa8b50ff3, 0x08ec, 0x4dd3, {0xbf, 0x04, 0x28, 0xbf, 0x71, 0x75, 0xc7, 0x4a} }
|
||||||
|
|
||||||
[Protocols.common]
|
[Protocols.common]
|
||||||
## Arm System Control and Management Interface(SCMI) Base protocol
|
## Arm System Control and Management Interface(SCMI) Base protocol
|
||||||
## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
|
## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
|
||||||
@@ -132,6 +139,16 @@
|
|||||||
# Define if the GICv3 controller should use the GICv2 legacy
|
# Define if the GICv3 controller should use the GICv2 legacy
|
||||||
gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042
|
gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042
|
||||||
|
|
||||||
|
## Define the conduit to use for monitor calls.
|
||||||
|
# Default PcdMonitorConduitHvc = FALSE, conduit = SMC
|
||||||
|
# If PcdMonitorConduitHvc = TRUE, conduit = HVC
|
||||||
|
gArmTokenSpaceGuid.PcdMonitorConduitHvc|FALSE|BOOLEAN|0x00000047
|
||||||
|
|
||||||
|
# Whether to remap all unused memory NX before installing the CPU arch
|
||||||
|
# protocol driver. This is needed on platforms that map all DRAM with RWX
|
||||||
|
# attributes initially, and can be disabled otherwise.
|
||||||
|
gArmTokenSpaceGuid.PcdRemapUnusedMemoryNx|TRUE|BOOLEAN|0x00000048
|
||||||
|
|
||||||
[PcdsFeatureFlag.ARM]
|
[PcdsFeatureFlag.ARM]
|
||||||
# Whether to map normal memory as non-shareable. FALSE is the safe choice, but
|
# Whether to map normal memory as non-shareable. FALSE is the safe choice, but
|
||||||
# TRUE may be appropriate to fix performance problems if you don't care about
|
# TRUE may be appropriate to fix performance problems if you don't care about
|
||||||
@@ -209,6 +226,13 @@
|
|||||||
#
|
#
|
||||||
gArmTokenSpaceGuid.PcdArmDmaDeviceOffset|0x0|UINT64|0x0000044
|
gArmTokenSpaceGuid.PcdArmDmaDeviceOffset|0x0|UINT64|0x0000044
|
||||||
|
|
||||||
|
#
|
||||||
|
# Boot the Uefi Shell instead of UiApp when no valid boot option is found.
|
||||||
|
# This is useful in CI environment so that startup.nsh can be launched.
|
||||||
|
# The default value is FALSE.
|
||||||
|
#
|
||||||
|
gArmTokenSpaceGuid.PcdUefiShellDefaultBootEnable|FALSE|BOOLEAN|0x0000052
|
||||||
|
|
||||||
[PcdsFixedAtBuild.common, PcdsPatchableInModule.common]
|
[PcdsFixedAtBuild.common, PcdsPatchableInModule.common]
|
||||||
gArmTokenSpaceGuid.PcdFdBaseAddress|0|UINT64|0x0000002B
|
gArmTokenSpaceGuid.PcdFdBaseAddress|0|UINT64|0x0000002B
|
||||||
gArmTokenSpaceGuid.PcdFvBaseAddress|0|UINT64|0x0000002D
|
gArmTokenSpaceGuid.PcdFvBaseAddress|0|UINT64|0x0000002D
|
||||||
|
@@ -113,7 +113,6 @@
|
|||||||
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
|
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
|
||||||
ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
|
ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
|
||||||
ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
|
ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
|
||||||
ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
|
|
||||||
ArmPkg/Library/SemiHostingDebugLib/SemiHostingDebugLib.inf
|
ArmPkg/Library/SemiHostingDebugLib/SemiHostingDebugLib.inf
|
||||||
ArmPkg/Library/SemiHostingSerialPortLib/SemiHostingSerialPortLib.inf
|
ArmPkg/Library/SemiHostingSerialPortLib/SemiHostingSerialPortLib.inf
|
||||||
ArmPkg/Library/SemihostLib/SemihostLib.inf
|
ArmPkg/Library/SemihostLib/SemihostLib.inf
|
||||||
@@ -131,9 +130,12 @@
|
|||||||
ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
|
ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
|
||||||
ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf
|
ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf
|
||||||
|
|
||||||
|
ArmPkg/Library/ArmTrngLib/ArmTrngLib.inf
|
||||||
|
ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
|
||||||
|
ArmPkg/Library/ArmHvcLibNull/ArmHvcLibNull.inf
|
||||||
|
ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf
|
||||||
ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
|
ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
|
||||||
ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf
|
ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf
|
||||||
ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
|
|
||||||
ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
|
ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
|
||||||
ArmPkg/Library/OpteeLib/OpteeLib.inf
|
ArmPkg/Library/OpteeLib/OpteeLib.inf
|
||||||
|
|
||||||
@@ -160,9 +162,13 @@
|
|||||||
ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
|
ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
|
||||||
ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLibNull.inf
|
ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLibNull.inf
|
||||||
|
|
||||||
|
ArmPkg/Drivers/MmCommunicationPei/MmCommunicationPei.inf
|
||||||
|
|
||||||
[Components.AARCH64]
|
[Components.AARCH64]
|
||||||
|
ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.inf
|
||||||
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
|
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
|
||||||
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
|
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
|
||||||
|
ArmPkg/Application/ArmCpuInfo/ArmCpuInfo.inf
|
||||||
|
|
||||||
[Components.AARCH64, Components.ARM]
|
[Components.AARCH64, Components.ARM]
|
||||||
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
|
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2013-2017, ARM Ltd. All rights reserved.<BR>
|
Copyright (c) 2013-2023, Arm Ltd. All rights reserved.<BR>
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
@@ -8,20 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
|
|
||||||
#include "ArmGicDxe.h"
|
#include "ArmGicDxe.h"
|
||||||
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
IrqInterruptHandler (
|
|
||||||
IN EFI_EXCEPTION_TYPE InterruptType,
|
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
|
||||||
);
|
|
||||||
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
ExitBootServicesEvent (
|
|
||||||
IN EFI_EVENT Event,
|
|
||||||
IN VOID *Context
|
|
||||||
);
|
|
||||||
|
|
||||||
// Making this global saves a few bytes in image size
|
// Making this global saves a few bytes in image size
|
||||||
EFI_HANDLE gHardwareInterruptHandle = NULL;
|
EFI_HANDLE gHardwareInterruptHandle = NULL;
|
||||||
|
|
||||||
@@ -61,7 +47,7 @@ GicGetDistributorIcfgBaseAndBit (
|
|||||||
|
|
||||||
RegIndex = Source / ARM_GIC_ICDICFR_F_STRIDE; // NOTE: truncation is significant
|
RegIndex = Source / ARM_GIC_ICDICFR_F_STRIDE; // NOTE: truncation is significant
|
||||||
Field = Source % ARM_GIC_ICDICFR_F_STRIDE;
|
Field = Source % ARM_GIC_ICDICFR_F_STRIDE;
|
||||||
*RegAddress = PcdGet64 (PcdGicDistributorBase)
|
*RegAddress = (UINTN)PcdGet64 (PcdGicDistributorBase)
|
||||||
+ ARM_GIC_ICDICFR
|
+ ARM_GIC_ICDICFR
|
||||||
+ (ARM_GIC_ICDICFR_BYTES * RegIndex);
|
+ (ARM_GIC_ICDICFR_BYTES * RegIndex);
|
||||||
*Config1Bit = ((Field * ARM_GIC_ICDICFR_F_WIDTH)
|
*Config1Bit = ((Field * ARM_GIC_ICDICFR_F_WIDTH)
|
||||||
@@ -137,7 +123,7 @@ CpuArchEventProtocolNotify (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: Cpu->RegisterInterruptHandler() - %r\n",
|
"%a: Cpu->RegisterInterruptHandler() - %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
@@ -153,7 +139,7 @@ CpuArchEventProtocolNotify (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: Cpu->RegisterInterruptHandler() - %r\n",
|
"%a: Cpu->RegisterInterruptHandler() - %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2021, Arm Limited. All rights reserved.
|
* Copyright (c) 2011-2023, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
*
|
*
|
||||||
@@ -104,10 +104,17 @@ GicGetCpuRedistributorBase (
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINTN
|
/**
|
||||||
|
Return the GIC CPU Interrupt Interface ID.
|
||||||
|
|
||||||
|
@param GicInterruptInterfaceBase Base address of the GIC Interrupt Interface.
|
||||||
|
|
||||||
|
@retval CPU Interface Identification information.
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicGetInterfaceIdentification (
|
ArmGicGetInterfaceIdentification (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Read the GIC Identification Register
|
// Read the GIC Identification Register
|
||||||
@@ -117,7 +124,7 @@ ArmGicGetInterfaceIdentification (
|
|||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicGetMaxNumInterrupts (
|
ArmGicGetMaxNumInterrupts (
|
||||||
IN INTN GicDistributorBase
|
IN UINTN GicDistributorBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN ItLines;
|
UINTN ItLines;
|
||||||
@@ -133,15 +140,17 @@ ArmGicGetMaxNumInterrupts (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicSendSgiTo (
|
ArmGicSendSgiTo (
|
||||||
IN INTN GicDistributorBase,
|
IN UINTN GicDistributorBase,
|
||||||
IN INTN TargetListFilter,
|
IN UINT8 TargetListFilter,
|
||||||
IN INTN CPUTargetList,
|
IN UINT8 CPUTargetList,
|
||||||
IN INTN SgiId
|
IN UINT8 SgiId
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MmioWrite32 (
|
MmioWrite32 (
|
||||||
GicDistributorBase + ARM_GIC_ICDSGIR,
|
GicDistributorBase + ARM_GIC_ICDSGIR,
|
||||||
((TargetListFilter & 0x3) << 24) | ((CPUTargetList & 0xFF) << 16) | SgiId
|
((TargetListFilter & 0x3) << 24) |
|
||||||
|
((CPUTargetList & 0xFF) << 16) |
|
||||||
|
(SgiId & 0xF)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,19 +176,17 @@ ArmGicAcknowledgeInterrupt (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN Value;
|
UINTN Value;
|
||||||
|
UINTN IntId;
|
||||||
ARM_GIC_ARCH_REVISION Revision;
|
ARM_GIC_ARCH_REVISION Revision;
|
||||||
|
|
||||||
|
ASSERT (InterruptId != NULL);
|
||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if (Revision == ARM_GIC_ARCH_REVISION_2) {
|
if (Revision == ARM_GIC_ARCH_REVISION_2) {
|
||||||
Value = ArmGicV2AcknowledgeInterrupt (GicInterruptInterfaceBase);
|
Value = ArmGicV2AcknowledgeInterrupt (GicInterruptInterfaceBase);
|
||||||
// InterruptId is required for the caller to know if a valid or spurious
|
IntId = Value & ARM_GIC_ICCIAR_ACKINTID;
|
||||||
// interrupt has been read
|
|
||||||
ASSERT (InterruptId != NULL);
|
|
||||||
if (InterruptId != NULL) {
|
|
||||||
*InterruptId = Value & ARM_GIC_ICCIAR_ACKINTID;
|
|
||||||
}
|
|
||||||
} else if (Revision == ARM_GIC_ARCH_REVISION_3) {
|
} else if (Revision == ARM_GIC_ARCH_REVISION_3) {
|
||||||
Value = ArmGicV3AcknowledgeInterrupt ();
|
Value = ArmGicV3AcknowledgeInterrupt ();
|
||||||
|
IntId = Value;
|
||||||
} else {
|
} else {
|
||||||
ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
|
ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
|
||||||
// Report Spurious interrupt which is what the above controllers would
|
// Report Spurious interrupt which is what the above controllers would
|
||||||
@@ -187,6 +194,12 @@ ArmGicAcknowledgeInterrupt (
|
|||||||
Value = 1023;
|
Value = 1023;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (InterruptId != NULL) {
|
||||||
|
// InterruptId is required for the caller to know if a valid or spurious
|
||||||
|
// interrupt has been read
|
||||||
|
*InterruptId = IntId;
|
||||||
|
}
|
||||||
|
|
||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,13 +232,13 @@ ArmGicSetInterruptPriority (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 RegOffset;
|
UINT32 RegOffset;
|
||||||
UINTN RegShift;
|
UINT8 RegShift;
|
||||||
ARM_GIC_ARCH_REVISION Revision;
|
ARM_GIC_ARCH_REVISION Revision;
|
||||||
UINTN GicCpuRedistributorBase;
|
UINTN GicCpuRedistributorBase;
|
||||||
|
|
||||||
// Calculate register offset and bit position
|
// Calculate register offset and bit position
|
||||||
RegOffset = Source / 4;
|
RegOffset = (UINT32)(Source / 4);
|
||||||
RegShift = (Source % 4) * 8;
|
RegShift = (UINT8)((Source % 4) * 8);
|
||||||
|
|
||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
||||||
@@ -263,13 +276,13 @@ ArmGicEnableInterrupt (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 RegOffset;
|
UINT32 RegOffset;
|
||||||
UINTN RegShift;
|
UINT8 RegShift;
|
||||||
ARM_GIC_ARCH_REVISION Revision;
|
ARM_GIC_ARCH_REVISION Revision;
|
||||||
UINTN GicCpuRedistributorBase;
|
UINTN GicCpuRedistributorBase;
|
||||||
|
|
||||||
// Calculate enable register offset and bit position
|
// Calculate enable register offset and bit position
|
||||||
RegOffset = Source / 32;
|
RegOffset = (UINT32)(Source / 32);
|
||||||
RegShift = Source % 32;
|
RegShift = (UINT8)(Source % 32);
|
||||||
|
|
||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
||||||
@@ -308,13 +321,13 @@ ArmGicDisableInterrupt (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 RegOffset;
|
UINT32 RegOffset;
|
||||||
UINTN RegShift;
|
UINT8 RegShift;
|
||||||
ARM_GIC_ARCH_REVISION Revision;
|
ARM_GIC_ARCH_REVISION Revision;
|
||||||
UINTN GicCpuRedistributorBase;
|
UINTN GicCpuRedistributorBase;
|
||||||
|
|
||||||
// Calculate enable register offset and bit position
|
// Calculate enable register offset and bit position
|
||||||
RegOffset = Source / 32;
|
RegOffset = (UINT32)(Source / 32);
|
||||||
RegShift = Source % 32;
|
RegShift = (UINT8)(Source % 32);
|
||||||
|
|
||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
||||||
@@ -352,14 +365,14 @@ ArmGicIsInterruptEnabled (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 RegOffset;
|
UINT32 RegOffset;
|
||||||
UINTN RegShift;
|
UINT8 RegShift;
|
||||||
ARM_GIC_ARCH_REVISION Revision;
|
ARM_GIC_ARCH_REVISION Revision;
|
||||||
UINTN GicCpuRedistributorBase;
|
UINTN GicCpuRedistributorBase;
|
||||||
UINT32 Interrupts;
|
UINT32 Interrupts;
|
||||||
|
|
||||||
// Calculate enable register offset and bit position
|
// Calculate enable register offset and bit position
|
||||||
RegOffset = Source / 32;
|
RegOffset = (UINT32)(Source / 32);
|
||||||
RegShift = Source % 32;
|
RegShift = (UINT8)(Source % 32);
|
||||||
|
|
||||||
Revision = ArmGicGetSupportedArchRevision ();
|
Revision = ArmGicGetSupportedArchRevision ();
|
||||||
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
|
||||||
@@ -390,7 +403,7 @@ ArmGicIsInterruptEnabled (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicDisableDistributor (
|
ArmGicDisableDistributor (
|
||||||
IN INTN GicDistributorBase
|
IN UINTN GicDistributorBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Disable Gic Distributor
|
// Disable Gic Distributor
|
||||||
@@ -400,7 +413,7 @@ ArmGicDisableDistributor (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicEnableInterruptInterface (
|
ArmGicEnableInterruptInterface (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_GIC_ARCH_REVISION Revision;
|
ARM_GIC_ARCH_REVISION Revision;
|
||||||
@@ -418,7 +431,7 @@ ArmGicEnableInterruptInterface (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicDisableInterruptInterface (
|
ArmGicDisableInterruptInterface (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_GIC_ARCH_REVISION Revision;
|
ARM_GIC_ARCH_REVISION Revision;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
|
* Copyright (c) 2011-2023, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
*
|
*
|
||||||
@@ -13,10 +13,11 @@
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicEnableDistributor (
|
ArmGicEnableDistributor (
|
||||||
IN INTN GicDistributorBase
|
IN UINTN GicDistributorBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_GIC_ARCH_REVISION Revision;
|
ARM_GIC_ARCH_REVISION Revision;
|
||||||
|
UINT32 GicDistributorCtl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable GIC distributor in Non-Secure world.
|
* Enable GIC distributor in Non-Secure world.
|
||||||
@@ -26,7 +27,8 @@ ArmGicEnableDistributor (
|
|||||||
if (Revision == ARM_GIC_ARCH_REVISION_2) {
|
if (Revision == ARM_GIC_ARCH_REVISION_2) {
|
||||||
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x1);
|
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x1);
|
||||||
} else {
|
} else {
|
||||||
if (MmioRead32 (GicDistributorBase + ARM_GIC_ICDDCR) & ARM_GIC_ICDDCR_ARE) {
|
GicDistributorCtl = MmioRead32 (GicDistributorBase + ARM_GIC_ICDDCR);
|
||||||
|
if ((GicDistributorCtl & ARM_GIC_ICDDCR_ARE) != 0) {
|
||||||
MmioOr32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x2);
|
MmioOr32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x2);
|
||||||
} else {
|
} else {
|
||||||
MmioOr32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x1);
|
MmioOr32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x1);
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 2009, Hewlett-Packard Company. All rights reserved.<BR>
|
Copyright (c) 2009, Hewlett-Packard Company. All rights reserved.<BR>
|
||||||
Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR>
|
Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR>
|
||||||
Portions copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
|
Portions copyright (c) 2011-2023, Arm Ltd. All rights reserved.<BR>
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ Abstract:
|
|||||||
extern EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV2Protocol;
|
extern EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV2Protocol;
|
||||||
extern EFI_HARDWARE_INTERRUPT2_PROTOCOL gHardwareInterrupt2V2Protocol;
|
extern EFI_HARDWARE_INTERRUPT2_PROTOCOL gHardwareInterrupt2V2Protocol;
|
||||||
|
|
||||||
STATIC UINT32 mGicInterruptInterfaceBase;
|
STATIC UINTN mGicInterruptInterfaceBase;
|
||||||
STATIC UINT32 mGicDistributorBase;
|
STATIC UINTN mGicDistributorBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Enable interrupt source Source.
|
Enable interrupt source Source.
|
||||||
@@ -162,7 +162,7 @@ GicV2IrqInterruptHandler (
|
|||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 GicInterrupt;
|
UINTN GicInterrupt;
|
||||||
HARDWARE_INTERRUPT_HANDLER InterruptHandler;
|
HARDWARE_INTERRUPT_HANDLER InterruptHandler;
|
||||||
|
|
||||||
GicInterrupt = ArmGicV2AcknowledgeInterrupt (mGicInterruptInterfaceBase);
|
GicInterrupt = ArmGicV2AcknowledgeInterrupt (mGicInterruptInterfaceBase);
|
||||||
@@ -179,7 +179,7 @@ GicV2IrqInterruptHandler (
|
|||||||
// Call the registered interrupt handler.
|
// Call the registered interrupt handler.
|
||||||
InterruptHandler (GicInterrupt, SystemContext);
|
InterruptHandler (GicInterrupt, SystemContext);
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR, "Spurious GIC interrupt: 0x%x\n", GicInterrupt));
|
DEBUG ((DEBUG_ERROR, "Spurious GIC interrupt: 0x%x\n", (UINT32)GicInterrupt));
|
||||||
GicV2EndOfInterrupt (&gHardwareInterruptV2Protocol, GicInterrupt);
|
GicV2EndOfInterrupt (&gHardwareInterruptV2Protocol, GicInterrupt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -350,7 +350,7 @@ GicV2ExitBootServicesEvent (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINT32 GicInterrupt;
|
UINTN GicInterrupt;
|
||||||
|
|
||||||
// Disable all the interrupts
|
// Disable all the interrupts
|
||||||
for (Index = 0; Index < mGicNumInterrupts; Index++) {
|
for (Index = 0; Index < mGicNumInterrupts; Index++) {
|
||||||
@@ -393,23 +393,26 @@ GicV2DxeInitialize (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINT32 RegOffset;
|
UINT32 RegOffset;
|
||||||
UINTN RegShift;
|
UINT8 RegShift;
|
||||||
UINT32 CpuTarget;
|
UINT32 CpuTarget;
|
||||||
|
|
||||||
// Make sure the Interrupt Controller Protocol is not already installed in
|
// Make sure the Interrupt Controller Protocol is not already installed in
|
||||||
// the system.
|
// the system.
|
||||||
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
|
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
|
||||||
|
|
||||||
mGicInterruptInterfaceBase = PcdGet64 (PcdGicInterruptInterfaceBase);
|
ASSERT (PcdGet64 (PcdGicInterruptInterfaceBase) <= MAX_UINTN);
|
||||||
mGicDistributorBase = PcdGet64 (PcdGicDistributorBase);
|
ASSERT (PcdGet64 (PcdGicDistributorBase) <= MAX_UINTN);
|
||||||
|
|
||||||
|
mGicInterruptInterfaceBase = (UINTN)PcdGet64 (PcdGicInterruptInterfaceBase);
|
||||||
|
mGicDistributorBase = (UINTN)PcdGet64 (PcdGicDistributorBase);
|
||||||
mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase);
|
mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase);
|
||||||
|
|
||||||
for (Index = 0; Index < mGicNumInterrupts; Index++) {
|
for (Index = 0; Index < mGicNumInterrupts; Index++) {
|
||||||
GicV2DisableInterruptSource (&gHardwareInterruptV2Protocol, Index);
|
GicV2DisableInterruptSource (&gHardwareInterruptV2Protocol, Index);
|
||||||
|
|
||||||
// Set Priority
|
// Set Priority
|
||||||
RegOffset = Index / 4;
|
RegOffset = (UINT32)(Index / 4);
|
||||||
RegShift = (Index % 4) * 8;
|
RegShift = (UINT8)((Index % 4) * 8);
|
||||||
MmioAndThenOr32 (
|
MmioAndThenOr32 (
|
||||||
mGicDistributorBase + ARM_GIC_ICDIPR + (4 * RegOffset),
|
mGicDistributorBase + ARM_GIC_ICDIPR + (4 * RegOffset),
|
||||||
~(0xff << RegShift),
|
~(0xff << RegShift),
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013-2014, ARM Limited. All rights reserved.
|
* Copyright (c) 2013-2023, ARM Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <Library/ArmGicLib.h>
|
#include <Library/ArmGicLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/IoLib.h>
|
#include <Library/IoLib.h>
|
||||||
|
|
||||||
UINTN
|
UINTN
|
||||||
@@ -26,5 +27,6 @@ ArmGicV2EndOfInterrupt (
|
|||||||
IN UINTN Source
|
IN UINTN Source
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, Source);
|
ASSERT (Source <= MAX_UINT32);
|
||||||
|
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, (UINT32)Source);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
|
* Copyright (c) 2011-2023, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
*
|
*
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicV2EnableInterruptInterface (
|
ArmGicV2EnableInterruptInterface (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -26,7 +26,7 @@ ArmGicV2EnableInterruptInterface (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicV2DisableInterruptInterface (
|
ArmGicV2DisableInterruptInterface (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Disable Gic Interface
|
// Disable Gic Interface
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2018, ARM Limited. All rights reserved.
|
* Copyright (c) 2011-2023, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
*
|
*
|
||||||
@@ -156,7 +156,7 @@ GicV3IrqInterruptHandler (
|
|||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 GicInterrupt;
|
UINTN GicInterrupt;
|
||||||
HARDWARE_INTERRUPT_HANDLER InterruptHandler;
|
HARDWARE_INTERRUPT_HANDLER InterruptHandler;
|
||||||
|
|
||||||
GicInterrupt = ArmGicV3AcknowledgeInterrupt ();
|
GicInterrupt = ArmGicV3AcknowledgeInterrupt ();
|
||||||
@@ -173,7 +173,7 @@ GicV3IrqInterruptHandler (
|
|||||||
// Call the registered interrupt handler.
|
// Call the registered interrupt handler.
|
||||||
InterruptHandler (GicInterrupt, SystemContext);
|
InterruptHandler (GicInterrupt, SystemContext);
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR, "Spurious GIC interrupt: 0x%x\n", GicInterrupt));
|
DEBUG ((DEBUG_ERROR, "Spurious GIC interrupt: 0x%x\n", (UINT32)GicInterrupt));
|
||||||
GicV3EndOfInterrupt (&gHardwareInterruptV3Protocol, GicInterrupt);
|
GicV3EndOfInterrupt (&gHardwareInterruptV3Protocol, GicInterrupt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,7 +381,7 @@ GicV3DxeInitialize (
|
|||||||
// the system.
|
// the system.
|
||||||
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
|
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
|
||||||
|
|
||||||
mGicDistributorBase = PcdGet64 (PcdGicDistributorBase);
|
mGicDistributorBase = (UINTN)PcdGet64 (PcdGicDistributorBase);
|
||||||
mGicRedistributorsBase = PcdGet64 (PcdGicRedistributorsBase);
|
mGicRedistributorsBase = PcdGet64 (PcdGicRedistributorsBase);
|
||||||
mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase);
|
mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase);
|
||||||
|
|
||||||
|
1859
ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
Normal file
1859
ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.c
Normal file
File diff suppressed because it is too large
Load Diff
56
ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.inf
Normal file
56
ArmPkg/Drivers/ArmPsciMpServicesDxe/ArmPsciMpServicesDxe.inf
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
## @file
|
||||||
|
# ARM MP services protocol driver
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 1.27
|
||||||
|
BASE_NAME = ArmPsciMpServicesDxe
|
||||||
|
FILE_GUID = 007ab472-dc4a-4df8-a5c2-abb4a327278c
|
||||||
|
MODULE_TYPE = DXE_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
|
||||||
|
ENTRY_POINT = ArmPsciMpServicesDxeInitialize
|
||||||
|
|
||||||
|
[Sources.Common]
|
||||||
|
ArmPsciMpServicesDxe.c
|
||||||
|
MpFuncs.S
|
||||||
|
MpServicesInternal.h
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
ArmPkg/ArmPkg.dec
|
||||||
|
ArmPlatformPkg/ArmPlatformPkg.dec
|
||||||
|
EmbeddedPkg/EmbeddedPkg.dec
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
ArmLib
|
||||||
|
ArmMmuLib
|
||||||
|
ArmSmcLib
|
||||||
|
BaseMemoryLib
|
||||||
|
CacheMaintenanceLib
|
||||||
|
CpuExceptionHandlerLib
|
||||||
|
DebugLib
|
||||||
|
HobLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
UefiLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiMpServiceProtocolGuid ## PRODUCES
|
||||||
|
gEfiLoadedImageProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gArmMpCoreInfoGuid
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
TRUE
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
GCC:*_*_*_CC_FLAGS = -mstrict-align
|
74
ArmPkg/Drivers/ArmPsciMpServicesDxe/MpFuncs.S
Normal file
74
ArmPkg/Drivers/ArmPsciMpServicesDxe/MpFuncs.S
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#===============================================================================
|
||||||
|
# Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
.text
|
||||||
|
.align 3
|
||||||
|
|
||||||
|
#include <AsmMacroIoLibV8.h>
|
||||||
|
#include <IndustryStandard/ArmStdSmc.h>
|
||||||
|
#include <Library/ArmLib.h>
|
||||||
|
|
||||||
|
#include "MpServicesInternal.h"
|
||||||
|
|
||||||
|
GCC_ASM_IMPORT (gApStacksBase)
|
||||||
|
GCC_ASM_IMPORT (gProcessorIDs)
|
||||||
|
GCC_ASM_IMPORT (ApProcedure)
|
||||||
|
GCC_ASM_IMPORT (gApStackSize)
|
||||||
|
GCC_ASM_IMPORT (gTcr)
|
||||||
|
GCC_ASM_IMPORT (gTtbr0)
|
||||||
|
GCC_ASM_IMPORT (gMair)
|
||||||
|
|
||||||
|
GCC_ASM_EXPORT (ApEntryPoint)
|
||||||
|
|
||||||
|
// Entry-point for the AP
|
||||||
|
// VOID
|
||||||
|
// ApEntryPoint (
|
||||||
|
// VOID
|
||||||
|
// );
|
||||||
|
ASM_PFX(ApEntryPoint):
|
||||||
|
// Configure the MMU and caches
|
||||||
|
ldr x0, gTcr
|
||||||
|
bl ArmSetTCR
|
||||||
|
ldr x0, gTtbr0
|
||||||
|
bl ArmSetTTBR0
|
||||||
|
ldr x0, gMair
|
||||||
|
bl ArmSetMAIR
|
||||||
|
bl ArmDisableAlignmentCheck
|
||||||
|
bl ArmEnableStackAlignmentCheck
|
||||||
|
bl ArmEnableInstructionCache
|
||||||
|
bl ArmEnableDataCache
|
||||||
|
bl ArmEnableMmu
|
||||||
|
|
||||||
|
mrs x0, mpidr_el1
|
||||||
|
// Mask the non-affinity bits
|
||||||
|
bic x0, x0, 0x00ff000000
|
||||||
|
and x0, x0, 0xffffffffff
|
||||||
|
ldr x1, gProcessorIDs
|
||||||
|
mov x2, 0 // x2 = processor index
|
||||||
|
|
||||||
|
// Find index in gProcessorIDs for current processor
|
||||||
|
1:
|
||||||
|
ldr x3, [x1, x2, lsl #3] // x4 = gProcessorIDs + x2 * 8
|
||||||
|
cmp x3, #-1 // check if we've reached the end of gProcessorIDs
|
||||||
|
beq ProcessorNotFound
|
||||||
|
add x2, x2, 1 // x2++
|
||||||
|
cmp x0, x3 // if mpidr_el1 != gProcessorIDs[x] then loop
|
||||||
|
bne 1b
|
||||||
|
|
||||||
|
// Calculate stack address
|
||||||
|
// x2 contains the index for the current processor plus 1
|
||||||
|
ldr x0, gApStacksBase
|
||||||
|
ldr x1, gApStackSize
|
||||||
|
mul x3, x2, x1 // x3 = (ProcessorIndex + 1) * gApStackSize
|
||||||
|
add sp, x0, x3 // sp = gApStacksBase + x3
|
||||||
|
mov x29, xzr
|
||||||
|
bl ApProcedure // doesn't return
|
||||||
|
|
||||||
|
ProcessorNotFound:
|
||||||
|
// Turn off the processor
|
||||||
|
MOV32 (w0, ARM_SMC_ID_PSCI_CPU_OFF)
|
||||||
|
smc #0
|
||||||
|
b .
|
345
ArmPkg/Drivers/ArmPsciMpServicesDxe/MpServicesInternal.h
Normal file
345
ArmPkg/Drivers/ArmPsciMpServicesDxe/MpServicesInternal.h
Normal file
@@ -0,0 +1,345 @@
|
|||||||
|
/** @file
|
||||||
|
|
||||||
|
Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Portions copyright (c) 2011, Apple Inc. All rights reserved.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef MP_SERVICES_INTERNAL_H_
|
||||||
|
#define MP_SERVICES_INTERNAL_H_
|
||||||
|
|
||||||
|
#include <Protocol/Cpu.h>
|
||||||
|
#include <Protocol/MpService.h>
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#define AP_STACK_SIZE 0x1000
|
||||||
|
|
||||||
|
//
|
||||||
|
// Internal Data Structures
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// AP state
|
||||||
|
//
|
||||||
|
// The state transitions for an AP when it processes a procedure are:
|
||||||
|
// Idle ----> Ready ----> Busy ----> Finished ----> Idle
|
||||||
|
// [BSP] [BSP] [AP] [BSP]
|
||||||
|
//
|
||||||
|
typedef enum {
|
||||||
|
CpuStateIdle,
|
||||||
|
CpuStateReady,
|
||||||
|
CpuStateBlocked,
|
||||||
|
CpuStateBusy,
|
||||||
|
CpuStateFinished,
|
||||||
|
CpuStateDisabled
|
||||||
|
} CPU_STATE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define Individual Processor Data block.
|
||||||
|
//
|
||||||
|
typedef struct {
|
||||||
|
EFI_PROCESSOR_INFORMATION Info;
|
||||||
|
EFI_AP_PROCEDURE Procedure;
|
||||||
|
VOID *Parameter;
|
||||||
|
CPU_STATE State;
|
||||||
|
EFI_EVENT CheckThisAPEvent;
|
||||||
|
EFI_EVENT WaitEvent;
|
||||||
|
UINTN Timeout;
|
||||||
|
UINTN TimeTaken;
|
||||||
|
BOOLEAN TimeoutActive;
|
||||||
|
BOOLEAN *SingleApFinished;
|
||||||
|
} CPU_AP_DATA;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define MP data block which consumes individual processor block.
|
||||||
|
//
|
||||||
|
typedef struct {
|
||||||
|
UINTN NumberOfProcessors;
|
||||||
|
UINTN NumberOfEnabledProcessors;
|
||||||
|
EFI_EVENT CheckAllAPsEvent;
|
||||||
|
EFI_EVENT AllWaitEvent;
|
||||||
|
UINTN FinishCount;
|
||||||
|
UINTN StartCount;
|
||||||
|
EFI_AP_PROCEDURE Procedure;
|
||||||
|
VOID *ProcedureArgument;
|
||||||
|
BOOLEAN SingleThread;
|
||||||
|
UINTN StartedNumber;
|
||||||
|
CPU_AP_DATA *CpuData;
|
||||||
|
UINTN *FailedList;
|
||||||
|
UINTN FailedListIndex;
|
||||||
|
UINTN AllTimeout;
|
||||||
|
UINTN AllTimeTaken;
|
||||||
|
BOOLEAN AllTimeoutActive;
|
||||||
|
} CPU_MP_DATA;
|
||||||
|
|
||||||
|
/** Secondary core entry point.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
ApEntryPoint (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/** C entry-point for the AP.
|
||||||
|
This function gets called from the assembly function ApEntryPoint.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
ApProcedure (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Turns on the specified core using PSCI and executes the user-supplied
|
||||||
|
function that's been configured via a previous call to SetApProcedure.
|
||||||
|
|
||||||
|
@param ProcessorIndex The index of the core to turn on.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The processor was successfully turned on.
|
||||||
|
@retval EFI_DEVICE_ERROR An error occurred turning the processor on.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
DispatchCpu (
|
||||||
|
IN UINTN ProcessorIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Returns whether the specified processor is the BSP.
|
||||||
|
|
||||||
|
@param[in] ProcessorIndex The index the processor to check.
|
||||||
|
|
||||||
|
@return TRUE if the processor is the BSP, FALSE otherwise.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
BOOLEAN
|
||||||
|
IsProcessorBSP (
|
||||||
|
UINTN ProcessorIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Returns whether the processor executing this function is the BSP.
|
||||||
|
|
||||||
|
@return Whether the current processor is the BSP.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
BOOLEAN
|
||||||
|
IsCurrentProcessorBSP (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Returns whether the specified processor is enabled.
|
||||||
|
|
||||||
|
@param[in] ProcessorIndex The index of the processor to check.
|
||||||
|
|
||||||
|
@return TRUE if the processor is enabled, FALSE otherwise.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
BOOLEAN
|
||||||
|
IsProcessorEnabled (
|
||||||
|
UINTN ProcessorIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Configures the processor context with the user-supplied procedure and
|
||||||
|
argument.
|
||||||
|
|
||||||
|
@param CpuData The processor context.
|
||||||
|
@param Procedure The user-supplied procedure.
|
||||||
|
@param ProcedureArgument The user-supplied procedure argument.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
SetApProcedure (
|
||||||
|
IN CPU_AP_DATA *CpuData,
|
||||||
|
IN EFI_AP_PROCEDURE Procedure,
|
||||||
|
IN VOID *ProcedureArgument
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the Application Processors state.
|
||||||
|
|
||||||
|
@param[in] CpuData The pointer to CPU_AP_DATA of specified AP
|
||||||
|
|
||||||
|
@return The AP status
|
||||||
|
**/
|
||||||
|
CPU_STATE
|
||||||
|
GetApState (
|
||||||
|
IN CPU_AP_DATA *CpuData
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Returns the index of the next processor that is blocked.
|
||||||
|
|
||||||
|
@param[out] NextNumber The index of the next blocked processor.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successfully found the next blocked processor.
|
||||||
|
@retval EFI_NOT_FOUND There are no blocked processors.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
GetNextBlockedNumber (
|
||||||
|
OUT UINTN *NextNumber
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Stalls the BSP for the minimum of gPollInterval and Timeout.
|
||||||
|
|
||||||
|
@param[in] Timeout The time limit in microseconds remaining for
|
||||||
|
APs to return from Procedure.
|
||||||
|
|
||||||
|
@retval StallTime Time of execution stall.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
UINTN
|
||||||
|
CalculateAndStallInterval (
|
||||||
|
IN UINTN Timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Sets up the state for the StartupAllAPs function.
|
||||||
|
|
||||||
|
@param SingleThread Whether the APs will execute sequentially.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
StartupAllAPsPrepareState (
|
||||||
|
IN BOOLEAN SingleThread
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Handles execution of StartupAllAPs when a WaitEvent has been specified.
|
||||||
|
|
||||||
|
@param Procedure The user-supplied procedure.
|
||||||
|
@param ProcedureArgument The user-supplied procedure argument.
|
||||||
|
@param WaitEvent The wait event to be signaled when the work is
|
||||||
|
complete or a timeout has occurred.
|
||||||
|
@param TimeoutInMicroseconds The timeout for the work to be completed. Zero
|
||||||
|
indicates an infinite timeout.
|
||||||
|
@param SingleThread Whether the APs will execute sequentially.
|
||||||
|
@param FailedCpuList User-supplied pointer for list of failed CPUs.
|
||||||
|
|
||||||
|
@return EFI_SUCCESS on success.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
StartupAllAPsWithWaitEvent (
|
||||||
|
IN EFI_AP_PROCEDURE Procedure,
|
||||||
|
IN VOID *ProcedureArgument,
|
||||||
|
IN EFI_EVENT WaitEvent,
|
||||||
|
IN UINTN TimeoutInMicroseconds,
|
||||||
|
IN BOOLEAN SingleThread,
|
||||||
|
IN UINTN **FailedCpuList
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Handles execution of StartupAllAPs when no wait event has been specified.
|
||||||
|
|
||||||
|
@param Procedure The user-supplied procedure.
|
||||||
|
@param ProcedureArgument The user-supplied procedure argument.
|
||||||
|
@param TimeoutInMicroseconds The timeout for the work to be completed. Zero
|
||||||
|
indicates an infinite timeout.
|
||||||
|
@param SingleThread Whether the APs will execute sequentially.
|
||||||
|
@param FailedCpuList User-supplied pointer for list of failed CPUs.
|
||||||
|
|
||||||
|
@return EFI_SUCCESS on success.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
StartupAllAPsNoWaitEvent (
|
||||||
|
IN EFI_AP_PROCEDURE Procedure,
|
||||||
|
IN VOID *ProcedureArgument,
|
||||||
|
IN UINTN TimeoutInMicroseconds,
|
||||||
|
IN BOOLEAN SingleThread,
|
||||||
|
IN UINTN **FailedCpuList
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Adds the specified processor the list of failed processors.
|
||||||
|
|
||||||
|
@param ProcessorIndex The processor index to add.
|
||||||
|
@param ApState Processor state.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
AddProcessorToFailedList (
|
||||||
|
UINTN ProcessorIndex,
|
||||||
|
CPU_STATE ApState
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Handles the StartupAllAPs case where the timeout has occurred.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
ProcessStartupAllAPsTimeout (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
If a timeout is specified in StartupAllAps(), a timer is set, which invokes
|
||||||
|
this procedure periodically to check whether all APs have finished.
|
||||||
|
|
||||||
|
@param[in] Event The WaitEvent the user supplied.
|
||||||
|
@param[in] Context The event context.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
CheckAllAPsStatus (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Invoked periodically via a timer to check the state of the processor.
|
||||||
|
|
||||||
|
@param Event The event supplied by the timer expiration.
|
||||||
|
@param Context The processor context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
CheckThisAPStatus (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function is called by all processors (both BSP and AP) once and collects
|
||||||
|
MP related data.
|
||||||
|
|
||||||
|
@param BSP TRUE if the processor is the BSP.
|
||||||
|
@param Mpidr The MPIDR for the specified processor. This should be
|
||||||
|
the full MPIDR and not only the affinity bits.
|
||||||
|
@param ProcessorIndex The index of the processor.
|
||||||
|
|
||||||
|
@return EFI_SUCCESS if the data for the processor collected and filled in.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
FillInProcessorInformation (
|
||||||
|
IN BOOLEAN BSP,
|
||||||
|
IN UINTN Mpidr,
|
||||||
|
IN UINTN ProcessorIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Event notification function called when the EFI_EVENT_GROUP_READY_TO_BOOT is
|
||||||
|
signaled. After this point, non-blocking mode is no longer allowed.
|
||||||
|
|
||||||
|
@param Event Event whose notification function is being invoked.
|
||||||
|
@param Context The pointer to the notification function's context,
|
||||||
|
which is implementation-dependent.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
ReadyToBootSignaled (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif /* MP_SERVICES_INTERNAL_H_ */
|
@@ -145,8 +145,8 @@ ScmiCommandExecute (
|
|||||||
|
|
||||||
/** Internal common function useful for common protocol discovery messages.
|
/** Internal common function useful for common protocol discovery messages.
|
||||||
|
|
||||||
@param[in] ProtocolId Protocol Id of the the protocol.
|
@param[in] ProtocolId Protocol Id of the protocol.
|
||||||
@param[in] MesaageId Message Id of the message.
|
@param[in] MessageId Message Id of the message.
|
||||||
|
|
||||||
@param[out] ReturnValues SCMI response return values.
|
@param[out] ReturnValues SCMI response return values.
|
||||||
|
|
||||||
|
@@ -236,12 +236,7 @@ ClockDescribeRates (
|
|||||||
*TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
|
*TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
|
||||||
+ NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
|
+ NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
|
||||||
|
|
||||||
if (*Format == ScmiClockRateFormatDiscrete) {
|
|
||||||
RequiredArraySize = (*TotalRates) * sizeof (UINT64);
|
RequiredArraySize = (*TotalRates) * sizeof (UINT64);
|
||||||
} else {
|
|
||||||
// We need to return triplet of 64 bit value for each rate
|
|
||||||
RequiredArraySize = (*TotalRates) * 3 * sizeof (UINT64);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RequiredArraySize > (*RateArraySize)) {
|
if (RequiredArraySize > (*RateArraySize)) {
|
||||||
*RateArraySize = RequiredArraySize;
|
*RateArraySize = RequiredArraySize;
|
||||||
@@ -259,7 +254,6 @@ ClockDescribeRates (
|
|||||||
ConvertTo64Bit (Rate->Low, Rate->High);
|
ConvertTo64Bit (Rate->Low, Rate->High);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (RateNo = 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags); RateNo++) {
|
|
||||||
// Linear clock rates from minimum to maximum in steps
|
// Linear clock rates from minimum to maximum in steps
|
||||||
// Minimum clock rate.
|
// Minimum clock rate.
|
||||||
Rate = &DescribeRates->Rates[RateOffset++];
|
Rate = &DescribeRates->Rates[RateOffset++];
|
||||||
@@ -276,7 +270,6 @@ ClockDescribeRates (
|
|||||||
RateArray[RateIndex++].ContinuousRate.Step =
|
RateArray[RateIndex++].ContinuousRate.Step =
|
||||||
ConvertTo64Bit (Rate->Low, Rate->High);
|
ConvertTo64Bit (Rate->Low, Rate->High);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) != 0);
|
} while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) != 0);
|
||||||
|
|
||||||
// Update RateArraySize with RequiredArraySize.
|
// Update RateArraySize with RequiredArraySize.
|
||||||
|
@@ -18,6 +18,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
#define MIN_T0SZ 16
|
#define MIN_T0SZ 16
|
||||||
#define BITS_PER_LEVEL 9
|
#define BITS_PER_LEVEL 9
|
||||||
|
|
||||||
|
/**
|
||||||
|
Parses T0SZ to determine the level and number of entries at the root
|
||||||
|
of the translation table.
|
||||||
|
|
||||||
|
@param T0SZ The T0SZ value to be parsed.
|
||||||
|
@param RootTableLevel The level of the root table.
|
||||||
|
@param RootTableEntryCount The number of entries in the root table.
|
||||||
|
**/
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
GetRootTranslationTableInfo (
|
GetRootTranslationTableInfo (
|
||||||
@@ -30,6 +38,13 @@ GetRootTranslationTableInfo (
|
|||||||
*RootTableEntryCount = TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL;
|
*RootTableEntryCount = TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts ARM translation table attributes to GCD attributes.
|
||||||
|
|
||||||
|
@param PageAttributes The translation table attributes to be converted.
|
||||||
|
|
||||||
|
@retval The analogous GCD attributes.
|
||||||
|
**/
|
||||||
STATIC
|
STATIC
|
||||||
UINT64
|
UINT64
|
||||||
PageAttributeToGcdAttribute (
|
PageAttributeToGcdAttribute (
|
||||||
@@ -64,6 +79,10 @@ PageAttributeToGcdAttribute (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine protection attributes
|
// Determine protection attributes
|
||||||
|
if ((PageAttributes & TT_AF) == 0) {
|
||||||
|
GcdAttributes |= EFI_MEMORY_RP;
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
{
|
{
|
||||||
@@ -79,6 +98,31 @@ PageAttributeToGcdAttribute (
|
|||||||
return GcdAttributes;
|
return GcdAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert an arch specific set of page attributes into a mask
|
||||||
|
of EFI_MEMORY_xx constants.
|
||||||
|
|
||||||
|
@param PageAttributes The set of page attributes.
|
||||||
|
|
||||||
|
@retval The mask of EFI_MEMORY_xx constants.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
RegionAttributeToGcdAttribute (
|
||||||
|
IN UINTN PageAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return PageAttributeToGcdAttribute (PageAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieves the attribute of the first page entry in the translation table.
|
||||||
|
|
||||||
|
@param[in] FirstLevelTableAddress The base address of the translation table.
|
||||||
|
@param[in] TableLevel The current level being traversed.
|
||||||
|
|
||||||
|
@retval The attributes of the first page entry found, or INVALID_ENTRY.
|
||||||
|
**/
|
||||||
STATIC
|
STATIC
|
||||||
UINT64
|
UINT64
|
||||||
GetFirstPageAttribute (
|
GetFirstPageAttribute (
|
||||||
@@ -99,12 +143,25 @@ GetFirstPageAttribute (
|
|||||||
} else if (((FirstEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY) ||
|
} else if (((FirstEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY) ||
|
||||||
((TableLevel == 3) && ((FirstEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY_LEVEL3)))
|
((TableLevel == 3) && ((FirstEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY_LEVEL3)))
|
||||||
{
|
{
|
||||||
return FirstEntry & TT_ATTR_INDX_MASK;
|
return FirstEntry & TT_ATTRIBUTES_MASK;
|
||||||
} else {
|
} else {
|
||||||
return INVALID_ENTRY;
|
return INVALID_ENTRY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function recursively traverses the translation table heirarchy to
|
||||||
|
synchronise the GCD with the translation table.
|
||||||
|
|
||||||
|
@param[in] TableAddress The address of the table being processed.
|
||||||
|
@param[in] EntryCount The number of entries in the current level of the table.
|
||||||
|
@param[in] TableLevel The current level of the memory table being processed.
|
||||||
|
@param[in] BaseAddress The starting address of the region.
|
||||||
|
@param[in, out] PrevEntryAttribute The attributes of the previous region.
|
||||||
|
@param[in, out] StartGcdRegion The start of the GCD region.
|
||||||
|
|
||||||
|
@retval The address at the end of the last region processed.
|
||||||
|
**/
|
||||||
STATIC
|
STATIC
|
||||||
UINT64
|
UINT64
|
||||||
GetNextEntryAttribute (
|
GetNextEntryAttribute (
|
||||||
@@ -127,17 +184,19 @@ GetNextEntryAttribute (
|
|||||||
// Get the memory space map from GCD
|
// Get the memory space map from GCD
|
||||||
MemorySpaceMap = NULL;
|
MemorySpaceMap = NULL;
|
||||||
Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
// We cannot get more than 3-level page table
|
if (EFI_ERROR (Status) || (TableLevel > 3)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
ASSERT (TableLevel <= 3);
|
ASSERT (TableLevel <= 3);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// While the top level table might not contain TT_ENTRY_COUNT entries;
|
// While the top level table might not contain TT_ENTRY_COUNT entries;
|
||||||
// the subsequent ones should be filled up
|
// the subsequent ones should be filled up
|
||||||
for (Index = 0; Index < EntryCount; Index++) {
|
for (Index = 0; Index < EntryCount; Index++) {
|
||||||
Entry = TableAddress[Index];
|
Entry = TableAddress[Index];
|
||||||
EntryType = Entry & TT_TYPE_MASK;
|
EntryType = Entry & TT_TYPE_MASK;
|
||||||
EntryAttribute = Entry & TT_ATTR_INDX_MASK;
|
EntryAttribute = Entry & TT_ATTRIBUTES_MASK;
|
||||||
|
|
||||||
// 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) ||
|
||||||
@@ -197,6 +256,15 @@ GetNextEntryAttribute (
|
|||||||
return BaseAddress + (EntryCount * TT_ADDRESS_AT_LEVEL (TableLevel));
|
return BaseAddress + (EntryCount * TT_ADDRESS_AT_LEVEL (TableLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sync the GCD memory space attributes with the translation table.
|
||||||
|
|
||||||
|
@param[in] CpuProtocol The CPU architectural protocol instance.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The GCD memory space attributes are synced with
|
||||||
|
the MMU page table.
|
||||||
|
@retval Others The return value of GetMemorySpaceMap().
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SyncCacheConfig (
|
SyncCacheConfig (
|
||||||
IN EFI_CPU_ARCH_PROTOCOL *CpuProtocol
|
IN EFI_CPU_ARCH_PROTOCOL *CpuProtocol
|
||||||
@@ -222,7 +290,11 @@ SyncCacheConfig (
|
|||||||
//
|
//
|
||||||
MemorySpaceMap = NULL;
|
MemorySpaceMap = NULL;
|
||||||
Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
return 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
|
||||||
@@ -256,7 +328,7 @@ SyncCacheConfig (
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update GCD with the last region if valid
|
// Update GCD with the last region if valid
|
||||||
if (PageAttribute != INVALID_ENTRY) {
|
if ((PageAttribute != INVALID_ENTRY) && (EndAddressGcdRegion > BaseAddressGcdRegion)) {
|
||||||
SetGcdMemorySpaceAttributes (
|
SetGcdMemorySpaceAttributes (
|
||||||
MemorySpaceMap,
|
MemorySpaceMap,
|
||||||
NumberOfDescriptors,
|
NumberOfDescriptors,
|
||||||
@@ -271,6 +343,13 @@ SyncCacheConfig (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert EFI memory attributes to ARM translation table attributes.
|
||||||
|
|
||||||
|
@param[in] EfiAttributes EFI memory attributes.
|
||||||
|
|
||||||
|
@retval The analogous translation table attributes.
|
||||||
|
**/
|
||||||
UINT64
|
UINT64
|
||||||
EfiAttributeToArmAttribute (
|
EfiAttributeToArmAttribute (
|
||||||
IN UINT64 EfiAttributes
|
IN UINT64 EfiAttributes
|
||||||
@@ -301,7 +380,9 @@ EfiAttributeToArmAttribute (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the access flag to match the block attributes
|
// Set the access flag to match the block attributes
|
||||||
|
if ((EfiAttributes & EFI_MEMORY_RP) == 0) {
|
||||||
ArmAttributes |= TT_AF;
|
ArmAttributes |= TT_AF;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine protection attributes
|
// Determine protection attributes
|
||||||
if ((EfiAttributes & EFI_MEMORY_RO) != 0) {
|
if ((EfiAttributes & EFI_MEMORY_RO) != 0) {
|
||||||
@@ -316,8 +397,25 @@ EfiAttributeToArmAttribute (
|
|||||||
return ArmAttributes;
|
return ArmAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function will recursively go down the page table to find the first block address linked to 'BaseAddress'.
|
/**
|
||||||
// And then the function will identify the size of the region that has the same page table attribute.
|
This function returns the attributes of the memory region containing the
|
||||||
|
specified address.
|
||||||
|
|
||||||
|
RegionLength and RegionAttributes are only valid if the result is EFI_SUCCESS.
|
||||||
|
|
||||||
|
@param[in] TranslationTable The translation table base address.
|
||||||
|
@param[in] TableLevel The level of the translation table.
|
||||||
|
@param[in] LastBlockEntry The last block address of the table level.
|
||||||
|
@param[in, out] BaseAddress The base address of the memory region.
|
||||||
|
@param[out] RegionLength The length of the memory region.
|
||||||
|
@param[out] RegionAttributes The attributes of the memory region.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes of the memory region were
|
||||||
|
returned successfully.
|
||||||
|
@retval EFI_NOT_FOUND The memory region was not found.
|
||||||
|
@retval EFI_NO_MAPPING The translation table entry associated with
|
||||||
|
BaseAddress is invalid.
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetMemoryRegionRec (
|
GetMemoryRegionRec (
|
||||||
IN UINT64 *TranslationTable,
|
IN UINT64 *TranslationTable,
|
||||||
@@ -357,10 +455,10 @@ GetMemoryRegionRec (
|
|||||||
RegionAttributes
|
RegionAttributes
|
||||||
);
|
);
|
||||||
|
|
||||||
// In case of 'Success', it means the end of the block region has been found into the upper
|
// EFI_SUCCESS: The end of the end of the region was found.
|
||||||
// level translation table
|
// EFI_NO_MAPPING: The translation entry associated with BaseAddress is invalid.
|
||||||
if (!EFI_ERROR (Status)) {
|
if (Status != EFI_NOT_FOUND) {
|
||||||
return EFI_SUCCESS;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we processed the table move to the next entry
|
// Now we processed the table move to the next entry
|
||||||
@@ -372,12 +470,13 @@ GetMemoryRegionRec (
|
|||||||
*RegionLength = 0;
|
*RegionLength = 0;
|
||||||
*RegionAttributes = *BlockEntry & TT_ATTRIBUTES_MASK;
|
*RegionAttributes = *BlockEntry & TT_ATTRIBUTES_MASK;
|
||||||
} else {
|
} else {
|
||||||
// We have an 'Invalid' entry
|
return EFI_NO_MAPPING;
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (BlockEntry <= LastBlockEntry) {
|
while (BlockEntry <= LastBlockEntry) {
|
||||||
if ((*BlockEntry & TT_ATTRIBUTES_MASK) == *RegionAttributes) {
|
if (((*BlockEntry & TT_TYPE_MASK) == BlockEntryType) &&
|
||||||
|
((*BlockEntry & TT_ATTRIBUTES_MASK) == *RegionAttributes))
|
||||||
|
{
|
||||||
*RegionLength = *RegionLength + TT_BLOCK_ENTRY_SIZE_AT_LEVEL (TableLevel);
|
*RegionLength = *RegionLength + TT_BLOCK_ENTRY_SIZE_AT_LEVEL (TableLevel);
|
||||||
} else {
|
} else {
|
||||||
// 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
|
||||||
@@ -389,10 +488,29 @@ GetMemoryRegionRec (
|
|||||||
|
|
||||||
// If we have reached the end of the TranslationTable and we have not found the end of the region then
|
// If we have reached the end of the TranslationTable and we have not found the end of the region then
|
||||||
// we return EFI_NOT_FOUND.
|
// we return EFI_NOT_FOUND.
|
||||||
// The caller will continue to look for the memory region at its level
|
// The caller will continue to look for the memory region at its level.
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieves a memory region from a given base address.
|
||||||
|
|
||||||
|
This function retrieves a memory region starting from a given base address.
|
||||||
|
|
||||||
|
@param[in, out] BaseAddress The base address from which to retrieve
|
||||||
|
the memory region. On successful return, this is
|
||||||
|
updated to the end address of the retrieved region.
|
||||||
|
@param[out] RegionLength The length of the retrieved memory region.
|
||||||
|
@param[out] RegionAttributes The attributes of the retrieved memory region.
|
||||||
|
|
||||||
|
@retval EFI_STATUS Returns EFI_SUCCESS if the memory region is
|
||||||
|
retrieved successfully, or the status of the
|
||||||
|
recursive call to GetMemoryRegionRec.
|
||||||
|
@retval EFI_NOT_FOUND The memory region was not found.
|
||||||
|
@retval EFI_NO_MAPPING The translation table entry associated with
|
||||||
|
BaseAddress is invalid.
|
||||||
|
@retval EFI_INVALID_PARAMETER One of the input parameters was NULL.
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetMemoryRegion (
|
GetMemoryRegion (
|
||||||
IN OUT UINTN *BaseAddress,
|
IN OUT UINTN *BaseAddress,
|
||||||
@@ -406,10 +524,18 @@ GetMemoryRegion (
|
|||||||
UINTN EntryCount;
|
UINTN EntryCount;
|
||||||
UINTN T0SZ;
|
UINTN T0SZ;
|
||||||
|
|
||||||
|
if ((BaseAddress == NULL) || (RegionLength == NULL) || (RegionAttributes == NULL)) {
|
||||||
ASSERT ((BaseAddress != NULL) && (RegionLength != NULL) && (RegionAttributes != NULL));
|
ASSERT ((BaseAddress != NULL) && (RegionLength != NULL) && (RegionAttributes != NULL));
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
TranslationTable = ArmGetTTBR0BaseAddress ();
|
TranslationTable = ArmGetTTBR0BaseAddress ();
|
||||||
|
|
||||||
|
// Initialize the output parameters. These paramaters are only valid if the
|
||||||
|
// result is EFI_SUCCESS.
|
||||||
|
*RegionLength = 0;
|
||||||
|
*RegionAttributes = 0;
|
||||||
|
|
||||||
T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;
|
T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;
|
||||||
// Get the Table info from T0SZ
|
// Get the Table info from T0SZ
|
||||||
GetRootTranslationTableInfo (T0SZ, &TableLevel, &EntryCount);
|
GetRootTranslationTableInfo (T0SZ, &TableLevel, &EntryCount);
|
||||||
@@ -424,10 +550,10 @@ GetMemoryRegion (
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 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. Check if the region length was updated.
|
||||||
if (Status == EFI_NOT_FOUND) {
|
if ((Status == EFI_NOT_FOUND) && (*RegionLength > 0)) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@@ -13,6 +13,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include "CpuDxe.h"
|
#include "CpuDxe.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert a set of ARM short descriptor section attributes into a mask
|
||||||
|
of EFI_MEMORY_xx constants.
|
||||||
|
|
||||||
|
@param[in] SectionAttributes The set of page attributes.
|
||||||
|
@param[out] GcdAttributes Pointer to the return value.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were converted successfully.
|
||||||
|
@retval EFI_UNSUPPORTED The section attributes did not have a
|
||||||
|
GCD transation.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SectionToGcdAttributes (
|
SectionToGcdAttributes (
|
||||||
IN UINT32 SectionAttributes,
|
IN UINT32 SectionAttributes,
|
||||||
@@ -50,23 +62,16 @@ SectionToGcdAttributes (
|
|||||||
|
|
||||||
// determine protection attributes
|
// determine protection attributes
|
||||||
switch (SectionAttributes & TT_DESCRIPTOR_SECTION_AP_MASK) {
|
switch (SectionAttributes & TT_DESCRIPTOR_SECTION_AP_MASK) {
|
||||||
case TT_DESCRIPTOR_SECTION_AP_NO_NO: // no read, no write
|
case TT_DESCRIPTOR_SECTION_AP_NO_RW:
|
||||||
// *GcdAttributes |= EFI_MEMORY_RO | EFI_MEMORY_RP;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TT_DESCRIPTOR_SECTION_AP_RW_NO:
|
|
||||||
case TT_DESCRIPTOR_SECTION_AP_RW_RW:
|
case TT_DESCRIPTOR_SECTION_AP_RW_RW:
|
||||||
// normal read/write access, do not add additional attributes
|
// normal read/write access, do not add additional attributes
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// read only cases map to write-protect
|
// read only cases map to write-protect
|
||||||
case TT_DESCRIPTOR_SECTION_AP_RO_NO:
|
case TT_DESCRIPTOR_SECTION_AP_NO_RO:
|
||||||
case TT_DESCRIPTOR_SECTION_AP_RO_RO:
|
case TT_DESCRIPTOR_SECTION_AP_RO_RO:
|
||||||
*GcdAttributes |= EFI_MEMORY_RO;
|
*GcdAttributes |= EFI_MEMORY_RO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now process eXectue Never attribute
|
// now process eXectue Never attribute
|
||||||
@@ -74,9 +79,45 @@ SectionToGcdAttributes (
|
|||||||
*GcdAttributes |= EFI_MEMORY_XP;
|
*GcdAttributes |= EFI_MEMORY_XP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((SectionAttributes & TT_DESCRIPTOR_SECTION_AF) == 0) {
|
||||||
|
*GcdAttributes |= EFI_MEMORY_RP;
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert an arch specific set of page attributes into a mask
|
||||||
|
of EFI_MEMORY_xx constants.
|
||||||
|
|
||||||
|
@param[in] PageAttributes The set of page attributes.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were converted successfully.
|
||||||
|
@retval EFI_UNSUPPORTED The section attributes did not have a
|
||||||
|
GCD transation.
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
RegionAttributeToGcdAttribute (
|
||||||
|
IN UINTN PageAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT64 Result;
|
||||||
|
|
||||||
|
SectionToGcdAttributes (PageAttributes, &Result);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert a set of ARM short descriptor page attributes into a mask
|
||||||
|
of EFI_MEMORY_xx constants.
|
||||||
|
|
||||||
|
@param[in] PageAttributes The set of page attributes.
|
||||||
|
@param[out] GcdAttributes Pointer to the return value.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were converted successfully.
|
||||||
|
@retval EFI_UNSUPPORTED The page attributes did not have a GCD transation.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PageToGcdAttributes (
|
PageToGcdAttributes (
|
||||||
IN UINT32 PageAttributes,
|
IN UINT32 PageAttributes,
|
||||||
@@ -114,23 +155,16 @@ PageToGcdAttributes (
|
|||||||
|
|
||||||
// determine protection attributes
|
// determine protection attributes
|
||||||
switch (PageAttributes & TT_DESCRIPTOR_PAGE_AP_MASK) {
|
switch (PageAttributes & TT_DESCRIPTOR_PAGE_AP_MASK) {
|
||||||
case TT_DESCRIPTOR_PAGE_AP_NO_NO: // no read, no write
|
case TT_DESCRIPTOR_PAGE_AP_NO_RW:
|
||||||
// *GcdAttributes |= EFI_MEMORY_RO | EFI_MEMORY_RP;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TT_DESCRIPTOR_PAGE_AP_RW_NO:
|
|
||||||
case TT_DESCRIPTOR_PAGE_AP_RW_RW:
|
case TT_DESCRIPTOR_PAGE_AP_RW_RW:
|
||||||
// normal read/write access, do not add additional attributes
|
// normal read/write access, do not add additional attributes
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// read only cases map to write-protect
|
// read only cases map to write-protect
|
||||||
case TT_DESCRIPTOR_PAGE_AP_RO_NO:
|
case TT_DESCRIPTOR_PAGE_AP_NO_RO:
|
||||||
case TT_DESCRIPTOR_PAGE_AP_RO_RO:
|
case TT_DESCRIPTOR_PAGE_AP_RO_RO:
|
||||||
*GcdAttributes |= EFI_MEMORY_RO;
|
*GcdAttributes |= EFI_MEMORY_RO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now process eXectue Never attribute
|
// now process eXectue Never attribute
|
||||||
@@ -138,9 +172,30 @@ PageToGcdAttributes (
|
|||||||
*GcdAttributes |= EFI_MEMORY_XP;
|
*GcdAttributes |= EFI_MEMORY_XP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((PageAttributes & TT_DESCRIPTOR_PAGE_AF) == 0) {
|
||||||
|
*GcdAttributes |= EFI_MEMORY_RP;
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Synchronizes the GCD with the translation table for a specified page.
|
||||||
|
|
||||||
|
This function synchronizes cache configuration for a given page based on its section index
|
||||||
|
and the first level descriptor. It traverses the second level table entries of the page and
|
||||||
|
updates the GCD attributes accordingly for each entry.
|
||||||
|
|
||||||
|
@param[in] SectionIndex The index of the section where the page resides.
|
||||||
|
@param[in] FirstLevelDescriptor The first translation table level of the page.
|
||||||
|
@param[in] NumberOfDescriptors The number of descriptors in the GCD memory space map.
|
||||||
|
@param[in] MemorySpaceMap The GCD memory space descriptor.
|
||||||
|
@param[in, out] NextRegionBase The next region base address.
|
||||||
|
@param[in, out] NextRegionLength The next region length.
|
||||||
|
@param[in, out] NextSectionAttributes The next section attributes.
|
||||||
|
|
||||||
|
@retval EFI_STATUS Always return success
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SyncCacheConfigPage (
|
SyncCacheConfigPage (
|
||||||
IN UINT32 SectionIndex,
|
IN UINT32 SectionIndex,
|
||||||
@@ -165,7 +220,8 @@ SyncCacheConfigPage (
|
|||||||
|
|
||||||
// Convert SectionAttributes into PageAttributes
|
// Convert SectionAttributes into PageAttributes
|
||||||
NextPageAttributes =
|
NextPageAttributes =
|
||||||
TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY (*NextSectionAttributes, 0) |
|
TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY (*NextSectionAttributes) |
|
||||||
|
TT_DESCRIPTOR_CONVERT_TO_PAGE_AF (*NextSectionAttributes) |
|
||||||
TT_DESCRIPTOR_CONVERT_TO_PAGE_AP (*NextSectionAttributes);
|
TT_DESCRIPTOR_CONVERT_TO_PAGE_AP (*NextSectionAttributes);
|
||||||
|
|
||||||
// obtain page table base
|
// obtain page table base
|
||||||
@@ -174,7 +230,7 @@ SyncCacheConfigPage (
|
|||||||
for (i = 0; i < TRANSLATION_TABLE_PAGE_COUNT; i++) {
|
for (i = 0; i < TRANSLATION_TABLE_PAGE_COUNT; i++) {
|
||||||
if ((SecondLevelTable[i] & TT_DESCRIPTOR_PAGE_TYPE_MASK) == TT_DESCRIPTOR_PAGE_TYPE_PAGE) {
|
if ((SecondLevelTable[i] & TT_DESCRIPTOR_PAGE_TYPE_MASK) == TT_DESCRIPTOR_PAGE_TYPE_PAGE) {
|
||||||
// extract attributes (cacheability and permissions)
|
// extract attributes (cacheability and permissions)
|
||||||
PageAttributes = SecondLevelTable[i] & (TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK | TT_DESCRIPTOR_PAGE_AP_MASK);
|
PageAttributes = SecondLevelTable[i] & (TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK | TT_DESCRIPTOR_PAGE_AP_MASK | TT_DESCRIPTOR_PAGE_AF);
|
||||||
|
|
||||||
if (NextPageAttributes == 0) {
|
if (NextPageAttributes == 0) {
|
||||||
// start on a new region
|
// start on a new region
|
||||||
@@ -184,7 +240,10 @@ SyncCacheConfigPage (
|
|||||||
} else if (PageAttributes != NextPageAttributes) {
|
} else if (PageAttributes != NextPageAttributes) {
|
||||||
// Convert Section Attributes into GCD Attributes
|
// Convert Section Attributes into GCD Attributes
|
||||||
Status = PageToGcdAttributes (NextPageAttributes, &GcdAttributes);
|
Status = PageToGcdAttributes (NextPageAttributes, &GcdAttributes);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
GcdAttributes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
||||||
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, *NextRegionBase, *NextRegionLength, GcdAttributes);
|
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, *NextRegionBase, *NextRegionLength, GcdAttributes);
|
||||||
@@ -197,7 +256,10 @@ SyncCacheConfigPage (
|
|||||||
} else if (NextPageAttributes != 0) {
|
} else if (NextPageAttributes != 0) {
|
||||||
// Convert Page Attributes into GCD Attributes
|
// Convert Page Attributes into GCD Attributes
|
||||||
Status = PageToGcdAttributes (NextPageAttributes, &GcdAttributes);
|
Status = PageToGcdAttributes (NextPageAttributes, &GcdAttributes);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
GcdAttributes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
||||||
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, *NextRegionBase, *NextRegionLength, GcdAttributes);
|
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, *NextRegionBase, *NextRegionLength, GcdAttributes);
|
||||||
@@ -212,12 +274,21 @@ SyncCacheConfigPage (
|
|||||||
|
|
||||||
// Convert back PageAttributes into SectionAttributes
|
// Convert back PageAttributes into SectionAttributes
|
||||||
*NextSectionAttributes =
|
*NextSectionAttributes =
|
||||||
TT_DESCRIPTOR_CONVERT_TO_SECTION_CACHE_POLICY (NextPageAttributes, 0) |
|
TT_DESCRIPTOR_CONVERT_TO_SECTION_CACHE_POLICY (NextPageAttributes) |
|
||||||
|
TT_DESCRIPTOR_CONVERT_TO_SECTION_AF (NextPageAttributes) |
|
||||||
TT_DESCRIPTOR_CONVERT_TO_SECTION_AP (NextPageAttributes);
|
TT_DESCRIPTOR_CONVERT_TO_SECTION_AP (NextPageAttributes);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sync the GCD memory space attributes with the translation table.
|
||||||
|
|
||||||
|
@param[in] CpuProtocol The CPU architectural protocol instance.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The GCD memory space attributes are synced with the MMU page table.
|
||||||
|
@retval Others The return value of GetMemorySpaceMap().
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SyncCacheConfig (
|
SyncCacheConfig (
|
||||||
IN EFI_CPU_ARCH_PROTOCOL *CpuProtocol
|
IN EFI_CPU_ARCH_PROTOCOL *CpuProtocol
|
||||||
@@ -244,7 +315,12 @@ SyncCacheConfig (
|
|||||||
//
|
//
|
||||||
MemorySpaceMap = NULL;
|
MemorySpaceMap = NULL;
|
||||||
Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "SyncCacheConfig - GetMemorySpaceMap() failed! Status: %r\n", Status));
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
return 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
|
||||||
@@ -256,14 +332,14 @@ SyncCacheConfig (
|
|||||||
FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)(ArmGetTTBR0BaseAddress ());
|
FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)(ArmGetTTBR0BaseAddress ());
|
||||||
|
|
||||||
// Get the first region
|
// Get the first region
|
||||||
NextSectionAttributes = FirstLevelTable[0] & (TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK | TT_DESCRIPTOR_SECTION_AP_MASK);
|
NextSectionAttributes = FirstLevelTable[0] & (TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK | TT_DESCRIPTOR_SECTION_AP_MASK | TT_DESCRIPTOR_SECTION_AF);
|
||||||
|
|
||||||
// iterate through each 1MB descriptor
|
// iterate through each 1MB descriptor
|
||||||
NextRegionBase = NextRegionLength = 0;
|
NextRegionBase = NextRegionLength = 0;
|
||||||
for (i = 0; i < TRANSLATION_TABLE_SECTION_COUNT; i++) {
|
for (i = 0; i < TRANSLATION_TABLE_SECTION_COUNT; i++) {
|
||||||
if ((FirstLevelTable[i] & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) {
|
if ((FirstLevelTable[i] & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) {
|
||||||
// extract attributes (cacheability and permissions)
|
// extract attributes (cacheability and permissions)
|
||||||
SectionAttributes = FirstLevelTable[i] & (TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK | TT_DESCRIPTOR_SECTION_AP_MASK);
|
SectionAttributes = FirstLevelTable[i] & (TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK | TT_DESCRIPTOR_SECTION_AP_MASK | TT_DESCRIPTOR_SECTION_AF);
|
||||||
|
|
||||||
if (NextSectionAttributes == 0) {
|
if (NextSectionAttributes == 0) {
|
||||||
// start on a new region
|
// start on a new region
|
||||||
@@ -273,7 +349,12 @@ SyncCacheConfig (
|
|||||||
} else if (SectionAttributes != NextSectionAttributes) {
|
} else if (SectionAttributes != NextSectionAttributes) {
|
||||||
// Convert Section Attributes into GCD Attributes
|
// Convert Section Attributes into GCD Attributes
|
||||||
Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes);
|
Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "SyncCacheConfig - SectionToGcdAttributes() failed! Status: %r\n", Status));
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
GcdAttributes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
||||||
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes);
|
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes);
|
||||||
@@ -309,7 +390,11 @@ SyncCacheConfig (
|
|||||||
if (NextSectionAttributes != 0) {
|
if (NextSectionAttributes != 0) {
|
||||||
// Convert Section Attributes into GCD Attributes
|
// Convert Section Attributes into GCD Attributes
|
||||||
Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes);
|
Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "SyncCacheConfig - SectionToGcdAttributes() failed! Status: %r\n", Status));
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
GcdAttributes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
||||||
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes);
|
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes);
|
||||||
@@ -326,7 +411,11 @@ SyncCacheConfig (
|
|||||||
if (NextSectionAttributes != 0) {
|
if (NextSectionAttributes != 0) {
|
||||||
// Convert Section Attributes into GCD Attributes
|
// Convert Section Attributes into GCD Attributes
|
||||||
Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes);
|
Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "SyncCacheConfig - SectionToGcdAttributes() failed! Status: %r\n", Status));
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
GcdAttributes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
// update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK)
|
||||||
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes);
|
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes);
|
||||||
@@ -337,6 +426,13 @@ SyncCacheConfig (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert EFI memory attributes to ARM translation table attributes.
|
||||||
|
|
||||||
|
@param[in] EfiAttributes EFI memory attributes.
|
||||||
|
|
||||||
|
@retval The analogous translation table attributes.
|
||||||
|
**/
|
||||||
UINT64
|
UINT64
|
||||||
EfiAttributeToArmAttribute (
|
EfiAttributeToArmAttribute (
|
||||||
IN UINT64 EfiAttributes
|
IN UINT64 EfiAttributes
|
||||||
@@ -383,23 +479,46 @@ EfiAttributeToArmAttribute (
|
|||||||
ArmAttributes |= TT_DESCRIPTOR_SECTION_XN_MASK;
|
ArmAttributes |= TT_DESCRIPTOR_SECTION_XN_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((EfiAttributes & EFI_MEMORY_RP) == 0) {
|
||||||
|
ArmAttributes |= TT_DESCRIPTOR_SECTION_AF;
|
||||||
|
}
|
||||||
|
|
||||||
return ArmAttributes;
|
return ArmAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function finds the end of a memory region in a translation table. A
|
||||||
|
memory region is defined as a contiguous set of pages with the same attributes.
|
||||||
|
|
||||||
|
@param[in] PageTable The translation table to traverse.
|
||||||
|
@param[in] BaseAddress The address from which to start the search
|
||||||
|
@param[in] RegionAttributes The attributes of the start of the region.
|
||||||
|
@param[out] RegionLength The length of the region found.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The region was found.
|
||||||
|
@retval EFI_NOT_FOUND The end of the region was not found.
|
||||||
|
@retval EFI_NO_MAPPING The region specified by BaseAddress is not mapped
|
||||||
|
in the input translation table.
|
||||||
|
@retval EFI_UNSUPPORTED Large pages are not supported.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetMemoryRegionPage (
|
GetMemoryRegionPage (
|
||||||
IN UINT32 *PageTable,
|
IN UINT32 *PageTable,
|
||||||
IN OUT UINTN *BaseAddress,
|
IN UINTN *BaseAddress,
|
||||||
OUT UINTN *RegionLength,
|
IN UINTN *RegionAttributes,
|
||||||
OUT UINTN *RegionAttributes
|
OUT UINTN *RegionLength
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 PageAttributes;
|
UINT32 PageAttributes;
|
||||||
UINT32 TableIndex;
|
UINT32 TableIndex;
|
||||||
UINT32 PageDescriptor;
|
UINT32 PageDescriptor;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
// Convert the section attributes into page attributes
|
// Convert the section attributes into page attributes
|
||||||
PageAttributes = ConvertSectionAttributesToPageAttributes (*RegionAttributes, 0);
|
PageAttributes = ConvertSectionAttributesToPageAttributes (*RegionAttributes);
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
*RegionLength = 0;
|
||||||
|
|
||||||
// Calculate index into first level translation table for start of modification
|
// Calculate index into first level translation table for start of modification
|
||||||
TableIndex = ((*BaseAddress) & TT_DESCRIPTOR_PAGE_INDEX_MASK) >> TT_DESCRIPTOR_PAGE_BASE_SHIFT;
|
TableIndex = ((*BaseAddress) & TT_DESCRIPTOR_PAGE_INDEX_MASK) >> TT_DESCRIPTOR_PAGE_BASE_SHIFT;
|
||||||
@@ -411,25 +530,44 @@ GetMemoryRegionPage (
|
|||||||
PageDescriptor = PageTable[TableIndex];
|
PageDescriptor = PageTable[TableIndex];
|
||||||
|
|
||||||
if ((PageDescriptor & TT_DESCRIPTOR_PAGE_TYPE_MASK) == TT_DESCRIPTOR_PAGE_TYPE_FAULT) {
|
if ((PageDescriptor & TT_DESCRIPTOR_PAGE_TYPE_MASK) == TT_DESCRIPTOR_PAGE_TYPE_FAULT) {
|
||||||
// Case: End of the boundary of the region
|
Status = (*RegionLength > 0) ? EFI_SUCCESS : EFI_NO_MAPPING;
|
||||||
return EFI_SUCCESS;
|
break;
|
||||||
} else if ((PageDescriptor & TT_DESCRIPTOR_PAGE_TYPE_PAGE) == TT_DESCRIPTOR_PAGE_TYPE_PAGE) {
|
} else if ((PageDescriptor & TT_DESCRIPTOR_PAGE_TYPE_PAGE) == TT_DESCRIPTOR_PAGE_TYPE_PAGE) {
|
||||||
if ((PageDescriptor & TT_DESCRIPTOR_PAGE_ATTRIBUTE_MASK) == PageAttributes) {
|
if ((PageDescriptor & TT_DESCRIPTOR_PAGE_ATTRIBUTE_MASK) != PageAttributes) {
|
||||||
*RegionLength = *RegionLength + TT_DESCRIPTOR_PAGE_SIZE;
|
Status = EFI_SUCCESS;
|
||||||
} else {
|
break;
|
||||||
// Case: End of the boundary of the region
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*RegionLength += TT_DESCRIPTOR_PAGE_SIZE;
|
||||||
} else {
|
} else {
|
||||||
// We do not support Large Page yet. We return EFI_SUCCESS that means end of the region.
|
// Large pages are unsupported.
|
||||||
|
Status = EFI_UNSUPPORTED;
|
||||||
ASSERT (0);
|
ASSERT (0);
|
||||||
return EFI_SUCCESS;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_NOT_FOUND;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the memory region that contains the specified address. A memory region is defined
|
||||||
|
as a contiguous set of pages with the same attributes.
|
||||||
|
|
||||||
|
RegionLength and RegionAttributes are only valid if EFI_SUCCESS is returned.
|
||||||
|
|
||||||
|
@param[in, out] BaseAddress On input, the address to search for.
|
||||||
|
On output, the base address of the region found.
|
||||||
|
@param[out] RegionLength The length of the region found.
|
||||||
|
@param[out] RegionAttributes The attributes of the region found.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Region found
|
||||||
|
@retval EFI_NOT_FOUND Region not found
|
||||||
|
@retval EFI_UNSUPPORTED Large pages are unsupported
|
||||||
|
@retval EFI_NO_MAPPING The page specified by BaseAddress is unmapped
|
||||||
|
@retval EFI_INVALID_PARAMETER The BaseAddress exceeds the addressable range of
|
||||||
|
the translation table.
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetMemoryRegion (
|
GetMemoryRegion (
|
||||||
IN OUT UINTN *BaseAddress,
|
IN OUT UINTN *BaseAddress,
|
||||||
@@ -444,6 +582,7 @@ GetMemoryRegion (
|
|||||||
UINT32 SectionDescriptor;
|
UINT32 SectionDescriptor;
|
||||||
ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;
|
ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;
|
||||||
UINT32 *PageTable;
|
UINT32 *PageTable;
|
||||||
|
UINTN Length;
|
||||||
|
|
||||||
// Initialize the arguments
|
// Initialize the arguments
|
||||||
*RegionLength = 0;
|
*RegionLength = 0;
|
||||||
@@ -453,7 +592,11 @@ GetMemoryRegion (
|
|||||||
|
|
||||||
// Calculate index into first level translation table for start of modification
|
// Calculate index into first level translation table for start of modification
|
||||||
TableIndex = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (*BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;
|
TableIndex = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (*BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;
|
||||||
|
|
||||||
|
if (TableIndex >= TRANSLATION_TABLE_SECTION_COUNT) {
|
||||||
ASSERT (TableIndex < TRANSLATION_TABLE_SECTION_COUNT);
|
ASSERT (TableIndex < TRANSLATION_TABLE_SECTION_COUNT);
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the section at the given index
|
// Get the section at the given index
|
||||||
SectionDescriptor = FirstLevelTable[TableIndex];
|
SectionDescriptor = FirstLevelTable[TableIndex];
|
||||||
@@ -479,10 +622,15 @@ GetMemoryRegion (
|
|||||||
ASSERT (PageTableIndex < TRANSLATION_TABLE_PAGE_COUNT);
|
ASSERT (PageTableIndex < TRANSLATION_TABLE_PAGE_COUNT);
|
||||||
|
|
||||||
PageAttributes = PageTable[PageTableIndex] & TT_DESCRIPTOR_PAGE_ATTRIBUTE_MASK;
|
PageAttributes = PageTable[PageTableIndex] & TT_DESCRIPTOR_PAGE_ATTRIBUTE_MASK;
|
||||||
*RegionAttributes = TT_DESCRIPTOR_CONVERT_TO_SECTION_CACHE_POLICY (PageAttributes, 0) |
|
*RegionAttributes = TT_DESCRIPTOR_CONVERT_TO_SECTION_CACHE_POLICY (PageAttributes) |
|
||||||
|
TT_DESCRIPTOR_CONVERT_TO_SECTION_S (PageAttributes) |
|
||||||
|
TT_DESCRIPTOR_CONVERT_TO_SECTION_XN (PageAttributes) |
|
||||||
|
TT_DESCRIPTOR_CONVERT_TO_SECTION_AF (PageAttributes) |
|
||||||
TT_DESCRIPTOR_CONVERT_TO_SECTION_AP (PageAttributes);
|
TT_DESCRIPTOR_CONVERT_TO_SECTION_AP (PageAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
|
||||||
for ( ; TableIndex < TRANSLATION_TABLE_SECTION_COUNT; TableIndex++) {
|
for ( ; TableIndex < TRANSLATION_TABLE_SECTION_COUNT; TableIndex++) {
|
||||||
// Get the section at the given index
|
// Get the section at the given index
|
||||||
SectionDescriptor = FirstLevelTable[TableIndex];
|
SectionDescriptor = FirstLevelTable[TableIndex];
|
||||||
@@ -491,14 +639,18 @@ GetMemoryRegion (
|
|||||||
if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (SectionDescriptor)) {
|
if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (SectionDescriptor)) {
|
||||||
// Extract the page table location from the descriptor
|
// Extract the page table location from the descriptor
|
||||||
PageTable = (UINT32 *)(SectionDescriptor & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK);
|
PageTable = (UINT32 *)(SectionDescriptor & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK);
|
||||||
|
Length = 0;
|
||||||
|
|
||||||
// Scan the page table to find the end of the region.
|
// Scan the page table to find the end of the region.
|
||||||
Status = GetMemoryRegionPage (PageTable, BaseAddress, RegionLength, RegionAttributes);
|
Status = GetMemoryRegionPage (PageTable, BaseAddress, RegionAttributes, &Length);
|
||||||
|
*RegionLength += Length;
|
||||||
|
|
||||||
// If we have found the end of the region (Status == EFI_SUCCESS) then we exit the for-loop
|
// Status == EFI_NOT_FOUND implies we have not reached the end of the region.
|
||||||
if (Status == EFI_SUCCESS) {
|
if ((Status == EFI_NOT_FOUND) && (Length > 0)) {
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
{
|
{
|
||||||
@@ -514,5 +666,10 @@ GetMemoryRegion (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
// Check if the region length was updated.
|
||||||
|
if (*RegionLength > 0) {
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include <Guid/IdleLoopEvent.h>
|
#include <Guid/IdleLoopEvent.h>
|
||||||
|
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
|
||||||
BOOLEAN mIsFlushingGCD;
|
BOOLEAN mIsFlushingGCD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,6 +229,77 @@ InitializeDma (
|
|||||||
CpuArchProtocol->DmaBufferAlignment = ArmCacheWritebackGranule ();
|
CpuArchProtocol->DmaBufferAlignment = ArmCacheWritebackGranule ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Map all EfiConventionalMemory regions in the memory map with NX
|
||||||
|
attributes so that allocating or freeing EfiBootServicesData regions
|
||||||
|
does not result in changes to memory permission attributes.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
RemapUnusedMemoryNx (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT64 TestBit;
|
||||||
|
UINTN MemoryMapSize;
|
||||||
|
UINTN MapKey;
|
||||||
|
UINTN DescriptorSize;
|
||||||
|
UINT32 DescriptorVersion;
|
||||||
|
EFI_MEMORY_DESCRIPTOR *MemoryMap;
|
||||||
|
EFI_MEMORY_DESCRIPTOR *MemoryMapEntry;
|
||||||
|
EFI_MEMORY_DESCRIPTOR *MemoryMapEnd;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
TestBit = LShiftU64 (1, EfiBootServicesData);
|
||||||
|
if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & TestBit) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryMapSize = 0;
|
||||||
|
MemoryMap = NULL;
|
||||||
|
|
||||||
|
Status = gBS->GetMemoryMap (
|
||||||
|
&MemoryMapSize,
|
||||||
|
MemoryMap,
|
||||||
|
&MapKey,
|
||||||
|
&DescriptorSize,
|
||||||
|
&DescriptorVersion
|
||||||
|
);
|
||||||
|
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
|
||||||
|
do {
|
||||||
|
MemoryMap = (EFI_MEMORY_DESCRIPTOR *)AllocatePool (MemoryMapSize);
|
||||||
|
ASSERT (MemoryMap != NULL);
|
||||||
|
Status = gBS->GetMemoryMap (
|
||||||
|
&MemoryMapSize,
|
||||||
|
MemoryMap,
|
||||||
|
&MapKey,
|
||||||
|
&DescriptorSize,
|
||||||
|
&DescriptorVersion
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
FreePool (MemoryMap);
|
||||||
|
}
|
||||||
|
} while (Status == EFI_BUFFER_TOO_SMALL);
|
||||||
|
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
MemoryMapEntry = MemoryMap;
|
||||||
|
MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + MemoryMapSize);
|
||||||
|
while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
|
||||||
|
if (MemoryMapEntry->Type == EfiConventionalMemory) {
|
||||||
|
ArmSetMemoryAttributes (
|
||||||
|
MemoryMapEntry->PhysicalStart,
|
||||||
|
EFI_PAGES_TO_SIZE (MemoryMapEntry->NumberOfPages),
|
||||||
|
EFI_MEMORY_XP,
|
||||||
|
EFI_MEMORY_XP
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
CpuDxeInitialize (
|
CpuDxeInitialize (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
@@ -240,10 +313,26 @@ CpuDxeInitialize (
|
|||||||
|
|
||||||
InitializeDma (&mCpu);
|
InitializeDma (&mCpu);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Once we install the CPU arch protocol, the DXE core's memory
|
||||||
|
// protection routines will invoke them to manage the permissions of page
|
||||||
|
// allocations as they are created. Given that this includes pages
|
||||||
|
// allocated for page tables by this driver, we must ensure that unused
|
||||||
|
// memory is mapped with the same permissions as boot services data
|
||||||
|
// regions. Otherwise, we may end up with unbounded recursion, due to the
|
||||||
|
// fact that updating permissions on a newly allocated page table may trigger
|
||||||
|
// a block entry split, which triggers a page table allocation, etc etc
|
||||||
|
//
|
||||||
|
if (FeaturePcdGet (PcdRemapUnusedMemoryNx)) {
|
||||||
|
RemapUnusedMemoryNx ();
|
||||||
|
}
|
||||||
|
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&mCpuHandle,
|
&mCpuHandle,
|
||||||
&gEfiCpuArchProtocolGuid,
|
&gEfiCpuArchProtocolGuid,
|
||||||
&mCpu,
|
&mCpu,
|
||||||
|
&gEfiMemoryAttributeProtocolGuid,
|
||||||
|
&mMemoryAttribute,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -30,9 +30,12 @@
|
|||||||
#include <Protocol/Cpu.h>
|
#include <Protocol/Cpu.h>
|
||||||
#include <Protocol/DebugSupport.h>
|
#include <Protocol/DebugSupport.h>
|
||||||
#include <Protocol/LoadedImage.h>
|
#include <Protocol/LoadedImage.h>
|
||||||
|
#include <Protocol/MemoryAttribute.h>
|
||||||
|
|
||||||
extern BOOLEAN mIsFlushingGCD;
|
extern BOOLEAN mIsFlushingGCD;
|
||||||
|
|
||||||
|
extern EFI_MEMORY_ATTRIBUTE_PROTOCOL mMemoryAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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
|
||||||
@@ -126,4 +129,18 @@ SetGcdMemorySpaceAttributes (
|
|||||||
IN UINT64 Attributes
|
IN UINT64 Attributes
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert an arch specific set of page attributes into a mask
|
||||||
|
of EFI_MEMORY_xx constants.
|
||||||
|
|
||||||
|
@param PageAttributes The set of page attributes.
|
||||||
|
|
||||||
|
@retval The mask of EFI_MEMORY_xx constants.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
RegionAttributeToGcdAttribute (
|
||||||
|
IN UINTN PageAttributes
|
||||||
|
);
|
||||||
|
|
||||||
#endif // CPU_DXE_H_
|
#endif // CPU_DXE_H_
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
CpuDxe.h
|
CpuDxe.h
|
||||||
CpuMmuCommon.c
|
CpuMmuCommon.c
|
||||||
Exception.c
|
Exception.c
|
||||||
|
MemoryAttribute.c
|
||||||
|
|
||||||
[Sources.ARM]
|
[Sources.ARM]
|
||||||
Arm/Mmu.c
|
Arm/Mmu.c
|
||||||
@@ -47,12 +48,14 @@
|
|||||||
DefaultExceptionHandlerLib
|
DefaultExceptionHandlerLib
|
||||||
DxeServicesTableLib
|
DxeServicesTableLib
|
||||||
HobLib
|
HobLib
|
||||||
|
MemoryAllocationLib
|
||||||
PeCoffGetEntryPointLib
|
PeCoffGetEntryPointLib
|
||||||
UefiDriverEntryPoint
|
UefiDriverEntryPoint
|
||||||
UefiLib
|
UefiLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiCpuArchProtocolGuid
|
gEfiCpuArchProtocolGuid
|
||||||
|
gEfiMemoryAttributeProtocolGuid
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiDebugImageInfoTableGuid
|
gEfiDebugImageInfoTableGuid
|
||||||
@@ -62,9 +65,11 @@
|
|||||||
|
|
||||||
[Pcd.common]
|
[Pcd.common]
|
||||||
gArmTokenSpaceGuid.PcdVFPEnabled
|
gArmTokenSpaceGuid.PcdVFPEnabled
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy
|
||||||
|
|
||||||
[FeaturePcd.common]
|
[FeaturePcd.common]
|
||||||
gArmTokenSpaceGuid.PcdDebuggerExceptionSupport
|
gArmTokenSpaceGuid.PcdDebuggerExceptionSupport
|
||||||
|
gArmTokenSpaceGuid.PcdRemapUnusedMemoryNx
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
gHardwareInterruptProtocolGuid OR gHardwareInterrupt2ProtocolGuid
|
gHardwareInterruptProtocolGuid OR gHardwareInterrupt2ProtocolGuid
|
||||||
|
@@ -217,7 +217,7 @@ CpuSetMemoryAttributes (
|
|||||||
if (EFI_ERROR (Status) || (RegionArmAttributes != ArmAttributes) ||
|
if (EFI_ERROR (Status) || (RegionArmAttributes != ArmAttributes) ||
|
||||||
((BaseAddress + Length) > (RegionBaseAddress + RegionLength)))
|
((BaseAddress + Length) > (RegionBaseAddress + RegionLength)))
|
||||||
{
|
{
|
||||||
return ArmSetMemoryAttributes (BaseAddress, Length, EfiAttributes);
|
return ArmSetMemoryAttributes (BaseAddress, Length, EfiAttributes, 0);
|
||||||
} else {
|
} else {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
273
ArmPkg/Drivers/CpuDxe/MemoryAttribute.c
Normal file
273
ArmPkg/Drivers/CpuDxe/MemoryAttribute.c
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
/** @file
|
||||||
|
|
||||||
|
Copyright (c) 2023, Google LLC. All rights reserved.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "CpuDxe.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check whether the provided memory range is covered by a single entry of type
|
||||||
|
EfiGcdSystemMemory in the GCD memory map.
|
||||||
|
|
||||||
|
@param BaseAddress The physical address that is the start address of
|
||||||
|
a memory region.
|
||||||
|
@param Length The size in bytes of the memory region.
|
||||||
|
|
||||||
|
@return Whether the region is system memory or not.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
BOOLEAN
|
||||||
|
RegionIsSystemMemory (
|
||||||
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
|
IN UINT64 Length
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
||||||
|
EFI_PHYSICAL_ADDRESS GcdEndAddress;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);
|
||||||
|
if (EFI_ERROR (Status) ||
|
||||||
|
(GcdDescriptor.GcdMemoryType != EfiGcdMemoryTypeSystemMemory))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GcdEndAddress = GcdDescriptor.BaseAddress + GcdDescriptor.Length;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return TRUE if the GCD descriptor covers the range entirely
|
||||||
|
//
|
||||||
|
return GcdEndAddress >= (BaseAddress + Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function retrieves the attributes of the memory region specified by
|
||||||
|
BaseAddress and Length. If different attributes are obtained from different
|
||||||
|
parts of the memory region, EFI_NO_MAPPING will be returned.
|
||||||
|
|
||||||
|
@param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
||||||
|
@param BaseAddress The physical address that is the start address of
|
||||||
|
a memory region.
|
||||||
|
@param Length The size in bytes of the memory region.
|
||||||
|
@param Attributes Pointer to attributes returned.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes got for the memory region.
|
||||||
|
@retval EFI_INVALID_PARAMETER Length is zero.
|
||||||
|
Attributes is NULL.
|
||||||
|
@retval EFI_NO_MAPPING Attributes are not consistent cross the memory
|
||||||
|
region.
|
||||||
|
@retval EFI_UNSUPPORTED The processor does not support one or more
|
||||||
|
bytes of the memory resource range specified
|
||||||
|
by BaseAddress and Length.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
GetMemoryAttributes (
|
||||||
|
IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||||
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
|
IN UINT64 Length,
|
||||||
|
OUT UINT64 *Attributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN RegionAddress;
|
||||||
|
UINTN RegionLength;
|
||||||
|
UINTN RegionAttributes;
|
||||||
|
UINTN Union;
|
||||||
|
UINTN Intersection;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
if ((Length == 0) || (Attributes == NULL)) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RegionIsSystemMemory (BaseAddress, Length)) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_VERBOSE,
|
||||||
|
"%a: BaseAddress == 0x%lx, Length == 0x%lx\n",
|
||||||
|
__func__,
|
||||||
|
BaseAddress,
|
||||||
|
Length
|
||||||
|
));
|
||||||
|
|
||||||
|
Union = 0;
|
||||||
|
Intersection = MAX_UINTN;
|
||||||
|
|
||||||
|
for (RegionAddress = (UINTN)BaseAddress;
|
||||||
|
RegionAddress < (UINTN)(BaseAddress + Length);
|
||||||
|
RegionAddress += RegionLength)
|
||||||
|
{
|
||||||
|
Status = GetMemoryRegion (
|
||||||
|
&RegionAddress,
|
||||||
|
&RegionLength,
|
||||||
|
&RegionAttributes
|
||||||
|
);
|
||||||
|
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_VERBOSE,
|
||||||
|
"%a: RegionAddress == 0x%lx, RegionLength == 0x%lx, RegionAttributes == 0x%lx\n",
|
||||||
|
__func__,
|
||||||
|
(UINT64)RegionAddress,
|
||||||
|
(UINT64)RegionLength,
|
||||||
|
(UINT64)RegionAttributes
|
||||||
|
));
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return EFI_NO_MAPPING;
|
||||||
|
}
|
||||||
|
|
||||||
|
Union |= RegionAttributes;
|
||||||
|
Intersection &= RegionAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_VERBOSE,
|
||||||
|
"%a: Union == %lx, Intersection == %lx\n",
|
||||||
|
__func__,
|
||||||
|
(UINT64)Union,
|
||||||
|
(UINT64)Intersection
|
||||||
|
));
|
||||||
|
|
||||||
|
if (Union != Intersection) {
|
||||||
|
return EFI_NO_MAPPING;
|
||||||
|
}
|
||||||
|
|
||||||
|
*Attributes = RegionAttributeToGcdAttribute (Union);
|
||||||
|
*Attributes &= EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function set given attributes of the memory region specified by
|
||||||
|
BaseAddress and Length.
|
||||||
|
|
||||||
|
The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.
|
||||||
|
|
||||||
|
@param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
||||||
|
@param BaseAddress The physical address that is the start address of
|
||||||
|
a memory region.
|
||||||
|
@param Length The size in bytes of the memory region.
|
||||||
|
@param Attributes The bit mask of attributes to set for the memory
|
||||||
|
region.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were set for the memory region.
|
||||||
|
@retval EFI_INVALID_PARAMETER Length is zero.
|
||||||
|
Attributes specified an illegal combination of
|
||||||
|
attributes that cannot be set together.
|
||||||
|
@retval EFI_UNSUPPORTED The processor does not support one or more
|
||||||
|
bytes of the memory resource range specified
|
||||||
|
by BaseAddress and Length.
|
||||||
|
The bit mask of attributes is not supported for
|
||||||
|
the memory resource range specified by
|
||||||
|
BaseAddress and Length.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due to
|
||||||
|
lack of system resources.
|
||||||
|
@retval EFI_ACCESS_DENIED Attributes for the requested memory region are
|
||||||
|
controlled by system firmware and cannot be
|
||||||
|
updated via the protocol.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
SetMemoryAttributes (
|
||||||
|
IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||||
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
|
IN UINT64 Length,
|
||||||
|
IN UINT64 Attributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"%a: BaseAddress == 0x%lx, Length == 0x%lx, Attributes == 0x%lx\n",
|
||||||
|
__func__,
|
||||||
|
(UINTN)BaseAddress,
|
||||||
|
(UINTN)Length,
|
||||||
|
(UINTN)Attributes
|
||||||
|
));
|
||||||
|
|
||||||
|
if ((Length == 0) ||
|
||||||
|
((Attributes & ~(EFI_MEMORY_RO | EFI_MEMORY_RP | EFI_MEMORY_XP)) != 0))
|
||||||
|
{
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RegionIsSystemMemory (BaseAddress, Length)) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ArmSetMemoryAttributes (BaseAddress, Length, Attributes, Attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function clears given attributes of the memory region specified by
|
||||||
|
BaseAddress and Length.
|
||||||
|
|
||||||
|
The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.
|
||||||
|
|
||||||
|
@param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
||||||
|
@param BaseAddress The physical address that is the start address of
|
||||||
|
a memory region.
|
||||||
|
@param Length The size in bytes of the memory region.
|
||||||
|
@param Attributes The bit mask of attributes to clear for the memory
|
||||||
|
region.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were cleared for the memory region.
|
||||||
|
@retval EFI_INVALID_PARAMETER Length is zero.
|
||||||
|
Attributes specified an illegal combination of
|
||||||
|
attributes that cannot be cleared together.
|
||||||
|
@retval EFI_UNSUPPORTED The processor does not support one or more
|
||||||
|
bytes of the memory resource range specified
|
||||||
|
by BaseAddress and Length.
|
||||||
|
The bit mask of attributes is not supported for
|
||||||
|
the memory resource range specified by
|
||||||
|
BaseAddress and Length.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due to
|
||||||
|
lack of system resources.
|
||||||
|
@retval EFI_ACCESS_DENIED Attributes for the requested memory region are
|
||||||
|
controlled by system firmware and cannot be
|
||||||
|
updated via the protocol.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
ClearMemoryAttributes (
|
||||||
|
IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||||
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
|
IN UINT64 Length,
|
||||||
|
IN UINT64 Attributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"%a: BaseAddress == 0x%lx, Length == 0x%lx, Attributes == 0x%lx\n",
|
||||||
|
__func__,
|
||||||
|
(UINTN)BaseAddress,
|
||||||
|
(UINTN)Length,
|
||||||
|
(UINTN)Attributes
|
||||||
|
));
|
||||||
|
|
||||||
|
if ((Length == 0) ||
|
||||||
|
((Attributes & ~(EFI_MEMORY_RO | EFI_MEMORY_RP | EFI_MEMORY_XP)) != 0))
|
||||||
|
{
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RegionIsSystemMemory (BaseAddress, Length)) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ArmSetMemoryAttributes (BaseAddress, Length, 0, Attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_MEMORY_ATTRIBUTE_PROTOCOL mMemoryAttribute = {
|
||||||
|
GetMemoryAttributes,
|
||||||
|
SetMemoryAttributes,
|
||||||
|
ClearMemoryAttributes
|
||||||
|
};
|
@@ -3,6 +3,7 @@
|
|||||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||||
Copyright (c) 2011 Hewlett Packard Corporation. All rights reserved.<BR>
|
Copyright (c) 2011 Hewlett Packard Corporation. All rights reserved.<BR>
|
||||||
Copyright (c) 2011-2013, ARM Limited. All rights reserved.<BR>
|
Copyright (c) 2011-2013, ARM Limited. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2023, Google, LLC. All rights reserved.<BR>
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ Abstract:
|
|||||||
// The protocols, PPI and GUID definitions for this module
|
// The protocols, PPI and GUID definitions for this module
|
||||||
//
|
//
|
||||||
#include <Ppi/ArmMpCoreInfo.h>
|
#include <Ppi/ArmMpCoreInfo.h>
|
||||||
|
#include <Ppi/MemoryAttribute.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// The Library classes this module consumes
|
// The Library classes this module consumes
|
||||||
@@ -34,6 +36,77 @@ Abstract:
|
|||||||
#include <Library/PcdLib.h>
|
#include <Library/PcdLib.h>
|
||||||
#include <Library/HobLib.h>
|
#include <Library/HobLib.h>
|
||||||
#include <Library/ArmLib.h>
|
#include <Library/ArmLib.h>
|
||||||
|
#include <Library/ArmMmuLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the requested memory permission attributes on a region of memory.
|
||||||
|
|
||||||
|
BaseAddress and Length must be aligned to EFI_PAGE_SIZE.
|
||||||
|
|
||||||
|
Attributes must contain a combination of EFI_MEMORY_RP, EFI_MEMORY_RO and
|
||||||
|
EFI_MEMORY_XP, and specifies the attributes that must be set for the
|
||||||
|
region in question. Attributes that are omitted will be cleared from the
|
||||||
|
region only if they are set in AttributeMask.
|
||||||
|
|
||||||
|
AttributeMask must contain a combination of EFI_MEMORY_RP, EFI_MEMORY_RO and
|
||||||
|
EFI_MEMORY_XP, and specifies the attributes that the call will operate on.
|
||||||
|
AttributeMask must not be 0x0, and must contain at least the bits set in
|
||||||
|
Attributes.
|
||||||
|
|
||||||
|
@param[in] This The protocol instance pointer.
|
||||||
|
@param[in] BaseAddress The physical address that is the start address
|
||||||
|
of a memory region.
|
||||||
|
@param[in] Length The size in bytes of the memory region.
|
||||||
|
@param[in] Attributes Memory attributes to set or clear.
|
||||||
|
@param[in] AttributeMask Mask of memory attributes to operate on.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were set for the memory region.
|
||||||
|
@retval EFI_INVALID_PARAMETER Length is zero.
|
||||||
|
AttributeMask is zero.
|
||||||
|
AttributeMask lacks bits set in Attributes.
|
||||||
|
BaseAddress or Length is not suitably aligned.
|
||||||
|
@retval EFI_UNSUPPORTED The processor does not support one or more
|
||||||
|
bytes of the memory resource range specified
|
||||||
|
by BaseAddress and Length.
|
||||||
|
The bit mask of attributes is not supported for
|
||||||
|
the memory resource range specified by
|
||||||
|
BaseAddress and Length.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due to
|
||||||
|
lack of system resources.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SetMemoryPermissions (
|
||||||
|
IN EDKII_MEMORY_ATTRIBUTE_PPI *This,
|
||||||
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
|
IN UINT64 Length,
|
||||||
|
IN UINT64 Attributes,
|
||||||
|
IN UINT64 AttributeMask
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ((Length == 0) ||
|
||||||
|
(AttributeMask == 0) ||
|
||||||
|
((AttributeMask & (EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) == 0) ||
|
||||||
|
((Attributes & ~AttributeMask) != 0) ||
|
||||||
|
(((BaseAddress | Length) & EFI_PAGE_MASK) != 0))
|
||||||
|
{
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ArmSetMemoryAttributes (BaseAddress, Length, Attributes, AttributeMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC CONST EDKII_MEMORY_ATTRIBUTE_PPI mMemoryAttributePpi = {
|
||||||
|
SetMemoryPermissions
|
||||||
|
};
|
||||||
|
|
||||||
|
STATIC CONST EFI_PEI_PPI_DESCRIPTOR mMemoryAttributePpiDesc = {
|
||||||
|
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
||||||
|
&gEdkiiMemoryAttributePpiGuid,
|
||||||
|
(VOID *)&mMemoryAttributePpi
|
||||||
|
};
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
@@ -79,5 +152,8 @@ InitializeCpuPeim (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = PeiServicesInstallPpi (&mMemoryAttributePpiDesc);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# This module provides platform specific function to detect boot mode.
|
# This module provides platform specific function to detect boot mode.
|
||||||
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
|
# Copyright (c) 2023, Google, LLC. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
#
|
#
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
CpuPei.c
|
CpuPei.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
EmbeddedPkg/EmbeddedPkg.dec
|
EmbeddedPkg/EmbeddedPkg.dec
|
||||||
ArmPkg/ArmPkg.dec
|
ArmPkg/ArmPkg.dec
|
||||||
@@ -37,9 +39,11 @@
|
|||||||
DebugLib
|
DebugLib
|
||||||
HobLib
|
HobLib
|
||||||
ArmLib
|
ArmLib
|
||||||
|
ArmMmuLib
|
||||||
|
|
||||||
[Ppis]
|
[Ppis]
|
||||||
gArmMpCoreInfoPpiGuid
|
gArmMpCoreInfoPpiGuid
|
||||||
|
gEdkiiMemoryAttributePpiGuid
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gArmMpCoreInfoGuid
|
gArmMpCoreInfoGuid
|
||||||
|
221
ArmPkg/Drivers/MmCommunicationPei/MmCommunicationPei.c
Normal file
221
ArmPkg/Drivers/MmCommunicationPei/MmCommunicationPei.c
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
/** @file -- MmCommunicationPei.c
|
||||||
|
Provides an interface to send MM request in PEI
|
||||||
|
|
||||||
|
Copyright (c) 2016-2021, Arm Limited. All rights reserved.<BR>
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiPei.h>
|
||||||
|
#include <IndustryStandard/ArmStdSmc.h>
|
||||||
|
|
||||||
|
#include <Protocol/MmCommunication.h>
|
||||||
|
#include <Ppi/MmCommunication.h>
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/ArmSmcLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
#include <Library/PeimEntryPoint.h>
|
||||||
|
#include <Library/PeiServicesLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
MmCommunicationPeim
|
||||||
|
Communicates with a registered handler.
|
||||||
|
This function provides a service to send and receive messages from a registered UEFI service during PEI.
|
||||||
|
|
||||||
|
@param[in] This The EFI_PEI_MM_COMMUNICATION_PPI instance.
|
||||||
|
@param[in, out] CommBuffer Pointer to the data buffer
|
||||||
|
@param[in, out] CommSize The size of the data buffer being passed in. On exit, the
|
||||||
|
size of data being returned. Zero if the handler does not
|
||||||
|
wish to reply with any data.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The message was successfully posted.
|
||||||
|
@retval EFI_INVALID_PARAMETER CommBuffer or CommSize was NULL, or *CommSize does not
|
||||||
|
match MessageLength + sizeof (EFI_MM_COMMUNICATE_HEADER).
|
||||||
|
@retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implementation.
|
||||||
|
If this error is returned, the MessageLength field
|
||||||
|
in the CommBuffer header or the integer pointed by
|
||||||
|
CommSize, are updated to reflect the maximum payload
|
||||||
|
size the implementation can accommodate.
|
||||||
|
@retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or CommSize parameter,
|
||||||
|
if not omitted, are in address range that cannot be
|
||||||
|
accessed by the MM environment.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
MmCommunicationPeim (
|
||||||
|
IN CONST EFI_PEI_MM_COMMUNICATION_PPI *This,
|
||||||
|
IN OUT VOID *CommBuffer,
|
||||||
|
IN OUT UINTN *CommSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_MM_COMMUNICATE_HEADER *CommunicateHeader;
|
||||||
|
EFI_MM_COMMUNICATE_HEADER *TempCommHeader;
|
||||||
|
ARM_SMC_ARGS CommunicateSmcArgs;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN BufferSize;
|
||||||
|
|
||||||
|
ZeroMem (&CommunicateSmcArgs, sizeof (ARM_SMC_ARGS));
|
||||||
|
|
||||||
|
// Check that our static buffer is looking good.
|
||||||
|
// We are using PcdMmBufferBase to transfer variable data.
|
||||||
|
// We are not using the full size of the buffer since there is a cost
|
||||||
|
// of copying data between Normal and Secure World.
|
||||||
|
if ((PcdGet64 (PcdMmBufferBase) == 0) || (PcdGet64 (PcdMmBufferSize) == 0)) {
|
||||||
|
ASSERT (PcdGet64 (PcdMmBufferSize) > 0);
|
||||||
|
ASSERT (PcdGet64 (PcdMmBufferBase) != 0);
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check parameters
|
||||||
|
//
|
||||||
|
if ((CommBuffer == NULL) || (CommSize == NULL)) {
|
||||||
|
ASSERT (CommBuffer != NULL);
|
||||||
|
ASSERT (CommSize != NULL);
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the length of the CommBuffer is 0 then return the expected length.
|
||||||
|
// This case can be used by the consumer of this driver to find out the
|
||||||
|
// max size that can be used for allocating CommBuffer.
|
||||||
|
if ((*CommSize == 0) || (*CommSize > (UINTN)PcdGet64 (PcdMmBufferSize))) {
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"%a Invalid CommSize value 0x%llx!\n",
|
||||||
|
__func__,
|
||||||
|
*CommSize
|
||||||
|
));
|
||||||
|
*CommSize = (UINTN)PcdGet64 (PcdMmBufferSize);
|
||||||
|
return EFI_BAD_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Given CommBuffer is not NULL here, we use it to test the legitimacy of CommSize.
|
||||||
|
TempCommHeader = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)CommBuffer;
|
||||||
|
|
||||||
|
// CommBuffer is a mandatory parameter. Hence, Rely on
|
||||||
|
// MessageLength + Header to ascertain the
|
||||||
|
// total size of the communication payload rather than
|
||||||
|
// rely on optional CommSize parameter
|
||||||
|
BufferSize = TempCommHeader->MessageLength +
|
||||||
|
sizeof (TempCommHeader->HeaderGuid) +
|
||||||
|
sizeof (TempCommHeader->MessageLength);
|
||||||
|
|
||||||
|
//
|
||||||
|
// If CommSize is supplied it must match MessageLength + sizeof (EFI_MM_COMMUNICATE_HEADER);
|
||||||
|
//
|
||||||
|
if (*CommSize != BufferSize) {
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"%a Unexpected CommSize value, has: 0x%llx vs. expected: 0x%llx!\n",
|
||||||
|
__func__,
|
||||||
|
*CommSize,
|
||||||
|
BufferSize
|
||||||
|
));
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we know that the size is something we can handle, copy it over to the designated comm buffer.
|
||||||
|
CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)(PcdGet64 (PcdMmBufferBase));
|
||||||
|
|
||||||
|
CopyMem (CommunicateHeader, CommBuffer, *CommSize);
|
||||||
|
|
||||||
|
// SMC Function ID
|
||||||
|
CommunicateSmcArgs.Arg0 = ARM_SMC_ID_MM_COMMUNICATE_AARCH64;
|
||||||
|
|
||||||
|
// Cookie
|
||||||
|
CommunicateSmcArgs.Arg1 = 0;
|
||||||
|
|
||||||
|
// comm_buffer_address (64-bit physical address)
|
||||||
|
CommunicateSmcArgs.Arg2 = (UINTN)CommunicateHeader;
|
||||||
|
|
||||||
|
// comm_size_address (not used, indicated by setting to zero)
|
||||||
|
CommunicateSmcArgs.Arg3 = 0;
|
||||||
|
|
||||||
|
// Call the Standalone MM environment.
|
||||||
|
ArmCallSmc (&CommunicateSmcArgs);
|
||||||
|
|
||||||
|
switch (CommunicateSmcArgs.Arg0) {
|
||||||
|
case ARM_SMC_MM_RET_SUCCESS:
|
||||||
|
// On successful return, the size of data being returned is inferred from
|
||||||
|
// MessageLength + Header.
|
||||||
|
BufferSize = CommunicateHeader->MessageLength +
|
||||||
|
sizeof (CommunicateHeader->HeaderGuid) +
|
||||||
|
sizeof (CommunicateHeader->MessageLength);
|
||||||
|
if (BufferSize > (UINTN)PcdGet64 (PcdMmBufferSize)) {
|
||||||
|
// Something bad has happened, we should have landed in ARM_SMC_MM_RET_NO_MEMORY
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"%a Returned buffer exceeds communication buffer limit. Has: 0x%llx vs. max: 0x%llx!\n",
|
||||||
|
__func__,
|
||||||
|
BufferSize,
|
||||||
|
(UINTN)PcdGet64 (PcdMmBufferSize)
|
||||||
|
));
|
||||||
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyMem (CommBuffer, CommunicateHeader, BufferSize);
|
||||||
|
*CommSize = BufferSize;
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ARM_SMC_MM_RET_INVALID_PARAMS:
|
||||||
|
Status = EFI_INVALID_PARAMETER;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ARM_SMC_MM_RET_DENIED:
|
||||||
|
Status = EFI_ACCESS_DENIED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ARM_SMC_MM_RET_NO_MEMORY:
|
||||||
|
// Unexpected error since the CommSize was checked for zero length
|
||||||
|
// prior to issuing the SMC
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
ASSERT (0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Status = EFI_ACCESS_DENIED;
|
||||||
|
ASSERT (0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Module globals for the MM Communication PPI
|
||||||
|
//
|
||||||
|
STATIC CONST EFI_PEI_MM_COMMUNICATION_PPI mPeiMmCommunication = {
|
||||||
|
MmCommunicationPeim
|
||||||
|
};
|
||||||
|
|
||||||
|
STATIC CONST EFI_PEI_PPI_DESCRIPTOR mPeiMmCommunicationPpi = {
|
||||||
|
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
||||||
|
&gEfiPeiMmCommunicationPpiGuid,
|
||||||
|
(VOID *)&mPeiMmCommunication
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Entry point of PEI MM Communication driver
|
||||||
|
|
||||||
|
@param FileHandle Handle of the file being invoked.
|
||||||
|
Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().
|
||||||
|
@param PeiServices General purpose services available to every PEIM.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS If the interface could be successfully installed
|
||||||
|
@retval Others Returned from PeiServicesInstallPpi()
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
MmCommunicationPeiInitialize (
|
||||||
|
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||||
|
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return PeiServicesInstallPpi (&mPeiMmCommunicationPpi);
|
||||||
|
}
|
40
ArmPkg/Drivers/MmCommunicationPei/MmCommunicationPei.inf
Normal file
40
ArmPkg/Drivers/MmCommunicationPei/MmCommunicationPei.inf
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
## @file -- MmCommunicationPei.inf
|
||||||
|
# PEI MM Communicate driver
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
|
||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x0001001B
|
||||||
|
BASE_NAME = MmCommunicationPei
|
||||||
|
FILE_GUID = 58FFB346-1B75-42C7-AD69-37C652423C1A
|
||||||
|
MODULE_TYPE = PEIM
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = MmCommunicationPeiInitialize
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
MmCommunicationPei.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
ArmPkg/ArmPkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
DebugLib
|
||||||
|
ArmSmcLib
|
||||||
|
PeimEntryPoint
|
||||||
|
PeiServicesLib
|
||||||
|
HobLib
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gArmTokenSpaceGuid.PcdMmBufferBase
|
||||||
|
gArmTokenSpaceGuid.PcdMmBufferSize
|
||||||
|
|
||||||
|
[Ppis]
|
||||||
|
gEfiPeiMmCommunicationPpiGuid ## PRODUCES
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
TRUE
|
@@ -574,7 +574,7 @@ ExtendFile (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Remaining = Size;
|
Remaining = Size;
|
||||||
SetMem (WriteBuffer, 0, sizeof (WriteBuffer));
|
ZeroMem (WriteBuffer, sizeof (WriteBuffer));
|
||||||
while (Remaining > 0) {
|
while (Remaining > 0) {
|
||||||
WriteNb = MIN (Remaining, sizeof (WriteBuffer));
|
WriteNb = MIN (Remaining, sizeof (WriteBuffer));
|
||||||
WriteSize = WriteNb;
|
WriteSize = WriteNb;
|
||||||
|
@@ -38,10 +38,22 @@
|
|||||||
.global Name ; \
|
.global Name ; \
|
||||||
.section #Section, "ax" ; \
|
.section #Section, "ax" ; \
|
||||||
.type Name, %function ; \
|
.type Name, %function ; \
|
||||||
Name:
|
Name: ; \
|
||||||
|
AARCH64_BTI(c)
|
||||||
|
|
||||||
|
#define _ASM_FUNC_ALIGN(Name, Section, Align) \
|
||||||
|
.global Name ; \
|
||||||
|
.section #Section, "ax" ; \
|
||||||
|
.type Name, %function ; \
|
||||||
|
.balign Align ; \
|
||||||
|
Name: ; \
|
||||||
|
AARCH64_BTI(c)
|
||||||
|
|
||||||
#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
|
#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
|
||||||
|
|
||||||
|
#define ASM_FUNC_ALIGN(Name, Align) \
|
||||||
|
_ASM_FUNC_ALIGN(ASM_PFX(Name), .text. ## Name, Align)
|
||||||
|
|
||||||
#define MOV32(Reg, Val) \
|
#define MOV32(Reg, Val) \
|
||||||
movz Reg, (Val) >> 16, lsl #16 ; \
|
movz Reg, (Val) >> 16, lsl #16 ; \
|
||||||
movk Reg, (Val) & 0xffff
|
movk Reg, (Val) & 0xffff
|
||||||
|
@@ -112,6 +112,10 @@
|
|||||||
#define ARM_VECTOR_LOW_A32_FIQ 0x700
|
#define ARM_VECTOR_LOW_A32_FIQ 0x700
|
||||||
#define ARM_VECTOR_LOW_A32_SERR 0x780
|
#define ARM_VECTOR_LOW_A32_SERR 0x780
|
||||||
|
|
||||||
|
// The ID_AA64ISAR2_EL1 register is not recognized by older
|
||||||
|
// assemblers, we need to define it here.
|
||||||
|
#define ID_AA64ISAR2_EL1 S3_0_C0_C6_2
|
||||||
|
|
||||||
// The ID_AA64MMFR2_EL1 register was added in ARMv8.2. Since we
|
// The ID_AA64MMFR2_EL1 register was added in ARMv8.2. Since we
|
||||||
// build for ARMv8.0, we need to define the register here.
|
// build for ARMv8.0, we need to define the register here.
|
||||||
#define ID_AA64MMFR2_EL1 S3_0_C0_C7_2
|
#define ID_AA64MMFR2_EL1 S3_0_C0_C7_2
|
||||||
|
@@ -54,11 +54,9 @@
|
|||||||
#define TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE(Desc) (((Desc) & 3UL) == TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE)
|
#define TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE(Desc) (((Desc) & 3UL) == TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE)
|
||||||
|
|
||||||
// Translation table descriptor types
|
// Translation table descriptor types
|
||||||
#define TT_DESCRIPTOR_PAGE_TYPE_MASK (3UL << 0)
|
#define TT_DESCRIPTOR_PAGE_TYPE_MASK (1UL << 1)
|
||||||
#define TT_DESCRIPTOR_PAGE_TYPE_FAULT (0UL << 0)
|
#define TT_DESCRIPTOR_PAGE_TYPE_FAULT (0UL << 1)
|
||||||
#define TT_DESCRIPTOR_PAGE_TYPE_PAGE (2UL << 0)
|
#define TT_DESCRIPTOR_PAGE_TYPE_PAGE (1UL << 1)
|
||||||
#define TT_DESCRIPTOR_PAGE_TYPE_PAGE_XN (3UL << 0)
|
|
||||||
#define TT_DESCRIPTOR_PAGE_TYPE_LARGEPAGE (1UL << 0)
|
|
||||||
|
|
||||||
// Section descriptor definitions
|
// Section descriptor definitions
|
||||||
#define TT_DESCRIPTOR_SECTION_SIZE (0x00100000)
|
#define TT_DESCRIPTOR_SECTION_SIZE (0x00100000)
|
||||||
@@ -82,25 +80,24 @@
|
|||||||
#define TT_DESCRIPTOR_PAGE_S_NOT_SHARED (0UL << 10)
|
#define TT_DESCRIPTOR_PAGE_S_NOT_SHARED (0UL << 10)
|
||||||
#define TT_DESCRIPTOR_PAGE_S_SHARED (1UL << 10)
|
#define TT_DESCRIPTOR_PAGE_S_SHARED (1UL << 10)
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_SECTION_AP_MASK ((1UL << 15) | (3UL << 10))
|
#define TT_DESCRIPTOR_SECTION_AP_MASK ((1UL << 15) | (1UL << 11))
|
||||||
#define TT_DESCRIPTOR_SECTION_AP_NO_NO ((0UL << 15) | (0UL << 10))
|
#define TT_DESCRIPTOR_SECTION_AP_NO_RW ((0UL << 15) | (0UL << 11))
|
||||||
#define TT_DESCRIPTOR_SECTION_AP_RW_NO ((0UL << 15) | (1UL << 10))
|
#define TT_DESCRIPTOR_SECTION_AP_RW_RW ((0UL << 15) | (1UL << 11))
|
||||||
#define TT_DESCRIPTOR_SECTION_AP_RW_RO ((0UL << 15) | (2UL << 10))
|
#define TT_DESCRIPTOR_SECTION_AP_NO_RO ((1UL << 15) | (0UL << 11))
|
||||||
#define TT_DESCRIPTOR_SECTION_AP_RW_RW ((0UL << 15) | (3UL << 10))
|
#define TT_DESCRIPTOR_SECTION_AP_RO_RO ((1UL << 15) | (1UL << 11))
|
||||||
#define TT_DESCRIPTOR_SECTION_AP_RO_NO ((1UL << 15) | (1UL << 10))
|
|
||||||
#define TT_DESCRIPTOR_SECTION_AP_RO_RO ((1UL << 15) | (3UL << 10))
|
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_PAGE_AP_MASK ((1UL << 9) | (3UL << 4))
|
#define TT_DESCRIPTOR_SECTION_AF (1UL << 10)
|
||||||
#define TT_DESCRIPTOR_PAGE_AP_NO_NO ((0UL << 9) | (0UL << 4))
|
|
||||||
#define TT_DESCRIPTOR_PAGE_AP_RW_NO ((0UL << 9) | (1UL << 4))
|
#define TT_DESCRIPTOR_PAGE_AP_MASK ((1UL << 9) | (1UL << 5))
|
||||||
#define TT_DESCRIPTOR_PAGE_AP_RW_RO ((0UL << 9) | (2UL << 4))
|
#define TT_DESCRIPTOR_PAGE_AP_NO_RW ((0UL << 9) | (0UL << 5))
|
||||||
#define TT_DESCRIPTOR_PAGE_AP_RW_RW ((0UL << 9) | (3UL << 4))
|
#define TT_DESCRIPTOR_PAGE_AP_RW_RW ((0UL << 9) | (1UL << 5))
|
||||||
#define TT_DESCRIPTOR_PAGE_AP_RO_NO ((1UL << 9) | (1UL << 4))
|
#define TT_DESCRIPTOR_PAGE_AP_NO_RO ((1UL << 9) | (0UL << 5))
|
||||||
#define TT_DESCRIPTOR_PAGE_AP_RO_RO ((1UL << 9) | (3UL << 4))
|
#define TT_DESCRIPTOR_PAGE_AP_RO_RO ((1UL << 9) | (1UL << 5))
|
||||||
|
|
||||||
|
#define TT_DESCRIPTOR_PAGE_AF (1UL << 4)
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_SECTION_XN_MASK (0x1UL << 4)
|
#define TT_DESCRIPTOR_SECTION_XN_MASK (0x1UL << 4)
|
||||||
#define TT_DESCRIPTOR_PAGE_XN_MASK (0x1UL << 0)
|
#define TT_DESCRIPTOR_PAGE_XN_MASK (0x1UL << 0)
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_XN_MASK (0x1UL << 15)
|
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK ((3UL << 12) | (1UL << 3) | (1UL << 2))
|
#define TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK ((3UL << 12) | (1UL << 3) | (1UL << 2))
|
||||||
#define TT_DESCRIPTOR_SECTION_CACHEABLE_MASK (1UL << 3)
|
#define TT_DESCRIPTOR_SECTION_CACHEABLE_MASK (1UL << 3)
|
||||||
@@ -124,37 +121,27 @@
|
|||||||
#define TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC ((1UL << 6) | (1UL << 3) | (1UL << 2))
|
#define TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC ((1UL << 6) | (1UL << 3) | (1UL << 2))
|
||||||
#define TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_SHAREABLE_DEVICE ((2UL << 6) | (0UL << 3) | (0UL << 2))
|
#define TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_SHAREABLE_DEVICE ((2UL << 6) | (0UL << 3) | (0UL << 2))
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_MASK ((3UL << 12) | (1UL << 3) | (1UL << 2))
|
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_STRONGLY_ORDERED ((0UL << 12) | (0UL << 3) | (0UL << 2))
|
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_SHAREABLE_DEVICE ((0UL << 12) | (0UL << 3) | (1UL << 2))
|
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC ((0UL << 12) | (1UL << 3) | (0UL << 2))
|
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_WRITE_BACK_NO_ALLOC ((0UL << 12) | (1UL << 3) | (1UL << 2))
|
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_NON_CACHEABLE ((1UL << 12) | (0UL << 3) | (0UL << 2))
|
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_WRITE_BACK_ALLOC ((1UL << 12) | (1UL << 3) | (1UL << 2))
|
|
||||||
#define TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_NON_SHAREABLE_DEVICE ((2UL << 12) | (0UL << 3) | (0UL << 2))
|
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_AP(Desc) ((((Desc) & TT_DESCRIPTOR_SECTION_AP_MASK) >> 6) & TT_DESCRIPTOR_PAGE_AP_MASK)
|
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_AP(Desc) ((((Desc) & TT_DESCRIPTOR_SECTION_AP_MASK) >> 6) & TT_DESCRIPTOR_PAGE_AP_MASK)
|
||||||
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_NG(Desc) ((((Desc) & TT_DESCRIPTOR_SECTION_NG_MASK) >> 6) & TT_DESCRIPTOR_PAGE_NG_MASK)
|
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_NG(Desc) ((((Desc) & TT_DESCRIPTOR_SECTION_NG_MASK) >> 6) & TT_DESCRIPTOR_PAGE_NG_MASK)
|
||||||
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_S(Desc) ((((Desc) & TT_DESCRIPTOR_SECTION_S_MASK) >> 6) & TT_DESCRIPTOR_PAGE_S_MASK)
|
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_S(Desc) ((((Desc) & TT_DESCRIPTOR_SECTION_S_MASK) >> 6) & TT_DESCRIPTOR_PAGE_S_MASK)
|
||||||
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_XN(Desc, IsLargePage) ((IsLargePage)?\
|
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_AF(Desc) ((((Desc) & TT_DESCRIPTOR_SECTION_AF) >> 6) & TT_DESCRIPTOR_PAGE_AF)
|
||||||
((((Desc) & TT_DESCRIPTOR_SECTION_XN_MASK) << 11) & TT_DESCRIPTOR_LARGEPAGE_XN_MASK): \
|
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_XN(Desc) ((((Desc) & TT_DESCRIPTOR_SECTION_XN_MASK) >> 4) & TT_DESCRIPTOR_PAGE_XN_MASK)
|
||||||
((((Desc) & TT_DESCRIPTOR_SECTION_XN_MASK) >> 4) & TT_DESCRIPTOR_PAGE_XN_MASK))
|
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY(Desc) ((((Desc) & (0x3 << 12)) >> 6) | (Desc & (0x3 << 2)))
|
||||||
#define TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY(Desc, IsLargePage) (IsLargePage? \
|
|
||||||
(((Desc) & TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK) & TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_MASK): \
|
|
||||||
(((((Desc) & (0x3 << 12)) >> 6) | (Desc & (0x3 << 2)))))
|
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_CONVERT_TO_SECTION_AP(Desc) ((((Desc) & TT_DESCRIPTOR_PAGE_AP_MASK) << 6) & TT_DESCRIPTOR_SECTION_AP_MASK)
|
#define TT_DESCRIPTOR_CONVERT_TO_SECTION_AP(Desc) ((((Desc) & TT_DESCRIPTOR_PAGE_AP_MASK) << 6) & TT_DESCRIPTOR_SECTION_AP_MASK)
|
||||||
|
#define TT_DESCRIPTOR_CONVERT_TO_SECTION_S(Desc) ((((Desc) & TT_DESCRIPTOR_PAGE_S_MASK) << 6) & TT_DESCRIPTOR_SECTION_S_MASK)
|
||||||
#define TT_DESCRIPTOR_CONVERT_TO_SECTION_CACHE_POLICY(Desc, IsLargePage) (IsLargePage? \
|
#define TT_DESCRIPTOR_CONVERT_TO_SECTION_AF(Desc) ((((Desc) & TT_DESCRIPTOR_PAGE_AF) << 6) & TT_DESCRIPTOR_SECTION_AF)
|
||||||
(((Desc) & TT_DESCRIPTOR_LARGEPAGE_CACHE_POLICY_MASK) & TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK): \
|
#define TT_DESCRIPTOR_CONVERT_TO_SECTION_XN(Desc) ((((Desc) & TT_DESCRIPTOR_PAGE_XN_MASK) << 4) & TT_DESCRIPTOR_SECTION_XN_MASK)
|
||||||
(((((Desc) & (0x3 << 6)) << 6) | (Desc & (0x3 << 2)))))
|
#define TT_DESCRIPTOR_CONVERT_TO_SECTION_CACHE_POLICY(Desc) ((((Desc) & (0x3 << 6)) << 6) | (Desc & (0x3 << 2)))
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_SECTION_ATTRIBUTE_MASK (TT_DESCRIPTOR_SECTION_NS_MASK | TT_DESCRIPTOR_SECTION_NG_MASK | \
|
#define TT_DESCRIPTOR_SECTION_ATTRIBUTE_MASK (TT_DESCRIPTOR_SECTION_NS_MASK | TT_DESCRIPTOR_SECTION_NG_MASK | \
|
||||||
TT_DESCRIPTOR_SECTION_S_MASK | TT_DESCRIPTOR_SECTION_AP_MASK | \
|
TT_DESCRIPTOR_SECTION_S_MASK | TT_DESCRIPTOR_SECTION_AP_MASK | \
|
||||||
|
TT_DESCRIPTOR_SECTION_AF | \
|
||||||
TT_DESCRIPTOR_SECTION_XN_MASK | TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK)
|
TT_DESCRIPTOR_SECTION_XN_MASK | TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK)
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_PAGE_ATTRIBUTE_MASK (TT_DESCRIPTOR_PAGE_NG_MASK | TT_DESCRIPTOR_PAGE_S_MASK | \
|
#define TT_DESCRIPTOR_PAGE_ATTRIBUTE_MASK (TT_DESCRIPTOR_PAGE_NG_MASK | TT_DESCRIPTOR_PAGE_S_MASK | \
|
||||||
TT_DESCRIPTOR_PAGE_AP_MASK | TT_DESCRIPTOR_PAGE_XN_MASK | \
|
TT_DESCRIPTOR_PAGE_AP_MASK | TT_DESCRIPTOR_PAGE_XN_MASK | \
|
||||||
|
TT_DESCRIPTOR_PAGE_AF | \
|
||||||
TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK)
|
TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK)
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_SECTION_DOMAIN_MASK (0x0FUL << 5)
|
#define TT_DESCRIPTOR_SECTION_DOMAIN_MASK (0x0FUL << 5)
|
||||||
@@ -170,56 +157,49 @@
|
|||||||
#define TT_DESCRIPTOR_PAGE_BASE_ADDRESS(a) ((a) & TT_DESCRIPTOR_PAGE_BASE_ADDRESS_MASK)
|
#define TT_DESCRIPTOR_PAGE_BASE_ADDRESS(a) ((a) & TT_DESCRIPTOR_PAGE_BASE_ADDRESS_MASK)
|
||||||
#define TT_DESCRIPTOR_PAGE_BASE_SHIFT 12
|
#define TT_DESCRIPTOR_PAGE_BASE_SHIFT 12
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_SECTION_WRITE_BACK(NonSecure) (TT_DESCRIPTOR_SECTION_TYPE_SECTION | \
|
#define TT_DESCRIPTOR_SECTION_DEFAULT (TT_DESCRIPTOR_SECTION_TYPE_SECTION | \
|
||||||
((NonSecure) ? TT_DESCRIPTOR_SECTION_NS : 0) | \
|
|
||||||
TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
|
TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
|
||||||
TT_DESCRIPTOR_SECTION_S_SHARED | \
|
TT_DESCRIPTOR_SECTION_S_SHARED | \
|
||||||
TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
|
TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
|
||||||
TT_DESCRIPTOR_SECTION_AP_RW_RW | \
|
TT_DESCRIPTOR_SECTION_AP_RW_RW | \
|
||||||
|
TT_DESCRIPTOR_SECTION_AF)
|
||||||
|
|
||||||
|
#define TT_DESCRIPTOR_SECTION_WRITE_BACK (TT_DESCRIPTOR_SECTION_DEFAULT | \
|
||||||
TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC)
|
TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC)
|
||||||
#define TT_DESCRIPTOR_SECTION_WRITE_THROUGH(NonSecure) (TT_DESCRIPTOR_SECTION_TYPE_SECTION | \
|
|
||||||
((NonSecure) ? TT_DESCRIPTOR_SECTION_NS : 0) | \
|
#define TT_DESCRIPTOR_SECTION_WRITE_THROUGH (TT_DESCRIPTOR_SECTION_DEFAULT | \
|
||||||
TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
|
|
||||||
TT_DESCRIPTOR_SECTION_S_SHARED | \
|
|
||||||
TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
|
|
||||||
TT_DESCRIPTOR_SECTION_AP_RW_RW | \
|
|
||||||
TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC)
|
TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC)
|
||||||
#define TT_DESCRIPTOR_SECTION_DEVICE(NonSecure) (TT_DESCRIPTOR_SECTION_TYPE_SECTION | \
|
|
||||||
((NonSecure) ? TT_DESCRIPTOR_SECTION_NS : 0) | \
|
#define TT_DESCRIPTOR_SECTION_DEVICE (TT_DESCRIPTOR_SECTION_DEFAULT | \
|
||||||
TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
|
|
||||||
TT_DESCRIPTOR_SECTION_S_NOT_SHARED | \
|
|
||||||
TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
|
|
||||||
TT_DESCRIPTOR_SECTION_AP_RW_RW | \
|
|
||||||
TT_DESCRIPTOR_SECTION_XN_MASK | \
|
|
||||||
TT_DESCRIPTOR_SECTION_CACHE_POLICY_SHAREABLE_DEVICE)
|
TT_DESCRIPTOR_SECTION_CACHE_POLICY_SHAREABLE_DEVICE)
|
||||||
#define TT_DESCRIPTOR_SECTION_UNCACHED(NonSecure) (TT_DESCRIPTOR_SECTION_TYPE_SECTION | \
|
|
||||||
((NonSecure) ? TT_DESCRIPTOR_SECTION_NS : 0) | \
|
#define TT_DESCRIPTOR_SECTION_UNCACHED (TT_DESCRIPTOR_SECTION_DEFAULT | \
|
||||||
TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
|
|
||||||
TT_DESCRIPTOR_SECTION_S_NOT_SHARED | \
|
|
||||||
TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
|
|
||||||
TT_DESCRIPTOR_SECTION_AP_RW_RW | \
|
|
||||||
TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE)
|
TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE)
|
||||||
|
|
||||||
#define TT_DESCRIPTOR_PAGE_WRITE_BACK (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
#define TT_DESCRIPTOR_PAGE_WRITE_BACK (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
||||||
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
||||||
TT_DESCRIPTOR_PAGE_S_SHARED | \
|
TT_DESCRIPTOR_PAGE_S_SHARED | \
|
||||||
TT_DESCRIPTOR_PAGE_AP_RW_RW | \
|
TT_DESCRIPTOR_PAGE_AP_RW_RW | \
|
||||||
|
TT_DESCRIPTOR_PAGE_AF | \
|
||||||
TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC)
|
TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC)
|
||||||
#define TT_DESCRIPTOR_PAGE_WRITE_THROUGH (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
#define TT_DESCRIPTOR_PAGE_WRITE_THROUGH (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
||||||
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
||||||
TT_DESCRIPTOR_PAGE_S_SHARED | \
|
TT_DESCRIPTOR_PAGE_S_SHARED | \
|
||||||
TT_DESCRIPTOR_PAGE_AP_RW_RW | \
|
TT_DESCRIPTOR_PAGE_AP_RW_RW | \
|
||||||
|
TT_DESCRIPTOR_PAGE_AF | \
|
||||||
TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC)
|
TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC)
|
||||||
#define TT_DESCRIPTOR_PAGE_DEVICE (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
#define TT_DESCRIPTOR_PAGE_DEVICE (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
||||||
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
||||||
TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
|
TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
|
||||||
TT_DESCRIPTOR_PAGE_AP_RW_RW | \
|
TT_DESCRIPTOR_PAGE_AP_RW_RW | \
|
||||||
|
TT_DESCRIPTOR_PAGE_AF | \
|
||||||
TT_DESCRIPTOR_PAGE_XN_MASK | \
|
TT_DESCRIPTOR_PAGE_XN_MASK | \
|
||||||
TT_DESCRIPTOR_PAGE_CACHE_POLICY_SHAREABLE_DEVICE)
|
TT_DESCRIPTOR_PAGE_CACHE_POLICY_SHAREABLE_DEVICE)
|
||||||
#define TT_DESCRIPTOR_PAGE_UNCACHED (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
#define TT_DESCRIPTOR_PAGE_UNCACHED (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
|
||||||
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
|
||||||
TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
|
TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
|
||||||
TT_DESCRIPTOR_PAGE_AP_RW_RW | \
|
TT_DESCRIPTOR_PAGE_AP_RW_RW | \
|
||||||
|
TT_DESCRIPTOR_PAGE_AF | \
|
||||||
TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_CACHEABLE)
|
TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_CACHEABLE)
|
||||||
|
|
||||||
// First Level Descriptors
|
// First Level Descriptors
|
||||||
@@ -230,8 +210,7 @@ typedef UINT32 ARM_PAGE_TABLE_ENTRY;
|
|||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
ConvertSectionAttributesToPageAttributes (
|
ConvertSectionAttributesToPageAttributes (
|
||||||
IN UINT32 SectionAttributes,
|
IN UINT32 SectionAttributes
|
||||||
IN BOOLEAN IsLargePage
|
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif // ARMV7_MMU_H_
|
#endif // ARMV7_MMU_H_
|
||||||
|
@@ -1,13 +1,20 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2020, NUVIA Inc. All rights reserved.<BR>
|
* Copyright (c) 2020, NUVIA Inc. All rights reserved.<BR>
|
||||||
* Copyright (c) 2012-2017, ARM Limited. All rights reserved.
|
* Copyright (c) 2012 - 2022, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
*
|
*
|
||||||
* @par Revision Reference:
|
* @par Revision Reference:
|
||||||
* - SMC Calling Convention version 1.2
|
* - [1] SMC Calling Convention version 1.2
|
||||||
* (https://developer.arm.com/documentation/den0028/c/?lang=en)
|
* (https://developer.arm.com/documentation/den0028/c/?lang=en)
|
||||||
|
* - [2] Arm True Random Number Generator Firmware, Interface 1.0,
|
||||||
|
* Platform Design Document.
|
||||||
|
* (https://developer.arm.com/documentation/den0098/latest/)
|
||||||
|
*
|
||||||
|
* @par Glossary:
|
||||||
|
* - TRNG - True Random Number Generator
|
||||||
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef ARM_STD_SMC_H_
|
#ifndef ARM_STD_SMC_H_
|
||||||
@@ -93,6 +100,8 @@
|
|||||||
#define ARM_SMC_ID_PSCI_MIGRATE_AARCH32 0x84000005
|
#define ARM_SMC_ID_PSCI_MIGRATE_AARCH32 0x84000005
|
||||||
#define ARM_SMC_ID_PSCI_SYSTEM_OFF 0x84000008
|
#define ARM_SMC_ID_PSCI_SYSTEM_OFF 0x84000008
|
||||||
#define ARM_SMC_ID_PSCI_SYSTEM_RESET 0x84000009
|
#define ARM_SMC_ID_PSCI_SYSTEM_RESET 0x84000009
|
||||||
|
#define ARM_SMC_ID_PSCI_FEATURES 0x8400000A
|
||||||
|
#define ARM_SMC_ID_PSCI_SYSTEM_RESET2_AARCH64 0xC4000012
|
||||||
|
|
||||||
/* The current PSCI version is: 0.2 */
|
/* The current PSCI version is: 0.2 */
|
||||||
#define ARM_SMC_PSCI_VERSION_MAJOR 0
|
#define ARM_SMC_PSCI_VERSION_MAJOR 0
|
||||||
@@ -137,4 +146,111 @@
|
|||||||
/* 0xbf00ff02 is reserved */
|
/* 0xbf00ff02 is reserved */
|
||||||
#define ARM_SMC_ID_TOS_REVISION 0xbf00ff03
|
#define ARM_SMC_ID_TOS_REVISION 0xbf00ff03
|
||||||
|
|
||||||
|
// Firmware TRNG interface Function IDs
|
||||||
|
|
||||||
|
/*
|
||||||
|
SMC/HVC call to get the version of the TRNG backend,
|
||||||
|
Cf. [2], 2.1 TRNG_VERSION
|
||||||
|
Input values:
|
||||||
|
W0 0x8400_0050
|
||||||
|
W1-W7 Reserved (MBZ)
|
||||||
|
Return values:
|
||||||
|
Success (W0 > 0) W0[31] MBZ
|
||||||
|
W0[30:16] Major revision
|
||||||
|
W0[15:0] Minor revision
|
||||||
|
W1 - W3 Reserved (MBZ)
|
||||||
|
Error (W0 < 0)
|
||||||
|
NOT_SUPPORTED Function not implemented
|
||||||
|
*/
|
||||||
|
#define ARM_SMC_ID_TRNG_VERSION 0x84000050
|
||||||
|
|
||||||
|
/*
|
||||||
|
SMC/HVC call to check if a TRNG function ID is implemented by the backend,
|
||||||
|
Cf. [2], Section 2.2 TRNG_FEATURES
|
||||||
|
Input Values
|
||||||
|
W0 0x8400_0051
|
||||||
|
W1 trng_func_id
|
||||||
|
W2-W7 Reserved (MBZ)
|
||||||
|
Return values:
|
||||||
|
Success (W0 >= 0):
|
||||||
|
SUCCESS Function is implemented.
|
||||||
|
> 0 Function is implemented and
|
||||||
|
has specific capabilities,
|
||||||
|
see function definition.
|
||||||
|
Error (W0 < 0)
|
||||||
|
NOT_SUPPORTED Function with FID=trng_func_id
|
||||||
|
is not implemented
|
||||||
|
*/
|
||||||
|
#define ARM_SMC_ID_TRNG_FEATURES 0x84000051
|
||||||
|
|
||||||
|
/*
|
||||||
|
SMC/HVC call to get the UUID of the TRNG backend,
|
||||||
|
Cf. [2], Section 2.3 TRNG_GET_UUID
|
||||||
|
Input Values:
|
||||||
|
W0 0x8400_0052
|
||||||
|
W1-W7 Reserved (MBZ)
|
||||||
|
Return Values:
|
||||||
|
Success (W0 != -1)
|
||||||
|
W0 UUID[31:0]
|
||||||
|
W1 UUID[63:32]
|
||||||
|
W2 UUID[95:64]
|
||||||
|
W3 UUID[127:96]
|
||||||
|
Error (W0 = -1)
|
||||||
|
W0 NOT_SUPPORTED
|
||||||
|
*/
|
||||||
|
#define ARM_SMC_ID_TRNG_GET_UUID 0x84000052
|
||||||
|
|
||||||
|
/*
|
||||||
|
AARCH32 SMC/HVC call to get entropy bits, Cf. [2], Section 2.4 TRNG_RND.
|
||||||
|
Input values:
|
||||||
|
W0 0x8400_0053
|
||||||
|
W2-W7 Reserved (MBZ)
|
||||||
|
Return values:
|
||||||
|
Success (W0 = 0):
|
||||||
|
W0 MBZ
|
||||||
|
W1 Entropy[95:64]
|
||||||
|
W2 Entropy[63:32]
|
||||||
|
W3 Entropy[31:0]
|
||||||
|
Error (W0 < 0)
|
||||||
|
W0 NOT_SUPPORTED
|
||||||
|
NO_ENTROPY
|
||||||
|
INVALID_PARAMETERS
|
||||||
|
W1 - W3 Reserved (MBZ)
|
||||||
|
*/
|
||||||
|
#define ARM_SMC_ID_TRNG_RND_AARCH32 0x84000053
|
||||||
|
|
||||||
|
/*
|
||||||
|
AARCH64 SMC/HVC call to get entropy bits, Cf. [2], Section 2.4 TRNG_RND.
|
||||||
|
Input values:
|
||||||
|
X0 0xC400_0053
|
||||||
|
X2-X7 Reserved (MBZ)
|
||||||
|
Return values:
|
||||||
|
Success (X0 = 0):
|
||||||
|
X0 MBZ
|
||||||
|
X1 Entropy[191:128]
|
||||||
|
X2 Entropy[127:64]
|
||||||
|
X3 Entropy[63:0]
|
||||||
|
Error (X0 < 0)
|
||||||
|
X0 NOT_SUPPORTED
|
||||||
|
NO_ENTROPY
|
||||||
|
INVALID_PARAMETERS
|
||||||
|
X1 - X3 Reserved (MBZ)
|
||||||
|
*/
|
||||||
|
#define ARM_SMC_ID_TRNG_RND_AARCH64 0xC4000053
|
||||||
|
|
||||||
|
// Firmware TRNG status codes
|
||||||
|
#define TRNG_STATUS_SUCCESS (INT32)(0)
|
||||||
|
#define TRNG_STATUS_NOT_SUPPORTED (INT32)(-1)
|
||||||
|
#define TRNG_STATUS_INVALID_PARAMETER (INT32)(-2)
|
||||||
|
#define TRNG_STATUS_NO_ENTROPY (INT32)(-3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SMC64 SiP Service Calls
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SMC_FASTCALL 0x80000000
|
||||||
|
#define SMC64_FUNCTION (SMC_FASTCALL | 0x40000000)
|
||||||
|
#define SMC_SIP_FUNCTION (SMC64_FUNCTION | 0x02000000)
|
||||||
|
#define SMC_SIP_FUNCTION_ID(n) (SMC_SIP_FUNCTION | (n))
|
||||||
|
|
||||||
#endif // ARM_STD_SMC_H_
|
#endif // ARM_STD_SMC_H_
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2021, Arm Limited. All rights reserved.<BR>
|
* Copyright (c) 2011-2023, Arm Limited. All rights reserved.<BR>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
*
|
*
|
||||||
@@ -110,10 +110,10 @@
|
|||||||
// Bit Mask for
|
// Bit Mask for
|
||||||
#define ARM_GIC_ICCIAR_ACKINTID 0x3FF
|
#define ARM_GIC_ICCIAR_ACKINTID 0x3FF
|
||||||
|
|
||||||
UINTN
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicGetInterfaceIdentification (
|
ArmGicGetInterfaceIdentification (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
);
|
);
|
||||||
|
|
||||||
// GIC Secure interfaces
|
// GIC Secure interfaces
|
||||||
@@ -121,8 +121,8 @@ VOID
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicSetupNonSecure (
|
ArmGicSetupNonSecure (
|
||||||
IN UINTN MpId,
|
IN UINTN MpId,
|
||||||
IN INTN GicDistributorBase,
|
IN UINTN GicDistributorBase,
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
@@ -136,40 +136,40 @@ ArmGicSetSecureInterrupts (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicEnableInterruptInterface (
|
ArmGicEnableInterruptInterface (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicDisableInterruptInterface (
|
ArmGicDisableInterruptInterface (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicEnableDistributor (
|
ArmGicEnableDistributor (
|
||||||
IN INTN GicDistributorBase
|
IN UINTN GicDistributorBase
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicDisableDistributor (
|
ArmGicDisableDistributor (
|
||||||
IN INTN GicDistributorBase
|
IN UINTN GicDistributorBase
|
||||||
);
|
);
|
||||||
|
|
||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicGetMaxNumInterrupts (
|
ArmGicGetMaxNumInterrupts (
|
||||||
IN INTN GicDistributorBase
|
IN UINTN GicDistributorBase
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicSendSgiTo (
|
ArmGicSendSgiTo (
|
||||||
IN INTN GicDistributorBase,
|
IN UINTN GicDistributorBase,
|
||||||
IN INTN TargetListFilter,
|
IN UINT8 TargetListFilter,
|
||||||
IN INTN CPUTargetList,
|
IN UINT8 CPUTargetList,
|
||||||
IN INTN SgiId
|
IN UINT8 SgiId
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -203,7 +203,7 @@ ArmGicEndOfInterrupt (
|
|||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicSetPriorityMask (
|
ArmGicSetPriorityMask (
|
||||||
IN INTN GicInterruptInterfaceBase,
|
IN UINTN GicInterruptInterfaceBase,
|
||||||
IN INTN PriorityMask
|
IN INTN PriorityMask
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -251,20 +251,20 @@ VOID
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicV2SetupNonSecure (
|
ArmGicV2SetupNonSecure (
|
||||||
IN UINTN MpId,
|
IN UINTN MpId,
|
||||||
IN INTN GicDistributorBase,
|
IN UINTN GicDistributorBase,
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicV2EnableInterruptInterface (
|
ArmGicV2EnableInterruptInterface (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGicV2DisableInterruptInterface (
|
ArmGicV2DisableInterruptInterface (
|
||||||
IN INTN GicInterruptInterfaceBase
|
IN UINTN GicInterruptInterfaceBase
|
||||||
);
|
);
|
||||||
|
|
||||||
UINTN
|
UINTN
|
||||||
|
@@ -25,29 +25,24 @@
|
|||||||
EFI_MEMORY_WT | EFI_MEMORY_WB | \
|
EFI_MEMORY_WT | EFI_MEMORY_WB | \
|
||||||
EFI_MEMORY_UCE)
|
EFI_MEMORY_UCE)
|
||||||
|
|
||||||
/**
|
|
||||||
* The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
|
|
||||||
*
|
|
||||||
* The Non Secure memory attribute (ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_*) should only
|
|
||||||
* be used in Secure World to distinguished Secure to Non-Secure memory.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED = 0,
|
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED = 0,
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED,
|
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK,
|
|
||||||
|
|
||||||
// On some platforms, memory mapped flash region is designed as not supporting
|
// On some platforms, memory mapped flash region is designed as not supporting
|
||||||
// shareable attribute, so WRITE_BACK_NONSHAREABLE is added for such special
|
// shareable attribute, so WRITE_BACK_NONSHAREABLE is added for such special
|
||||||
// need.
|
// need.
|
||||||
// Do NOT use below two attributes if you are not sure.
|
// Do NOT use below two attributes if you are not sure.
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE,
|
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE,
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE,
|
|
||||||
|
// Special region types for memory that must be mapped with read-only or
|
||||||
|
// non-execute permissions from the very start, e.g., to support the use
|
||||||
|
// of the WXN virtual memory control.
|
||||||
|
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO,
|
||||||
|
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_XP,
|
||||||
|
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH,
|
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH,
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH,
|
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,
|
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,
|
||||||
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE
|
|
||||||
} ARM_MEMORY_REGION_ATTRIBUTES;
|
} ARM_MEMORY_REGION_ATTRIBUTES;
|
||||||
|
|
||||||
#define IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE(attr) ((UINT32)(attr) & 1)
|
#define IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE(attr) ((UINT32)(attr) & 1)
|
||||||
@@ -115,7 +110,9 @@ typedef enum {
|
|||||||
#define GET_MPIDR_AFF1(MpId) (((MpId) & ARM_CORE_AFF1) >> 8)
|
#define GET_MPIDR_AFF1(MpId) (((MpId) & ARM_CORE_AFF1) >> 8)
|
||||||
#define GET_MPIDR_AFF2(MpId) (((MpId) & ARM_CORE_AFF2) >> 16)
|
#define GET_MPIDR_AFF2(MpId) (((MpId) & ARM_CORE_AFF2) >> 16)
|
||||||
#define GET_MPIDR_AFF3(MpId) (((MpId) & ARM_CORE_AFF3) >> 32)
|
#define GET_MPIDR_AFF3(MpId) (((MpId) & ARM_CORE_AFF3) >> 32)
|
||||||
|
#define GET_MPIDR_AFFINITY_BITS(MpId) ((MpId) & 0xFF00FFFFFF)
|
||||||
#define PRIMARY_CORE_ID (PcdGet32(PcdArmPrimaryCore) & ARM_CORE_MASK)
|
#define PRIMARY_CORE_ID (PcdGet32(PcdArmPrimaryCore) & ARM_CORE_MASK)
|
||||||
|
#define MPIDR_MT_BIT BIT24
|
||||||
|
|
||||||
/** Reads the CCSIDR register for the specified cache.
|
/** Reads the CCSIDR register for the specified cache.
|
||||||
|
|
||||||
|
@@ -21,47 +21,54 @@ ArmConfigureMmu (
|
|||||||
OUT UINTN *TranslationTableSize OPTIONAL
|
OUT UINTN *TranslationTableSize OPTIONAL
|
||||||
);
|
);
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
ArmSetMemoryRegionNoExec (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length
|
|
||||||
);
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
ArmClearMemoryRegionNoExec (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length
|
|
||||||
);
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
ArmSetMemoryRegionReadOnly (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length
|
|
||||||
);
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
ArmClearMemoryRegionReadOnly (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length
|
|
||||||
);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmReplaceLiveTranslationEntry (
|
ArmReplaceLiveTranslationEntry (
|
||||||
IN UINT64 *Entry,
|
IN UINT64 *Entry,
|
||||||
IN UINT64 Value,
|
IN UINT64 Value,
|
||||||
IN UINT64 RegionStart
|
IN UINT64 RegionStart,
|
||||||
|
IN BOOLEAN DisableMmu
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the requested memory permission attributes on a region of memory.
|
||||||
|
|
||||||
|
BaseAddress and Length must be aligned to EFI_PAGE_SIZE.
|
||||||
|
|
||||||
|
If Attributes contains a memory type attribute (EFI_MEMORY_UC/WC/WT/WB), the
|
||||||
|
region is mapped according to this memory type, and additional memory
|
||||||
|
permission attributes (EFI_MEMORY_RP/RO/XP) are taken into account as well,
|
||||||
|
discarding any permission attributes that are currently set for the region.
|
||||||
|
AttributeMask is ignored in this case, and must be set to 0x0.
|
||||||
|
|
||||||
|
If Attributes contains only a combination of memory permission attributes
|
||||||
|
(EFI_MEMORY_RP/RO/XP), each page in the region will retain its existing
|
||||||
|
memory type, even if it is not uniformly set across the region. In this case,
|
||||||
|
AttributesMask may be set to a mask of permission attributes, and memory
|
||||||
|
permissions omitted from this mask will not be updated for any page in the
|
||||||
|
region. All attributes appearing in Attributes must appear in AttributeMask
|
||||||
|
as well. (Attributes & ~AttributeMask must produce 0x0)
|
||||||
|
|
||||||
|
@param[in] BaseAddress The physical address that is the start address of
|
||||||
|
a memory region.
|
||||||
|
@param[in] Length The size in bytes of the memory region.
|
||||||
|
@param[in] Attributes Mask of memory attributes to set.
|
||||||
|
@param[in] AttributeMask Mask of memory attributes to take into account.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were set for the memory region.
|
||||||
|
@retval EFI_INVALID_PARAMETER BaseAddress or Length is not suitably aligned.
|
||||||
|
Invalid combination of Attributes and
|
||||||
|
AttributeMask.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due to
|
||||||
|
lack of system resources.
|
||||||
|
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ArmSetMemoryAttributes (
|
ArmSetMemoryAttributes (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN UINT64 Attributes
|
IN UINT64 Attributes,
|
||||||
|
IN UINT64 AttributeMask
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif // ARM_MMU_LIB_H_
|
#endif // ARM_MMU_LIB_H_
|
||||||
|
42
ArmPkg/Include/Library/ArmMonitorLib.h
Normal file
42
ArmPkg/Include/Library/ArmMonitorLib.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/** @file
|
||||||
|
|
||||||
|
Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef ARM_MONITOR_LIB_H_
|
||||||
|
#define ARM_MONITOR_LIB_H_
|
||||||
|
|
||||||
|
/** The size of the SMC arguments is different between AArch64 and AArch32.
|
||||||
|
|
||||||
|
The native size is used for the arguments.
|
||||||
|
It will be casted to either HVC or SMC args.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
UINTN Arg0;
|
||||||
|
UINTN Arg1;
|
||||||
|
UINTN Arg2;
|
||||||
|
UINTN Arg3;
|
||||||
|
UINTN Arg4;
|
||||||
|
UINTN Arg5;
|
||||||
|
UINTN Arg6;
|
||||||
|
UINTN Arg7;
|
||||||
|
} ARM_MONITOR_ARGS;
|
||||||
|
|
||||||
|
/** Monitor call.
|
||||||
|
|
||||||
|
An HyperVisor Call (HVC) or System Monitor Call (SMC) will be issued
|
||||||
|
depending on the default conduit. PcdMonitorConduitHvc determines the type
|
||||||
|
of the call: if true, do an HVC.
|
||||||
|
|
||||||
|
@param [in,out] Args Arguments for the HVC/SMC.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
ArmMonitorCall (
|
||||||
|
IN OUT ARM_MONITOR_ARGS *Args
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // ARM_MONITOR_LIB_H_
|
@@ -1,5 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
|
* Copyright (c) 2022, Ampere Computing LLC. All rights reserved.
|
||||||
* Copyright (c) 2021, NUVIA Inc. All rights reserved.
|
* Copyright (c) 2021, NUVIA Inc. All rights reserved.
|
||||||
* Copyright (c) 2015, Hisilicon Limited. All rights reserved.
|
* Copyright (c) 2015, Hisilicon Limited. All rights reserved.
|
||||||
* Copyright (c) 2015, Linaro Limited. All rights reserved.
|
* Copyright (c) 2015, Linaro Limited. All rights reserved.
|
||||||
@@ -36,6 +37,7 @@ typedef struct {
|
|||||||
} OEM_MISC_PROCESSOR_DATA;
|
} OEM_MISC_PROCESSOR_DATA;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
BiosVersionType00,
|
||||||
ProductNameType01,
|
ProductNameType01,
|
||||||
SerialNumType01,
|
SerialNumType01,
|
||||||
UuidType01,
|
UuidType01,
|
||||||
@@ -43,7 +45,7 @@ typedef enum {
|
|||||||
VersionType01,
|
VersionType01,
|
||||||
SkuNumberType01,
|
SkuNumberType01,
|
||||||
FamilyType01,
|
FamilyType01,
|
||||||
AssertTagType02,
|
AssetTagType02,
|
||||||
SerialNumberType02,
|
SerialNumberType02,
|
||||||
BoardManufacturerType02,
|
BoardManufacturerType02,
|
||||||
ProductNameType02,
|
ProductNameType02,
|
||||||
@@ -58,6 +60,7 @@ typedef enum {
|
|||||||
SkuNumberType03,
|
SkuNumberType03,
|
||||||
ProcessorPartNumType04,
|
ProcessorPartNumType04,
|
||||||
ProcessorSerialNumType04,
|
ProcessorSerialNumType04,
|
||||||
|
ProcessorVersionType04,
|
||||||
SmbiosHiiStringFieldMax
|
SmbiosHiiStringFieldMax
|
||||||
} OEM_MISC_SMBIOS_HII_STRING_FIELD;
|
} OEM_MISC_SMBIOS_HII_STRING_FIELD;
|
||||||
|
|
||||||
@@ -233,4 +236,36 @@ OemGetChassisNumPowerCords (
|
|||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fetches the system UUID.
|
||||||
|
|
||||||
|
@param[out] SystemUuid The pointer to the buffer to store the System UUID.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
OemGetSystemUuid (
|
||||||
|
OUT GUID *SystemUuid
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Fetches the BIOS release.
|
||||||
|
|
||||||
|
@return The BIOS release.
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
OemGetBiosRelease (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Fetches the embedded controller firmware release.
|
||||||
|
|
||||||
|
@return The embedded controller firmware release.
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
OemGetEmbeddedControllerFirmwareRelease (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
#endif // OEM_MISC_LIB_H_
|
#endif // OEM_MISC_LIB_H_
|
||||||
|
@@ -94,7 +94,6 @@
|
|||||||
|
|
||||||
GCC_ASM_EXPORT(ExceptionHandlersEnd)
|
GCC_ASM_EXPORT(ExceptionHandlersEnd)
|
||||||
GCC_ASM_EXPORT(CommonCExceptionHandler)
|
GCC_ASM_EXPORT(CommonCExceptionHandler)
|
||||||
GCC_ASM_EXPORT(RegisterEl0Stack)
|
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
@@ -387,6 +386,6 @@ ASM_PFX(CommonExceptionEntry):
|
|||||||
|
|
||||||
eret
|
eret
|
||||||
|
|
||||||
ASM_PFX(RegisterEl0Stack):
|
ASM_FUNC(RegisterEl0Stack)
|
||||||
msr sp_el0, x0
|
msr sp_el0, x0
|
||||||
ret
|
ret
|
||||||
|
29
ArmPkg/Library/ArmHvcLibNull/ArmHvcLibNull.c
Normal file
29
ArmPkg/Library/ArmHvcLibNull/ArmHvcLibNull.c
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/** @file
|
||||||
|
Arm HyperVisor Call (HVC) Null Library.
|
||||||
|
|
||||||
|
Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <Library/ArmHvcLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Trigger an HVC call
|
||||||
|
|
||||||
|
HVC calls can take up to 8 arguments and return up to 4 return values.
|
||||||
|
Therefore, the 4 first fields in the ARM_HVC_ARGS structure are used
|
||||||
|
for both input and output values.
|
||||||
|
|
||||||
|
@param [in,out] Args Arguments for the HVC call.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
ArmCallHvc (
|
||||||
|
IN OUT ARM_HVC_ARGS *Args
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return;
|
||||||
|
}
|
22
ArmPkg/Library/ArmHvcLibNull/ArmHvcLibNull.inf
Normal file
22
ArmPkg/Library/ArmHvcLibNull/ArmHvcLibNull.inf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
## @file
|
||||||
|
# Arm Hvc Null Library
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 1.29
|
||||||
|
BASE_NAME = ArmHvcLibNull
|
||||||
|
FILE_GUID = 02076A46-D6DB-48DD-8E5F-153172DD73A1
|
||||||
|
MODULE_TYPE = BASE
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
LIBRARY_CLASS = ArmHvcLib
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
ArmHvcLibNull.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
ArmPkg/ArmPkg.dec
|
||||||
|
MdePkg/MdePkg.dec
|
@@ -40,7 +40,43 @@ ArmCleanInvalidateDataCacheEntryBySetWay (
|
|||||||
|
|
||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmReadIdAA64Pfr0 (
|
ArmReadIdAA64Dfr0 (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ArmReadIdAA64Dfr1 (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ArmReadIdAA64Isar0 (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ArmReadIdAA64Isar1 (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ArmReadIdAA64Isar2 (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ArmReadIdAA64Mmfr0 (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ArmReadIdAA64Mmfr1 (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -54,4 +90,16 @@ ArmReadIdAA64Mmfr2 (
|
|||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ArmReadIdAA64Pfr0 (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ArmReadIdAA64Pfr1 (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
#endif // AARCH64_LIB_H_
|
#endif // AARCH64_LIB_H_
|
||||||
|
@@ -425,10 +425,6 @@ ASM_FUNC(ArmCallWFI)
|
|||||||
wfi
|
wfi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
ASM_FUNC(ArmReadIdAA64Mmfr2)
|
|
||||||
mrs x0, ID_AA64MMFR2_EL1 // read EL1 MMFR2
|
|
||||||
ret
|
|
||||||
|
|
||||||
ASM_FUNC(ArmReadMpidr)
|
ASM_FUNC(ArmReadMpidr)
|
||||||
mrs x0, mpidr_el1 // read EL1 MPIDR
|
mrs x0, mpidr_el1 // read EL1 MPIDR
|
||||||
ret
|
ret
|
||||||
@@ -452,10 +448,6 @@ ASM_FUNC(ArmIsArchTimerImplemented)
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
ASM_FUNC(ArmReadIdAA64Pfr0)
|
|
||||||
mrs x0, id_aa64pfr0_el1 // Read ID_AA64PFR0 Register
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
// VOID ArmWriteHcr(UINTN Hcr)
|
// VOID ArmWriteHcr(UINTN Hcr)
|
||||||
ASM_FUNC(ArmWriteHcr)
|
ASM_FUNC(ArmWriteHcr)
|
||||||
@@ -482,4 +474,54 @@ ASM_FUNC(ArmWriteCntHctl)
|
|||||||
msr cnthctl_el2, x0
|
msr cnthctl_el2, x0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Dfr0)
|
||||||
|
mrs x0, ID_AA64DFR0_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Dfr1)
|
||||||
|
mrs x0, ID_AA64DFR1_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Isar0)
|
||||||
|
mrs x0, ID_AA64ISAR0_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Isar1)
|
||||||
|
mrs x0, ID_AA64ISAR1_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Isar2)
|
||||||
|
mrs x0, ID_AA64ISAR2_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Mmfr0)
|
||||||
|
mrs x0, ID_AA64MMFR0_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Mmfr1)
|
||||||
|
mrs x0, ID_AA64MMFR1_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Mmfr2)
|
||||||
|
mrs x0, ID_AA64MMFR2_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Pfr0)
|
||||||
|
mrs x0, ID_AA64PFR0_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
ASM_FUNC(ArmReadIdAA64Pfr1)
|
||||||
|
mrs x0, ID_AA64PFR1_EL1
|
||||||
|
ret
|
||||||
|
|
||||||
ASM_FUNCTION_REMOVE_IF_UNREFERENCED
|
ASM_FUNCTION_REMOVE_IF_UNREFERENCED
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
.set CTRL_C_BIT, (1 << 2)
|
.set CTRL_C_BIT, (1 << 2)
|
||||||
.set CTRL_B_BIT, (1 << 7)
|
.set CTRL_B_BIT, (1 << 7)
|
||||||
.set CTRL_I_BIT, (1 << 12)
|
.set CTRL_I_BIT, (1 << 12)
|
||||||
|
.set CTRL_AFE_BIT,(1 << 29)
|
||||||
|
|
||||||
|
|
||||||
ASM_FUNC(ArmInvalidateDataCacheEntryByMVA)
|
ASM_FUNC(ArmInvalidateDataCacheEntryByMVA)
|
||||||
@@ -64,6 +65,7 @@ ASM_FUNC(ArmInvalidateInstructionCache)
|
|||||||
ASM_FUNC(ArmEnableMmu)
|
ASM_FUNC(ArmEnableMmu)
|
||||||
mrc p15,0,R0,c1,c0,0
|
mrc p15,0,R0,c1,c0,0
|
||||||
orr R0,R0,#1
|
orr R0,R0,#1
|
||||||
|
orr R0,R0,#CTRL_AFE_BIT
|
||||||
mcr p15,0,R0,c1,c0,0
|
mcr p15,0,R0,c1,c0,0
|
||||||
dsb
|
dsb
|
||||||
isb
|
isb
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
|
#include <Pi/PiMultiPhase.h>
|
||||||
#include <Chipset/AArch64.h>
|
#include <Chipset/AArch64.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/CacheMaintenanceLib.h>
|
#include <Library/CacheMaintenanceLib.h>
|
||||||
@@ -18,6 +19,17 @@
|
|||||||
#include <Library/ArmMmuLib.h>
|
#include <Library/ArmMmuLib.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
VOID (
|
||||||
|
EFIAPI *mReplaceLiveEntryFunc
|
||||||
|
)(
|
||||||
|
IN UINT64 *Entry,
|
||||||
|
IN UINT64 Value,
|
||||||
|
IN UINT64 RegionStart,
|
||||||
|
IN BOOLEAN DisableMmu
|
||||||
|
) = ArmReplaceLiveTranslationEntry;
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
UINT64
|
UINT64
|
||||||
@@ -25,33 +37,47 @@ ArmMemoryAttributeToPageAttribute (
|
|||||||
IN ARM_MEMORY_REGION_ATTRIBUTES Attributes
|
IN ARM_MEMORY_REGION_ATTRIBUTES Attributes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UINT64 Permissions;
|
||||||
|
|
||||||
|
switch (Attributes) {
|
||||||
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO:
|
||||||
|
Permissions = TT_AP_NO_RO;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_XP:
|
||||||
|
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
||||||
|
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
||||||
|
Permissions = TT_XN_MASK;
|
||||||
|
} else {
|
||||||
|
Permissions = TT_UXN_MASK | TT_PXN_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Permissions = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (Attributes) {
|
switch (Attributes) {
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:
|
|
||||||
return TT_ATTR_INDX_MEMORY_WRITE_BACK;
|
return TT_ATTR_INDX_MEMORY_WRITE_BACK;
|
||||||
|
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO:
|
||||||
return TT_ATTR_INDX_MEMORY_WRITE_BACK | TT_SH_INNER_SHAREABLE;
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_XP:
|
||||||
|
return TT_ATTR_INDX_MEMORY_WRITE_BACK | TT_SH_INNER_SHAREABLE | Permissions;
|
||||||
|
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:
|
|
||||||
return TT_ATTR_INDX_MEMORY_WRITE_THROUGH | TT_SH_INNER_SHAREABLE;
|
return TT_ATTR_INDX_MEMORY_WRITE_THROUGH | TT_SH_INNER_SHAREABLE;
|
||||||
|
|
||||||
// Uncached and device mappings are treated as outer shareable by default,
|
// Uncached and device mappings are treated as outer shareable by default,
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:
|
|
||||||
return TT_ATTR_INDX_MEMORY_NON_CACHEABLE;
|
return TT_ATTR_INDX_MEMORY_NON_CACHEABLE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ASSERT (0);
|
ASSERT (0);
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:
|
return TT_ATTR_INDX_DEVICE_MEMORY | Permissions;
|
||||||
if (ArmReadCurrentEL () == AARCH64_EL2) {
|
|
||||||
return TT_ATTR_INDX_DEVICE_MEMORY | TT_XN_MASK;
|
|
||||||
} else {
|
|
||||||
return TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,14 +109,40 @@ ReplaceTableEntry (
|
|||||||
IN UINT64 *Entry,
|
IN UINT64 *Entry,
|
||||||
IN UINT64 Value,
|
IN UINT64 Value,
|
||||||
IN UINT64 RegionStart,
|
IN UINT64 RegionStart,
|
||||||
|
IN UINT64 BlockMask,
|
||||||
IN BOOLEAN IsLiveBlockMapping
|
IN BOOLEAN IsLiveBlockMapping
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!ArmMmuEnabled () || !IsLiveBlockMapping) {
|
BOOLEAN DisableMmu;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Replacing a live block entry with a table entry (or vice versa) requires a
|
||||||
|
// break-before-make sequence as per the architecture. This means the mapping
|
||||||
|
// must be made invalid and cleaned from the TLBs first, and this is a bit of
|
||||||
|
// a hassle if the mapping in question covers the code that is actually doing
|
||||||
|
// the mapping and the unmapping, and so we only bother with this if actually
|
||||||
|
// necessary.
|
||||||
|
//
|
||||||
|
|
||||||
|
if (!IsLiveBlockMapping || !ArmMmuEnabled ()) {
|
||||||
|
// If the mapping is not a live block mapping, or the MMU is not on yet, we
|
||||||
|
// can simply overwrite the entry.
|
||||||
*Entry = Value;
|
*Entry = Value;
|
||||||
ArmUpdateTranslationTableEntry (Entry, (VOID *)(UINTN)RegionStart);
|
ArmUpdateTranslationTableEntry (Entry, (VOID *)(UINTN)RegionStart);
|
||||||
} else {
|
} else {
|
||||||
ArmReplaceLiveTranslationEntry (Entry, Value, RegionStart);
|
// If the mapping in question does not cover the code that updates the
|
||||||
|
// entry in memory, or the entry that we are intending to update, we can
|
||||||
|
// use an ordinary break before make. Otherwise, we will need to
|
||||||
|
// temporarily disable the MMU.
|
||||||
|
DisableMmu = FALSE;
|
||||||
|
if ((((RegionStart ^ (UINTN)mReplaceLiveEntryFunc) & ~BlockMask) == 0) ||
|
||||||
|
(((RegionStart ^ (UINTN)Entry) & ~BlockMask) == 0))
|
||||||
|
{
|
||||||
|
DisableMmu = TRUE;
|
||||||
|
DEBUG ((DEBUG_WARN, "%a: splitting block entry with MMU disabled\n", __func__));
|
||||||
|
}
|
||||||
|
|
||||||
|
mReplaceLiveEntryFunc (Entry, Value, RegionStart, DisableMmu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +212,8 @@ UpdateRegionMappingRecursive (
|
|||||||
IN UINT64 AttributeSetMask,
|
IN UINT64 AttributeSetMask,
|
||||||
IN UINT64 AttributeClearMask,
|
IN UINT64 AttributeClearMask,
|
||||||
IN UINT64 *PageTable,
|
IN UINT64 *PageTable,
|
||||||
IN UINTN Level
|
IN UINTN Level,
|
||||||
|
IN BOOLEAN TableIsLive
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN BlockShift;
|
UINTN BlockShift;
|
||||||
@@ -170,6 +223,7 @@ UpdateRegionMappingRecursive (
|
|||||||
UINT64 EntryValue;
|
UINT64 EntryValue;
|
||||||
VOID *TranslationTable;
|
VOID *TranslationTable;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
BOOLEAN NextTableIsLive;
|
||||||
|
|
||||||
ASSERT (((RegionStart | RegionEnd) & EFI_PAGE_MASK) == 0);
|
ASSERT (((RegionStart | RegionEnd) & EFI_PAGE_MASK) == 0);
|
||||||
|
|
||||||
@@ -179,7 +233,7 @@ UpdateRegionMappingRecursive (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_VERBOSE,
|
DEBUG_VERBOSE,
|
||||||
"%a(%d): %llx - %llx set %lx clr %lx\n",
|
"%a(%d): %llx - %llx set %lx clr %lx\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
Level,
|
Level,
|
||||||
RegionStart,
|
RegionStart,
|
||||||
RegionEnd,
|
RegionEnd,
|
||||||
@@ -197,16 +251,30 @@ UpdateRegionMappingRecursive (
|
|||||||
// than a block, and recurse to create the block or page entries at
|
// than a block, and recurse to create the block or page entries at
|
||||||
// the next level. No block mappings are allowed at all at level 0,
|
// the next level. No block mappings are allowed at all at level 0,
|
||||||
// so in that case, we have to recurse unconditionally.
|
// so in that case, we have to recurse unconditionally.
|
||||||
// If we are changing a table entry and the AttributeClearMask is non-zero,
|
//
|
||||||
// we cannot replace it with a block entry without potentially losing
|
// One special case to take into account is any region that covers the page
|
||||||
// attribute information, so keep the table entry in that case.
|
// table itself: if we'd cover such a region with block mappings, we are
|
||||||
|
// more likely to end up in the situation later where we need to disable
|
||||||
|
// the MMU in order to update page table entries safely, so prefer page
|
||||||
|
// mappings in that particular case.
|
||||||
//
|
//
|
||||||
if ((Level == 0) || (((RegionStart | BlockEnd) & BlockMask) != 0) ||
|
if ((Level == 0) || (((RegionStart | BlockEnd) & BlockMask) != 0) ||
|
||||||
(IsTableEntry (*Entry, Level) && (AttributeClearMask != 0)))
|
((Level < 3) && (((UINT64)PageTable & ~BlockMask) == RegionStart)) ||
|
||||||
|
IsTableEntry (*Entry, Level))
|
||||||
{
|
{
|
||||||
ASSERT (Level < 3);
|
ASSERT (Level < 3);
|
||||||
|
|
||||||
if (!IsTableEntry (*Entry, Level)) {
|
if (!IsTableEntry (*Entry, Level)) {
|
||||||
|
//
|
||||||
|
// If the region we are trying to map is already covered by a block
|
||||||
|
// entry with the right attributes, don't bother splitting it up.
|
||||||
|
//
|
||||||
|
if (IsBlockEntry (*Entry, Level) &&
|
||||||
|
((*Entry & TT_ATTRIBUTES_MASK & ~AttributeClearMask) == AttributeSetMask))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// No table entry exists yet, so we need to allocate a page table
|
// No table entry exists yet, so we need to allocate a page table
|
||||||
// for the next level.
|
// for the next level.
|
||||||
@@ -237,7 +305,8 @@ UpdateRegionMappingRecursive (
|
|||||||
*Entry & TT_ATTRIBUTES_MASK,
|
*Entry & TT_ATTRIBUTES_MASK,
|
||||||
0,
|
0,
|
||||||
TranslationTable,
|
TranslationTable,
|
||||||
Level + 1
|
Level + 1,
|
||||||
|
FALSE
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
@@ -249,8 +318,11 @@ UpdateRegionMappingRecursive (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NextTableIsLive = FALSE;
|
||||||
} else {
|
} else {
|
||||||
TranslationTable = (VOID *)(UINTN)(*Entry & TT_ADDRESS_MASK_BLOCK_ENTRY);
|
TranslationTable = (VOID *)(UINTN)(*Entry & TT_ADDRESS_MASK_BLOCK_ENTRY);
|
||||||
|
NextTableIsLive = TableIsLive;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -262,7 +334,8 @@ UpdateRegionMappingRecursive (
|
|||||||
AttributeSetMask,
|
AttributeSetMask,
|
||||||
AttributeClearMask,
|
AttributeClearMask,
|
||||||
TranslationTable,
|
TranslationTable,
|
||||||
Level + 1
|
Level + 1,
|
||||||
|
NextTableIsLive
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
if (!IsTableEntry (*Entry, Level)) {
|
if (!IsTableEntry (*Entry, Level)) {
|
||||||
@@ -285,7 +358,8 @@ UpdateRegionMappingRecursive (
|
|||||||
Entry,
|
Entry,
|
||||||
EntryValue,
|
EntryValue,
|
||||||
RegionStart,
|
RegionStart,
|
||||||
IsBlockEntry (*Entry, Level)
|
BlockMask,
|
||||||
|
TableIsLive && IsBlockEntry (*Entry, Level)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -294,20 +368,7 @@ UpdateRegionMappingRecursive (
|
|||||||
EntryValue |= (Level == 3) ? TT_TYPE_BLOCK_ENTRY_LEVEL3
|
EntryValue |= (Level == 3) ? TT_TYPE_BLOCK_ENTRY_LEVEL3
|
||||||
: TT_TYPE_BLOCK_ENTRY;
|
: TT_TYPE_BLOCK_ENTRY;
|
||||||
|
|
||||||
if (IsTableEntry (*Entry, Level)) {
|
ReplaceTableEntry (Entry, EntryValue, RegionStart, BlockMask, FALSE);
|
||||||
//
|
|
||||||
// We are replacing a table entry with a block entry. This is only
|
|
||||||
// possible if we are keeping none of the original attributes.
|
|
||||||
// We can free the table entry's page table, and all the ones below
|
|
||||||
// it, since we are dropping the only possible reference to it.
|
|
||||||
//
|
|
||||||
ASSERT (AttributeClearMask == 0);
|
|
||||||
TranslationTable = (VOID *)(UINTN)(*Entry & TT_ADDRESS_MASK_BLOCK_ENTRY);
|
|
||||||
ReplaceTableEntry (Entry, EntryValue, RegionStart, TRUE);
|
|
||||||
FreePageTablesRecursive (TranslationTable, Level + 1);
|
|
||||||
} else {
|
|
||||||
ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +381,9 @@ UpdateRegionMapping (
|
|||||||
IN UINT64 RegionStart,
|
IN UINT64 RegionStart,
|
||||||
IN UINT64 RegionLength,
|
IN UINT64 RegionLength,
|
||||||
IN UINT64 AttributeSetMask,
|
IN UINT64 AttributeSetMask,
|
||||||
IN UINT64 AttributeClearMask
|
IN UINT64 AttributeClearMask,
|
||||||
|
IN UINT64 *RootTable,
|
||||||
|
IN BOOLEAN TableIsLive
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN T0SZ;
|
UINTN T0SZ;
|
||||||
@@ -336,8 +399,9 @@ UpdateRegionMapping (
|
|||||||
RegionStart + RegionLength,
|
RegionStart + RegionLength,
|
||||||
AttributeSetMask,
|
AttributeSetMask,
|
||||||
AttributeClearMask,
|
AttributeClearMask,
|
||||||
ArmGetTTBR0BaseAddress (),
|
RootTable,
|
||||||
GetRootTableLevel (T0SZ)
|
GetRootTableLevel (T0SZ),
|
||||||
|
TableIsLive
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +416,9 @@ FillTranslationTable (
|
|||||||
MemoryRegion->VirtualBase,
|
MemoryRegion->VirtualBase,
|
||||||
MemoryRegion->Length,
|
MemoryRegion->Length,
|
||||||
ArmMemoryAttributeToPageAttribute (MemoryRegion->Attributes) | TT_AF,
|
ArmMemoryAttributeToPageAttribute (MemoryRegion->Attributes) | TT_AF,
|
||||||
0
|
0,
|
||||||
|
RootTable,
|
||||||
|
FALSE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,14 +462,52 @@ GcdAttributeToPageAttribute (
|
|||||||
PageAttributes |= TT_AP_NO_RO;
|
PageAttributes |= TT_AP_NO_RO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PageAttributes | TT_AF;
|
if ((GcdAttributes & EFI_MEMORY_RP) == 0) {
|
||||||
|
PageAttributes |= TT_AF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return PageAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the requested memory permission attributes on a region of memory.
|
||||||
|
|
||||||
|
BaseAddress and Length must be aligned to EFI_PAGE_SIZE.
|
||||||
|
|
||||||
|
If Attributes contains a memory type attribute (EFI_MEMORY_UC/WC/WT/WB), the
|
||||||
|
region is mapped according to this memory type, and additional memory
|
||||||
|
permission attributes (EFI_MEMORY_RP/RO/XP) are taken into account as well,
|
||||||
|
discarding any permission attributes that are currently set for the region.
|
||||||
|
AttributeMask is ignored in this case, and must be set to 0x0.
|
||||||
|
|
||||||
|
If Attributes contains only a combination of memory permission attributes
|
||||||
|
(EFI_MEMORY_RP/RO/XP), each page in the region will retain its existing
|
||||||
|
memory type, even if it is not uniformly set across the region. In this case,
|
||||||
|
AttributesMask may be set to a mask of permission attributes, and memory
|
||||||
|
permissions omitted from this mask will not be updated for any page in the
|
||||||
|
region. All attributes appearing in Attributes must appear in AttributeMask
|
||||||
|
as well. (Attributes & ~AttributeMask must produce 0x0)
|
||||||
|
|
||||||
|
@param[in] BaseAddress The physical address that is the start address of
|
||||||
|
a memory region.
|
||||||
|
@param[in] Length The size in bytes of the memory region.
|
||||||
|
@param[in] Attributes Mask of memory attributes to set.
|
||||||
|
@param[in] AttributeMask Mask of memory attributes to take into account.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were set for the memory region.
|
||||||
|
@retval EFI_INVALID_PARAMETER BaseAddress or Length is not suitably aligned.
|
||||||
|
Invalid combination of Attributes and
|
||||||
|
AttributeMask.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due to
|
||||||
|
lack of system resources.
|
||||||
|
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ArmSetMemoryAttributes (
|
ArmSetMemoryAttributes (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN UINT64 Attributes
|
IN UINT64 Attributes,
|
||||||
|
IN UINT64 AttributeMask
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 PageAttributes;
|
UINT64 PageAttributes;
|
||||||
@@ -417,97 +521,34 @@ ArmSetMemoryAttributes (
|
|||||||
// No memory type was set in Attributes, so we are going to update the
|
// No memory type was set in Attributes, so we are going to update the
|
||||||
// permissions only.
|
// permissions only.
|
||||||
//
|
//
|
||||||
PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK;
|
PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK | TT_AF;
|
||||||
PageAttributeMask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK |
|
PageAttributeMask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK |
|
||||||
TT_PXN_MASK | TT_XN_MASK);
|
TT_PXN_MASK | TT_XN_MASK | TT_AF);
|
||||||
|
if (AttributeMask != 0) {
|
||||||
|
if (((AttributeMask & ~(UINT64)(EFI_MEMORY_RP|EFI_MEMORY_RO|EFI_MEMORY_XP)) != 0) ||
|
||||||
|
((Attributes & ~AttributeMask) != 0))
|
||||||
|
{
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add attributes omitted from AttributeMask to the set of attributes to preserve
|
||||||
|
PageAttributeMask |= GcdAttributeToPageAttribute (~AttributeMask) &
|
||||||
|
(TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK | TT_AF);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ASSERT (AttributeMask == 0);
|
||||||
|
if (AttributeMask != 0) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return UpdateRegionMapping (
|
return UpdateRegionMapping (
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
Length,
|
Length,
|
||||||
PageAttributes,
|
PageAttributes,
|
||||||
PageAttributeMask
|
PageAttributeMask,
|
||||||
);
|
ArmGetTTBR0BaseAddress (),
|
||||||
}
|
TRUE
|
||||||
|
|
||||||
STATIC
|
|
||||||
EFI_STATUS
|
|
||||||
SetMemoryRegionAttribute (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length,
|
|
||||||
IN UINT64 Attributes,
|
|
||||||
IN UINT64 BlockEntryMask
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return UpdateRegionMapping (BaseAddress, Length, Attributes, BlockEntryMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
ArmSetMemoryRegionNoExec (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length
|
|
||||||
)
|
|
||||||
{
|
|
||||||
UINT64 Val;
|
|
||||||
|
|
||||||
if (ArmReadCurrentEL () == AARCH64_EL1) {
|
|
||||||
Val = TT_PXN_MASK | TT_UXN_MASK;
|
|
||||||
} else {
|
|
||||||
Val = TT_XN_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SetMemoryRegionAttribute (
|
|
||||||
BaseAddress,
|
|
||||||
Length,
|
|
||||||
Val,
|
|
||||||
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
ArmClearMemoryRegionNoExec (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length
|
|
||||||
)
|
|
||||||
{
|
|
||||||
UINT64 Mask;
|
|
||||||
|
|
||||||
// XN maps to UXN in the EL1&0 translation regime
|
|
||||||
Mask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_PXN_MASK | TT_XN_MASK);
|
|
||||||
|
|
||||||
return SetMemoryRegionAttribute (
|
|
||||||
BaseAddress,
|
|
||||||
Length,
|
|
||||||
0,
|
|
||||||
Mask
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
ArmSetMemoryRegionReadOnly (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return SetMemoryRegionAttribute (
|
|
||||||
BaseAddress,
|
|
||||||
Length,
|
|
||||||
TT_AP_NO_RO,
|
|
||||||
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
ArmClearMemoryRegionReadOnly (
|
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
|
||||||
IN UINT64 Length
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return SetMemoryRegionAttribute (
|
|
||||||
BaseAddress,
|
|
||||||
Length,
|
|
||||||
TT_AP_NO_RW,
|
|
||||||
~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,7 +654,7 @@ ArmConfigureMmu (
|
|||||||
// loss of coherency when using mismatched attributes, and given that memory
|
// loss of coherency when using mismatched attributes, and given that memory
|
||||||
// is mapped cacheable except for extraordinary cases (such as non-coherent
|
// is mapped cacheable except for extraordinary cases (such as non-coherent
|
||||||
// DMA), have the page table walker perform cached accesses as well, and
|
// DMA), have the page table walker perform cached accesses as well, and
|
||||||
// assert below that that matches the attributes we use for CPU accesses to
|
// assert below that matches the attributes we use for CPU accesses to
|
||||||
// the region.
|
// the region.
|
||||||
//
|
//
|
||||||
TCR |= TCR_SH_INNER_SHAREABLE |
|
TCR |= TCR_SH_INNER_SHAREABLE |
|
||||||
@@ -629,14 +670,6 @@ ArmConfigureMmu (
|
|||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// We set TTBR0 just after allocating the table to retrieve its location from
|
|
||||||
// the subsequent functions without needing to pass this value across the
|
|
||||||
// functions. The MMU is only enabled after the translation tables are
|
|
||||||
// populated.
|
|
||||||
//
|
|
||||||
ArmSetTTBR0 (TranslationTable);
|
|
||||||
|
|
||||||
if (TranslationTableBase != NULL) {
|
if (TranslationTableBase != NULL) {
|
||||||
*TranslationTableBase = TranslationTable;
|
*TranslationTableBase = TranslationTable;
|
||||||
}
|
}
|
||||||
@@ -645,6 +678,7 @@ ArmConfigureMmu (
|
|||||||
*TranslationTableSize = RootTableEntryCount * sizeof (UINT64);
|
*TranslationTableSize = RootTableEntryCount * sizeof (UINT64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ArmMmuEnabled ()) {
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
@@ -653,6 +687,8 @@ ArmConfigureMmu (
|
|||||||
TranslationTable,
|
TranslationTable,
|
||||||
RootTableEntryCount * sizeof (UINT64)
|
RootTableEntryCount * sizeof (UINT64)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
ZeroMem (TranslationTable, RootTableEntryCount * sizeof (UINT64));
|
ZeroMem (TranslationTable, RootTableEntryCount * sizeof (UINT64));
|
||||||
|
|
||||||
while (MemoryTable->Length != 0) {
|
while (MemoryTable->Length != 0) {
|
||||||
@@ -677,12 +713,17 @@ ArmConfigureMmu (
|
|||||||
MAIR_ATTR (TT_ATTR_INDX_MEMORY_WRITE_BACK, MAIR_ATTR_NORMAL_MEMORY_WRITE_BACK)
|
MAIR_ATTR (TT_ATTR_INDX_MEMORY_WRITE_BACK, MAIR_ATTR_NORMAL_MEMORY_WRITE_BACK)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ArmSetTTBR0 (TranslationTable);
|
||||||
|
|
||||||
|
if (!ArmMmuEnabled ()) {
|
||||||
ArmDisableAlignmentCheck ();
|
ArmDisableAlignmentCheck ();
|
||||||
ArmEnableStackAlignmentCheck ();
|
ArmEnableStackAlignmentCheck ();
|
||||||
ArmEnableInstructionCache ();
|
ArmEnableInstructionCache ();
|
||||||
ArmEnableDataCache ();
|
ArmEnableDataCache ();
|
||||||
|
|
||||||
ArmEnableMmu ();
|
ArmEnableMmu ();
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
FreeTranslationTable:
|
FreeTranslationTable:
|
||||||
@@ -697,7 +738,12 @@ ArmMmuBaseLibConstructor (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
extern UINT32 ArmReplaceLiveTranslationEntrySize;
|
extern UINT32 ArmReplaceLiveTranslationEntrySize;
|
||||||
|
VOID *Hob;
|
||||||
|
|
||||||
|
Hob = GetFirstGuidHob (&gArmMmuReplaceLiveTranslationEntryFuncGuid);
|
||||||
|
if (Hob != NULL) {
|
||||||
|
mReplaceLiveEntryFunc = *(VOID **)GET_GUID_HOB_DATA (Hob);
|
||||||
|
} else {
|
||||||
//
|
//
|
||||||
// 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
|
||||||
@@ -706,6 +752,7 @@ ArmMmuBaseLibConstructor (
|
|||||||
(VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
(VOID *)(UINTN)ArmReplaceLiveTranslationEntry,
|
||||||
ArmReplaceLiveTranslationEntrySize
|
ArmReplaceLiveTranslationEntrySize
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,14 @@
|
|||||||
|
|
||||||
.macro __replace_entry, el
|
.macro __replace_entry, el
|
||||||
|
|
||||||
|
// check whether we should disable the MMU
|
||||||
|
cbz x3, .L1_\@
|
||||||
|
|
||||||
|
// clean and invalidate first so that we don't clobber
|
||||||
|
// adjacent entries that are dirty in the caches
|
||||||
|
dc civac, x0
|
||||||
|
dsb nsh
|
||||||
|
|
||||||
// disable the MMU
|
// disable the MMU
|
||||||
mrs x8, sctlr_el\el
|
mrs x8, sctlr_el\el
|
||||||
bic x9, x8, #CTRL_M_BIT
|
bic x9, x8, #CTRL_M_BIT
|
||||||
@@ -38,6 +46,28 @@
|
|||||||
// re-enable the MMU
|
// re-enable the MMU
|
||||||
msr sctlr_el\el, x8
|
msr sctlr_el\el, x8
|
||||||
isb
|
isb
|
||||||
|
b .L2_\@
|
||||||
|
|
||||||
|
.L1_\@:
|
||||||
|
// write invalid entry
|
||||||
|
str xzr, [x0]
|
||||||
|
dsb nshst
|
||||||
|
|
||||||
|
// flush translations for the target address from the TLBs
|
||||||
|
lsr x2, x2, #12
|
||||||
|
.if \el == 1
|
||||||
|
tlbi vaae1, x2
|
||||||
|
.else
|
||||||
|
tlbi vae\el, x2
|
||||||
|
.endif
|
||||||
|
dsb nsh
|
||||||
|
|
||||||
|
// write updated entry
|
||||||
|
str x1, [x0]
|
||||||
|
dsb nshst
|
||||||
|
isb
|
||||||
|
|
||||||
|
.L2_\@:
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
//VOID
|
//VOID
|
||||||
@@ -46,19 +76,17 @@
|
|||||||
// IN UINT64 Value,
|
// IN UINT64 Value,
|
||||||
// IN UINT64 Address
|
// IN UINT64 Address
|
||||||
// )
|
// )
|
||||||
ASM_FUNC(ArmReplaceLiveTranslationEntry)
|
//
|
||||||
|
// Align this routine to a log2 upper bound of its size, so that it is
|
||||||
|
// guaranteed not to cross a page or block boundary.
|
||||||
|
ASM_FUNC_ALIGN(ArmReplaceLiveTranslationEntry, 0x200)
|
||||||
|
|
||||||
// disable interrupts
|
// disable interrupts
|
||||||
mrs x4, daif
|
mrs x4, daif
|
||||||
msr daifset, #0xf
|
msr daifset, #0xf
|
||||||
isb
|
isb
|
||||||
|
|
||||||
// clean and invalidate first so that we don't clobber
|
EL1_OR_EL2_OR_EL3(x5)
|
||||||
// adjacent entries that are dirty in the caches
|
|
||||||
dc civac, x0
|
|
||||||
dsb nsh
|
|
||||||
|
|
||||||
EL1_OR_EL2_OR_EL3(x3)
|
|
||||||
1:__replace_entry 1
|
1:__replace_entry 1
|
||||||
b 4f
|
b 4f
|
||||||
2:__replace_entry 2
|
2:__replace_entry 2
|
||||||
@@ -72,3 +100,9 @@ ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize)
|
|||||||
|
|
||||||
ASM_PFX(ArmReplaceLiveTranslationEntrySize):
|
ASM_PFX(ArmReplaceLiveTranslationEntrySize):
|
||||||
.long . - ArmReplaceLiveTranslationEntry
|
.long . - ArmReplaceLiveTranslationEntry
|
||||||
|
|
||||||
|
// Double check that we did not overrun the assumed maximum size or cross a
|
||||||
|
// 0x200 boundary (and thus implicitly not any larger power of two, including
|
||||||
|
// the page size).
|
||||||
|
.balign 0x200
|
||||||
|
.org ArmReplaceLiveTranslationEntry + 0x200
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include <Library/ArmMmuLib.h>
|
#include <Library/ArmMmuLib.h>
|
||||||
#include <Library/CacheMaintenanceLib.h>
|
#include <Library/CacheMaintenanceLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@@ -21,6 +22,8 @@ ArmMmuPeiLibConstructor (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
extern UINT32 ArmReplaceLiveTranslationEntrySize;
|
extern UINT32 ArmReplaceLiveTranslationEntrySize;
|
||||||
|
VOID *ArmReplaceLiveTranslationEntryFunc;
|
||||||
|
VOID *Hob;
|
||||||
|
|
||||||
EFI_FV_FILE_INFO FileInfo;
|
EFI_FV_FILE_INFO FileInfo;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@@ -42,6 +45,20 @@ ArmMmuPeiLibConstructor (
|
|||||||
(UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize))
|
(UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize))
|
||||||
{
|
{
|
||||||
DEBUG ((DEBUG_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));
|
DEBUG ((DEBUG_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Expose the XIP version of the ArmReplaceLiveTranslationEntry() routine
|
||||||
|
// via a HOB so we can fall back to it later when we need to split block
|
||||||
|
// mappings in a way that adheres to break-before-make requirements.
|
||||||
|
//
|
||||||
|
ArmReplaceLiveTranslationEntryFunc = ArmReplaceLiveTranslationEntry;
|
||||||
|
|
||||||
|
Hob = BuildGuidDataHob (
|
||||||
|
&gArmMmuReplaceLiveTranslationEntryFuncGuid,
|
||||||
|
&ArmReplaceLiveTranslationEntryFunc,
|
||||||
|
sizeof ArmReplaceLiveTranslationEntryFunc
|
||||||
|
);
|
||||||
|
ASSERT (Hob != NULL);
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));
|
DEBUG ((DEBUG_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));
|
||||||
//
|
//
|
||||||
|
@@ -15,16 +15,16 @@
|
|||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
ConvertSectionAttributesToPageAttributes (
|
ConvertSectionAttributesToPageAttributes (
|
||||||
IN UINT32 SectionAttributes,
|
IN UINT32 SectionAttributes
|
||||||
IN BOOLEAN IsLargePage
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 PageAttributes;
|
UINT32 PageAttributes;
|
||||||
|
|
||||||
PageAttributes = 0;
|
PageAttributes = 0;
|
||||||
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY (SectionAttributes, IsLargePage);
|
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY (SectionAttributes);
|
||||||
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AP (SectionAttributes);
|
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AP (SectionAttributes);
|
||||||
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_XN (SectionAttributes, IsLargePage);
|
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AF (SectionAttributes);
|
||||||
|
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_XN (SectionAttributes);
|
||||||
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_NG (SectionAttributes);
|
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_NG (SectionAttributes);
|
||||||
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_S (SectionAttributes);
|
PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_S (SectionAttributes);
|
||||||
|
|
||||||
|
@@ -100,24 +100,27 @@ PopulateLevel2PageTable (
|
|||||||
|
|
||||||
switch (Attributes) {
|
switch (Attributes) {
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:
|
|
||||||
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;
|
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;
|
||||||
break;
|
break;
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:
|
|
||||||
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;
|
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;
|
||||||
PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;
|
PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;
|
||||||
break;
|
break;
|
||||||
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO:
|
||||||
|
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;
|
||||||
|
PageAttributes |= TT_DESCRIPTOR_PAGE_AP_NO_RO;
|
||||||
|
break;
|
||||||
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_XP:
|
||||||
|
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;
|
||||||
|
PageAttributes |= TT_DESCRIPTOR_PAGE_XN_MASK;
|
||||||
|
break;
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:
|
|
||||||
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_THROUGH;
|
PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_THROUGH;
|
||||||
break;
|
break;
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:
|
|
||||||
PageAttributes = TT_DESCRIPTOR_PAGE_DEVICE;
|
PageAttributes = TT_DESCRIPTOR_PAGE_DEVICE;
|
||||||
break;
|
break;
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:
|
|
||||||
PageAttributes = TT_DESCRIPTOR_PAGE_UNCACHED;
|
PageAttributes = TT_DESCRIPTOR_PAGE_UNCACHED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -145,7 +148,7 @@ PopulateLevel2PageTable (
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
BaseSectionAddress = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (*SectionEntry);
|
BaseSectionAddress = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (*SectionEntry);
|
||||||
|
|
||||||
@@ -239,39 +242,31 @@ FillTranslationTable (
|
|||||||
|
|
||||||
switch (MemoryRegion->Attributes) {
|
switch (MemoryRegion->Attributes) {
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK (0);
|
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK;
|
||||||
break;
|
break;
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK (0);
|
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK;
|
||||||
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
|
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
|
||||||
break;
|
break;
|
||||||
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO:
|
||||||
|
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK;
|
||||||
|
Attributes |= TT_DESCRIPTOR_SECTION_AP_NO_RO;
|
||||||
|
break;
|
||||||
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_XP:
|
||||||
|
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK;
|
||||||
|
Attributes |= TT_DESCRIPTOR_SECTION_XN_MASK;
|
||||||
|
break;
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH (0);
|
Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH;
|
||||||
break;
|
break;
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_DEVICE (0);
|
Attributes = TT_DESCRIPTOR_SECTION_DEVICE;
|
||||||
break;
|
break;
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED (0);
|
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED;
|
||||||
break;
|
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:
|
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK (1);
|
|
||||||
break;
|
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:
|
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK (1);
|
|
||||||
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
|
|
||||||
break;
|
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:
|
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH (1);
|
|
||||||
break;
|
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:
|
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_DEVICE (1);
|
|
||||||
break;
|
|
||||||
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:
|
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED (1);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED (0);
|
Attributes = TT_DESCRIPTOR_SECTION_UNCACHED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
|
|
||||||
#include <Library/ArmLib.h>
|
#include <Library/ArmLib.h>
|
||||||
|
#include <Library/ArmMmuLib.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
@@ -53,7 +54,7 @@ ConvertSectionToPages (
|
|||||||
|
|
||||||
// Get section attributes and convert to page attributes
|
// Get section attributes and convert to page attributes
|
||||||
SectionDescriptor = FirstLevelTable[FirstLevelIdx];
|
SectionDescriptor = FirstLevelTable[FirstLevelIdx];
|
||||||
PageDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (SectionDescriptor, FALSE);
|
PageDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (SectionDescriptor);
|
||||||
|
|
||||||
// Allocate a page table for the 4KB entries (we use up a full page even though we only need 1KB)
|
// Allocate a page table for the 4KB entries (we use up a full page even though we only need 1KB)
|
||||||
PageTable = (volatile ARM_PAGE_TABLE_ENTRY *)AllocatePages (1);
|
PageTable = (volatile ARM_PAGE_TABLE_ENTRY *)AllocatePages (1);
|
||||||
@@ -81,12 +82,12 @@ UpdatePageEntries (
|
|||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN UINT64 Attributes,
|
IN UINT64 Attributes,
|
||||||
|
IN UINT32 EntryMask,
|
||||||
OUT BOOLEAN *FlushTlbs OPTIONAL
|
OUT BOOLEAN *FlushTlbs OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT32 EntryValue;
|
UINT32 EntryValue;
|
||||||
UINT32 EntryMask;
|
|
||||||
UINT32 FirstLevelIdx;
|
UINT32 FirstLevelIdx;
|
||||||
UINT32 Offset;
|
UINT32 Offset;
|
||||||
UINT32 NumPageEntries;
|
UINT32 NumPageEntries;
|
||||||
@@ -104,12 +105,7 @@ UpdatePageEntries (
|
|||||||
|
|
||||||
// EntryMask: bitmask of values to change (1 = change this value, 0 = leave alone)
|
// EntryMask: bitmask of values to change (1 = change this value, 0 = leave alone)
|
||||||
// EntryValue: values at bit positions specified by EntryMask
|
// EntryValue: values at bit positions specified by EntryMask
|
||||||
EntryMask = TT_DESCRIPTOR_PAGE_TYPE_MASK | TT_DESCRIPTOR_PAGE_AP_MASK;
|
|
||||||
if ((Attributes & EFI_MEMORY_XP) != 0) {
|
|
||||||
EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE_XN;
|
|
||||||
} else {
|
|
||||||
EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE;
|
EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE;
|
||||||
}
|
|
||||||
|
|
||||||
// Although the PI spec is unclear on this, the GCD guarantees that only
|
// Although the PI spec is unclear on this, the GCD guarantees that only
|
||||||
// one Attribute bit is set at a time, so the order of the conditionals below
|
// one Attribute bit is set at a time, so the order of the conditionals below
|
||||||
@@ -142,12 +138,20 @@ UpdatePageEntries (
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((Attributes & EFI_MEMORY_RP) == 0) {
|
||||||
|
EntryValue |= TT_DESCRIPTOR_PAGE_AF;
|
||||||
|
}
|
||||||
|
|
||||||
if ((Attributes & EFI_MEMORY_RO) != 0) {
|
if ((Attributes & EFI_MEMORY_RO) != 0) {
|
||||||
EntryValue |= TT_DESCRIPTOR_PAGE_AP_RO_RO;
|
EntryValue |= TT_DESCRIPTOR_PAGE_AP_RO_RO;
|
||||||
} else {
|
} else {
|
||||||
EntryValue |= TT_DESCRIPTOR_PAGE_AP_RW_RW;
|
EntryValue |= TT_DESCRIPTOR_PAGE_AP_RW_RW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((Attributes & EFI_MEMORY_XP) != 0) {
|
||||||
|
EntryValue |= TT_DESCRIPTOR_PAGE_XN_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
// Obtain page table base
|
// Obtain page table base
|
||||||
FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();
|
FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();
|
||||||
|
|
||||||
@@ -167,6 +171,17 @@ UpdatePageEntries (
|
|||||||
|
|
||||||
// Does this descriptor need to be converted from section entry to 4K pages?
|
// Does this descriptor need to be converted from section entry to 4K pages?
|
||||||
if (!TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (Descriptor)) {
|
if (!TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (Descriptor)) {
|
||||||
|
//
|
||||||
|
// If the section mapping covers the requested region with the expected
|
||||||
|
// attributes, splitting it is unnecessary, and should be avoided as it
|
||||||
|
// may result in unbounded recursion when using a strict NX policy.
|
||||||
|
//
|
||||||
|
if ((EntryValue & ~TT_DESCRIPTOR_PAGE_TYPE_MASK & EntryMask) ==
|
||||||
|
(ConvertSectionAttributesToPageAttributes (Descriptor) & EntryMask))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Status = ConvertSectionToPages (FirstLevelIdx << TT_DESCRIPTOR_SECTION_BASE_SHIFT);
|
Status = ConvertSectionToPages (FirstLevelIdx << TT_DESCRIPTOR_SECTION_BASE_SHIFT);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
// Exit for loop
|
// Exit for loop
|
||||||
@@ -216,11 +231,11 @@ EFI_STATUS
|
|||||||
UpdateSectionEntries (
|
UpdateSectionEntries (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN UINT64 Attributes
|
IN UINT64 Attributes,
|
||||||
|
IN UINT32 EntryMask
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT32 EntryMask;
|
|
||||||
UINT32 EntryValue;
|
UINT32 EntryValue;
|
||||||
UINT32 FirstLevelIdx;
|
UINT32 FirstLevelIdx;
|
||||||
UINT32 NumSections;
|
UINT32 NumSections;
|
||||||
@@ -236,8 +251,6 @@ UpdateSectionEntries (
|
|||||||
// EntryValue: values at bit positions specified by EntryMask
|
// EntryValue: values at bit positions specified by EntryMask
|
||||||
|
|
||||||
// Make sure we handle a section range that is unmapped
|
// Make sure we handle a section range that is unmapped
|
||||||
EntryMask = TT_DESCRIPTOR_SECTION_TYPE_MASK | TT_DESCRIPTOR_SECTION_XN_MASK |
|
|
||||||
TT_DESCRIPTOR_SECTION_AP_MASK;
|
|
||||||
EntryValue = TT_DESCRIPTOR_SECTION_TYPE_SECTION;
|
EntryValue = TT_DESCRIPTOR_SECTION_TYPE_SECTION;
|
||||||
|
|
||||||
// Although the PI spec is unclear on this, the GCD guarantees that only
|
// Although the PI spec is unclear on this, the GCD guarantees that only
|
||||||
@@ -281,6 +294,10 @@ UpdateSectionEntries (
|
|||||||
EntryValue |= TT_DESCRIPTOR_SECTION_XN_MASK;
|
EntryValue |= TT_DESCRIPTOR_SECTION_XN_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((Attributes & EFI_MEMORY_RP) == 0) {
|
||||||
|
EntryValue |= TT_DESCRIPTOR_SECTION_AF;
|
||||||
|
}
|
||||||
|
|
||||||
// obtain page table base
|
// obtain page table base
|
||||||
FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();
|
FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();
|
||||||
|
|
||||||
@@ -302,6 +319,7 @@ 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,
|
||||||
|
ConvertSectionAttributesToPageAttributes (EntryMask),
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -332,11 +350,26 @@ UpdateSectionEntries (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Update the permission or memory type attributes on a range of memory.
|
||||||
|
|
||||||
|
@param BaseAddress The start of the region.
|
||||||
|
@param Length The size of the region.
|
||||||
|
@param Attributes A mask of EFI_MEMORY_xx constants.
|
||||||
|
@param SectionMask A mask of short descriptor section attributes
|
||||||
|
describing which descriptor bits to update.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were set successfully.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES The operation failed due to insufficient memory.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ArmSetMemoryAttributes (
|
SetMemoryAttributes (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN UINT64 Attributes
|
IN UINT64 Attributes,
|
||||||
|
IN UINT32 SectionMask
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@@ -367,7 +400,12 @@ ArmSetMemoryAttributes (
|
|||||||
Attributes
|
Attributes
|
||||||
));
|
));
|
||||||
|
|
||||||
Status = UpdateSectionEntries (BaseAddress, ChunkLength, Attributes);
|
Status = UpdateSectionEntries (
|
||||||
|
BaseAddress,
|
||||||
|
ChunkLength,
|
||||||
|
Attributes,
|
||||||
|
SectionMask
|
||||||
|
);
|
||||||
|
|
||||||
FlushTlbs = TRUE;
|
FlushTlbs = TRUE;
|
||||||
} else {
|
} else {
|
||||||
@@ -393,6 +431,7 @@ ArmSetMemoryAttributes (
|
|||||||
BaseAddress,
|
BaseAddress,
|
||||||
ChunkLength,
|
ChunkLength,
|
||||||
Attributes,
|
Attributes,
|
||||||
|
ConvertSectionAttributesToPageAttributes (SectionMask),
|
||||||
&FlushTlbs
|
&FlushTlbs
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -412,38 +451,96 @@ ArmSetMemoryAttributes (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the requested memory permission attributes on a region of memory.
|
||||||
|
|
||||||
|
BaseAddress and Length must be aligned to EFI_PAGE_SIZE.
|
||||||
|
|
||||||
|
If Attributes contains a memory type attribute (EFI_MEMORY_UC/WC/WT/WB), the
|
||||||
|
region is mapped according to this memory type, and additional memory
|
||||||
|
permission attributes (EFI_MEMORY_RP/RO/XP) are taken into account as well,
|
||||||
|
discarding any permission attributes that are currently set for the region.
|
||||||
|
AttributeMask is ignored in this case, and must be set to 0x0.
|
||||||
|
|
||||||
|
If Attributes contains only a combination of memory permission attributes
|
||||||
|
(EFI_MEMORY_RP/RO/XP), each page in the region will retain its existing
|
||||||
|
memory type, even if it is not uniformly set across the region. In this case,
|
||||||
|
AttributesMask may be set to a mask of permission attributes, and memory
|
||||||
|
permissions omitted from this mask will not be updated for any page in the
|
||||||
|
region. All attributes appearing in Attributes must appear in AttributeMask
|
||||||
|
as well. (Attributes & ~AttributeMask must produce 0x0)
|
||||||
|
|
||||||
|
@param[in] BaseAddress The physical address that is the start address of
|
||||||
|
a memory region.
|
||||||
|
@param[in] Length The size in bytes of the memory region.
|
||||||
|
@param[in] Attributes Mask of memory attributes to set.
|
||||||
|
@param[in] AttributeMask Mask of memory attributes to take into account.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The attributes were set for the memory region.
|
||||||
|
@retval EFI_INVALID_PARAMETER BaseAddress or Length is not suitably aligned.
|
||||||
|
Invalid combination of Attributes and
|
||||||
|
AttributeMask.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due to
|
||||||
|
lack of system resources.
|
||||||
|
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ArmSetMemoryRegionNoExec (
|
ArmSetMemoryAttributes (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length
|
IN UINT64 Length,
|
||||||
|
IN UINT64 Attributes,
|
||||||
|
IN UINT64 AttributeMask
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_XP);
|
UINT32 TtEntryMask;
|
||||||
|
|
||||||
|
if (((BaseAddress | Length) & EFI_PAGE_MASK) != 0) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
if ((Attributes & EFI_MEMORY_CACHETYPE_MASK) == 0) {
|
||||||
ArmClearMemoryRegionNoExec (
|
//
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
// No memory type was set in Attributes, so we are going to update the
|
||||||
IN UINT64 Length
|
// permissions only.
|
||||||
)
|
//
|
||||||
|
if (AttributeMask != 0) {
|
||||||
|
if (((AttributeMask & ~(UINT64)(EFI_MEMORY_RP|EFI_MEMORY_RO|EFI_MEMORY_XP)) != 0) ||
|
||||||
|
((Attributes & ~AttributeMask) != 0))
|
||||||
{
|
{
|
||||||
return ArmSetMemoryAttributes (BaseAddress, Length, __EFI_MEMORY_RWX);
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AttributeMask = EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
TtEntryMask = 0;
|
||||||
ArmSetMemoryRegionReadOnly (
|
if ((AttributeMask & EFI_MEMORY_RP) != 0) {
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
TtEntryMask |= TT_DESCRIPTOR_SECTION_AF;
|
||||||
IN UINT64 Length
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_RO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
if ((AttributeMask & EFI_MEMORY_RO) != 0) {
|
||||||
ArmClearMemoryRegionReadOnly (
|
TtEntryMask |= TT_DESCRIPTOR_SECTION_AP_MASK;
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
}
|
||||||
IN UINT64 Length
|
|
||||||
)
|
if ((AttributeMask & EFI_MEMORY_XP) != 0) {
|
||||||
{
|
TtEntryMask |= TT_DESCRIPTOR_SECTION_XN_MASK;
|
||||||
return ArmSetMemoryAttributes (BaseAddress, Length, __EFI_MEMORY_RWX);
|
}
|
||||||
|
} else {
|
||||||
|
ASSERT (AttributeMask == 0);
|
||||||
|
if (AttributeMask != 0) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
TtEntryMask = TT_DESCRIPTOR_SECTION_TYPE_MASK |
|
||||||
|
TT_DESCRIPTOR_SECTION_XN_MASK |
|
||||||
|
TT_DESCRIPTOR_SECTION_AP_MASK |
|
||||||
|
TT_DESCRIPTOR_SECTION_AF;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetMemoryAttributes (
|
||||||
|
BaseAddress,
|
||||||
|
Length,
|
||||||
|
Attributes,
|
||||||
|
TtEntryMask
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,11 @@
|
|||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
ArmLib
|
ArmLib
|
||||||
CacheMaintenanceLib
|
CacheMaintenanceLib
|
||||||
|
HobLib
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gArmMmuReplaceLiveTranslationEntryFuncGuid
|
||||||
|
|
||||||
[Pcd.ARM]
|
[Pcd.ARM]
|
||||||
gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride
|
gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride
|
||||||
|
@@ -29,4 +29,8 @@
|
|||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
ArmLib
|
ArmLib
|
||||||
CacheMaintenanceLib
|
CacheMaintenanceLib
|
||||||
|
HobLib
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gArmMmuReplaceLiveTranslationEntryFuncGuid
|
||||||
|
34
ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c
Normal file
34
ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/** @file
|
||||||
|
Arm Monitor Library.
|
||||||
|
|
||||||
|
Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <Library/ArmHvcLib.h>
|
||||||
|
#include <Library/ArmMonitorLib.h>
|
||||||
|
#include <Library/ArmSmcLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
|
||||||
|
/** Monitor call.
|
||||||
|
|
||||||
|
An HyperVisor Call (HVC) or System Monitor Call (SMC) will be issued
|
||||||
|
depending on the default conduit. PcdMonitorConduitHvc determines the type
|
||||||
|
of the call: if true, do an HVC.
|
||||||
|
|
||||||
|
@param [in,out] Args Arguments for the HVC/SMC.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
ArmMonitorCall (
|
||||||
|
IN OUT ARM_MONITOR_ARGS *Args
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (FeaturePcdGet (PcdMonitorConduitHvc)) {
|
||||||
|
ArmCallHvc ((ARM_HVC_ARGS *)Args);
|
||||||
|
} else {
|
||||||
|
ArmCallSmc ((ARM_SMC_ARGS *)Args);
|
||||||
|
}
|
||||||
|
}
|
29
ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf
Normal file
29
ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## @file
|
||||||
|
# Arm Monitor Library
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 1.29
|
||||||
|
BASE_NAME = ArmMonitorLib
|
||||||
|
FILE_GUID = F918DACB-FBB8-4CB6-A61D-08E75AF0E7CD
|
||||||
|
MODULE_TYPE = BASE
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
LIBRARY_CLASS = ArmMonitorLib
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
ArmMonitorLib.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
ArmPkg/ArmPkg.dec
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
ArmHvcLib
|
||||||
|
ArmSmcLib
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gArmTokenSpaceGuid.PcdMonitorConduitHvc
|
@@ -65,7 +65,7 @@ LibResetSystem (
|
|||||||
ArmCallSmc (&ArmSmcArgs);
|
ArmCallSmc (&ArmSmcArgs);
|
||||||
|
|
||||||
// We should never be here
|
// We should never be here
|
||||||
DEBUG ((DEBUG_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: PSCI Reset failed\n", __func__));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved.<BR>
|
Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved.<BR>
|
||||||
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
@@ -47,9 +48,25 @@ ResetWarm (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UINTN Arg1;
|
||||||
|
UINTN Ret;
|
||||||
|
|
||||||
|
Arg1 = ARM_SMC_ID_PSCI_SYSTEM_RESET2_AARCH64;
|
||||||
|
|
||||||
|
// Is SYSTEM_RESET2 supported?
|
||||||
|
Ret = ArmCallSmc0 (ARM_SMC_ID_PSCI_FEATURES, &Arg1, NULL, NULL);
|
||||||
|
if (Ret == ARM_SMC_PSCI_RET_SUCCESS) {
|
||||||
|
// Send PSCI SYSTEM_RESET2 command
|
||||||
|
ArmCallSmc0 (Arg1, NULL, NULL, NULL);
|
||||||
|
} else {
|
||||||
// Map a warm reset into a cold reset
|
// Map a warm reset into a cold reset
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"Warm reboot not supported by platform, issuing cold reboot\n"
|
||||||
|
));
|
||||||
ResetCold ();
|
ResetCold ();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function causes the system to enter a power state equivalent
|
This function causes the system to enter a power state equivalent
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <AsmMacroIoLibV8.h>
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.align 3
|
.align 3
|
||||||
|
|
||||||
GCC_ASM_EXPORT(ArmCallSvc)
|
ASM_FUNC(ArmCallSvc)
|
||||||
|
|
||||||
ASM_PFX(ArmCallSvc):
|
|
||||||
// Push frame pointer and return address on the stack
|
// Push frame pointer and return address on the stack
|
||||||
stp x29, x30, [sp, #-32]!
|
stp x29, x30, [sp, #-32]!
|
||||||
mov x29, sp
|
mov x29, sp
|
||||||
|
50
ArmPkg/Library/ArmTrngLib/ArmTrngDefs.h
Normal file
50
ArmPkg/Library/ArmTrngLib/ArmTrngDefs.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/** @file
|
||||||
|
Arm Firmware TRNG definitions.
|
||||||
|
|
||||||
|
Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
@par Reference(s):
|
||||||
|
- [1] Arm True Random Number Generator Firmware, Interface 1.0,
|
||||||
|
Platform Design Document.
|
||||||
|
(https://developer.arm.com/documentation/den0098/latest/)
|
||||||
|
|
||||||
|
@par Glossary:
|
||||||
|
- TRNG - True Random Number Generator
|
||||||
|
- FID - Function ID
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef ARM_FW_TRNG_DEFS_H_
|
||||||
|
#define ARM_FW_TRNG_DEFS_H_
|
||||||
|
|
||||||
|
#include <IndustryStandard/ArmStdSmc.h>
|
||||||
|
|
||||||
|
// Firmware TRNG revision mask and shift
|
||||||
|
#define TRNG_REV_MAJOR_MASK 0x7FFF
|
||||||
|
#define TRNG_REV_MINOR_MASK 0xFFFF
|
||||||
|
#define TRNG_REV_MAJOR_SHIFT 16
|
||||||
|
|
||||||
|
#if defined (MDE_CPU_ARM)
|
||||||
|
|
||||||
|
/** FID to use on AArch32 platform to request entropy.
|
||||||
|
*/
|
||||||
|
#define ARM_SMC_ID_TRNG_RND ARM_SMC_ID_TRNG_RND_AARCH32
|
||||||
|
|
||||||
|
/** Maximum bits of entropy supported on AArch32.
|
||||||
|
*/
|
||||||
|
#define MAX_ENTROPY_BITS 96
|
||||||
|
#elif defined (MDE_CPU_AARCH64)
|
||||||
|
|
||||||
|
/** FID to use on AArch64 platform to request entropy.
|
||||||
|
*/
|
||||||
|
#define ARM_SMC_ID_TRNG_RND ARM_SMC_ID_TRNG_RND_AARCH64
|
||||||
|
|
||||||
|
/** Maximum bits of entropy supported on AArch64.
|
||||||
|
*/
|
||||||
|
#define MAX_ENTROPY_BITS 192
|
||||||
|
#else
|
||||||
|
#error "Firmware TRNG not supported. Unknown chipset."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // ARM_FW_TRNG_DEFS_H_
|
382
ArmPkg/Library/ArmTrngLib/ArmTrngLib.c
Normal file
382
ArmPkg/Library/ArmTrngLib/ArmTrngLib.c
Normal file
@@ -0,0 +1,382 @@
|
|||||||
|
/** @file
|
||||||
|
Arm Firmware TRNG interface library.
|
||||||
|
|
||||||
|
Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
@par Reference(s):
|
||||||
|
- [1] Arm True Random Number Generator Firmware, Interface 1.0,
|
||||||
|
Platform Design Document.
|
||||||
|
(https://developer.arm.com/documentation/den0098/latest/)
|
||||||
|
- [2] NIST Special Publication 800-90B, Recommendation for the Entropy
|
||||||
|
Sources Used for Random Bit Generation.
|
||||||
|
(https://csrc.nist.gov/publications/detail/sp/800-90b/final)
|
||||||
|
|
||||||
|
@par Glossary:
|
||||||
|
- TRNG - True Random Number Generator
|
||||||
|
- FID - Function ID
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <Base.h>
|
||||||
|
#include <Library/ArmLib.h>
|
||||||
|
#include <Library/ArmMonitorLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
|
||||||
|
#include "ArmTrngDefs.h"
|
||||||
|
|
||||||
|
/** Convert TRNG status codes to RETURN status codes.
|
||||||
|
|
||||||
|
@param [in] TrngStatus TRNG status code.
|
||||||
|
|
||||||
|
@retval RETURN_SUCCESS Success.
|
||||||
|
@retval RETURN_UNSUPPORTED Function not implemented or
|
||||||
|
negative return code.
|
||||||
|
@retval RETURN_INVALID_PARAMETER A parameter is invalid.
|
||||||
|
@retval RETURN_NOT_READY No Entropy available.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
RETURN_STATUS
|
||||||
|
TrngStatusToReturnStatus (
|
||||||
|
IN INT32 TrngStatus
|
||||||
|
)
|
||||||
|
{
|
||||||
|
switch (TrngStatus) {
|
||||||
|
case TRNG_STATUS_NOT_SUPPORTED:
|
||||||
|
return RETURN_UNSUPPORTED;
|
||||||
|
|
||||||
|
case TRNG_STATUS_INVALID_PARAMETER:
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
case TRNG_STATUS_NO_ENTROPY:
|
||||||
|
return RETURN_NOT_READY;
|
||||||
|
|
||||||
|
case TRNG_STATUS_SUCCESS:
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (TrngStatus < 0) {
|
||||||
|
return RETURN_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the version of the Arm TRNG backend.
|
||||||
|
|
||||||
|
A TRNG may be implemented by the system firmware, in which case this
|
||||||
|
function shall return the version of the Arm TRNG backend.
|
||||||
|
The implementation must return NOT_SUPPORTED if a Back end is not present.
|
||||||
|
|
||||||
|
@param [out] MajorRevision Major revision.
|
||||||
|
@param [out] MinorRevision Minor revision.
|
||||||
|
|
||||||
|
@retval RETURN_SUCCESS The function completed successfully.
|
||||||
|
@retval RETURN_INVALID_PARAMETER Invalid parameter.
|
||||||
|
@retval RETURN_UNSUPPORTED Backend not present.
|
||||||
|
**/
|
||||||
|
RETURN_STATUS
|
||||||
|
EFIAPI
|
||||||
|
GetArmTrngVersion (
|
||||||
|
OUT UINT16 *MajorRevision,
|
||||||
|
OUT UINT16 *MinorRevision
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
ARM_MONITOR_ARGS Parameters;
|
||||||
|
INT32 Revision;
|
||||||
|
|
||||||
|
if ((MajorRevision == NULL) || (MinorRevision == NULL)) {
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZeroMem (&Parameters, sizeof (Parameters));
|
||||||
|
|
||||||
|
Parameters.Arg0 = ARM_SMC_ID_TRNG_VERSION;
|
||||||
|
ArmMonitorCall (&Parameters);
|
||||||
|
|
||||||
|
Revision = (INT32)Parameters.Arg0;
|
||||||
|
Status = TrngStatusToReturnStatus (Revision);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
*MinorRevision = (Revision & TRNG_REV_MINOR_MASK);
|
||||||
|
*MajorRevision = ((Revision >> TRNG_REV_MAJOR_SHIFT) & TRNG_REV_MAJOR_MASK);
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the features supported by the Arm TRNG backend.
|
||||||
|
|
||||||
|
The caller can determine if functions defined in the Arm TRNG ABI are
|
||||||
|
present in the ABI implementation.
|
||||||
|
|
||||||
|
@param [in] FunctionId Function Id.
|
||||||
|
@param [out] Capability Function specific capability if present.
|
||||||
|
|
||||||
|
@retval RETURN_SUCCESS The function completed successfully.
|
||||||
|
@retval RETURN_INVALID_PARAMETER Invalid parameter.
|
||||||
|
@retval RETURN_UNSUPPORTED Function not implemented.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
RETURN_STATUS
|
||||||
|
EFIAPI
|
||||||
|
GetArmTrngFeatures (
|
||||||
|
IN CONST UINT32 FunctionId,
|
||||||
|
OUT UINT32 *Capability OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ARM_MONITOR_ARGS Parameters;
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
|
ZeroMem (&Parameters, sizeof (Parameters));
|
||||||
|
|
||||||
|
Parameters.Arg0 = ARM_SMC_ID_TRNG_FEATURES;
|
||||||
|
Parameters.Arg1 = FunctionId;
|
||||||
|
ArmMonitorCall (&Parameters);
|
||||||
|
|
||||||
|
Status = TrngStatusToReturnStatus (Parameters.Arg0);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Capability != NULL) {
|
||||||
|
*Capability = (UINT32)Parameters.Arg0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the UUID of the Arm TRNG backend.
|
||||||
|
|
||||||
|
A TRNG may be implemented by the system firmware, in which case this
|
||||||
|
function shall return the UUID of the TRNG backend.
|
||||||
|
Returning the Arm TRNG UUID is optional and if not implemented,
|
||||||
|
RETURN_UNSUPPORTED shall be returned.
|
||||||
|
|
||||||
|
Note: The caller must not rely on the returned UUID as a trustworthy Arm TRNG
|
||||||
|
Back end identity
|
||||||
|
|
||||||
|
@param [out] Guid UUID of the Arm TRNG backend.
|
||||||
|
|
||||||
|
@retval RETURN_SUCCESS The function completed successfully.
|
||||||
|
@retval RETURN_INVALID_PARAMETER Invalid parameter.
|
||||||
|
@retval RETURN_UNSUPPORTED Function not implemented.
|
||||||
|
**/
|
||||||
|
RETURN_STATUS
|
||||||
|
EFIAPI
|
||||||
|
GetArmTrngUuid (
|
||||||
|
OUT GUID *Guid
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ARM_MONITOR_ARGS Parameters;
|
||||||
|
|
||||||
|
if (Guid == NULL) {
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZeroMem (&Parameters, sizeof (Parameters));
|
||||||
|
|
||||||
|
Parameters.Arg0 = ARM_SMC_ID_TRNG_GET_UUID;
|
||||||
|
ArmMonitorCall (&Parameters);
|
||||||
|
|
||||||
|
// Only invalid value is TRNG_STATUS_NOT_SUPPORTED (-1).
|
||||||
|
if ((INT32)Parameters.Arg0 == TRNG_STATUS_NOT_SUPPORTED) {
|
||||||
|
return TrngStatusToReturnStatus ((INT32)Parameters.Arg0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Guid->Data1 = (Parameters.Arg0 & MAX_UINT32);
|
||||||
|
Guid->Data2 = (Parameters.Arg1 & MAX_UINT16);
|
||||||
|
Guid->Data3 = ((Parameters.Arg1 >> 16) & MAX_UINT16);
|
||||||
|
|
||||||
|
Guid->Data4[0] = (Parameters.Arg2 & MAX_UINT8);
|
||||||
|
Guid->Data4[1] = ((Parameters.Arg2 >> 8) & MAX_UINT8);
|
||||||
|
Guid->Data4[2] = ((Parameters.Arg2 >> 16) & MAX_UINT8);
|
||||||
|
Guid->Data4[3] = ((Parameters.Arg2 >> 24) & MAX_UINT8);
|
||||||
|
|
||||||
|
Guid->Data4[4] = (Parameters.Arg3 & MAX_UINT8);
|
||||||
|
Guid->Data4[5] = ((Parameters.Arg3 >> 8) & MAX_UINT8);
|
||||||
|
Guid->Data4[6] = ((Parameters.Arg3 >> 16) & MAX_UINT8);
|
||||||
|
Guid->Data4[7] = ((Parameters.Arg3 >> 24) & MAX_UINT8);
|
||||||
|
|
||||||
|
DEBUG ((DEBUG_INFO, "FW-TRNG: UUID %g\n", Guid));
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns maximum number of entropy bits that can be returned in a single
|
||||||
|
call.
|
||||||
|
|
||||||
|
@return Returns the maximum number of Entropy bits that can be returned
|
||||||
|
in a single call to GetArmTrngEntropy().
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
GetArmTrngMaxSupportedEntropyBits (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return MAX_ENTROPY_BITS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns N bits of conditioned entropy.
|
||||||
|
|
||||||
|
See [2] Section 2.3.1 GetEntropy: An Interface to the Entropy Source
|
||||||
|
GetEntropy
|
||||||
|
Input:
|
||||||
|
bits_of_entropy: the requested amount of entropy
|
||||||
|
Output:
|
||||||
|
entropy_bitstring: The string that provides the requested entropy.
|
||||||
|
status: A Boolean value that is TRUE if the request has been satisfied,
|
||||||
|
and is FALSE otherwise.
|
||||||
|
|
||||||
|
@param [in] EntropyBits Number of entropy bits requested.
|
||||||
|
@param [in] BufferSize Size of the Buffer in bytes.
|
||||||
|
@param [out] Buffer Buffer to return the entropy bits.
|
||||||
|
|
||||||
|
@retval RETURN_SUCCESS The function completed successfully.
|
||||||
|
@retval RETURN_INVALID_PARAMETER Invalid parameter.
|
||||||
|
@retval RETURN_UNSUPPORTED Function not implemented.
|
||||||
|
@retval RETURN_BAD_BUFFER_SIZE Buffer size is too small.
|
||||||
|
@retval RETURN_NOT_READY No Entropy available.
|
||||||
|
**/
|
||||||
|
RETURN_STATUS
|
||||||
|
EFIAPI
|
||||||
|
GetArmTrngEntropy (
|
||||||
|
IN UINTN EntropyBits,
|
||||||
|
IN UINTN BufferSize,
|
||||||
|
OUT UINT8 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
ARM_MONITOR_ARGS Parameters;
|
||||||
|
UINTN EntropyBytes;
|
||||||
|
UINTN LastValidBits;
|
||||||
|
UINTN BytesToClear;
|
||||||
|
UINTN EntropyData[3];
|
||||||
|
|
||||||
|
if ((EntropyBits == 0) ||
|
||||||
|
(EntropyBits > MAX_ENTROPY_BITS) ||
|
||||||
|
(Buffer == NULL))
|
||||||
|
{
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntropyBytes = (EntropyBits + 7) >> 3;
|
||||||
|
if (EntropyBytes > BufferSize) {
|
||||||
|
return RETURN_BAD_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZeroMem (Buffer, BufferSize);
|
||||||
|
ZeroMem (&Parameters, sizeof (Parameters));
|
||||||
|
|
||||||
|
Parameters.Arg0 = ARM_SMC_ID_TRNG_RND;
|
||||||
|
Parameters.Arg1 = EntropyBits;
|
||||||
|
ArmMonitorCall (&Parameters);
|
||||||
|
|
||||||
|
Status = TrngStatusToReturnStatus ((INT32)Parameters.Arg0);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The entropy data is returned in the Parameters.Arg<3..1>
|
||||||
|
// With the lower order bytes in Parameters.Arg3 and the higher
|
||||||
|
// order bytes being stored in Parameters.Arg1.
|
||||||
|
EntropyData[0] = Parameters.Arg3;
|
||||||
|
EntropyData[1] = Parameters.Arg2;
|
||||||
|
EntropyData[2] = Parameters.Arg1;
|
||||||
|
|
||||||
|
CopyMem (Buffer, EntropyData, EntropyBytes);
|
||||||
|
|
||||||
|
// Mask off any unused top bytes, in accordance with specification.
|
||||||
|
BytesToClear = BufferSize - EntropyBytes;
|
||||||
|
if (BytesToClear != 0) {
|
||||||
|
ZeroMem (&Buffer[EntropyBytes], BytesToClear);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the unused MSB bits of the last byte.
|
||||||
|
LastValidBits = EntropyBits & 0x7;
|
||||||
|
if (LastValidBits != 0) {
|
||||||
|
Buffer[EntropyBytes - 1] &= (0xFF >> (8 - LastValidBits));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The constructor checks that the FW-TRNG interface is supported
|
||||||
|
by the host firmware.
|
||||||
|
|
||||||
|
It will ASSERT() if FW-TRNG is not supported.
|
||||||
|
It will always return RETURN_SUCCESS.
|
||||||
|
|
||||||
|
@retval RETURN_SUCCESS The constructor always returns RETURN_SUCCESS.
|
||||||
|
**/
|
||||||
|
RETURN_STATUS
|
||||||
|
EFIAPI
|
||||||
|
ArmTrngLibConstructor (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ARM_MONITOR_ARGS Parameters;
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
UINT16 MajorRev;
|
||||||
|
UINT16 MinorRev;
|
||||||
|
GUID Guid;
|
||||||
|
|
||||||
|
ZeroMem (&Parameters, sizeof (Parameters));
|
||||||
|
|
||||||
|
Parameters.Arg0 = SMCCC_VERSION;
|
||||||
|
ArmMonitorCall (&Parameters);
|
||||||
|
Status = TrngStatusToReturnStatus ((INT32)Parameters.Arg0);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
goto ErrorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cf [1] s2.1.3 'Caller responsibilities',
|
||||||
|
// SMCCC version must be greater or equal than 1.1
|
||||||
|
if ((INT32)Parameters.Arg0 < 0x10001) {
|
||||||
|
goto ErrorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = GetArmTrngVersion (&MajorRev, &MinorRev);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
goto ErrorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the required features are present.
|
||||||
|
Status = GetArmTrngFeatures (ARM_SMC_ID_TRNG_RND, NULL);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
goto ErrorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if TRNG UUID is supported and if so trace the GUID.
|
||||||
|
Status = GetArmTrngFeatures (ARM_SMC_ID_TRNG_GET_UUID, NULL);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
goto ErrorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_CODE_BEGIN ();
|
||||||
|
|
||||||
|
Status = GetArmTrngUuid (&Guid);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
goto ErrorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"FW-TRNG: Version %d.%d, GUID {%g}\n",
|
||||||
|
MajorRev,
|
||||||
|
MinorRev,
|
||||||
|
&Guid
|
||||||
|
));
|
||||||
|
|
||||||
|
DEBUG_CODE_END ();
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
|
||||||
|
ErrorHandler:
|
||||||
|
DEBUG ((DEBUG_ERROR, "ArmTrngLib could not be correctly initialized.\n"));
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
29
ArmPkg/Library/ArmTrngLib/ArmTrngLib.inf
Normal file
29
ArmPkg/Library/ArmTrngLib/ArmTrngLib.inf
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## @file
|
||||||
|
# Arm Firmware TRNG interface library.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 1.29
|
||||||
|
BASE_NAME = ArmTrngLib
|
||||||
|
FILE_GUID = 10DE97C9-28E4-4C9B-A53E-8D7D1B0DD4E0
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
MODULE_TYPE = BASE
|
||||||
|
LIBRARY_CLASS = ArmTrngLib
|
||||||
|
CONSTRUCTOR = ArmTrngLibConstructor
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
ArmTrngDefs.h
|
||||||
|
ArmTrngLib.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
ArmPkg/ArmPkg.dec
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
ArmMonitorLib
|
||||||
|
BaseLib
|
||||||
|
BaseMemoryLib
|
@@ -77,13 +77,8 @@ PeCoffLoaderRelocateImageExtraAction (
|
|||||||
|
|
||||||
if (ImageContext->PdbPointer) {
|
if (ImageContext->PdbPointer) {
|
||||||
#ifdef __CC_ARM
|
#ifdef __CC_ARM
|
||||||
#if (__ARMCC_VERSION < 500000)
|
|
||||||
// Print out the command for the RVD debugger to load symbols for this image
|
|
||||||
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
|
|
||||||
// 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 ((DEBUG_LOAD | DEBUG_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
|
|
||||||
#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 ((DEBUG_LOAD | DEBUG_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)));
|
||||||
|
@@ -22,6 +22,12 @@
|
|||||||
#include <Protocol/DebugSupport.h>
|
#include <Protocol/DebugSupport.h>
|
||||||
#include <Protocol/LoadedImage.h>
|
#include <Protocol/LoadedImage.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Maximum number of characters to print to serial (UINT8s) and to console if
|
||||||
|
// available (as UINT16s)
|
||||||
|
//
|
||||||
|
#define MAX_PRINT_CHARS 100
|
||||||
|
|
||||||
STATIC CHAR8 *gExceptionTypeString[] = {
|
STATIC CHAR8 *gExceptionTypeString[] = {
|
||||||
"Synchronous",
|
"Synchronous",
|
||||||
"IRQ",
|
"IRQ",
|
||||||
@@ -188,18 +194,14 @@ DefaultExceptionHandler (
|
|||||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CHAR8 Buffer[100];
|
CHAR8 Buffer[MAX_PRINT_CHARS];
|
||||||
|
CHAR16 UnicodeBuffer[MAX_PRINT_CHARS];
|
||||||
UINTN CharCount;
|
UINTN CharCount;
|
||||||
INT32 Offset;
|
INT32 Offset;
|
||||||
|
|
||||||
if (mRecursiveException) {
|
if (mRecursiveException) {
|
||||||
STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n";
|
STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n";
|
||||||
|
|
||||||
SerialPortWrite ((UINT8 *)Message, sizeof Message - 1);
|
SerialPortWrite ((UINT8 *)Message, sizeof Message - 1);
|
||||||
if (gST->ConOut != NULL) {
|
|
||||||
AsciiPrint (Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,9 +209,10 @@ DefaultExceptionHandler (
|
|||||||
|
|
||||||
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);
|
||||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||||
if (gST->ConOut != NULL) {
|
|
||||||
AsciiPrint (Buffer);
|
// Prepare a unicode buffer for ConOut, if applicable, in case the buffer
|
||||||
}
|
// gets reused.
|
||||||
|
UnicodeSPrintAsciiFormat (UnicodeBuffer, MAX_PRINT_CHARS, Buffer);
|
||||||
|
|
||||||
DEBUG_CODE_BEGIN ();
|
DEBUG_CODE_BEGIN ();
|
||||||
CHAR8 *Pdb, *PrevPdb;
|
CHAR8 *Pdb, *PrevPdb;
|
||||||
@@ -330,6 +333,13 @@ DefaultExceptionHandler (
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to print that we had a synchronous exception to ConOut. We do
|
||||||
|
// this after the serial logging as ConOut's logging is more complex and we
|
||||||
|
// aren't guaranteed to succeed.
|
||||||
|
if (gST->ConOut != NULL) {
|
||||||
|
gST->ConOut->OutputString (gST->ConOut, UnicodeBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,12 @@
|
|||||||
#include <Protocol/DebugSupport.h>
|
#include <Protocol/DebugSupport.h>
|
||||||
#include <Library/DefaultExceptionHandlerLib.h>
|
#include <Library/DefaultExceptionHandlerLib.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Maximum number of characters to print to serial (UINT8s) and to console if
|
||||||
|
// available (as UINT16s)
|
||||||
|
//
|
||||||
|
#define MAX_PRINT_CHARS 100
|
||||||
|
|
||||||
//
|
//
|
||||||
// The number of elements in a CHAR8 array, including the terminating NUL, that
|
// The number of elements in a CHAR8 array, including the terminating NUL, that
|
||||||
// is meant to hold the string rendering of the CPSR.
|
// is meant to hold the string rendering of the CPSR.
|
||||||
@@ -198,7 +204,8 @@ DefaultExceptionHandler (
|
|||||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CHAR8 Buffer[100];
|
CHAR8 Buffer[MAX_PRINT_CHARS];
|
||||||
|
CHAR16 UnicodeBuffer[MAX_PRINT_CHARS];
|
||||||
UINTN CharCount;
|
UINTN CharCount;
|
||||||
UINT32 DfsrStatus;
|
UINT32 DfsrStatus;
|
||||||
UINT32 IfsrStatus;
|
UINT32 IfsrStatus;
|
||||||
@@ -216,9 +223,10 @@ DefaultExceptionHandler (
|
|||||||
SystemContext.SystemContextArm->CPSR
|
SystemContext.SystemContextArm->CPSR
|
||||||
);
|
);
|
||||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||||
if (gST->ConOut != NULL) {
|
|
||||||
AsciiPrint (Buffer);
|
// Prepare a unicode buffer for ConOut, if applicable, as Buffer is used
|
||||||
}
|
// below.
|
||||||
|
UnicodeSPrintAsciiFormat (UnicodeBuffer, MAX_PRINT_CHARS, Buffer);
|
||||||
|
|
||||||
DEBUG_CODE_BEGIN ();
|
DEBUG_CODE_BEGIN ();
|
||||||
CHAR8 *Pdb;
|
CHAR8 *Pdb;
|
||||||
@@ -289,6 +297,14 @@ DefaultExceptionHandler (
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_ERROR, "\n"));
|
DEBUG ((DEBUG_ERROR, "\n"));
|
||||||
|
|
||||||
|
// Attempt to print that we had a synchronous exception to ConOut. We do
|
||||||
|
// this after the serial logging as ConOut's logging is more complex and we
|
||||||
|
// aren't guaranteed to succeed.
|
||||||
|
if (gST->ConOut != NULL) {
|
||||||
|
gST->ConOut->OutputString (gST->ConOut, UnicodeBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
|
|
||||||
CpuDeadLoop (); // may return if executing under a debugger
|
CpuDeadLoop (); // may return if executing under a debugger
|
||||||
|
Binary file not shown.
BIN
ArmPkg/Library/GnuNoteBti.bin
Normal file
BIN
ArmPkg/Library/GnuNoteBti.bin
Normal file
Binary file not shown.
@@ -151,7 +151,7 @@ PlatformBootManagerAfterConsole (
|
|||||||
LOAD_OPTION_ACTIVE
|
LOAD_OPTION_ACTIVE
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: PcdLinuxBootFileGuid was not set!\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: PcdLinuxBootFileGuid was not set!\n", __func__));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -86,7 +86,12 @@ OpteeSharedMemoryRemap (
|
|||||||
return EFI_BUFFER_TOO_SMALL;
|
return EFI_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = ArmSetMemoryAttributes (PhysicalAddress, Size, EFI_MEMORY_WB);
|
Status = ArmSetMemoryAttributes (
|
||||||
|
PhysicalAddress,
|
||||||
|
Size,
|
||||||
|
EFI_MEMORY_WB | EFI_MEMORY_XP,
|
||||||
|
0
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
Implementation for PlatformBootManagerLib library class interfaces.
|
Implementation for PlatformBootManagerLib library class interfaces.
|
||||||
|
|
||||||
Copyright (C) 2015-2016, Red Hat, Inc.
|
Copyright (C) 2015-2016, Red Hat, Inc.
|
||||||
Copyright (c) 2014 - 2021, ARM Ltd. All rights reserved.<BR>
|
Copyright (c) 2014 - 2023, Arm Ltd. All rights reserved.<BR>
|
||||||
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
||||||
Copyright (c) 2021, Semihalf All rights reserved.<BR>
|
Copyright (c) 2021, Semihalf All rights reserved.<BR>
|
||||||
@@ -195,7 +195,7 @@ FilterAndProcess (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_VERBOSE,
|
DEBUG_VERBOSE,
|
||||||
"%a: %g: %r\n",
|
"%a: %g: %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
ProtocolGuid,
|
ProtocolGuid,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
@@ -266,7 +266,7 @@ IsPciDisplay (
|
|||||||
&Pci
|
&Pci
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));
|
DEBUG ((DEBUG_ERROR, "%a: %s: %r\n", __func__, ReportText, Status));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ Connect (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,
|
EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,
|
||||||
"%a: %s: %r\n",
|
"%a: %s: %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
ReportText,
|
ReportText,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
@@ -356,7 +356,7 @@ AddOutput (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: %s: handle %p: device path not found\n",
|
"%a: %s: handle %p: device path not found\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
ReportText,
|
ReportText,
|
||||||
Handle
|
Handle
|
||||||
));
|
));
|
||||||
@@ -368,7 +368,7 @@ AddOutput (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: %s: adding to ConOut: %r\n",
|
"%a: %s: adding to ConOut: %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
ReportText,
|
ReportText,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
@@ -380,7 +380,7 @@ AddOutput (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: %s: adding to ErrOut: %r\n",
|
"%a: %s: adding to ErrOut: %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
ReportText,
|
ReportText,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
@@ -390,7 +390,7 @@ AddOutput (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_VERBOSE,
|
DEBUG_VERBOSE,
|
||||||
"%a: %s: added to ConOut and ErrOut\n",
|
"%a: %s: added to ConOut and ErrOut\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
ReportText
|
ReportText
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -470,6 +470,64 @@ PlatformRegisterFvBootOption (
|
|||||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Boot a Fv Boot Option.
|
||||||
|
|
||||||
|
This function is useful for booting the UEFI Shell as it is loaded
|
||||||
|
as a non active boot option.
|
||||||
|
|
||||||
|
@param[in] FileGuid The File GUID.
|
||||||
|
@param[in] Description String describing the Boot Option.
|
||||||
|
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
PlatformBootFvBootOption (
|
||||||
|
IN CONST EFI_GUID *FileGuid,
|
||||||
|
IN CHAR16 *Description
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||||
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
|
|
||||||
|
Status = gBS->HandleProtocol (
|
||||||
|
gImageHandle,
|
||||||
|
&gEfiLoadedImageProtocolGuid,
|
||||||
|
(VOID **)&LoadedImage
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// The UEFI Shell was registered in PlatformRegisterFvBootOption ()
|
||||||
|
// previously, thus it must still be available in this FV.
|
||||||
|
//
|
||||||
|
EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
|
||||||
|
DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
|
||||||
|
ASSERT (DevicePath != NULL);
|
||||||
|
DevicePath = AppendDevicePathNode (
|
||||||
|
DevicePath,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *)&FileNode
|
||||||
|
);
|
||||||
|
ASSERT (DevicePath != NULL);
|
||||||
|
|
||||||
|
Status = EfiBootManagerInitializeLoadOption (
|
||||||
|
&NewOption,
|
||||||
|
LoadOptionNumberUnassigned,
|
||||||
|
LoadOptionTypeBoot,
|
||||||
|
LOAD_OPTION_ACTIVE,
|
||||||
|
Description,
|
||||||
|
DevicePath,
|
||||||
|
NULL,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
FreePool (DevicePath);
|
||||||
|
|
||||||
|
EfiBootManagerBoot (&NewOption);
|
||||||
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
GetPlatformOptions (
|
GetPlatformOptions (
|
||||||
@@ -547,7 +605,7 @@ GetPlatformOptions (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: failed to register \"%s\": %r\n",
|
"%a: failed to register \"%s\": %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
BootOptions[Index].Description,
|
BootOptions[Index].Description,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
@@ -575,7 +633,7 @@ GetPlatformOptions (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: failed to register hotkey for \"%s\": %r\n",
|
"%a: failed to register hotkey for \"%s\": %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
BootOptions[Index].Description,
|
BootOptions[Index].Description,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
@@ -757,7 +815,7 @@ HandleCapsules (
|
|||||||
BOOLEAN NeedReset;
|
BOOLEAN NeedReset;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__));
|
DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __func__));
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEsrtManagementProtocolGuid,
|
&gEsrtManagementProtocolGuid,
|
||||||
@@ -785,7 +843,7 @@ HandleCapsules (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: failed to process capsule %p - %r\n",
|
"%a: failed to process capsule %p - %r\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
CapsuleHeader,
|
CapsuleHeader,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
@@ -800,7 +858,7 @@ HandleCapsules (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_WARN,
|
DEBUG_WARN,
|
||||||
"%a: capsule update successful, resetting ...\n",
|
"%a: capsule update successful, resetting ...\n",
|
||||||
__FUNCTION__
|
__func__
|
||||||
));
|
));
|
||||||
|
|
||||||
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||||
@@ -868,7 +926,7 @@ BootDiscoveryPolicyHandler (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
"%a - Unexpected DiscoveryPolicy (0x%x). Run Minimal Discovery Policy\n",
|
"%a - Unexpected DiscoveryPolicy (0x%x). Run Minimal Discovery Policy\n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
DiscoveryPolicy
|
DiscoveryPolicy
|
||||||
));
|
));
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@@ -884,14 +942,14 @@ BootDiscoveryPolicyHandler (
|
|||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
"%a - Failed to locate gEfiBootManagerPolicyProtocolGuid."
|
"%a - Failed to locate gEfiBootManagerPolicyProtocolGuid."
|
||||||
"Driver connect will be skipped.\n",
|
"Driver connect will be skipped.\n",
|
||||||
__FUNCTION__
|
__func__
|
||||||
));
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = BMPolicy->ConnectDeviceClass (BMPolicy, Class);
|
Status = BMPolicy->ConnectDeviceClass (BMPolicy, Class);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a - ConnectDeviceClass returns - %r\n", __FUNCTION__, Status));
|
DEBUG ((DEBUG_ERROR, "%a - ConnectDeviceClass returns - %r\n", __func__, Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,6 +1133,18 @@ PlatformBootManagerUnableToBoot (
|
|||||||
EfiBootManagerConnectAll ();
|
EfiBootManagerConnectAll ();
|
||||||
EfiBootManagerRefreshAllBootOption ();
|
EfiBootManagerRefreshAllBootOption ();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Boot the 'UEFI Shell'. If the Pcd is not set, the UEFI Shell is not
|
||||||
|
// an active boot option and must be manually selected through UiApp
|
||||||
|
// (at least during the fist boot).
|
||||||
|
//
|
||||||
|
if (FixedPcdGetBool (PcdUefiShellDefaultBootEnable)) {
|
||||||
|
PlatformBootFvBootOption (
|
||||||
|
&gUefiShellFileGuid,
|
||||||
|
L"UEFI Shell (default)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Record the updated number of boot configured boot options
|
// Record the updated number of boot configured boot options
|
||||||
//
|
//
|
||||||
@@ -1096,7 +1166,7 @@ PlatformBootManagerUnableToBoot (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_WARN,
|
DEBUG_WARN,
|
||||||
"%a: rebooting after refreshing all boot options\n",
|
"%a: rebooting after refreshing all boot options\n",
|
||||||
__FUNCTION__
|
__func__
|
||||||
));
|
));
|
||||||
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
# Implementation for PlatformBootManagerLib library class interfaces.
|
# Implementation for PlatformBootManagerLib library class interfaces.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2015-2016, Red Hat, Inc.
|
# Copyright (C) 2015-2016, Red Hat, Inc.
|
||||||
# Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>
|
# Copyright (c) 2014 - 2023, Arm Ltd. All rights reserved.<BR>
|
||||||
# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
PlatformBm.h
|
PlatformBm.h
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
|
ArmPkg/ArmPkg.dec
|
||||||
EmbeddedPkg/EmbeddedPkg.dec
|
EmbeddedPkg/EmbeddedPkg.dec
|
||||||
MdeModulePkg/MdeModulePkg.dec
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
@@ -55,7 +56,7 @@
|
|||||||
gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
|
gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
|
||||||
|
|
||||||
[FixedPcd]
|
[FixedPcd]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
|
gArmTokenSpaceGuid.PcdUefiShellDefaultBootEnable
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
|
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
|
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
|
||||||
@@ -66,6 +67,7 @@
|
|||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
|
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy
|
gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gBootDiscoveryPolicyMgrFormsetGuid
|
gBootDiscoveryPolicyMgrFormsetGuid
|
||||||
|
@@ -1,147 +0,0 @@
|
|||||||
/**@file
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
|
||||||
Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
|
|
||||||
Portions copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include <PiDxe.h>
|
|
||||||
#include <Library/PeCoffLib.h>
|
|
||||||
|
|
||||||
#include <Library/BaseLib.h>
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/PeCoffExtraActionLib.h>
|
|
||||||
#include <Library/SemihostLib.h>
|
|
||||||
#include <Library/PrintLib.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
Append string to debugger script file, create file if needed.
|
|
||||||
|
|
||||||
This library can show up in multiple places so we need to append the file every time we write to it.
|
|
||||||
For example Sec can use this to load the DXE core, and the DXE core would use this to load all the
|
|
||||||
other modules. So we have two instances of the library in the system.
|
|
||||||
|
|
||||||
@param Buffer Buffer to write to file.
|
|
||||||
@param Length Length of Buffer in bytes.
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
WriteStringToFile (
|
|
||||||
IN VOID *Buffer,
|
|
||||||
IN UINT32 Length
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Working around and issue with the code that is commented out. For now send it to the console.
|
|
||||||
// You can copy the console into a file and source the file as a script and you get symbols.
|
|
||||||
// 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
|
|
||||||
SemihostWriteString (Buffer);
|
|
||||||
|
|
||||||
/*
|
|
||||||
I'm currently having issues with this code crashing the debugger. Seems like it should work.
|
|
||||||
|
|
||||||
UINT32 SemihostHandle;
|
|
||||||
UINT32 SemihostMode = SEMIHOST_FILE_MODE_WRITE | SEMIHOST_FILE_MODE_BINARY | SEMIHOST_FILE_MODE_UPDATE;
|
|
||||||
|
|
||||||
SemihostFileOpen ("c:\rvi_symbols.inc", SemihostMode, &SemihostHandle);
|
|
||||||
SemihostFileWrite (SemihostHandle, &Length, Buffer);
|
|
||||||
SemihostFileClose (SemihostHandle);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
If the build is done on cygwin the paths are cygpaths.
|
|
||||||
/cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
|
|
||||||
them to work with RVD commands
|
|
||||||
|
|
||||||
@param Name Path to convert if needed
|
|
||||||
|
|
||||||
**/
|
|
||||||
CHAR8 *
|
|
||||||
DeCygwinPathIfNeeded (
|
|
||||||
IN CHAR8 *Name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
CHAR8 *Ptr;
|
|
||||||
UINTN Index;
|
|
||||||
UINTN Len;
|
|
||||||
|
|
||||||
Ptr = AsciiStrStr (Name, "/cygdrive/");
|
|
||||||
if (Ptr == NULL) {
|
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
Len = AsciiStrLen (Ptr);
|
|
||||||
|
|
||||||
// convert "/cygdrive" to spaces
|
|
||||||
for (Index = 0; Index < 9; Index++) {
|
|
||||||
Ptr[Index] = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert /c to c:
|
|
||||||
Ptr[9] = Ptr[10];
|
|
||||||
Ptr[10] = ':';
|
|
||||||
|
|
||||||
// switch path separators
|
|
||||||
for (Index = 11; Index < Len; Index++) {
|
|
||||||
if (Ptr[Index] == '/') {
|
|
||||||
Ptr[Index] = '\\';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
|
||||||
|
|
||||||
If ImageContext is NULL, then ASSERT().
|
|
||||||
|
|
||||||
@param ImageContext Pointer to the image context structure that describes the
|
|
||||||
PE/COFF image that has already been loaded and relocated.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
PeCoffLoaderRelocateImageExtraAction (
|
|
||||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
|
||||||
)
|
|
||||||
{
|
|
||||||
CHAR8 Buffer[256];
|
|
||||||
|
|
||||||
#if (__ARMCC_VERSION < 500000)
|
|
||||||
AsciiSPrint (Buffer, sizeof (Buffer), "load /a /ni /np \"%a\" &0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
|
||||||
#else
|
|
||||||
AsciiSPrint (Buffer, sizeof (Buffer), "add-symbol-file %a 0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
|
||||||
#endif
|
|
||||||
DeCygwinPathIfNeeded (&Buffer[16]);
|
|
||||||
|
|
||||||
WriteStringToFile (Buffer, AsciiStrSize (Buffer));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
|
||||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
|
||||||
|
|
||||||
If ImageContext is NULL, then ASSERT().
|
|
||||||
|
|
||||||
@param ImageContext Pointer to the image context structure that describes the
|
|
||||||
PE/COFF image that is being unloaded.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
PeCoffLoaderUnloadImageExtraAction (
|
|
||||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
|
||||||
)
|
|
||||||
{
|
|
||||||
CHAR8 Buffer[256];
|
|
||||||
|
|
||||||
AsciiSPrint (Buffer, sizeof (Buffer), "unload symbols_only \"%a\"\n", ImageContext->PdbPointer);
|
|
||||||
DeCygwinPathIfNeeded (Buffer);
|
|
||||||
|
|
||||||
WriteStringToFile (Buffer, AsciiStrSize (Buffer));
|
|
||||||
}
|
|
@@ -1,35 +0,0 @@
|
|||||||
#/** @file
|
|
||||||
# PeCoff extra action library for DXE phase that run Unix emulator.
|
|
||||||
#
|
|
||||||
# Lib to provide memory journal status code reporting Routines
|
|
||||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
|
||||||
# Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR>
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#**/
|
|
||||||
|
|
||||||
[Defines]
|
|
||||||
INF_VERSION = 0x00010005
|
|
||||||
BASE_NAME = RvdUnixPeCoffExtraActionLib
|
|
||||||
FILE_GUID = 5EDEB7E7-EA55-4E92-8216-335AC98A3B11
|
|
||||||
MODULE_TYPE = BASE
|
|
||||||
VERSION_STRING = 1.0
|
|
||||||
LIBRARY_CLASS = PeCoffExtraActionLib
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following information is for reference only and not required by the build tools.
|
|
||||||
#
|
|
||||||
# VALID_ARCHITECTURES = ARM
|
|
||||||
#
|
|
||||||
|
|
||||||
[Sources.common]
|
|
||||||
RvdPeCoffExtraActionLib.c
|
|
||||||
|
|
||||||
[Packages]
|
|
||||||
MdePkg/MdePkg.dec
|
|
||||||
ArmPkg/ArmPkg.dec
|
|
||||||
|
|
||||||
[LibraryClasses]
|
|
||||||
DebugLib
|
|
||||||
SemihostLib
|
|
@@ -1,6 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
* OemMiscLib.c
|
* OemMiscLib.c
|
||||||
*
|
*
|
||||||
|
* Copyright (c) 2022, Ampere Computing LLC. All rights reserved.
|
||||||
* Copyright (c) 2021, NUVIA Inc. All rights reserved.
|
* Copyright (c) 2021, NUVIA Inc. All rights reserved.
|
||||||
* Copyright (c) 2018, Hisilicon Limited. All rights reserved.
|
* Copyright (c) 2018, Hisilicon Limited. All rights reserved.
|
||||||
* Copyright (c) 2018, Linaro Limited. All rights reserved.
|
* Copyright (c) 2018, Linaro Limited. All rights reserved.
|
||||||
@@ -10,10 +11,12 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
|
#include <Guid/ZeroGuid.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/HiiLib.h>
|
#include <Library/HiiLib.h>
|
||||||
#include <Library/OemMiscLib.h>
|
#include <Library/OemMiscLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
|
||||||
/** Gets the CPU frequency of the specified processor.
|
/** Gets the CPU frequency of the specified processor.
|
||||||
|
|
||||||
@@ -236,3 +239,47 @@ OemGetChassisNumPowerCords (
|
|||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fetches the system UUID.
|
||||||
|
|
||||||
|
@param[out] SystemUuid The pointer to the buffer to store the System UUID.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
OemGetSystemUuid (
|
||||||
|
OUT GUID *SystemUuid
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT (FALSE);
|
||||||
|
CopyGuid (SystemUuid, &gZeroGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Fetches the BIOS release.
|
||||||
|
|
||||||
|
@return The BIOS release.
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
OemGetBiosRelease (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return PcdGet16 (PcdSystemBiosRelease);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Fetches the embedded controller firmware release.
|
||||||
|
|
||||||
|
@return The embedded controller firmware release.
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
OemGetEmbeddedControllerFirmwareRelease (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return PcdGet16 (PcdEmbeddedControllerFirmwareRelease);
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#/** @file
|
#/** @file
|
||||||
# OemMiscLib.inf
|
# OemMiscLib.inf
|
||||||
#
|
#
|
||||||
|
# Copyright (c) 2022, Ampere Computing LLC. All rights reserved.
|
||||||
# Copyright (c) 2021, NUVIA Inc. All rights reserved.
|
# Copyright (c) 2021, NUVIA Inc. All rights reserved.
|
||||||
# Copyright (c) 2018, Hisilicon Limited. All rights reserved.
|
# Copyright (c) 2018, Hisilicon Limited. All rights reserved.
|
||||||
# Copyright (c) 2018, Linaro Limited. All rights reserved.
|
# Copyright (c) 2018, Linaro Limited. All rights reserved.
|
||||||
@@ -29,3 +30,11 @@
|
|||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
BaseMemoryLib
|
BaseMemoryLib
|
||||||
DebugLib
|
DebugLib
|
||||||
|
PcdLib
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gZeroGuid
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gArmTokenSpaceGuid.PcdEmbeddedControllerFirmwareRelease
|
||||||
|
gArmTokenSpaceGuid.PcdSystemBiosRelease
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
ProcessorSubClass.c
|
ProcessorSubClass.c
|
||||||
|
|
||||||
|
Copyright (c) 2022, Ampere Computing LLC. All rights reserved.
|
||||||
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
||||||
Copyright (c) 2015, Hisilicon Limited. All rights reserved.
|
Copyright (c) 2015, Hisilicon Limited. All rights reserved.
|
||||||
Copyright (c) 2015, Linaro Limited. All rights reserved.
|
Copyright (c) 2015, Linaro Limited. All rights reserved.
|
||||||
@@ -512,7 +513,6 @@ AllocateType4AndSetProcessorInformationStrings (
|
|||||||
PartNumber = STRING_TOKEN (STR_PROCESSOR_PART_NUMBER);
|
PartNumber = STRING_TOKEN (STR_PROCESSOR_PART_NUMBER);
|
||||||
|
|
||||||
SET_HII_STRING_IF_PCD_NOT_EMPTY (PcdProcessorManufacturer, ProcessorManu);
|
SET_HII_STRING_IF_PCD_NOT_EMPTY (PcdProcessorManufacturer, ProcessorManu);
|
||||||
SET_HII_STRING_IF_PCD_NOT_EMPTY (PcdProcessorVersion, ProcessorVersion);
|
|
||||||
SET_HII_STRING_IF_PCD_NOT_EMPTY (PcdProcessorAssetTag, AssetTag);
|
SET_HII_STRING_IF_PCD_NOT_EMPTY (PcdProcessorAssetTag, AssetTag);
|
||||||
|
|
||||||
if (StrLen ((CHAR16 *)FixedPcdGetPtr (PcdProcessorSerialNumber)) > 0) {
|
if (StrLen ((CHAR16 *)FixedPcdGetPtr (PcdProcessorSerialNumber)) > 0) {
|
||||||
@@ -527,6 +527,12 @@ AllocateType4AndSetProcessorInformationStrings (
|
|||||||
OemUpdateSmbiosInfo (mHiiHandle, PartNumber, ProcessorPartNumType04);
|
OemUpdateSmbiosInfo (mHiiHandle, PartNumber, ProcessorPartNumType04);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StrLen ((CHAR16 *)FixedPcdGetPtr (PcdProcessorVersion)) > 0) {
|
||||||
|
HiiSetString (mHiiHandle, ProcessorVersion, (CHAR16 *)FixedPcdGetPtr (PcdProcessorVersion), NULL);
|
||||||
|
} else {
|
||||||
|
OemUpdateSmbiosInfo (mHiiHandle, ProcessorVersion, ProcessorVersionType04);
|
||||||
|
}
|
||||||
|
|
||||||
// Processor Designation
|
// Processor Designation
|
||||||
StringBufferSize = sizeof (CHAR16) * SMBIOS_STRING_MAX_LENGTH;
|
StringBufferSize = sizeof (CHAR16) * SMBIOS_STRING_MAX_LENGTH;
|
||||||
ProcessorStr = AllocateZeroPool (StringBufferSize);
|
ProcessorStr = AllocateZeroPool (StringBufferSize);
|
||||||
@@ -735,7 +741,7 @@ AddSmbiosProcessorTypeTable (
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"[%a]:[%dL] Smbios Type04 Table Log Failed! %r \n",
|
"[%a]:[%dL] Smbios Type04 Table Log Failed! %r \n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
DEBUG_LINE_NUMBER,
|
DEBUG_LINE_NUMBER,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
Functions for processor information common to ARM and AARCH64.
|
Functions for processor information common to ARM and AARCH64.
|
||||||
|
|
||||||
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
||||||
Copyright (c) 2021, Ampere Computing LLC. All rights reserved.<BR>
|
Copyright (c) 2021 - 2022, Ampere Computing LLC. All rights reserved.<BR>
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ SmbiosGetSmcArm64SocId (
|
|||||||
SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
|
SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
|
||||||
|
|
||||||
if (SmcCallStatus >= 0) {
|
if (SmcCallStatus >= 0) {
|
||||||
*Jep106Code = (INT32)SmcParam;
|
*Jep106Code = SmcCallStatus;
|
||||||
} else {
|
} else {
|
||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ SmbiosGetSmcArm64SocId (
|
|||||||
SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
|
SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
|
||||||
|
|
||||||
if (SmcCallStatus >= 0) {
|
if (SmcCallStatus >= 0) {
|
||||||
*SocRevision = (INT32)SmcParam;
|
*SocRevision = SmcCallStatus;
|
||||||
} else {
|
} else {
|
||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
|
|
||||||
|
Copyright (c) 2022 - 2023, Ampere Computing LLC. All rights reserved.<BR>
|
||||||
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
||||||
Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
|
||||||
Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
|
Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/HiiLib.h>
|
#include <Library/HiiLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/OemMiscLib.h>
|
||||||
#include <Library/PrintLib.h>
|
#include <Library/PrintLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
|
||||||
@@ -122,22 +124,47 @@ GetBiosReleaseDate (
|
|||||||
return ReleaseDate;
|
return ReleaseDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Fetches the Firmware version string for SMBIOS type 0
|
||||||
Fetches the firmware ('BIOS') version from the
|
|
||||||
FirmwareVersionInfo HOB.
|
This function first acquires the firmware version string from OemMiscLib;
|
||||||
|
if it is invalid, PcdFirmwareVersionString is used as a fallback,
|
||||||
|
and then sets it in SMBIOS type 0.
|
||||||
|
|
||||||
@return The version as a UTF-16 string
|
|
||||||
**/
|
**/
|
||||||
CHAR16 *
|
VOID
|
||||||
GetBiosVersion (
|
SetBiosVersion (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CHAR16 *ReleaseString;
|
CHAR16 *DefaultVersionString;
|
||||||
|
CHAR16 *Version;
|
||||||
|
EFI_STRING_ID TokenToUpdate;
|
||||||
|
|
||||||
ReleaseString = (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVersionString);
|
DefaultVersionString = HiiGetString (
|
||||||
|
mSmbiosMiscHiiHandle,
|
||||||
|
STRING_TOKEN (STR_MISC_BIOS_VERSION),
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
return ReleaseString;
|
OemUpdateSmbiosInfo (
|
||||||
|
mSmbiosMiscHiiHandle,
|
||||||
|
STRING_TOKEN (STR_MISC_BIOS_VERSION),
|
||||||
|
BiosVersionType00
|
||||||
|
);
|
||||||
|
|
||||||
|
Version = HiiGetString (
|
||||||
|
mSmbiosMiscHiiHandle,
|
||||||
|
STRING_TOKEN (STR_MISC_BIOS_VERSION),
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (((StrCmp (Version, DefaultVersionString) == 0) || (StrLen (Version) == 0))) {
|
||||||
|
Version = (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVersionString);
|
||||||
|
if (StrLen (Version) > 0) {
|
||||||
|
TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);
|
||||||
|
HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,18 +212,7 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscBiosVendor) {
|
|||||||
HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Vendor, NULL);
|
HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Vendor, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Version = GetBiosVersion ();
|
SetBiosVersion ();
|
||||||
|
|
||||||
if (StrLen (Version) > 0) {
|
|
||||||
TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);
|
|
||||||
HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL);
|
|
||||||
} else {
|
|
||||||
Version = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);
|
|
||||||
if (StrLen (Version) > 0) {
|
|
||||||
TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);
|
|
||||||
HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Char16String = GetBiosReleaseDate ();
|
Char16String = GetBiosReleaseDate ();
|
||||||
if (StrLen (Char16String) > 0) {
|
if (StrLen (Char16String) > 0) {
|
||||||
@@ -251,13 +267,11 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscBiosVendor) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SmbiosRecord->SystemBiosMajorRelease = (UINT8)(PcdGet16 (PcdSystemBiosRelease) >> 8);
|
SmbiosRecord->SystemBiosMajorRelease = (UINT8)(OemGetBiosRelease () >> 8);
|
||||||
SmbiosRecord->SystemBiosMinorRelease = (UINT8)(PcdGet16 (PcdSystemBiosRelease) & 0xFF);
|
SmbiosRecord->SystemBiosMinorRelease = (UINT8)(OemGetBiosRelease () & 0xFF);
|
||||||
|
|
||||||
SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = (UINT16)
|
SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = (UINT16)(OemGetEmbeddedControllerFirmwareRelease () >> 8);
|
||||||
(PcdGet16 (PcdEmbeddedControllerFirmwareRelease) >> 8);
|
SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = (UINT16)(OemGetEmbeddedControllerFirmwareRelease () & 0xFF);
|
||||||
SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = (UINT16)
|
|
||||||
(PcdGet16 (PcdEmbeddedControllerFirmwareRelease) & 0xFF);
|
|
||||||
|
|
||||||
OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
|
OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
|
||||||
UnicodeStrToAsciiStrS (Vendor, OptionalStrStart, VendorStrLen + 1);
|
UnicodeStrToAsciiStrS (Vendor, OptionalStrStart, VendorStrLen + 1);
|
||||||
@@ -273,7 +287,7 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscBiosVendor) {
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"[%a]:[%dL] Smbios Type00 Table Log Failed! %r \n",
|
"[%a]:[%dL] Smbios Type00 Table Log Failed! %r \n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
DEBUG_LINE_NUMBER,
|
DEBUG_LINE_NUMBER,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
|
Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
|
||||||
|
|
||||||
|
Copyright (c) 2022, Ampere Computing LLC. All rights reserved.<BR>
|
||||||
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
|
Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
|
||||||
@@ -160,7 +161,7 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscSystemManufacturer) {
|
|||||||
|
|
||||||
SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);
|
SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);
|
||||||
|
|
||||||
CopyGuid (&SmbiosRecord->Uuid, &InputData->Uuid);
|
OemGetSystemUuid (&SmbiosRecord->Uuid);
|
||||||
|
|
||||||
OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
|
OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
|
||||||
UnicodeStrToAsciiStrS (Manufacturer, OptionalStrStart, ManuStrLen + 1);
|
UnicodeStrToAsciiStrS (Manufacturer, OptionalStrStart, ManuStrLen + 1);
|
||||||
@@ -183,7 +184,7 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscSystemManufacturer) {
|
|||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"[%a]:[%dL] Smbios Type01 Table Log Failed! %r \n",
|
"[%a]:[%dL] Smbios Type01 Table Log Failed! %r \n",
|
||||||
__FUNCTION__,
|
__func__,
|
||||||
DEBUG_LINE_NUMBER,
|
DEBUG_LINE_NUMBER,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user