mirror of https://github.com/ventoy/Ventoy
Compare commits
599 Commits
Author | SHA1 | Date |
---|---|---|
|
cb209f9b9e | 3 weeks ago |
|
b7b2f6a5c1 | 3 weeks ago |
|
3967fb5fb5 | 3 weeks ago |
|
a2ad95792d | 3 weeks ago |
|
791308d2ce | 3 weeks ago |
|
0ffb1b15ef | 1 month ago |
|
d6e1730ca0 | 1 month ago |
|
4d55f505f9 | 1 month ago |
|
30a61ac5c4 | 1 month ago |
|
9b79831516 | 1 month ago |
|
af2d6bc247 | 1 month ago |
|
d8ae740427 | 1 month ago |
|
b685157ae3 | 1 month ago |
|
3f6ddb6fb6 | 1 month ago |
|
b8838b305d | 1 month ago |
|
00de8b932d | 1 month ago |
|
1e49dbe957 | 1 month ago |
|
580416facc | 1 month ago |
|
75cf728fa9 | 1 month ago |
|
8723aeb4cc | 1 month ago |
|
dc9a99bb20 | 1 month ago |
|
a40456d9d2 | 1 month ago |
|
bdab55e8aa | 1 month ago |
|
1b2483ec14 | 1 month ago |
|
c16e76130b | 1 month ago |
|
d672af4819 | 1 month ago |
|
712f10e86a | 2 months ago |
|
2be340d2e8 | 2 months ago |
|
b77ef718b4 | 2 months ago |
|
72f5710b88 | 2 months ago |
|
ee7da60d88 | 3 months ago |
|
44fb9f4564 | 3 months ago |
|
3f65f0ef03 | 5 months ago |
|
4faa5e4344 | 5 months ago |
|
c7693d4ecd | 5 months ago |
|
4527e1db79 | 5 months ago |
|
757cacf274 | 7 months ago |
|
39703cabb7 | 9 months ago |
|
854d17a4e9 | 9 months ago |
|
a326b13fc3 | 9 months ago |
|
3ff1867a2a | 9 months ago |
|
7f63a1c327 | 9 months ago |
|
d617985093 | 9 months ago |
|
605da1ba94 | 9 months ago |
|
c8dc36a5c3 | 10 months ago |
|
689f7df902 | 10 months ago |
|
a9d53e7448 | 10 months ago |
|
46061bcd41 | 10 months ago |
|
01b0de7811 | 10 months ago |
|
2fee243a56 | 10 months ago |
|
d0e10f8e48 | 11 months ago |
|
7ff243f9bb | 11 months ago |
|
f8811a4656 | 12 months ago |
|
0ce90ad9b9 | 12 months ago |
|
5bfddae81d | 12 months ago |
|
2991f097fb | 12 months ago |
|
986835338d | 12 months ago |
|
f2562fecb9 | 12 months ago |
|
529541f218 | 12 months ago |
|
430f81ac49 | 1 year ago |
|
038c0533d9 | 1 year ago |
|
102b179cd9 | 1 year ago |
|
6785f5d049 | 1 year ago |
|
0c812ed5e9 | 1 year ago |
|
9f2b9b0867 | 1 year ago |
|
c79b072680 | 1 year ago |
|
6b4509a550 | 1 year ago |
|
feea11e2bb | 1 year ago |
|
35c952d891 | 1 year ago |
|
82053680bf | 1 year ago |
|
6d5de12f52 | 1 year ago |
|
84b2ee7ee3 | 1 year ago |
|
da1b306e81 | 1 year ago |
|
0961ce5624 | 1 year ago |
|
07574f0379 | 1 year ago |
|
142aa47944 | 1 year ago |
|
11739fa9d0 | 1 year ago |
|
9fc85051a7 | 1 year ago |
|
b9e82bcf16 | 1 year ago |
|
cff3a01289 | 1 year ago |
|
0f90149c4e | 1 year ago |
|
8ef9732931 | 1 year ago |
|
b32eda4262 | 1 year ago |
|
e743f7c15f | 1 year ago |
|
652475f1ef | 1 year ago |
|
abfc2a6343 | 1 year ago |
|
e73ac04cb6 | 1 year ago |
|
8727e63880 | 1 year ago |
|
2d281d7dee | 1 year ago |
|
385c806adf | 1 year ago |
|
e869bc2386 | 1 year ago |
|
b47aa1abc7 | 1 year ago |
|
d8698b2194 | 1 year ago |
|
7fa4724743 | 1 year ago |
|
2717405a7a | 1 year ago |
|
d494007df9 | 1 year ago |
|
bc9e3f641b | 1 year ago |
|
9f02d37001 | 1 year ago |
|
fa1461bac7 | 1 year ago |
|
3d56c3fa17 | 1 year ago |
|
a7e3d78d14 | 1 year ago |
|
879a7592bd | 1 year ago |
|
5a433f49f7 | 1 year ago |
|
0cce956c54 | 1 year ago |
|
0b6372857c | 1 year ago |
|
028663de9a | 1 year ago |
|
5feb3f7b4b | 1 year ago |
|
7035787f38 | 1 year ago |
|
7dd0f509f5 | 1 year ago |
|
15947caea2 | 1 year ago |
|
6aeba8f8b4 | 1 year ago |
|
fd46b2c3c3 | 1 year ago |
|
e502f4291e | 1 year ago |
|
9c59c27eff | 1 year ago |
|
daeb96ce80 | 1 year ago |
|
b7e878c466 | 1 year ago |
|
b76ebf5b07 | 1 year ago |
|
9532776f39 | 1 year ago |
|
d8e81d41e4 | 1 year ago |
|
fa3aa3b36f | 1 year ago |
|
e717d00d53 | 1 year ago |
|
6bcaf19a1a | 1 year ago |
|
bcbe8835d4 | 1 year ago |
|
ed746ce13e | 1 year ago |
|
07a790fc6a | 1 year ago |
|
fd393a02fd | 1 year ago |
|
0501d03dbb | 1 year ago |
|
c9939a8cfc | 1 year ago |
|
5067020a61 | 1 year ago |
|
4f5334026e | 1 year ago |
|
3e34dd8514 | 1 year ago |
|
4df793e021 | 1 year ago |
|
e0132ac4b5 | 1 year ago |
|
2b3192b098 | 1 year ago |
|
7ee3a6d9f8 | 1 year ago |
|
e1d3ca9fc4 | 1 year ago |
|
8653832551 | 1 year ago |
|
c308892db0 | 1 year ago |
|
1300f7f4f1 | 1 year ago |
|
d9182dbfa4 | 1 year ago |
|
e988c0dfe2 | 1 year ago |
|
0714971f8c | 2 years ago |
|
3c03df31ce | 2 years ago |
|
e24dacadcd | 2 years ago |
|
315cabb945 | 2 years ago |
|
72f25f14fc | 2 years ago |
|
47e1553d23 | 2 years ago |
|
9a2a7e83eb | 2 years ago |
|
5f747148c6 | 2 years ago |
|
686ed11037 | 2 years ago |
|
7fe4762faa | 2 years ago |
|
eac1c35f76 | 2 years ago |
|
c7dcaa5734 | 2 years ago |
|
4b17ee30c4 | 2 years ago |
|
a18aa36c01 | 2 years ago |
|
1de7489c6d | 2 years ago |
|
afb3340ce7 | 2 years ago |
|
fdce4a756a | 2 years ago |
|
5a7fa0c565 | 2 years ago |
|
287d77224c | 2 years ago |
|
c6bd857cbe | 2 years ago |
|
b4bb6efd3c | 2 years ago |
|
7386f64ed8 | 2 years ago |
|
044ca8811d | 2 years ago |
|
8c6fd872af | 2 years ago |
|
683101ae1a | 2 years ago |
|
0e968e266e | 2 years ago |
|
d94d59583a | 2 years ago |
|
05bbef63c1 | 2 years ago |
|
8923d4b8f1 | 2 years ago |
|
377cd9e468 | 2 years ago |
|
be78728342 | 2 years ago |
|
3938fbb351 | 2 years ago |
|
a2e7afd893 | 2 years ago |
|
27bb4a1168 | 2 years ago |
|
b8b8c7bd66 | 2 years ago |
|
12b51bcf09 | 2 years ago |
|
911d5dcab9 | 2 years ago |
|
f597497da6 | 2 years ago |
|
54bca8c942 | 2 years ago |
|
6b422ad9c1 | 2 years ago |
|
925d057883 | 2 years ago |
|
a377dd6172 | 2 years ago |
|
4707022ef9 | 2 years ago |
|
e03c73978a | 2 years ago |
|
f434d1f5d0 | 2 years ago |
|
23f8bc8aeb | 2 years ago |
|
f2016ab899 | 2 years ago |
|
7acbf7e819 | 2 years ago |
|
0135bf1934 | 2 years ago |
|
f2c94bd963 | 2 years ago |
|
676ae725ae | 2 years ago |
|
54dd35d277 | 2 years ago |
|
3e75b2df3b | 2 years ago |
|
2d1230cba4 | 2 years ago |
|
309f85fd35 | 2 years ago |
|
a13d6d9c0e | 2 years ago |
|
9b7d6cbc3d | 2 years ago |
|
bf797ceadb | 2 years ago |
|
cd0c7ca884 | 2 years ago |
|
201f7cc13c | 2 years ago |
|
44a3e23740 | 2 years ago |
|
9c3e1a6880 | 2 years ago |
|
8a664faa04 | 2 years ago |
|
398ba9fb56 | 2 years ago |
|
e7a0c2d359 | 2 years ago |
|
22ad828df2 | 2 years ago |
|
83f22173a5 | 2 years ago |
|
2de7d9ffe0 | 2 years ago |
|
5c174c4521 | 2 years ago |
|
c76ece4b74 | 2 years ago |
|
27eda4d1e7 | 2 years ago |
|
acf5a84467 | 2 years ago |
|
c93e406aa5 | 2 years ago |
|
1b164e74e4 | 2 years ago |
|
308cb86f83 | 2 years ago |
|
2ec593d355 | 2 years ago |
|
594e735b91 | 2 years ago |
|
6203366040 | 2 years ago |
|
64f4400305 | 2 years ago |
|
d00e08e2e1 | 2 years ago |
|
c6008be394 | 2 years ago |
|
a5c6859f5f | 2 years ago |
|
497d4cc991 | 2 years ago |
|
7e7687afe3 | 2 years ago |
|
dd3276badf | 2 years ago |
|
4a06f4a694 | 2 years ago |
|
c73bf256be | 2 years ago |
|
21851f7e96 | 2 years ago |
|
f222f8cac9 | 2 years ago |
|
40c4825aac | 2 years ago |
|
dd906e0b16 | 2 years ago |
|
324f2b927c | 2 years ago |
|
5797ca3396 | 2 years ago |
|
b36b322c03 | 2 years ago |
|
fd7e34b632 | 2 years ago |
|
e85c02756b | 2 years ago |
|
c1d68bd787 | 2 years ago |
|
a35a822723 | 2 years ago |
|
05137c83e2 | 2 years ago |
|
8058856182 | 2 years ago |
|
33b958e112 | 2 years ago |
|
9eb50a85e4 | 2 years ago |
|
3cc7e3772e | 2 years ago |
|
9c8292867f | 2 years ago |
|
a4053d2d05 | 2 years ago |
|
5c14ea0a4a | 2 years ago |
|
194e948cb6 | 2 years ago |
|
c896c03efe | 2 years ago |
|
574b4d850c | 2 years ago |
|
68a98325e6 | 2 years ago |
|
25b055bb0f | 2 years ago |
|
bda74cd89b | 2 years ago |
|
511b8091eb | 2 years ago |
|
3be4aacd78 | 2 years ago |
|
2d8b27b172 | 2 years ago |
|
c174410d35 | 2 years ago |
|
f83e84f868 | 2 years ago |
|
a39078b87a | 2 years ago |
|
2576235f97 | 2 years ago |
|
ee04af5243 | 2 years ago |
|
118bedd546 | 2 years ago |
|
44ff3dd8d4 | 2 years ago |
|
9da5a6ce65 | 2 years ago |
|
604b25ec82 | 2 years ago |
|
0918355035 | 2 years ago |
|
ce76fd5649 | 2 years ago |
|
42535f35bc | 2 years ago |
|
68a9cebe19 | 2 years ago |
|
cc77c74bf4 | 2 years ago |
|
ee952e3f69 | 2 years ago |
|
b11a499939 | 2 years ago |
|
fdf4693433 | 2 years ago |
|
ac65c0fb24 | 2 years ago |
|
ea0afe7c8b | 2 years ago |
|
f8ca8b13d3 | 2 years ago |
|
678a2abdf1 | 2 years ago |
|
e645301713 | 2 years ago |
|
43b415c032 | 2 years ago |
|
311d2961ca | 2 years ago |
|
1d66584190 | 2 years ago |
|
553c853865 | 2 years ago |
|
7d90912a09 | 2 years ago |
|
c2336f555a | 2 years ago |
|
87391e8b32 | 2 years ago |
|
f9c56c6686 | 2 years ago |
|
1ab1799b72 | 2 years ago |
|
4a42bdfce7 | 2 years ago |
|
3f09fb9a23 | 2 years ago |
|
c87ad1d734 | 2 years ago |
|
5590208885 | 2 years ago |
|
09a6d33d62 | 2 years ago |
|
9852252aba | 2 years ago |
|
0585d83a8f | 2 years ago |
|
ebe0b7d282 | 2 years ago |
|
261ddcef45 | 2 years ago |
|
ebc5e2e993 | 2 years ago |
|
d58bd8c3f7 | 2 years ago |
|
17f9e2fd09 | 2 years ago |
|
6b22a6200e | 2 years ago |
|
860dce6683 | 2 years ago |
|
7fc72d5ce6 | 2 years ago |
|
b7c3cbd23b | 2 years ago |
|
3de97bdf44 | 2 years ago |
|
e79dc57ebe | 2 years ago |
|
7bf85a1ef8 | 2 years ago |
|
a5e0641226 | 2 years ago |
|
2c65eec9ec | 2 years ago |
|
0c310c5bd8 | 2 years ago |
|
c81b49807b | 2 years ago |
|
085e20f64d | 2 years ago |
|
ff3ce4da66 | 2 years ago |
|
81d3492a61 | 2 years ago |
|
635b1a1c6c | 2 years ago |
|
10b80f2690 | 2 years ago |
|
36c21a21e4 | 2 years ago |
|
13eb9829fa | 2 years ago |
|
88f77c01e4 | 2 years ago |
|
11b30dab5f | 2 years ago |
|
fb729146de | 2 years ago |
|
92bd6733dd | 2 years ago |
|
9e28dd1394 | 2 years ago |
|
4100e7a886 | 2 years ago |
|
a4f5ce2c9e | 2 years ago |
|
c7967ea476 | 2 years ago |
|
3e7f1ca764 | 2 years ago |
|
1bc18295ae | 2 years ago |
|
b4f1f11742 | 2 years ago |
|
20010c5e88 | 2 years ago |
|
1de18e43c5 | 2 years ago |
|
15299d4d87 | 2 years ago |
|
5d6d6df39b | 2 years ago |
|
096cc99c3c | 2 years ago |
|
602e8c7fdf | 2 years ago |
|
da35a99f7c | 2 years ago |
|
e46e24dde7 | 2 years ago |
|
0b81845e42 | 2 years ago |
|
3c621e4aca | 2 years ago |
|
aecc579fcc | 2 years ago |
|
598af7f45c | 2 years ago |
|
24b05c0345 | 2 years ago |
|
6d72617ef6 | 2 years ago |
|
351f15ff18 | 2 years ago |
|
1ee65a60c2 | 2 years ago |
|
ecbf45defe | 2 years ago |
|
b976923f00 | 2 years ago |
|
8db8e07b61 | 2 years ago |
|
f200c14730 | 2 years ago |
|
c090197717 | 2 years ago |
|
3ac17aa825 | 2 years ago |
|
595b9441e9 | 2 years ago |
|
0f3d48b3d9 | 2 years ago |
|
61f289aa8a | 2 years ago |
|
b099547af6 | 2 years ago |
|
23bd2d24e9 | 2 years ago |
|
85d1910722 | 2 years ago |
|
9b2b4aa354 | 2 years ago |
|
45122b59c0 | 2 years ago |
|
5e607b7f9f | 2 years ago |
|
1c0b4ee903 | 2 years ago |
|
bf2517bb25 | 2 years ago |
|
1065a41992 | 2 years ago |
|
954cb14d87 | 2 years ago |
|
4f64aecfa3 | 2 years ago |
|
8af432b74b | 2 years ago |
|
d8bca311b2 | 2 years ago |
|
025425f260 | 2 years ago |
|
b4120c4079 | 2 years ago |
|
7f2f845a68 | 2 years ago |
|
2cd22da8fb | 2 years ago |
|
7b70a5278a | 2 years ago |
|
f8b1f98304 | 2 years ago |
|
ddf0617d83 | 2 years ago |
|
9b14b418b4 | 2 years ago |
|
fe137522ad | 2 years ago |
|
121d927367 | 2 years ago |
|
75f3e4c5ee | 2 years ago |
|
fcf10deff3 | 2 years ago |
|
4d4f958429 | 2 years ago |
|
e667233994 | 2 years ago |
|
57944520e5 | 2 years ago |
|
4544e221d3 | 2 years ago |
|
3263b64b8a | 2 years ago |
|
69da3a59d8 | 2 years ago |
|
75c6c7257f | 2 years ago |
|
d4d8736620 | 2 years ago |
|
63f9331c31 | 2 years ago |
|
e1d161af4f | 2 years ago |
|
9baa95359c | 2 years ago |
|
5f3d7f3823 | 2 years ago |
|
3d1dc81fda | 2 years ago |
|
3ebc610e7d | 2 years ago |
|
60588c8442 | 2 years ago |
|
c4c05fc073 | 2 years ago |
|
0984f5ba58 | 2 years ago |
|
fd0d335eb6 | 2 years ago |
|
12a284b543 | 2 years ago |
|
9e2e4ec0a9 | 2 years ago |
|
480afee1a7 | 2 years ago |
|
1305945bc0 | 2 years ago |
|
2feb148982 | 2 years ago |
|
5eec535391 | 2 years ago |
|
33a562c273 | 2 years ago |
|
75517039a1 | 2 years ago |
|
620229508b | 2 years ago |
|
5553dd4fc4 | 2 years ago |
|
89addae48f | 2 years ago |
|
682e8cdc42 | 2 years ago |
|
1882cfcce2 | 2 years ago |
|
b8be46f0dc | 2 years ago |
|
07693bf840 | 2 years ago |
|
b4a059dd68 | 2 years ago |
|
858eec99a1 | 2 years ago |
|
8180382fe1 | 2 years ago |
|
a5d9b1fd43 | 2 years ago |
|
8b76e06f6d | 2 years ago |
|
ecb133ed5e | 2 years ago |
|
da20eb5568 | 2 years ago |
|
2d76fa7303 | 2 years ago |
|
8fc8cc6867 | 2 years ago |
|
132649c4e5 | 2 years ago |
|
c3c8100866 | 2 years ago |
|
94e24e63c5 | 2 years ago |
|
c19cd649d8 | 2 years ago |
|
20914350fb | 2 years ago |
|
8b411663cf | 2 years ago |
|
01292939d3 | 2 years ago |
|
dcc5889677 | 2 years ago |
|
04828df028 | 2 years ago |
|
2f95139c77 | 2 years ago |
|
f2bb3667c4 | 2 years ago |
|
791da48673 | 2 years ago |
|
f683bcbd59 | 2 years ago |
|
15b8b1f358 | 2 years ago |
|
a20592ecd1 | 2 years ago |
|
ed1aa3d5be | 2 years ago |
|
8e66110374 | 2 years ago |
|
f5f65aa868 | 2 years ago |
|
4e5fcf211b | 2 years ago |
|
9789069c0d | 2 years ago |
|
1cf45ac0c5 | 2 years ago |
|
40fe21f909 | 2 years ago |
|
e6bdf075ca | 2 years ago |
|
7c76e57bf4 | 2 years ago |
|
7fe038b697 | 2 years ago |
|
c01c69db3b | 2 years ago |
|
0e996e74c9 | 2 years ago |
|
1371159f0b | 2 years ago |
|
44b38dce74 | 2 years ago |
|
392d8ef4fa | 2 years ago |
|
d1900c75cd | 2 years ago |
|
fa7e1d5fa0 | 2 years ago |
|
6ae8bf840d | 2 years ago |
|
ce862da402 | 2 years ago |
|
6d4f5ff00b | 2 years ago |
|
ab0f25d097 | 2 years ago |
|
ff14c07c4e | 2 years ago |
|
f7fac26c91 | 2 years ago |
|
ebae102f41 | 2 years ago |
|
c3718d6001 | 2 years ago |
|
d0744513a6 | 2 years ago |
|
5b0fca8468 | 2 years ago |
|
27918eb3f9 | 2 years ago |
|
7859271b20 | 2 years ago |
|
1c27c0b489 | 2 years ago |
|
0f89c2767f | 2 years ago |
|
d1584c10b4 | 2 years ago |
|
43e921878b | 2 years ago |
|
23f4f18e27 | 2 years ago |
|
53b95ae17b | 2 years ago |
|
e3506c0f10 | 2 years ago |
|
9118d5fe45 | 2 years ago |
|
f130325a9c | 2 years ago |
|
1ca48923da | 2 years ago |
|
730fdd5198 | 2 years ago |
|
d0f3597b26 | 2 years ago |
|
045f53d768 | 2 years ago |
|
a173acaf17 | 2 years ago |
|
96fdd594f0 | 2 years ago |
|
62dc0033ad | 2 years ago |
|
1c3fcbdfe9 | 2 years ago |
|
7d37cab21d | 2 years ago |
|
a1c6fe2d24 | 2 years ago |
|
dbeb4023a2 | 2 years ago |
|
58b1bbe0b5 | 2 years ago |
|
86b13727ca | 2 years ago |
|
006f26d07d | 2 years ago |
|
9203aa1ab3 | 2 years ago |
|
5291d66736 | 2 years ago |
|
ba5978d298 | 2 years ago |
|
7f717a7fe9 | 2 years ago |
|
c57717aea2 | 2 years ago |
|
be0e19fc5b | 2 years ago |
|
34a36bfc3e | 2 years ago |
|
82e99a3b37 | 2 years ago |
|
b685431d66 | 2 years ago |
|
8be8fd50b3 | 2 years ago |
|
999b15c4ef | 2 years ago |
|
28998edd94 | 2 years ago |
|
2ad69decad | 2 years ago |
|
c2cc0bd3dc | 2 years ago |
|
b128a0b6d3 | 3 years ago |
|
676831dbbe | 3 years ago |
|
e5fa5e6d84 | 3 years ago |
|
76a6b8061c | 3 years ago |
|
036b58ff0c | 3 years ago |
|
8e529c8559 | 3 years ago |
|
b8e624b0a0 | 3 years ago |
|
1f49265f29 | 3 years ago |
|
25dc323522 | 3 years ago |
|
446597d880 | 3 years ago |
|
b9b6852631 | 3 years ago |
|
4a44a82840 | 3 years ago |
|
f2e82862ab | 3 years ago |
|
368151aa3b | 3 years ago |
|
b5dcaecffe | 3 years ago |
|
a4cfbd6799 | 3 years ago |
|
ab964932cb | 3 years ago |
|
bcc81d31db | 3 years ago |
|
91330b97bf | 3 years ago |
|
fe7b9abcff | 3 years ago |
|
68d3b55167 | 3 years ago |
|
e1c26567a1 | 3 years ago |
|
4131d95cef | 3 years ago |
|
8c18f91ac1 | 3 years ago |
|
73fabd0c65 | 3 years ago |
|
0c140cf378 | 3 years ago |
|
293f677cbf | 3 years ago |
|
4bf43ab9d4 | 3 years ago |
|
9eeb94e8b5 | 3 years ago |
|
f4987fd7f4 | 3 years ago |
|
157c6f13ec | 3 years ago |
|
6a506ee7f3 | 3 years ago |
|
32643ecdbb | 3 years ago |
|
d2e5930520 | 3 years ago |
|
944f376ffe | 3 years ago |
|
d402338ade | 3 years ago |
|
d938100eeb | 3 years ago |
|
a4200ed99e | 3 years ago |
|
e4ccd5115e | 3 years ago |
|
cdb727dd22 | 3 years ago |
|
6b4093fb93 | 3 years ago |
|
21450d4a56 | 3 years ago |
|
164c8d6505 | 3 years ago |
|
37e7a539f9 | 3 years ago |
|
b5a649f96f | 3 years ago |
|
443a1344f2 | 3 years ago |
|
d3de1a91f8 | 3 years ago |
|
580ad598f6 | 3 years ago |
|
0891e34d47 | 3 years ago |
|
4d777090cb | 3 years ago |
|
b0568922d2 | 3 years ago |
|
69b6bb8fca | 3 years ago |
|
3d686c27d7 | 3 years ago |
|
90ba217ec7 | 3 years ago |
|
fab070ef64 | 3 years ago |
|
b3869b6894 | 3 years ago |
|
563214ed40 | 3 years ago |
|
b67f738b00 | 3 years ago |
|
a9c539572b | 3 years ago |
|
32602a79ab | 3 years ago |
|
863eafd2cc | 3 years ago |
|
0f135b6646 | 3 years ago |
|
675c24ffa3 | 3 years ago |
|
cd309eb663 | 3 years ago |
|
5cdd6540a4 | 3 years ago |
|
fde2e4430c | 3 years ago |
|
9a471f4956 | 3 years ago |
|
1f3b3afa35 | 3 years ago |
|
6947f2a047 | 3 years ago |
|
0a15e4e427 | 3 years ago |
|
e763d7590f | 3 years ago |
|
f842d46f90 | 3 years ago |
|
cc1cc6c301 | 3 years ago |
|
9f3d209798 | 3 years ago |
|
fc742244ab | 3 years ago |
|
3e66227dae | 3 years ago |
|
f32d342f66 | 3 years ago |
|
09d7ae68e7 | 3 years ago |
|
68fefbc1fc | 3 years ago |
|
8d893d4c94 | 3 years ago |
|
84798a4f7a | 3 years ago |
|
87f88eeb2b | 3 years ago |
|
7b2615744c | 3 years ago |
|
d7faff4438 | 3 years ago |
|
f15dfd7409 | 3 years ago |
|
09162e8d97 | 3 years ago |
|
eb8fcc8f30 | 3 years ago |
|
5fcb3971bc | 3 years ago |
|
e47e4484ce | 3 years ago |
|
7e26decb31 | 3 years ago |
|
e713946fd0 | 3 years ago |
|
a93b0f6656 | 3 years ago |
|
836e1aa11e | 3 years ago |
|
154bbc6e5f | 3 years ago |
|
d151e74336 | 3 years ago |
|
df87cafdfb | 3 years ago |
|
09494a5b23 | 3 years ago |
|
e15a1c5ece | 3 years ago |
@ -0,0 +1,101 @@
|
||||
name: Success Image Report
|
||||
description: To report an image file that boot successfully in Ventoy and is not yet listed in https://www.ventoy.net/en/isolist.html
|
||||
title: "[Success Image Report]: "
|
||||
assignees:
|
||||
- octocat
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
I list all the successfully tested image files in the official website: https://www.ventoy.net/en/isolist.html
|
||||
If you successfully test an image file which is not listed in the above page, you can tell me and I will be very glad to add it to the tested list.
|
||||
- type: checkboxes
|
||||
id: faq
|
||||
attributes:
|
||||
label: Official Website List
|
||||
description: Have you checked the list at [https://www.ventoy.net/en/isolist.html](https://www.ventoy.net/en/isolist.html) and the image file is not listed?
|
||||
options:
|
||||
- label: I have checked the list in official website and the image file is not listed there.
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Ventoy Version
|
||||
description: What version of ventoy did you test with the image file.
|
||||
placeholder: 1.0.57
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: bios
|
||||
attributes:
|
||||
label: BIOS Mode
|
||||
description: In which BIOS mode did you successfully test the image file? (It's recommended to test in both mode)
|
||||
options:
|
||||
- Legacy BIOS Mode
|
||||
- UEFI Mode
|
||||
- Both
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: partstyle
|
||||
attributes:
|
||||
label: Partition Style
|
||||
description: Which partition style did you use with Ventoy?
|
||||
options:
|
||||
- MBR
|
||||
- GPT
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: filename
|
||||
attributes:
|
||||
label: Image file name
|
||||
description: The successfully tested image file name.
|
||||
placeholder: xxxx.iso
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: checksum
|
||||
attributes:
|
||||
label: Image file checksum type
|
||||
description:
|
||||
options:
|
||||
- MD5
|
||||
- SHA1
|
||||
- SHA256
|
||||
- SHA512
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: checkvalue
|
||||
attributes:
|
||||
label: Image file checksum value
|
||||
description: What is the image file checksum value corresponding to the above checksum type?
|
||||
placeholder: xxxx
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: link
|
||||
attributes:
|
||||
label: Image file download link (if applicable)
|
||||
description: What is the image file download link?
|
||||
placeholder: https://xxx
|
||||
validations:
|
||||
required: false
|
||||
- type: input
|
||||
id: testenv
|
||||
attributes:
|
||||
label: Test environment
|
||||
description: The manufacturer/model and other details about your computer (or VM).
|
||||
placeholder: Lenovo Thinkpad T420 laptop
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: details
|
||||
attributes:
|
||||
label: More Details?
|
||||
description: You can give more details here.
|
||||
value: "This image file booted successfully in Ventoy."
|
||||
validations:
|
||||
required: false
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
|
||||
obj-m += dm_patch.o
|
||||
|
||||
EXTRA_CFLAGS := -Wall
|
||||
|
||||
dm_patch-objs := dmpatch.o
|
||||
|
@ -0,0 +1,7 @@
|
||||
|
||||
obj-m += dm_patch_ibt.o
|
||||
|
||||
EXTRA_CFLAGS := -Wall -DVTOY_IBT -fcf-protection=branch -mindirect-branch-register
|
||||
|
||||
dm_patch_ibt-objs := dmpatch.o
|
||||
|
@ -0,0 +1,632 @@
|
||||
/******************************************************************************
|
||||
* dmpatch.c ---- patch for device-mapper
|
||||
*
|
||||
* Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kallsyms.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/mempool.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#define MAX_PATCH 4
|
||||
|
||||
#define magic_sig 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF
|
||||
|
||||
typedef int (*kprobe_reg_pf)(void *);
|
||||
typedef void (*kprobe_unreg_pf)(void *);
|
||||
typedef int (*printk_pf)(const char *fmt, ...);
|
||||
typedef int (*set_memory_attr_pf)(unsigned long addr, int numpages);
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct ko_param
|
||||
{
|
||||
unsigned char magic[16];
|
||||
unsigned long struct_size;
|
||||
unsigned long pgsize;
|
||||
unsigned long printk_addr;
|
||||
unsigned long ro_addr;
|
||||
unsigned long rw_addr;
|
||||
unsigned long reg_kprobe_addr;
|
||||
unsigned long unreg_kprobe_addr;
|
||||
unsigned long sym_get_addr;
|
||||
unsigned long sym_get_size;
|
||||
unsigned long sym_put_addr;
|
||||
unsigned long sym_put_size;
|
||||
unsigned long kv_major;
|
||||
unsigned long ibt;
|
||||
unsigned long kv_minor;
|
||||
unsigned long blkdev_get_addr;
|
||||
unsigned long blkdev_put_addr;
|
||||
unsigned long bdev_open_addr;
|
||||
unsigned long kv_subminor;
|
||||
unsigned long bdev_file_open_addr;
|
||||
unsigned long padding[1];
|
||||
}ko_param;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
static printk_pf kprintf = NULL;
|
||||
static set_memory_attr_pf set_mem_ro = NULL;
|
||||
static set_memory_attr_pf set_mem_rw = NULL;
|
||||
static kprobe_reg_pf reg_kprobe = NULL;
|
||||
static kprobe_unreg_pf unreg_kprobe = NULL;
|
||||
|
||||
static volatile ko_param g_ko_param =
|
||||
{
|
||||
{ magic_sig },
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
#if defined(CONFIG_X86_64)
|
||||
#define PATCH_OP_POS1 3
|
||||
#define CODE_MATCH1(code, i) \
|
||||
(code[i] == 0x40 && code[i + 1] == 0x80 && code[i + 2] == 0xce && code[i + 3] == 0x80)
|
||||
|
||||
#define PATCH_OP_POS2 1
|
||||
#define CODE_MATCH2(code, i) \
|
||||
(code[i] == 0x0C && code[i + 1] == 0x80 && code[i + 2] == 0x89 && code[i + 3] == 0xC6)
|
||||
|
||||
#define PATCH_OP_POS3 4
|
||||
#define CODE_MATCH3(code, i) \
|
||||
(code[i] == 0x44 && code[i + 1] == 0x89 && code[i + 2] == 0xe8 && code[i + 3] == 0x0c && code[i + 4] == 0x80)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#elif defined(CONFIG_X86_32)
|
||||
#define PATCH_OP_POS1 2
|
||||
#define CODE_MATCH1(code, i) \
|
||||
(code[i] == 0x80 && code[i + 1] == 0xca && code[i + 2] == 0x80 && code[i + 3] == 0xe8)
|
||||
|
||||
#define PATCH_OP_POS2 PATCH_OP_POS1
|
||||
#define CODE_MATCH2 CODE_MATCH1
|
||||
#define PATCH_OP_POS3 PATCH_OP_POS1
|
||||
#define CODE_MATCH3 CODE_MATCH1
|
||||
|
||||
|
||||
#else
|
||||
#error "unsupported arch"
|
||||
#endif
|
||||
|
||||
#ifdef VTOY_IBT
|
||||
#ifdef CONFIG_X86_64
|
||||
/* Using 64-bit values saves one instruction clearing the high half of low */
|
||||
#define DECLARE_ARGS(val, low, high) unsigned long low, high
|
||||
#define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32)
|
||||
#define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high)
|
||||
#else
|
||||
#define DECLARE_ARGS(val, low, high) unsigned long long val
|
||||
#define EAX_EDX_VAL(val, low, high) (val)
|
||||
#define EAX_EDX_RET(val, low, high) "=A" (val)
|
||||
#endif
|
||||
|
||||
#define EX_TYPE_WRMSR 8
|
||||
#define EX_TYPE_RDMSR 9
|
||||
#define MSR_IA32_S_CET 0x000006a2 /* kernel mode cet */
|
||||
#define CET_ENDBR_EN (1ULL << 2)
|
||||
|
||||
/* Exception table entry */
|
||||
#ifdef __ASSEMBLY__
|
||||
|
||||
#define _ASM_EXTABLE_TYPE(from, to, type) \
|
||||
.pushsection "__ex_table","a" ; \
|
||||
.balign 4 ; \
|
||||
.long (from) - . ; \
|
||||
.long (to) - . ; \
|
||||
.long type ; \
|
||||
.popsection
|
||||
|
||||
#else /* ! __ASSEMBLY__ */
|
||||
|
||||
#define _ASM_EXTABLE_TYPE(from, to, type) \
|
||||
" .pushsection \"__ex_table\",\"a\"\n" \
|
||||
" .balign 4\n" \
|
||||
" .long (" #from ") - .\n" \
|
||||
" .long (" #to ") - .\n" \
|
||||
" .long " __stringify(type) " \n" \
|
||||
" .popsection\n"
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* VTOY_IBT */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define vdebug(fmt, args...) if(kprintf) kprintf(KERN_ERR fmt, ##args)
|
||||
|
||||
static unsigned int g_claim_ptr = 0;
|
||||
static unsigned char *g_get_patch[MAX_PATCH] = { NULL };
|
||||
static unsigned char *g_put_patch[MAX_PATCH] = { NULL };
|
||||
|
||||
static int notrace dmpatch_kv_above(unsigned long Major, unsigned long Minor, unsigned long SubMinor)
|
||||
{
|
||||
if (g_ko_param.kv_major != Major)
|
||||
{
|
||||
return (g_ko_param.kv_major > Major) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (g_ko_param.kv_minor != Minor)
|
||||
{
|
||||
return (g_ko_param.kv_minor > Minor) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (g_ko_param.kv_subminor != SubMinor)
|
||||
{
|
||||
return (g_ko_param.kv_subminor > SubMinor) ? 1 : 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void notrace dmpatch_restore_code(int bytes, unsigned char *opCode, unsigned int code)
|
||||
{
|
||||
unsigned long align;
|
||||
|
||||
if (opCode)
|
||||
{
|
||||
align = (unsigned long)opCode / g_ko_param.pgsize * g_ko_param.pgsize;
|
||||
set_mem_rw(align, 1);
|
||||
if (bytes == 1)
|
||||
{
|
||||
*opCode = (unsigned char)code;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(unsigned int *)opCode = code;
|
||||
}
|
||||
set_mem_ro(align, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static int notrace dmpatch_replace_code
|
||||
(
|
||||
int style,
|
||||
unsigned long addr,
|
||||
unsigned long size,
|
||||
int expect,
|
||||
const char *desc,
|
||||
unsigned char **patch
|
||||
)
|
||||
{
|
||||
int i = 0;
|
||||
int cnt = 0;
|
||||
unsigned long align;
|
||||
unsigned char *opCode = (unsigned char *)addr;
|
||||
|
||||
vdebug("patch for %s style[%d] 0x%lx %d\n", desc, style, addr, (int)size);
|
||||
|
||||
for (i = 0; i < (int)size - 8; i++)
|
||||
{
|
||||
if (style == 1)
|
||||
{
|
||||
if (CODE_MATCH1(opCode, i) && cnt < MAX_PATCH)
|
||||
{
|
||||
patch[cnt] = opCode + i + PATCH_OP_POS1;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
else if (style == 2)
|
||||
{
|
||||
if (CODE_MATCH2(opCode, i) && cnt < MAX_PATCH)
|
||||
{
|
||||
patch[cnt] = opCode + i + PATCH_OP_POS2;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
else if (style == 3)
|
||||
{
|
||||
if (CODE_MATCH3(opCode, i) && cnt < MAX_PATCH)
|
||||
{
|
||||
patch[cnt] = opCode + i + PATCH_OP_POS3;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (cnt != expect || cnt >= MAX_PATCH)
|
||||
{
|
||||
vdebug("patch error: cnt=%d expect=%d\n", cnt, expect);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < cnt; i++)
|
||||
{
|
||||
opCode = patch[i];
|
||||
align = (unsigned long)opCode / g_ko_param.pgsize * g_ko_param.pgsize;
|
||||
|
||||
set_mem_rw(align, 1);
|
||||
*opCode = 0;
|
||||
set_mem_ro(align, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned long notrace dmpatch_find_call_offset(unsigned long addr, unsigned long size, unsigned long func)
|
||||
{
|
||||
unsigned long i = 0;
|
||||
unsigned long dest;
|
||||
unsigned char *opCode = NULL;
|
||||
unsigned char aucOffset[8] = { 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
opCode = (unsigned char *)addr;
|
||||
|
||||
for (i = 0; i + 4 < size; i++)
|
||||
{
|
||||
if (opCode[i] == 0xE8)
|
||||
{
|
||||
aucOffset[0] = opCode[i + 1];
|
||||
aucOffset[1] = opCode[i + 2];
|
||||
aucOffset[2] = opCode[i + 3];
|
||||
aucOffset[3] = opCode[i + 4];
|
||||
|
||||
dest = addr + i + 5 + *(unsigned long *)aucOffset;
|
||||
if (dest == func)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int notrace dmpatch_patch_claim_ptr(void)
|
||||
{
|
||||
unsigned long i = 0;
|
||||
unsigned long t = 0;
|
||||
unsigned long offset1 = 0;
|
||||
unsigned long offset2 = 0;
|
||||
unsigned long align = 0;
|
||||
unsigned char *opCode = NULL;
|
||||
|
||||
opCode = (unsigned char *)g_ko_param.sym_get_addr;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
vdebug("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
|
||||
opCode[i + 0], opCode[i + 1], opCode[i + 2], opCode[i + 3],
|
||||
opCode[i + 4], opCode[i + 5], opCode[i + 6], opCode[i + 7],
|
||||
opCode[i + 8], opCode[i + 9], opCode[i + 10], opCode[i + 11],
|
||||
opCode[i + 12], opCode[i + 13], opCode[i + 14], opCode[i + 15]);
|
||||
}
|
||||
|
||||
if (dmpatch_kv_above(6, 7, 0)) /* >= 6.7 kernel */
|
||||
{
|
||||
vdebug("Get addr: 0x%lx %lu open 0x%lx\n", g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.bdev_open_addr);
|
||||
offset1 = dmpatch_find_call_offset(g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.bdev_open_addr);
|
||||
if (offset1 == 0)
|
||||
{
|
||||
vdebug("call bdev_open_addr Not found\n");
|
||||
|
||||
vdebug("Get addr: 0x%lx %lu file_open 0x%lx\n", g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.bdev_file_open_addr);
|
||||
offset1 = dmpatch_find_call_offset(g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.bdev_file_open_addr);
|
||||
if (offset1 == 0)
|
||||
{
|
||||
vdebug("call bdev_file_open_addr Not found\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vdebug("Get addr: 0x%lx %lu 0x%lx\n", g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.blkdev_get_addr);
|
||||
vdebug("Put addr: 0x%lx %lu 0x%lx\n", g_ko_param.sym_put_addr, g_ko_param.sym_put_size, g_ko_param.blkdev_put_addr);
|
||||
|
||||
offset1 = dmpatch_find_call_offset(g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.blkdev_get_addr);
|
||||
offset2 = dmpatch_find_call_offset(g_ko_param.sym_put_addr, g_ko_param.sym_put_size, g_ko_param.blkdev_put_addr);
|
||||
if (offset1 == 0 || offset2 == 0)
|
||||
{
|
||||
vdebug("call blkdev_get or blkdev_put Not found, %lu %lu\n", offset1, offset2);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vdebug("call addr1:0x%lx call addr2:0x%lx\n",
|
||||
g_ko_param.sym_get_addr + offset1,
|
||||
g_ko_param.sym_put_addr + offset2);
|
||||
|
||||
opCode = (unsigned char *)g_ko_param.sym_get_addr;
|
||||
for (i = offset1 - 1, t = 0; (i > 0) && (t < 24); i--, t++)
|
||||
{
|
||||
/* rdx */
|
||||
if (opCode[i] == 0x48 && opCode[i + 1] == 0xc7 && opCode[i + 2] == 0xc2)
|
||||
{
|
||||
g_claim_ptr = *(unsigned int *)(opCode + i + 3);
|
||||
g_get_patch[0] = opCode + i + 3;
|
||||
vdebug("claim_ptr(%08X) found at get addr 0x%lx\n", g_claim_ptr, g_ko_param.sym_get_addr + i + 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_claim_ptr == 0)
|
||||
{
|
||||
vdebug("Claim_ptr not found in get\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
align = (unsigned long)g_get_patch[0] / g_ko_param.pgsize * g_ko_param.pgsize;
|
||||
set_mem_rw(align, 1);
|
||||
*(unsigned int *)(g_get_patch[0]) = 0;
|
||||
set_mem_ro(align, 1);
|
||||
|
||||
|
||||
if (offset2 > 0)
|
||||
{
|
||||
opCode = (unsigned char *)g_ko_param.sym_put_addr;
|
||||
for (i = offset2 - 1, t = 0; (i > 0) && (t < 24); i--, t++)
|
||||
{
|
||||
/* rsi */
|
||||
if (opCode[i] == 0x48 && opCode[i + 1] == 0xc7 && opCode[i + 2] == 0xc6)
|
||||
{
|
||||
if (*(unsigned int *)(opCode + i + 3) == g_claim_ptr)
|
||||
{
|
||||
vdebug("claim_ptr found at put addr 0x%lx\n", g_ko_param.sym_put_addr + i + 3);
|
||||
g_put_patch[0] = opCode + i + 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_put_patch[0] == 0)
|
||||
{
|
||||
vdebug("Claim_ptr not found in put\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
align = (unsigned long)g_put_patch[0] / g_ko_param.pgsize * g_ko_param.pgsize;
|
||||
set_mem_rw(align, 1);
|
||||
*(unsigned int *)(g_put_patch[0]) = 0;
|
||||
set_mem_ro(align, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef VTOY_IBT
|
||||
static __always_inline unsigned long long dmpatch_rdmsr(unsigned int msr)
|
||||
{
|
||||
DECLARE_ARGS(val, low, high);
|
||||
|
||||
asm volatile("1: rdmsr\n"
|
||||
"2:\n"
|
||||
_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_RDMSR)
|
||||
: EAX_EDX_RET(val, low, high) : "c" (msr));
|
||||
|
||||
return EAX_EDX_VAL(val, low, high);
|
||||
}
|
||||
|
||||
static __always_inline void dmpatch_wrmsr(unsigned int msr, u32 low, u32 high)
|
||||
{
|
||||
asm volatile("1: wrmsr\n"
|
||||
"2:\n"
|
||||
_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_WRMSR)
|
||||
: : "c" (msr), "a"(low), "d" (high) : "memory");
|
||||
}
|
||||
|
||||
static u64 notrace dmpatch_ibt_save(void)
|
||||
{
|
||||
u64 msr = 0;
|
||||
u64 val = 0;
|
||||
|
||||
msr = dmpatch_rdmsr(MSR_IA32_S_CET);
|
||||
val = msr & ~CET_ENDBR_EN;
|
||||
dmpatch_wrmsr(MSR_IA32_S_CET, (u32)(val & 0xffffffffULL), (u32)(val >> 32));
|
||||
|
||||
return msr;
|
||||
}
|
||||
|
||||
static void notrace dmpatch_ibt_restore(u64 save)
|
||||
{
|
||||
u64 msr;
|
||||
|
||||
msr = dmpatch_rdmsr(MSR_IA32_S_CET);
|
||||
|
||||
msr &= ~CET_ENDBR_EN;
|
||||
msr |= (save & CET_ENDBR_EN);
|
||||
|
||||
dmpatch_wrmsr(MSR_IA32_S_CET, (u32)(msr & 0xffffffffULL), (u32)(msr >> 32));
|
||||
}
|
||||
#else
|
||||
static u64 notrace dmpatch_ibt_save(void) { return 0; }
|
||||
static void notrace dmpatch_ibt_restore(u64 save) { (void)save; }
|
||||
#endif
|
||||
|
||||
static int notrace dmpatch_process(unsigned long a, unsigned long b, unsigned long c)
|
||||
{
|
||||
int r = 0;
|
||||
int rc = 0;
|
||||
unsigned long kv_major = 0;
|
||||
unsigned long kv_minor = 0;
|
||||
unsigned long kv_subminor = 0;
|
||||
|
||||
vdebug("dmpatch_process as KV %d.%d.%d ...\n", (int)a, (int)b, (int)c);
|
||||
|
||||
kv_major = g_ko_param.kv_major;
|
||||
kv_minor = g_ko_param.kv_minor;
|
||||
kv_subminor = g_ko_param.kv_subminor;
|
||||
|
||||
g_ko_param.kv_major = a;
|
||||
g_ko_param.kv_minor = b;
|
||||
g_ko_param.kv_subminor = c;
|
||||
|
||||
if (dmpatch_kv_above(6, 5, 0)) /* >= kernel 6.5 */
|
||||
{
|
||||
vdebug("new interface patch dm_get_table_device...\n");
|
||||
r = dmpatch_patch_claim_ptr();
|
||||
}
|
||||
else
|
||||
{
|
||||
r = dmpatch_replace_code(1, g_ko_param.sym_get_addr, g_ko_param.sym_get_size, 2, "dm_get_table_device", g_get_patch);
|
||||
if (r && g_ko_param.kv_major >= 5)
|
||||
{
|
||||
vdebug("new2 patch dm_get_table_device...\n");
|
||||
r = dmpatch_replace_code(2, g_ko_param.sym_get_addr, g_ko_param.sym_get_size, 1, "dm_get_table_device", g_get_patch);
|
||||
}
|
||||
|
||||
if (r && g_ko_param.kv_major >= 5)
|
||||
{
|
||||
vdebug("new3 patch dm_get_table_device...\n");
|
||||
r = dmpatch_replace_code(3, g_ko_param.sym_get_addr, g_ko_param.sym_get_size, 1, "dm_get_table_device", g_get_patch);
|
||||
}
|
||||
}
|
||||
|
||||
if (r)
|
||||
{
|
||||
rc = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
vdebug("patch dm_get_table_device success\n");
|
||||
|
||||
if (dmpatch_kv_above(6, 5, 0))
|
||||
{
|
||||
r = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = dmpatch_replace_code(1, g_ko_param.sym_put_addr, g_ko_param.sym_put_size, 1, "dm_put_table_device", g_put_patch);
|
||||
if (r)
|
||||
{
|
||||
rc = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
vdebug("patch dm_put_table_device success\n");
|
||||
}
|
||||
|
||||
vdebug("#####################################\n");
|
||||
vdebug("######## dm patch success ###########\n");
|
||||
vdebug("#####################################\n");
|
||||
|
||||
out:
|
||||
|
||||
g_ko_param.kv_major = kv_major;
|
||||
g_ko_param.kv_minor = kv_minor;
|
||||
g_ko_param.kv_subminor = kv_subminor;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int notrace dmpatch_init(void)
|
||||
{
|
||||
int rc = 0;
|
||||
u64 msr = 0;
|
||||
|
||||
if (g_ko_param.ibt == 0x8888)
|
||||
{
|
||||
msr = dmpatch_ibt_save();
|
||||
}
|
||||
|
||||
kprintf = (printk_pf)(g_ko_param.printk_addr);
|
||||
|
||||
vdebug("dmpatch_init start pagesize=%lu kernel=%lu.%lu.%lu ...\n",
|
||||
g_ko_param.pgsize, g_ko_param.kv_major, g_ko_param.kv_minor, g_ko_param.kv_subminor);
|
||||
|
||||
if (g_ko_param.struct_size != sizeof(ko_param))
|
||||
{
|
||||
vdebug("Invalid struct size %d %d\n", (int)g_ko_param.struct_size, (int)sizeof(ko_param));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (g_ko_param.sym_get_addr == 0 || g_ko_param.sym_put_addr == 0 ||
|
||||
g_ko_param.ro_addr == 0 || g_ko_param.rw_addr == 0)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
set_mem_ro = (set_memory_attr_pf)(g_ko_param.ro_addr);
|
||||
set_mem_rw = (set_memory_attr_pf)(g_ko_param.rw_addr);
|
||||
reg_kprobe = (kprobe_reg_pf)g_ko_param.reg_kprobe_addr;
|
||||
unreg_kprobe = (kprobe_unreg_pf)g_ko_param.unreg_kprobe_addr;
|
||||
|
||||
rc = dmpatch_process(g_ko_param.kv_major, g_ko_param.kv_minor, g_ko_param.kv_subminor);
|
||||
if (rc)
|
||||
{
|
||||
if (g_ko_param.kv_major >= 5)
|
||||
{
|
||||
rc = dmpatch_process(6, 5, 0);
|
||||
if (rc)
|
||||
{
|
||||
rc = dmpatch_process(6, 7, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_ko_param.ibt == 0x8888)
|
||||
{
|
||||
dmpatch_ibt_restore(msr);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void notrace dmpatch_exit(void)
|
||||
{
|
||||
int i = 0;
|
||||
u64 msr;
|
||||
|
||||
if (g_ko_param.ibt == 0x8888)
|
||||
{
|
||||
msr = dmpatch_ibt_save();
|
||||
}
|
||||
|
||||
if (g_claim_ptr)
|
||||
{
|
||||
dmpatch_restore_code(4, g_get_patch[0], g_claim_ptr);
|
||||
if (g_put_patch[0])
|
||||
{
|
||||
dmpatch_restore_code(4, g_put_patch[0], g_claim_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < MAX_PATCH; i++)
|
||||
{
|
||||
dmpatch_restore_code(1, g_get_patch[i], 0x80);
|
||||
dmpatch_restore_code(1, g_put_patch[i], 0x80);
|
||||
}
|
||||
}
|
||||
|
||||
vdebug("dmpatch_exit success\n");
|
||||
|
||||
if (g_ko_param.ibt == 0x8888)
|
||||
{
|
||||
dmpatch_ibt_restore(msr);
|
||||
}
|
||||
}
|
||||
|
||||
module_init(dmpatch_init);
|
||||
module_exit(dmpatch_exit);
|
||||
|
||||
|
||||
MODULE_DESCRIPTION("dmpatch driver");
|
||||
MODULE_AUTHOR("longpanda <admin@ventoy.net>");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
@ -0,0 +1,38 @@
|
||||
1. install ubuntu 22.04 5.15.0-25
|
||||
2. apt-get install build-essential flex libncurses-dev linux-headers-generic linux-source libssl-dev bison yacc vim libelf-dev ...... and so on
|
||||
3. cp /lib/modules/5.15.0-25-generic/build/Module.symvers ./
|
||||
4. /boot/config-5.15.0-25-generic as .config make oldconfig
|
||||
5. make menuconfig
|
||||
1. close CONFIG_STACKPROTECTOR
|
||||
2. close CONFIG_RETPOLINE
|
||||
3. close CONFIG_UBSAN_BOUNDS
|
||||
4. close CONFIG_UBSAN_ENUM
|
||||
|
||||
6. modify ./scripts/mod/modpost.c
|
||||
1. skip add_srcversion (just return)
|
||||
2. force add_retpoline (#ifdef --> #ifndef)
|
||||
3. force add_intree_flag
|
||||
|
||||
7. make modules_prepare LOCALVERSION=-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
8. Append padding at the end of struct module <include/linux/module.h>
|
||||
struct module {
|
||||
enum module_state state;
|
||||
|
||||
/* Member of list of modules */
|
||||
struct list_head list;
|
||||
|
||||
/* Unique handle for this module */
|
||||
char name[MODULE_NAME_LEN];
|
||||
|
||||
....
|
||||
|
||||
char padding[1024];
|
||||
};
|
||||
|
||||
This is because struct module size is different in different kernel versions or with different CONFIG item.
|
||||
|
||||
|
||||
9. make modules M=/home/dmpatch
|
||||
10. strip --strip-debug /home/dmpatch/dm_patch.ko
|
||||
|
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
FTPIP=192.168.44.1
|
||||
FTPUSR='a:a'
|
||||
|
||||
rm -f dmpatch.c Makefile Makefile_IBT
|
||||
|
||||
for f in dmpatch.c Makefile Makefile_IBT; do
|
||||
curl -s -u $FTPUSR ftp://$FTPIP/$f -o $f
|
||||
if [ -f $f ]; then
|
||||
echo "download $f OK ..."
|
||||
else
|
||||
echo "download $f FAILED ..."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
rm -f *.ko
|
||||
|
||||
|
||||
echo "build dm_patch.ko ..."
|
||||
rm -rf ./aa
|
||||
mkdir ./aa
|
||||
|
||||
cp -a *.c aa/
|
||||
cp -a Makefile aa/
|
||||
|
||||
cd /home/panda/linux-source-5.15.0
|
||||
make modules M=/home/panda/build/aa/
|
||||
strip --strip-debug /home/panda/build/aa/dm_patch.ko
|
||||
cd -
|
||||
|
||||
cp -a aa/dm_patch.ko ./
|
||||
|
||||
|
||||
|
||||
echo "build dm_patch_ibt.ko ..."
|
||||
rm -rf ./aa
|
||||
mkdir ./aa
|
||||
|
||||
cp -a *.c aa/
|
||||
cp -a Makefile_IBT aa/Makefile
|
||||
|
||||
cd /home/panda/linux-source-5.15.0
|
||||
make modules M=/home/panda/build/aa/
|
||||
strip --strip-debug /home/panda/build/aa/dm_patch_ibt.ko
|
||||
cd -
|
||||
|
||||
cp -a aa/dm_patch_ibt.ko ./
|
||||
|
||||
rm -rf ./aa
|
||||
|
||||
|
||||
curl -s -T dm_patch.ko -u $FTPUSR ftp://$FTPIP/dm_patch_64.ko || exit 1
|
||||
curl -s -T dm_patch_ibt.ko -u $FTPUSR ftp://$FTPIP/dm_patch_ibt_64.ko || exit 1
|
||||
|
||||
|
||||
if [ -f ./dm_patch.ko -a -f ./dm_patch_ibt.ko ]; then
|
||||
echo -e "\n\n=============== SUCCESS =============\n\n"
|
||||
else
|
||||
echo -e "\n\n=============== FAILED ==============\n\n"
|
||||
fi
|
||||
|
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/efi/api.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static grub_efi_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
|
||||
|
||||
static grub_efi_status_t
|
||||
grub_efi_connect_all (void)
|
||||
{
|
||||
grub_efi_status_t status;
|
||||
grub_efi_uintn_t handle_count;
|
||||
grub_efi_handle_t *handle_buffer;
|
||||
grub_efi_uintn_t index;
|
||||
grub_efi_boot_services_t *b;
|
||||
grub_dprintf ("efi", "Connecting ...\n");
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = efi_call_5 (b->locate_handle_buffer,
|
||||
GRUB_EFI_ALL_HANDLES, NULL, NULL,
|
||||
&handle_count, &handle_buffer);
|
||||
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return status;
|
||||
|
||||
for (index = 0; index < handle_count; index++)
|
||||
{
|
||||
status = efi_call_4 (b->connect_controller,
|
||||
handle_buffer[index], NULL, NULL, 1);
|
||||
}
|
||||
|
||||
if (handle_buffer)
|
||||
{
|
||||
efi_call_1 (b->free_pool, handle_buffer);
|
||||
}
|
||||
return GRUB_EFI_SUCCESS;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_efi_load_driver (grub_size_t size, void *boot_image, int connect)
|
||||
{
|
||||
grub_efi_status_t status;
|
||||
grub_efi_handle_t driver_handle;
|
||||
grub_efi_boot_services_t *b;
|
||||
grub_efi_loaded_image_t *loaded_image;
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
|
||||
status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, NULL,
|
||||
boot_image, size, &driver_handle);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
{
|
||||
if (status == GRUB_EFI_OUT_OF_RESOURCES)
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources");
|
||||
else
|
||||
grub_error (GRUB_ERR_BAD_OS, "cannot load image");
|
||||
goto fail;
|
||||
}
|
||||
loaded_image = grub_efi_get_loaded_image (driver_handle);
|
||||
if (! loaded_image)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_OS, "no loaded image available");
|
||||
goto fail;
|
||||
}
|
||||
grub_dprintf ("efi", "Registering loaded image\n");
|
||||
status = efi_call_3 (b->handle_protocol, driver_handle,
|
||||
&loaded_image_guid, (void **)&loaded_image);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_OS, "not a dirver");
|
||||
goto fail;
|
||||
}
|
||||
grub_dprintf ("efi", "StartImage: %p\n", boot_image);
|
||||
status = efi_call_3 (b->start_image, driver_handle, NULL, NULL);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_OS, "StartImage failed");
|
||||
goto fail;
|
||||
}
|
||||
if (connect)
|
||||
{
|
||||
status = grub_efi_connect_all ();
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_OS, "cannot connect controllers\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
grub_dprintf ("efi", "Driver installed\n");
|
||||
return 0;
|
||||
fail:
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static const struct grub_arg_option options_fwload[] =
|
||||
{
|
||||
{"nc", 'n', 0, N_("Loads the driver, but does not connect the driver."), 0, 0},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_fwload (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = ctxt->state;
|
||||
int connect = 1;
|
||||
grub_file_t file = 0;
|
||||
grub_efi_boot_services_t *b;
|
||||
grub_efi_status_t status;
|
||||
grub_efi_uintn_t pages = 0;
|
||||
grub_ssize_t size;
|
||||
grub_efi_physical_address_t address;
|
||||
void *boot_image = 0;
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
if (argc != 1)
|
||||
goto fail;
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE);
|
||||
if (! file)
|
||||
goto fail;
|
||||
size = grub_file_size (file);
|
||||
if (!size)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
|
||||
goto fail;
|
||||
}
|
||||
pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12);
|
||||
status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES,
|
||||
GRUB_EFI_LOADER_CODE, pages, &address);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||
goto fail;
|
||||
}
|
||||
boot_image = (void *) ((grub_addr_t) address);
|
||||
if (grub_file_read (file, boot_image, size) != size)
|
||||
{
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
|
||||
goto fail;
|
||||
}
|
||||
grub_file_close (file);
|
||||
if (state[0].set)
|
||||
connect = 0;
|
||||
if (grub_efi_load_driver (size, boot_image, connect))
|
||||
goto fail;
|
||||
return GRUB_ERR_NONE;
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
if (address)
|
||||
efi_call_2 (b->free_pages, address, pages);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_fwconnect (grub_extcmd_context_t ctxt __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
grub_efi_connect_all ();
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd_fwload, cmd_fwconnect;
|
||||
|
||||
GRUB_MOD_INIT(fwload)
|
||||
{
|
||||
cmd_fwload = grub_register_extcmd ("fwload", grub_cmd_fwload, 0, N_("FILE"),
|
||||
N_("Install UEFI driver."), options_fwload);
|
||||
cmd_fwconnect = grub_register_extcmd ("fwconnect", grub_cmd_fwconnect, 0,
|
||||
NULL, N_("Connect drivers."), 0);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(fwload)
|
||||
{
|
||||
grub_unregister_extcmd (cmd_fwload);
|
||||
grub_unregister_extcmd (cmd_fwconnect);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/* smbios.c - get smbios tables. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/smbios.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/api.h>
|
||||
|
||||
struct grub_smbios_eps *
|
||||
grub_machine_smbios_get_eps (void)
|
||||
{
|
||||
unsigned i;
|
||||
static grub_efi_packed_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
|
||||
|
||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||
{
|
||||
grub_efi_packed_guid_t *guid =
|
||||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||
|
||||
if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_packed_guid_t)))
|
||||
return (struct grub_smbios_eps *)
|
||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct grub_smbios_eps3 *
|
||||
grub_machine_smbios_get_eps3 (void)
|
||||
{
|
||||
unsigned i;
|
||||
static grub_efi_packed_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
|
||||
|
||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||
{
|
||||
grub_efi_packed_guid_t *guid =
|
||||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||
|
||||
if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_packed_guid_t)))
|
||||
return (struct grub_smbios_eps3 *)
|
||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/* smbios.c - get smbios tables. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/acpi.h>
|
||||
#include <grub/smbios.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
struct grub_smbios_eps *
|
||||
grub_machine_smbios_get_eps (void)
|
||||
{
|
||||
grub_uint8_t *ptr;
|
||||
|
||||
grub_dprintf ("smbios", "Looking for SMBIOS EPS. Scanning BIOS\n");
|
||||
|
||||
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16)
|
||||
if (grub_memcmp (ptr, "_SM_", 4) == 0
|
||||
&& grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps)) == 0)
|
||||
return (struct grub_smbios_eps *) ptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct grub_smbios_eps3 *
|
||||
grub_machine_smbios_get_eps3 (void)
|
||||
{
|
||||
grub_uint8_t *ptr;
|
||||
|
||||
grub_dprintf ("smbios", "Looking for SMBIOS3 EPS. Scanning BIOS\n");
|
||||
|
||||
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16)
|
||||
if (grub_memcmp (ptr, "_SM3_", 5) == 0
|
||||
&& grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps3)) == 0)
|
||||
return (struct grub_smbios_eps3 *) ptr;
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,399 @@
|
||||
/* smbios.c - retrieve smbios information. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/smbios.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
/* Abstract useful values found in either the SMBIOS3 or SMBIOS EPS. */
|
||||
static struct {
|
||||
grub_addr_t start;
|
||||
grub_addr_t end;
|
||||
grub_uint16_t structures;
|
||||
} table_desc;
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
/* Locate the SMBIOS entry point structure depending on the hardware. */
|
||||
struct grub_smbios_eps *
|
||||
grub_smbios_get_eps (void)
|
||||
{
|
||||
static struct grub_smbios_eps *eps = NULL;
|
||||
|
||||
if (eps != NULL)
|
||||
return eps;
|
||||
|
||||
eps = grub_machine_smbios_get_eps ();
|
||||
|
||||
return eps;
|
||||
}
|
||||
|
||||
/* Locate the SMBIOS3 entry point structure depending on the hardware. */
|
||||
static struct grub_smbios_eps3 *
|
||||
grub_smbios_get_eps3 (void)
|
||||
{
|
||||
static struct grub_smbios_eps3 *eps = NULL;
|
||||
|
||||
if (eps != NULL)
|
||||
return eps;
|
||||
|
||||
eps = grub_machine_smbios_get_eps3 ();
|
||||
|
||||
return eps;
|
||||
}
|
||||
|
||||
static char *
|
||||
linux_string (const char *value)
|
||||
{
|
||||
char *out = grub_malloc( grub_strlen (value) + 1);
|
||||
const char *src = value;
|
||||
char *dst = out;
|
||||
|
||||
for (; *src; src++)
|
||||
if (*src > ' ' && *src < 127 && *src != ':')
|
||||
*dst++ = *src;
|
||||
|
||||
*dst = 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions convert values from the various SMBIOS structure field types
|
||||
* into a string formatted to be returned to the user. They expect that the
|
||||
* structure and offset were already validated. When the requested data is
|
||||
* successfully retrieved and formatted, the pointer to the string is returned;
|
||||
* otherwise, NULL is returned on failure. Don't free the result.
|
||||
*/
|
||||
|
||||
static const char *
|
||||
grub_smbios_format_byte (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||
{
|
||||
static char buffer[sizeof ("255")];
|
||||
|
||||
grub_snprintf (buffer, sizeof (buffer), "%u", structure[offset]);
|
||||
|
||||
return (const char *)buffer;
|
||||
}
|
||||
|
||||
static const char *
|
||||
grub_smbios_format_word (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||
{
|
||||
static char buffer[sizeof ("65535")];
|
||||
|
||||
grub_uint16_t value = grub_get_unaligned16 (structure + offset);
|
||||
grub_snprintf (buffer, sizeof (buffer), "%u", value);
|
||||
|
||||
return (const char *)buffer;
|
||||
}
|
||||
|
||||
static const char *
|
||||
grub_smbios_format_dword (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||
{
|
||||
static char buffer[sizeof ("4294967295")];
|
||||
|
||||
grub_uint32_t value = grub_get_unaligned32 (structure + offset);
|
||||
grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT32_T, value);
|
||||
|
||||
return (const char *)buffer;
|
||||
}
|
||||
|
||||
static const char *
|
||||
grub_smbios_format_qword (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||
{
|
||||
static char buffer[sizeof ("18446744073709551615")];
|
||||
|
||||
grub_uint64_t value = grub_get_unaligned64 (structure + offset);
|
||||
grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT64_T, value);
|
||||
|
||||
return (const char *)buffer;
|
||||
}
|
||||
|
||||
static const char *
|
||||
grub_smbios_get_string (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||
{
|
||||
const grub_uint8_t *ptr = structure + structure[1];
|
||||
const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end;
|
||||
const grub_uint8_t referenced_string_number = structure[offset];
|
||||
grub_uint8_t i;
|
||||
|
||||
/* A string referenced with zero is interpreted as unset. */
|
||||
if (referenced_string_number == 0)
|
||||
return NULL;
|
||||
|
||||
/* Search the string set. */
|
||||
for (i = 1; *ptr != 0 && ptr < table_end; i++)
|
||||
if (i == referenced_string_number)
|
||||
{
|
||||
const char *str = (const char *)ptr;
|
||||
while (*ptr++ != 0)
|
||||
if (ptr >= table_end)
|
||||
return NULL; /* The string isn't terminated. */
|
||||
return str;
|
||||
}
|
||||
else
|
||||
while (*ptr++ != 0 && ptr < table_end);
|
||||
|
||||
/* The string number is greater than the number of strings in the set. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
grub_smbios_format_uuid (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||
{
|
||||
static char buffer[sizeof ("ffffffff-ffff-ffff-ffff-ffffffffffff")];
|
||||
const grub_uint8_t *f = structure + offset; /* little-endian fields */
|
||||
const grub_uint8_t *g = f + 8; /* byte-by-byte fields */
|
||||
|
||||
grub_snprintf (buffer, sizeof (buffer),
|
||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-"
|
||||
"%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
f[3], f[2], f[1], f[0], f[5], f[4], f[7], f[6],
|
||||
g[0], g[1], g[2], g[3], g[4], g[5], g[6], g[7]);
|
||||
|
||||
return (const char *)buffer;
|
||||
}
|
||||
|
||||
/* List the field formatting functions and the number of bytes they need. */
|
||||
static const struct {
|
||||
const char *(*format) (const grub_uint8_t *structure, grub_uint8_t offset);
|
||||
grub_uint8_t field_length;
|
||||
} field_extractors[] = {
|
||||
{grub_smbios_format_byte, 1},
|
||||
{grub_smbios_format_word, 2},
|
||||
{grub_smbios_format_dword, 4},
|
||||
{grub_smbios_format_qword, 8},
|
||||
{grub_smbios_get_string, 1},
|
||||
{grub_smbios_format_uuid, 16}
|
||||
};
|
||||
|
||||
/* List command options, with structure field getters ordered as above. */
|
||||
#define FIRST_GETTER_OPT (3)
|
||||
#define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
|
||||
#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
|
||||
|
||||
static const struct grub_arg_option options[] = {
|
||||
{"type", 't', 0, N_("Match structures with the given type."),
|
||||
N_("type"), ARG_TYPE_INT},
|
||||
{"handle", 'h', 0, N_("Match structures with the given handle."),
|
||||
N_("handle"), ARG_TYPE_INT},
|
||||
{"match", 'm', 0, N_("Select a structure when several match."),
|
||||
N_("match"), ARG_TYPE_INT},
|
||||
{"get-byte", 'b', 0, N_("Get the byte's value at the given offset."),
|
||||
N_("offset"), ARG_TYPE_INT},
|
||||
{"get-word", 'w', 0, N_("Get two bytes' value at the given offset."),
|
||||
N_("offset"), ARG_TYPE_INT},
|
||||
{"get-dword", 'd', 0, N_("Get four bytes' value at the given offset."),
|
||||
N_("offset"), ARG_TYPE_INT},
|
||||
{"get-qword", 'q', 0, N_("Get eight bytes' value at the given offset."),
|
||||
N_("offset"), ARG_TYPE_INT},
|
||||
{"get-string", 's', 0, N_("Get the string specified at the given offset."),
|
||||
N_("offset"), ARG_TYPE_INT},
|
||||
{"get-uuid", 'u', 0, N_("Get the UUID's value at the given offset."),
|
||||
N_("offset"), ARG_TYPE_INT},
|
||||
{"set", '\0', 0, N_("Store the value in the given variable name."),
|
||||
N_("variable"), ARG_TYPE_STRING},
|
||||
{"linux", '\0', 0, N_("Filter the result like linux does."),
|
||||
N_("variable"), ARG_TYPE_NONE},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/*
|
||||
* Return a matching SMBIOS structure.
|
||||
*
|
||||
* This method can use up to three criteria for selecting a structure:
|
||||
* - The "type" field (use -1 to ignore)
|
||||
* - The "handle" field (use -1 to ignore)
|
||||
* - Which to return if several match (use 0 to ignore)
|
||||
*
|
||||
* The return value is a pointer to the first matching structure. If no
|
||||
* structures match the given parameters, NULL is returned.
|
||||
*/
|
||||
static const grub_uint8_t *
|
||||
grub_smbios_match_structure (const grub_int16_t type,
|
||||
const grub_int32_t handle,
|
||||
const grub_uint16_t match)
|
||||
{
|
||||
const grub_uint8_t *ptr = (const grub_uint8_t *)table_desc.start;
|
||||
const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end;
|
||||
grub_uint16_t structures = table_desc.structures;
|
||||
grub_uint16_t structure_count = 0;
|
||||
grub_uint16_t matches = 0;
|
||||
|
||||
while (ptr < table_end
|
||||
&& ptr[1] >= 4 /* Valid structures include the 4-byte header. */
|
||||
&& (structure_count++ < structures || structures == 0))
|
||||
{
|
||||
grub_uint16_t structure_handle = grub_get_unaligned16 (ptr + 2);
|
||||
grub_uint8_t structure_type = ptr[0];
|
||||
|
||||
if ((handle < 0 || handle == structure_handle)
|
||||
&& (type < 0 || type == structure_type)
|
||||
&& (match == 0 || match == ++matches))
|
||||
return ptr;
|
||||
else
|
||||
{
|
||||
ptr += ptr[1];
|
||||
while ((*ptr++ != 0 || *ptr++ != 0) && ptr < table_end);
|
||||
}
|
||||
|
||||
if (structure_type == GRUB_SMBIOS_TYPE_END_OF_TABLE)
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_smbios (grub_extcmd_context_t ctxt,
|
||||
int argc __attribute__ ((unused)),
|
||||
char **argv __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_arg_list *state = ctxt->state;
|
||||
|
||||
grub_int16_t type = -1;
|
||||
grub_int32_t handle = -1;
|
||||
grub_uint16_t match = 0;
|
||||
grub_uint8_t offset = 0;
|
||||
|
||||
const grub_uint8_t *structure;
|
||||
const char *value;
|
||||
char *modified_value = NULL;
|
||||
grub_int32_t option;
|
||||
grub_int8_t field_type = -1;
|
||||
grub_uint8_t i;
|
||||
|
||||
if (table_desc.start == 0)
|
||||
return grub_error (GRUB_ERR_IO,
|
||||
N_("the SMBIOS entry point structure was not found"));
|
||||
|
||||
/* Read the given filtering options. */
|
||||
if (state[0].set)
|
||||
{
|
||||
option = grub_strtol (state[0].arg, NULL, 0);
|
||||
if (option < 0 || option > 255)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("the type must be between 0 and 255"));
|
||||
type = (grub_int16_t)option;
|
||||
}
|
||||
if (state[1].set)
|
||||
{
|
||||
option = grub_strtol (state[1].arg, NULL, 0);
|
||||
if (option < 0 || option > 65535)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("the handle must be between 0 and 65535"));
|
||||
handle = (grub_int32_t)option;
|
||||
}
|
||||
if (state[2].set)
|
||||
{
|
||||
option = grub_strtol (state[2].arg, NULL, 0);
|
||||
if (option <= 0 || option > 65535)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("the match must be a positive integer"));
|
||||
match = (grub_uint16_t)option;
|
||||
}
|
||||
|
||||
/* Determine the data type of the structure field to retrieve. */
|
||||
for (i = 0; i < ARRAY_SIZE(field_extractors); i++)
|
||||
if (state[FIRST_GETTER_OPT + i].set)
|
||||
{
|
||||
if (field_type >= 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("only one --get option is usable at a time"));
|
||||
field_type = i;
|
||||
}
|
||||
|
||||
/* Require a choice of a structure field to return. */
|
||||
if (field_type < 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("one of the --get options is required"));
|
||||
|
||||
/* Locate a matching SMBIOS structure. */
|
||||
structure = grub_smbios_match_structure (type, handle, match);
|
||||
if (structure == NULL)
|
||||
return grub_error (GRUB_ERR_IO,
|
||||
N_("no structure matched the given options"));
|
||||
|
||||
/* Ensure the requested byte offset is inside the structure. */
|
||||
option = grub_strtol (state[FIRST_GETTER_OPT + field_type].arg, NULL, 0);
|
||||
if (option < 0 || option >= structure[1])
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
N_("the given offset is outside the structure"));
|
||||
|
||||
/* Ensure the requested data type at the offset is inside the structure. */
|
||||
offset = (grub_uint8_t)option;
|
||||
if (offset + field_extractors[field_type].field_length > structure[1])
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
N_("the field ends outside the structure"));
|
||||
|
||||
/* Format the requested structure field into a readable string. */
|
||||
value = field_extractors[field_type].format (structure, offset);
|
||||
if (value == NULL)
|
||||
return grub_error (GRUB_ERR_IO,
|
||||
N_("failed to retrieve the structure field"));
|
||||
|
||||
if (state[LINUX_OPT].set)
|
||||
value = modified_value = linux_string (value);
|
||||
|
||||
/* Store or print the formatted value. */
|
||||
if (state[SETTER_OPT].set)
|
||||
grub_env_set (state[SETTER_OPT].arg, value);
|
||||
else
|
||||
grub_printf ("%s\n", value);
|
||||
|
||||
grub_free(modified_value);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT(smbios)
|
||||
{
|
||||
struct grub_smbios_eps3 *eps3;
|
||||
struct grub_smbios_eps *eps;
|
||||
|
||||
if ((eps3 = grub_smbios_get_eps3 ()))
|
||||
{
|
||||
table_desc.start = (grub_addr_t)eps3->table_address;
|
||||
table_desc.end = table_desc.start + eps3->maximum_table_length;
|
||||
table_desc.structures = 0; /* SMBIOS3 drops the structure count. */
|
||||
}
|
||||
else if ((eps = grub_smbios_get_eps ()))
|
||||
{
|
||||
table_desc.start = (grub_addr_t)eps->intermediate.table_address;
|
||||
table_desc.end = table_desc.start + eps->intermediate.table_length;
|
||||
table_desc.structures = eps->intermediate.structures;
|
||||
}
|
||||
|
||||
cmd = grub_register_extcmd ("smbios", grub_cmd_smbios, 0,
|
||||
N_("[-t type] [-h handle] [-m match] "
|
||||
"(-b|-w|-d|-q|-s|-u) offset "
|
||||
"[--set variable]"),
|
||||
N_("Retrieve SMBIOS information."), options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(smbios)
|
||||
{
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,285 @@
|
||||
/*
|
||||
* LZ4 - Fast LZ compression algorithm
|
||||
* Header File
|
||||
* Copyright (C) 2011-2013, Yann Collet.
|
||||
* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* You can contact the author at :
|
||||
* - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
|
||||
* - LZ4 source repository : http://code.google.com/p/lz4/
|
||||
*/
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
|
||||
int isize, int maxOutputSize);
|
||||
|
||||
/*
|
||||
* CPU Feature Detection
|
||||
*/
|
||||
|
||||
/* 32 or 64 bits ? */
|
||||
#if (GRUB_CPU_SIZEOF_VOID_P == 8)
|
||||
#define LZ4_ARCH64 1
|
||||
#else
|
||||
#define LZ4_ARCH64 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compiler Options
|
||||
*/
|
||||
|
||||
|
||||
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||
|
||||
#if (GCC_VERSION >= 302) || (defined (__INTEL_COMPILER) && __INTEL_COMPILER >= 800) || defined(__clang__)
|
||||
#define expect(expr, value) (__builtin_expect((expr), (value)))
|
||||
#else
|
||||
#define expect(expr, value) (expr)
|
||||
#endif
|
||||
|
||||
#define likely(expr) expect((expr) != 0, 1)
|
||||
#define unlikely(expr) expect((expr) != 0, 0)
|
||||
|
||||
/* Basic types */
|
||||
#define BYTE grub_uint8_t
|
||||
#define U16 grub_uint16_t
|
||||
#define U32 grub_uint32_t
|
||||
#define S32 grub_int32_t
|
||||
#define U64 grub_uint64_t
|
||||
|
||||
typedef struct _U16_S {
|
||||
U16 v;
|
||||
} GRUB_PACKED U16_S;
|
||||
typedef struct _U32_S {
|
||||
U32 v;
|
||||
} GRUB_PACKED U32_S;
|
||||
typedef struct _U64_S {
|
||||
U64 v;
|
||||
} GRUB_PACKED U64_S;
|
||||
|
||||
#define A64(x) (((U64_S *)(x))->v)
|
||||
#define A32(x) (((U32_S *)(x))->v)
|
||||
#define A16(x) (((U16_S *)(x))->v)
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
#define MINMATCH 4
|
||||
|
||||
#define COPYLENGTH 8
|
||||
#define LASTLITERALS 5
|
||||
|
||||
#define ML_BITS 4
|
||||
#define ML_MASK ((1U<<ML_BITS)-1)
|
||||
#define RUN_BITS (8-ML_BITS)
|
||||
#define RUN_MASK ((1U<<RUN_BITS)-1)
|
||||
|
||||
/*
|
||||
* Architecture-specific macros
|
||||
*/
|
||||
#if LZ4_ARCH64
|
||||
#define STEPSIZE 8
|
||||
#define UARCH U64
|
||||
#define AARCH A64
|
||||
#define LZ4_COPYSTEP(s, d) A64(d) = A64(s); d += 8; s += 8;
|
||||
#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d)
|
||||
#define LZ4_SECURECOPY(s, d, e) if (d < e) LZ4_WILDCOPY(s, d, e)
|
||||
#define HTYPE U32
|
||||
#define INITBASE(base) const BYTE* const base = ip
|
||||
#else
|
||||
#define STEPSIZE 4
|
||||
#define UARCH U32
|
||||
#define AARCH A32
|
||||
#define LZ4_COPYSTEP(s, d) A32(d) = A32(s); d += 4; s += 4;
|
||||
#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d); LZ4_COPYSTEP(s, d);
|
||||
#define LZ4_SECURECOPY LZ4_WILDCOPY
|
||||
#define HTYPE const BYTE*
|
||||
#define INITBASE(base) const int base = 0
|
||||
#endif
|
||||
|
||||
#define LZ4_READ_LITTLEENDIAN_16(d, s, p) { d = (s) - grub_le_to_cpu16 (A16 (p)); }
|
||||
#define LZ4_WRITE_LITTLEENDIAN_16(p, v) { A16(p) = grub_cpu_to_le16 (v); p += 2; }
|
||||
|
||||
/* Macros */
|
||||
#define LZ4_WILDCOPY(s, d, e) do { LZ4_COPYPACKET(s, d) } while (d < e);
|
||||
|
||||
/* Decompression functions */
|
||||
grub_err_t
|
||||
lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len);
|
||||
|
||||
grub_err_t
|
||||
lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len)
|
||||
{
|
||||
const BYTE *src = s_start;
|
||||
U32 bufsiz = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) |
|
||||
src[3];
|
||||
|
||||
/* invalid compressed buffer size encoded at start */
|
||||
if (bufsiz + 4 > s_len)
|
||||
return grub_error(GRUB_ERR_BAD_FS,"lz4 decompression failed.");
|
||||
|
||||
/*
|
||||
* Returns 0 on success (decompression function returned non-negative)
|
||||
* and appropriate error on failure (decompression function returned negative).
|
||||
*/
|
||||
return (LZ4_uncompress_unknownOutputSize((char*)s_start + 4, d_start, bufsiz,
|
||||
d_len) < 0)?grub_error(GRUB_ERR_BAD_FS,"lz4 decompression failed."):0;
|
||||
}
|
||||
|
||||
int
|
||||
LZ4_uncompress_unknownOutputSize(const char *source,
|
||||
char *dest, int isize, int maxOutputSize)
|
||||
{
|
||||
/* Local Variables */
|
||||
const BYTE * ip = (const BYTE *) source;
|
||||
const BYTE *const iend = ip + isize;
|
||||
const BYTE * ref;
|
||||
|
||||
BYTE * op = (BYTE *) dest;
|
||||
BYTE *const oend = op + maxOutputSize;
|
||||
BYTE *cpy;
|
||||
|
||||
grub_size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 };
|
||||
|
||||
/* Main Loop */
|
||||
while (ip < iend) {
|
||||
BYTE token;
|
||||
int length;
|
||||
|
||||
/* get runlength */
|
||||
token = *ip++;
|
||||
if ((length = (token >> ML_BITS)) == RUN_MASK) {
|
||||
int s = 255;
|
||||
while ((ip < iend) && (s == 255)) {
|
||||
s = *ip++;
|
||||
length += s;
|
||||
}
|
||||
}
|
||||
/* copy literals */
|
||||
if ((grub_addr_t) length > ~(grub_addr_t)op)
|
||||
goto _output_error;
|
||||
cpy = op + length;
|
||||
if ((cpy > oend - COPYLENGTH) ||
|
||||
(ip + length > iend - COPYLENGTH)) {
|
||||
if (cpy > oend)
|
||||
/*
|
||||
* Error: request to write beyond destination
|
||||
* buffer.
|
||||
*/
|
||||
goto _output_error;
|
||||
if (ip + length > iend)
|
||||
/*
|
||||
* Error : request to read beyond source
|
||||
* buffer.
|
||||
*/
|
||||
goto _output_error;
|
||||
grub_memcpy(op, ip, length);
|
||||
op += length;
|
||||
ip += length;
|
||||
if (ip < iend)
|
||||
/* Error : LZ4 format violation */
|
||||
goto _output_error;
|
||||
/* Necessarily EOF, due to parsing restrictions. */
|
||||
break;
|
||||
}
|
||||
LZ4_WILDCOPY(ip, op, cpy);
|
||||
ip -= (op - cpy);
|
||||
op = cpy;
|
||||
|
||||
/* get offset */
|
||||
LZ4_READ_LITTLEENDIAN_16(ref, cpy, ip);
|
||||
ip += 2;
|
||||
if (ref < (BYTE * const) dest)
|
||||
/*
|
||||
* Error: offset creates reference outside of
|
||||
* destination buffer.
|
||||
*/
|
||||
goto _output_error;
|
||||
|
||||
/* get matchlength */
|
||||
if ((length = (token & ML_MASK)) == ML_MASK) {
|
||||
while (ip < iend) {
|
||||
int s = *ip++;
|
||||
length += s;
|
||||
if (s == 255)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* copy repeated sequence */
|
||||
if unlikely(op - ref < STEPSIZE) {
|
||||
#if LZ4_ARCH64
|
||||
grub_size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
|
||||
grub_size_t dec2 = dec2table[op - ref];
|
||||
#else
|
||||
const int dec2 = 0;
|
||||
#endif
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
ref -= dec[op - ref];
|
||||
A32(op) = A32(ref);
|
||||
op += STEPSIZE - 4;
|
||||
ref -= dec2;
|
||||
} else {
|
||||
LZ4_COPYSTEP(ref, op);
|
||||
}
|
||||
cpy = op + length - (STEPSIZE - 4);
|
||||
if (cpy > oend - COPYLENGTH) {
|
||||
if (cpy > oend)
|
||||
/*
|
||||
* Error: request to write outside of
|
||||
* destination buffer.
|
||||
*/
|
||||
goto _output_error;
|
||||
LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
|
||||
while (op < cpy)
|
||||
*op++ = *ref++;
|
||||
op = cpy;
|
||||
if (op == oend)
|
||||
/*
|
||||
* Check EOF (should never happen, since last
|
||||
* 5 bytes are supposed to be literals).
|
||||
*/
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
LZ4_SECURECOPY(ref, op, cpy);
|
||||
op = cpy; /* correction */
|
||||
}
|
||||
|
||||
/* end of decoding */
|
||||
return (int)(((char *)op) - dest);
|
||||
|
||||
/* write overflow error detected */
|
||||
_output_error:
|
||||
return (int)(-(((char *)ip) - source));
|
||||
}
|
@ -0,0 +1,961 @@
|
||||
/* gui_list.c - GUI component to display a selectable list of items. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/color.h>
|
||||
#include <grub/charset.h>
|
||||
|
||||
enum scrollbar_slice_mode {
|
||||
SCROLLBAR_SLICE_WEST,
|
||||
SCROLLBAR_SLICE_CENTER,
|
||||
SCROLLBAR_SLICE_EAST
|
||||
};
|
||||
|
||||
struct grub_gui_list_impl
|
||||
{
|
||||
struct grub_gui_list list;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
int visible;
|
||||
|
||||
int icon_width;
|
||||
int icon_height;
|
||||
int item_height;
|
||||
int item_padding;
|
||||
int item_icon_space;
|
||||
int item_spacing;
|
||||
grub_font_t item_font;
|
||||
int selected_item_font_inherit;
|
||||
grub_font_t selected_item_font;
|
||||
grub_video_rgba_color_t item_color;
|
||||
int selected_item_color_inherit;
|
||||
grub_video_rgba_color_t selected_item_color;
|
||||
|
||||
int draw_scrollbar;
|
||||
int need_to_recreate_scrollbar;
|
||||
char *scrollbar_frame_pattern;
|
||||
char *scrollbar_thumb_pattern;
|
||||
grub_gfxmenu_box_t scrollbar_frame;
|
||||
grub_gfxmenu_box_t scrollbar_thumb;
|
||||
int scrollbar_thumb_overlay;
|
||||
int scrollbar_width;
|
||||
enum scrollbar_slice_mode scrollbar_slice;
|
||||
int scrollbar_left_pad;
|
||||
int scrollbar_right_pad;
|
||||
int scrollbar_top_pad;
|
||||
int scrollbar_bottom_pad;
|
||||
|
||||
int first_shown_index;
|
||||
|
||||
int need_to_recreate_boxes;
|
||||
char *theme_dir;
|
||||
char *menu_box_pattern;
|
||||
char *item_box_pattern;
|
||||
int selected_item_box_pattern_inherit;
|
||||
char *selected_item_box_pattern;
|
||||
grub_gfxmenu_box_t menu_box;
|
||||
grub_gfxmenu_box_t selected_item_box;
|
||||
grub_gfxmenu_box_t item_box;
|
||||
|
||||
grub_gfxmenu_icon_manager_t icon_manager;
|
||||
|
||||
grub_gfxmenu_view_t view;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_list_impl *list_impl_t;
|
||||
|
||||
static void
|
||||
list_destroy (void *vself)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
|
||||
grub_free (self->theme_dir);
|
||||
grub_free (self->menu_box_pattern);
|
||||
grub_free (self->item_box_pattern);
|
||||
grub_free (self->selected_item_box_pattern);
|
||||
if (self->menu_box)
|
||||
self->menu_box->destroy (self->menu_box);
|
||||
if (self->item_box)
|
||||
self->item_box->destroy (self->item_box);
|
||||
if (self->selected_item_box)
|
||||
self->selected_item_box->destroy (self->selected_item_box);
|
||||
if (self->icon_manager)
|
||||
grub_gfxmenu_icon_manager_destroy (self->icon_manager);
|
||||
if (self->scrollbar_thumb)
|
||||
self->scrollbar_thumb->destroy (self->scrollbar_thumb);
|
||||
if (self->scrollbar_frame)
|
||||
self->scrollbar_frame->destroy (self->scrollbar_frame);
|
||||
grub_free (self->scrollbar_thumb_pattern);
|
||||
grub_free (self->scrollbar_frame_pattern);
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
static int
|
||||
get_num_shown_items (list_impl_t self)
|
||||
{
|
||||
int boxpad = self->item_padding;
|
||||
int item_vspace = self->item_spacing;
|
||||
int item_height = self->item_height;
|
||||
|
||||
grub_gfxmenu_box_t box = self->menu_box;
|
||||
int box_top_pad = box->get_top_pad (box);
|
||||
int box_bottom_pad = box->get_bottom_pad (box);
|
||||
grub_gfxmenu_box_t itembox = self->item_box;
|
||||
grub_gfxmenu_box_t selbox = self->selected_item_box;
|
||||
int item_top_pad = itembox->get_top_pad (itembox);
|
||||
int item_bottom_pad = itembox->get_bottom_pad (itembox);
|
||||
int sel_top_pad = selbox->get_top_pad (selbox);
|
||||
int sel_bottom_pad = selbox->get_bottom_pad (selbox);
|
||||
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
|
||||
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
|
||||
|
||||
if (item_height + item_vspace <= 0)
|
||||
return 1;
|
||||
|
||||
return (self->bounds.height + item_vspace - 2 * boxpad
|
||||
- max_top_pad - max_bottom_pad
|
||||
- box_top_pad - box_bottom_pad) / (item_height + item_vspace);
|
||||
}
|
||||
|
||||
static int
|
||||
check_boxes (list_impl_t self)
|
||||
{
|
||||
if (self->need_to_recreate_boxes)
|
||||
{
|
||||
grub_gui_recreate_box (&self->menu_box,
|
||||
self->menu_box_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
grub_gui_recreate_box (&self->item_box,
|
||||
self->item_box_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
grub_gui_recreate_box (&self->selected_item_box,
|
||||
self->selected_item_box_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
self->need_to_recreate_boxes = 0;
|
||||
}
|
||||
|
||||
return (self->menu_box != 0 && self->selected_item_box != 0
|
||||
&& self->item_box != 0);
|
||||
}
|
||||
|
||||
static int
|
||||
check_scrollbar (list_impl_t self)
|
||||
{
|
||||
if (self->need_to_recreate_scrollbar)
|
||||
{
|
||||
grub_gui_recreate_box (&self->scrollbar_frame,
|
||||
self->scrollbar_frame_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
grub_gui_recreate_box (&self->scrollbar_thumb,
|
||||
self->scrollbar_thumb_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
self->need_to_recreate_scrollbar = 0;
|
||||
}
|
||||
|
||||
if (self->scrollbar_frame == 0 || self->scrollbar_thumb == 0)
|
||||
return 0;
|
||||
|
||||
/* Sanity checks. */
|
||||
grub_gfxmenu_box_t frame = self->scrollbar_frame;
|
||||
grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
|
||||
grub_gfxmenu_box_t menu = self->menu_box;
|
||||
int min_width = frame->get_left_pad (frame)
|
||||
+ frame->get_right_pad (frame);
|
||||
int min_height = frame->get_top_pad (frame)
|
||||
+ frame->get_bottom_pad (frame)
|
||||
+ self->scrollbar_top_pad + self->scrollbar_bottom_pad
|
||||
+ menu->get_top_pad (menu)
|
||||
+ menu->get_bottom_pad (menu);
|
||||
if (!self->scrollbar_thumb_overlay)
|
||||
{
|
||||
min_width += thumb->get_left_pad (thumb)
|
||||
+ thumb->get_right_pad (thumb);
|
||||
min_height += thumb->get_top_pad (thumb)
|
||||
+ thumb->get_bottom_pad (thumb);
|
||||
}
|
||||
if (min_width <= self->scrollbar_width
|
||||
&& min_height <= (int) self->bounds.height)
|
||||
return 1;
|
||||
|
||||
/* Unprintable dimenstions. */
|
||||
self->draw_scrollbar = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
list_get_id (void *vself)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
return self->id;
|
||||
}
|
||||
|
||||
static int
|
||||
list_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
{
|
||||
return (grub_strcmp (type, "component") == 0
|
||||
|| grub_strcmp (type, "list") == 0);
|
||||
}
|
||||
|
||||
static struct grub_video_bitmap *
|
||||
get_item_icon (list_impl_t self, int item_index)
|
||||
{
|
||||
grub_menu_entry_t entry;
|
||||
entry = grub_menu_get_entry (self->view->menu, item_index);
|
||||
if (! entry)
|
||||
return 0;
|
||||
|
||||
return grub_gfxmenu_icon_manager_get_icon (self->icon_manager, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
make_selected_item_visible (list_impl_t self)
|
||||
{
|
||||
int selected_index = self->view->selected;
|
||||
if (selected_index < 0)
|
||||
return; /* No item is selected. */
|
||||
int num_shown_items = get_num_shown_items (self);
|
||||
int last_shown_index = self->first_shown_index + (num_shown_items - 1);
|
||||
if (selected_index < self->first_shown_index)
|
||||
self->first_shown_index = selected_index;
|
||||
else if (selected_index > last_shown_index)
|
||||
self->first_shown_index = selected_index - (num_shown_items - 1);
|
||||
}
|
||||
|
||||
/* Draw a scrollbar on the menu. */
|
||||
static void
|
||||
draw_scrollbar (list_impl_t self,
|
||||
int value, int extent, int min, int max,
|
||||
int scrollbar_width, int scrollbar_height)
|
||||
{
|
||||
unsigned thumby, thumbheight;
|
||||
|
||||
grub_gfxmenu_box_t frame = self->scrollbar_frame;
|
||||
grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
|
||||
int frame_vertical_pad = (frame->get_top_pad (frame)
|
||||
+ frame->get_bottom_pad (frame));
|
||||
int frame_horizontal_pad = (frame->get_left_pad (frame)
|
||||
+ frame->get_right_pad (frame));
|
||||
unsigned thumb_vertical_pad = (thumb->get_top_pad (thumb)
|
||||
+ thumb->get_bottom_pad (thumb));
|
||||
int thumb_horizontal_pad = (thumb->get_left_pad (thumb)
|
||||
+ thumb->get_right_pad (thumb));
|
||||
int tracktop = frame->get_top_pad (frame);
|
||||
unsigned tracklen;
|
||||
if (scrollbar_height <= frame_vertical_pad)
|
||||
tracklen = 0;
|
||||
else
|
||||
tracklen = scrollbar_height - frame_vertical_pad;
|
||||
frame->set_content_size (frame,
|
||||
scrollbar_width - frame_horizontal_pad,
|
||||
tracklen);
|
||||
if (self->scrollbar_thumb_overlay)
|
||||
{
|
||||
tracklen += thumb_vertical_pad;
|
||||
tracktop -= thumb->get_top_pad (thumb);
|
||||
}
|
||||
if (value <= min || max <= min)
|
||||
thumby = 0;
|
||||
else
|
||||
thumby = ((unsigned) tracklen * (value - min))
|
||||
/ ((unsigned) (max - min));
|
||||
if (max <= min)
|
||||
thumbheight = 1;
|
||||
else
|
||||
thumbheight = ((unsigned) (tracklen * extent)
|
||||
/ ((unsigned) (max - min))) + 1;
|
||||
/* Rare occasion: too many entries or too low height. */
|
||||
if (thumbheight < thumb_vertical_pad)
|
||||
{
|
||||
thumbheight = thumb_vertical_pad;
|
||||
if (value <= min || max <= extent
|
||||
|| tracklen <= thumb_vertical_pad)
|
||||
thumby = 0;
|
||||
else
|
||||
thumby = ((unsigned) ((tracklen - thumb_vertical_pad) * (value - min))
|
||||
/ ((unsigned)(max - extent)));
|
||||
}
|
||||
thumby += tracktop;
|
||||
int thumbx = frame->get_left_pad (frame);
|
||||
int thumbwidth = scrollbar_width - frame_horizontal_pad;
|
||||
if (!self->scrollbar_thumb_overlay)
|
||||
thumbwidth -= thumb_horizontal_pad;
|
||||
else
|
||||
thumbx -= thumb->get_left_pad (thumb);
|
||||
thumb->set_content_size (thumb, thumbwidth,
|
||||
thumbheight - thumb_vertical_pad);
|
||||
frame->draw (frame, 0, 0);
|
||||
thumb->draw (thumb, thumbx, thumby);
|
||||
}
|
||||
|
||||
/* Draw the list of items. */
|
||||
static void
|
||||
draw_menu (list_impl_t self, int num_shown_items)
|
||||
{
|
||||
if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
|
||||
return;
|
||||
|
||||
int boxpad = self->item_padding;
|
||||
int icon_text_space = self->item_icon_space;
|
||||
int item_vspace = self->item_spacing;
|
||||
|
||||
int ascent = grub_font_get_ascent (self->item_font);
|
||||
int descent = grub_font_get_descent (self->item_font);
|
||||
int selected_ascent = grub_font_get_ascent (self->selected_item_font);
|
||||
int selected_descent = grub_font_get_descent (self->selected_item_font);
|
||||
int text_box_height = self->item_height;
|
||||
|
||||
make_selected_item_visible (self);
|
||||
|
||||
grub_gfxmenu_box_t itembox = self->item_box;
|
||||
grub_gfxmenu_box_t selbox = self->selected_item_box;
|
||||
int item_leftpad = itembox->get_left_pad (itembox);
|
||||
int item_rightpad = itembox->get_right_pad (itembox);
|
||||
int item_border_width = item_leftpad + item_rightpad;
|
||||
int item_toppad = itembox->get_top_pad (itembox);
|
||||
int sel_leftpad = selbox->get_left_pad (selbox);
|
||||
int sel_rightpad = selbox->get_right_pad (selbox);
|
||||
int sel_border_width = sel_leftpad + sel_rightpad;
|
||||
int sel_toppad = selbox->get_top_pad (selbox);
|
||||
|
||||
int max_leftpad = grub_max (item_leftpad, sel_leftpad);
|
||||
int max_toppad = grub_max (item_toppad, sel_toppad);
|
||||
int item_top = 0;
|
||||
int menu_index;
|
||||
int visible_index;
|
||||
struct grub_video_rect oviewport;
|
||||
|
||||
grub_video_get_viewport (&oviewport.x, &oviewport.y,
|
||||
&oviewport.width, &oviewport.height);
|
||||
grub_video_set_viewport (oviewport.x + boxpad,
|
||||
oviewport.y + boxpad,
|
||||
oviewport.width - 2 * boxpad,
|
||||
oviewport.height - 2 * boxpad);
|
||||
|
||||
int cwidth = oviewport.width - 2 * boxpad;
|
||||
|
||||
itembox->set_content_size (itembox, cwidth - item_border_width,
|
||||
text_box_height);
|
||||
selbox->set_content_size (selbox, cwidth - sel_border_width,
|
||||
text_box_height);
|
||||
|
||||
int text_left_offset = self->icon_width + icon_text_space;
|
||||
int item_text_top_offset = (text_box_height - (ascent + descent)) / 2 + ascent;
|
||||
int sel_text_top_offset = (text_box_height - (selected_ascent
|
||||
+ selected_descent)) / 2
|
||||
+ selected_ascent;
|
||||
|
||||
grub_video_rect_t svpsave, sviewport;
|
||||
sviewport.x = max_leftpad + text_left_offset;
|
||||
int text_viewport_width = cwidth - sviewport.x;
|
||||
sviewport.height = text_box_height;
|
||||
|
||||
grub_video_color_t item_color;
|
||||
grub_video_color_t sel_color;
|
||||
item_color = grub_video_map_rgba_color (self->item_color);
|
||||
sel_color = grub_video_map_rgba_color (self->selected_item_color);
|
||||
|
||||
int item_box_top_offset = max_toppad - item_toppad;
|
||||
int sel_box_top_offset = max_toppad - sel_toppad;
|
||||
int item_viewport_width = text_viewport_width - item_rightpad;
|
||||
int sel_viewport_width = text_viewport_width - sel_rightpad;
|
||||
int tmp_icon_top_offset = (text_box_height - self->icon_height) / 2;
|
||||
int item_icon_top_offset = item_toppad + tmp_icon_top_offset;
|
||||
int sel_icon_top_offset = sel_toppad + tmp_icon_top_offset;
|
||||
|
||||
for (visible_index = 0, menu_index = self->first_shown_index;
|
||||
visible_index < num_shown_items && menu_index < self->view->menu->size;
|
||||
visible_index++, menu_index++)
|
||||
{
|
||||
int is_selected = (menu_index == self->view->selected);
|
||||
struct grub_video_bitmap *icon;
|
||||
grub_font_t font;
|
||||
grub_video_color_t color;
|
||||
int text_top_offset;
|
||||
int top_pad;
|
||||
int icon_top_offset;
|
||||
int viewport_width;
|
||||
|
||||
if (is_selected)
|
||||
{
|
||||
selbox->draw (selbox, 0, item_top + sel_box_top_offset);
|
||||
font = self->selected_item_font;
|
||||
color = sel_color;
|
||||
text_top_offset = sel_text_top_offset;
|
||||
top_pad = sel_toppad;
|
||||
icon_top_offset = sel_icon_top_offset;
|
||||
viewport_width = sel_viewport_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
itembox->draw (itembox, 0, item_top + item_box_top_offset);
|
||||
font = self->item_font;
|
||||
color = item_color;
|
||||
text_top_offset = item_text_top_offset;
|
||||
top_pad = item_toppad;
|
||||
icon_top_offset = item_icon_top_offset;
|
||||
viewport_width = item_viewport_width;
|
||||
}
|
||||
|
||||
icon = get_item_icon (self, menu_index);
|
||||
if (icon != 0)
|
||||
grub_video_blit_bitmap (icon, GRUB_VIDEO_BLIT_BLEND,
|
||||
max_leftpad,
|
||||
item_top + icon_top_offset,
|
||||
0, 0, self->icon_width, self->icon_height);
|
||||
|
||||
const char *item_title =
|
||||
grub_menu_get_entry (self->view->menu, menu_index)->title;
|
||||
|
||||
|
||||
int off = self->view->menu_title_offset[menu_index];
|
||||
const char *scrolled_title =
|
||||
grub_utf8_offset_code (item_title, grub_strlen (item_title), off);
|
||||
if (scrolled_title)
|
||||
item_title = scrolled_title;
|
||||
|
||||
sviewport.y = item_top + top_pad;
|
||||
sviewport.width = viewport_width;
|
||||
grub_gui_set_viewport (&sviewport, &svpsave);
|
||||
grub_font_draw_string (item_title,
|
||||
font,
|
||||
color,
|
||||
0,
|
||||
text_top_offset);
|
||||
grub_gui_restore_viewport (&svpsave);
|
||||
|
||||
item_top += text_box_height + item_vspace;
|
||||
}
|
||||
grub_video_set_viewport (oviewport.x,
|
||||
oviewport.y,
|
||||
oviewport.width,
|
||||
oviewport.height);
|
||||
}
|
||||
|
||||
static void
|
||||
list_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
grub_video_rect_t vpsave;
|
||||
|
||||
if (! self->visible)
|
||||
return;
|
||||
if (!grub_video_have_common_points (region, &self->bounds))
|
||||
return;
|
||||
|
||||
check_boxes (self);
|
||||
|
||||
if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
|
||||
return;
|
||||
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
{
|
||||
grub_gfxmenu_box_t box = self->menu_box;
|
||||
int box_left_pad = box->get_left_pad (box);
|
||||
int box_top_pad = box->get_top_pad (box);
|
||||
int box_right_pad = box->get_right_pad (box);
|
||||
int box_bottom_pad = box->get_bottom_pad (box);
|
||||
grub_video_rect_t vpsave2, content_rect;
|
||||
int num_shown_items = get_num_shown_items (self);
|
||||
int drawing_scrollbar = (self->draw_scrollbar
|
||||
&& (num_shown_items < self->view->menu->size)
|
||||
&& check_scrollbar (self));
|
||||
int scrollbar_width = self->scrollbar_width;
|
||||
|
||||
content_rect.x = box_left_pad;
|
||||
content_rect.y = box_top_pad;
|
||||
content_rect.width = self->bounds.width - box_left_pad - box_right_pad;
|
||||
content_rect.height = self->bounds.height - box_top_pad - box_bottom_pad;
|
||||
|
||||
box->set_content_size (box, content_rect.width, content_rect.height);
|
||||
|
||||
box->draw (box, 0, 0);
|
||||
|
||||
switch (self->scrollbar_slice)
|
||||
{
|
||||
case SCROLLBAR_SLICE_WEST:
|
||||
content_rect.x += self->scrollbar_right_pad;
|
||||
content_rect.width -= self->scrollbar_right_pad;
|
||||
break;
|
||||
case SCROLLBAR_SLICE_CENTER:
|
||||
if (drawing_scrollbar)
|
||||
content_rect.width -= scrollbar_width + self->scrollbar_left_pad
|
||||
+ self->scrollbar_right_pad;
|
||||
break;
|
||||
case SCROLLBAR_SLICE_EAST:
|
||||
content_rect.width -= self->scrollbar_left_pad;
|
||||
break;
|
||||
}
|
||||
|
||||
grub_gui_set_viewport (&content_rect, &vpsave2);
|
||||
draw_menu (self, num_shown_items);
|
||||
grub_gui_restore_viewport (&vpsave2);
|
||||
|
||||
if (drawing_scrollbar)
|
||||
{
|
||||
content_rect.y += self->scrollbar_top_pad;
|
||||
content_rect.height -= self->scrollbar_top_pad
|
||||
+ self->scrollbar_bottom_pad;
|
||||
content_rect.width = scrollbar_width;
|
||||
switch (self->scrollbar_slice)
|
||||
{
|
||||
case SCROLLBAR_SLICE_WEST:
|
||||
if (box_left_pad > scrollbar_width)
|
||||
{
|
||||
content_rect.x = box_left_pad - scrollbar_width;
|
||||
content_rect.width = scrollbar_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
content_rect.x = 0;
|
||||
content_rect.width = box_left_pad;
|
||||
}
|
||||
break;
|
||||
case SCROLLBAR_SLICE_CENTER:
|
||||
content_rect.x = self->bounds.width - box_right_pad
|
||||
- scrollbar_width - self->scrollbar_right_pad;
|
||||
content_rect.width = scrollbar_width;
|
||||
break;
|
||||
case SCROLLBAR_SLICE_EAST:
|
||||
content_rect.x = self->bounds.width - box_right_pad;
|
||||
content_rect.width = box_right_pad;
|
||||
break;
|
||||
}
|
||||
|
||||
grub_gui_set_viewport (&content_rect, &vpsave2);
|
||||
draw_scrollbar (self,
|
||||
self->first_shown_index, num_shown_items,
|
||||
0, self->view->menu->size,
|
||||
scrollbar_width,
|
||||
content_rect.height);
|
||||
grub_gui_restore_viewport (&vpsave2);
|
||||
}
|
||||
}
|
||||
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
static void
|
||||
list_set_parent (void *vself, grub_gui_container_t parent)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
self->parent = parent;
|
||||
}
|
||||
|
||||
static grub_gui_container_t
|
||||
list_get_parent (void *vself)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
return self->parent;
|
||||
}
|
||||
|
||||
static void
|
||||
list_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
self->bounds = *bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
list_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
*bounds = self->bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
list_get_minimal_size (void *vself, unsigned *width, unsigned *height)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
|
||||
if (check_boxes (self))
|
||||
{
|
||||
int boxpad = self->item_padding;
|
||||
int item_vspace = self->item_spacing;
|
||||
int item_height = self->item_height;
|
||||
int num_items = 3;
|
||||
|
||||
grub_gfxmenu_box_t box = self->menu_box;
|
||||
int box_left_pad = box->get_left_pad (box);
|
||||
int box_top_pad = box->get_top_pad (box);
|
||||
int box_right_pad = box->get_right_pad (box);
|
||||
int box_bottom_pad = box->get_bottom_pad (box);
|
||||
unsigned width_s;
|
||||
|
||||
grub_gfxmenu_box_t selbox = self->selected_item_box;
|
||||
int sel_top_pad = selbox->get_top_pad (selbox);
|
||||
int sel_bottom_pad = selbox->get_bottom_pad (selbox);
|
||||
int sel_left_pad = selbox->get_left_pad (selbox);
|
||||
int sel_right_pad = selbox->get_right_pad (selbox);
|
||||
|
||||
grub_gfxmenu_box_t itembox = self->item_box;
|
||||
int item_top_pad = itembox->get_top_pad (itembox);
|
||||
int item_bottom_pad = itembox->get_bottom_pad (itembox);
|
||||
int item_left_pad = itembox->get_left_pad (itembox);
|
||||
int item_right_pad = itembox->get_right_pad (itembox);
|
||||
|
||||
int max_left_pad = grub_max (item_left_pad, sel_left_pad);
|
||||
int max_right_pad = grub_max (item_right_pad, sel_right_pad);
|
||||
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
|
||||
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
|
||||
|
||||
*width = grub_font_get_string_width (self->item_font, "Typical OS");
|
||||
width_s = grub_font_get_string_width (self->selected_item_font,
|
||||
"Typical OS");
|
||||
if (*width < width_s)
|
||||
*width = width_s;
|
||||
|
||||
*width += 2 * boxpad + box_left_pad + box_right_pad
|
||||
+ max_left_pad + max_right_pad
|
||||
+ self->item_icon_space + self->icon_width;
|
||||
|
||||
switch (self->scrollbar_slice)
|
||||
{
|
||||
case SCROLLBAR_SLICE_WEST:
|
||||
*width += self->scrollbar_right_pad;
|
||||
break;
|
||||
case SCROLLBAR_SLICE_CENTER:
|
||||
*width += self->scrollbar_width + self->scrollbar_left_pad
|
||||
+ self->scrollbar_right_pad;
|
||||
break;
|
||||
case SCROLLBAR_SLICE_EAST:
|
||||
*width += self->scrollbar_left_pad;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the menu box height to fit the items. */
|
||||
*height = (item_height * num_items
|
||||
+ item_vspace * (num_items - 1)
|
||||
+ 2 * boxpad
|
||||
+ box_top_pad + box_bottom_pad
|
||||
+ max_top_pad + max_bottom_pad);
|
||||
}
|
||||
else
|
||||
{
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
list_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
if (grub_strcmp (name, "item_font") == 0)
|
||||
{
|
||||
self->item_font = grub_font_get (value);
|
||||
if (self->selected_item_font_inherit)
|
||||
self->selected_item_font = self->item_font;
|
||||
}
|
||||
else if (grub_strcmp (name, "selected_item_font") == 0)
|
||||
{
|
||||
if (! value || grub_strcmp (value, "inherit") == 0)
|
||||
{
|
||||
self->selected_item_font = self->item_font;
|
||||
self->selected_item_font_inherit = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->selected_item_font = grub_font_get (value);
|
||||
self->selected_item_font_inherit = 0;
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "item_color") == 0)
|
||||
{
|
||||
grub_video_rgba_color_t color;
|
||||
if (grub_video_parse_color (value, &color) == GRUB_ERR_NONE)
|
||||
{
|
||||
self->item_color = color;
|
||||
if (self->selected_item_color_inherit)
|
||||
self->selected_item_color = self->item_color;
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "selected_item_color") == 0)
|
||||
{
|
||||
if (! value || grub_strcmp (value, "inherit") == 0)
|
||||
{
|
||||
self->selected_item_color = self->item_color;
|
||||
self->selected_item_color_inherit = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_video_rgba_color_t color;
|
||||
if (grub_video_parse_color (value, &color)
|
||||
== GRUB_ERR_NONE)
|
||||
{
|
||||
self->selected_item_color = color;
|
||||
self->selected_item_color_inherit = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "icon_width") == 0)
|
||||
{
|
||||
self->icon_width = grub_strtol (value, 0, 10);
|
||||
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||
self->icon_width,
|
||||
self->icon_height);
|
||||
}
|
||||
else if (grub_strcmp (name, "icon_height") == 0)
|
||||
{
|
||||
self->icon_height = grub_strtol (value, 0, 10);
|
||||
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||
self->icon_width,
|
||||
self->icon_height);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_height") == 0)
|
||||
{
|
||||
self->item_height = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_padding") == 0)
|
||||
{
|
||||
self->item_padding = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_icon_space") == 0)
|
||||
{
|
||||
self->item_icon_space = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_spacing") == 0)
|
||||
{
|
||||
self->item_spacing = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "visible") == 0)
|
||||
{
|
||||
self->visible = grub_strcmp (value, "false") != 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "menu_pixmap_style") == 0)
|
||||
{
|
||||
self->need_to_recreate_boxes = 1;
|
||||
grub_free (self->menu_box_pattern);
|
||||
self->menu_box_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "item_pixmap_style") == 0)
|
||||
{
|
||||
self->need_to_recreate_boxes = 1;
|
||||
grub_free (self->item_box_pattern);
|
||||
self->item_box_pattern = value ? grub_strdup (value) : 0;
|
||||
if (self->selected_item_box_pattern_inherit)
|
||||
{
|
||||
grub_free (self->selected_item_box_pattern);
|
||||
self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "selected_item_pixmap_style") == 0)
|
||||
{
|
||||
if (!value || grub_strcmp (value, "inherit") == 0)
|
||||
{
|
||||
grub_free (self->selected_item_box_pattern);
|
||||
char *tmp = self->item_box_pattern;
|
||||
self->selected_item_box_pattern = tmp ? grub_strdup (tmp) : 0;
|
||||
self->selected_item_box_pattern_inherit = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->need_to_recreate_boxes = 1;
|
||||
grub_free (self->selected_item_box_pattern);
|
||||
self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
|
||||
self->selected_item_box_pattern_inherit = 0;
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_frame") == 0)
|
||||
{
|
||||
self->need_to_recreate_scrollbar = 1;
|
||||
grub_free (self->scrollbar_frame_pattern);
|
||||
self->scrollbar_frame_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_thumb") == 0)
|
||||
{
|
||||
self->need_to_recreate_scrollbar = 1;
|
||||
grub_free (self->scrollbar_thumb_pattern);
|
||||
self->scrollbar_thumb_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_thumb_overlay") == 0)
|
||||
{
|
||||
self->scrollbar_thumb_overlay = grub_strcmp (value, "true") == 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_width") == 0)
|
||||
{
|
||||
self->scrollbar_width = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_slice") == 0)
|
||||
{
|
||||
if (grub_strcmp (value, "west") == 0)
|
||||
self->scrollbar_slice = SCROLLBAR_SLICE_WEST;
|
||||
else if (grub_strcmp (value, "center") == 0)
|
||||
self->scrollbar_slice = SCROLLBAR_SLICE_CENTER;
|
||||
else if (grub_strcmp (value, "east") == 0)
|
||||
self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_left_pad") == 0)
|
||||
{
|
||||
self->scrollbar_left_pad = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_right_pad") == 0)
|
||||
{
|
||||
self->scrollbar_right_pad = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_top_pad") == 0)
|
||||
{
|
||||
self->scrollbar_top_pad = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_bottom_pad") == 0)
|
||||
{
|
||||
self->scrollbar_bottom_pad = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar") == 0)
|
||||
{
|
||||
self->draw_scrollbar = grub_strcmp (value, "false") != 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "theme_dir") == 0)
|
||||
{
|
||||
self->need_to_recreate_boxes = 1;
|
||||
grub_free (self->theme_dir);
|
||||
self->theme_dir = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
self->id = grub_strdup (value);
|
||||
else
|
||||
self->id = 0;
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Set necessary information that the gfxmenu view provides. */
|
||||
static void
|
||||
list_set_view_info (void *vself,
|
||||
grub_gfxmenu_view_t view)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
grub_gfxmenu_icon_manager_set_theme_path (self->icon_manager,
|
||||
view->theme_path);
|
||||
self->view = view;
|
||||
}
|
||||
|
||||
/* Refresh list variables */
|
||||
static void
|
||||
list_refresh_info (void *vself,
|
||||
grub_gfxmenu_view_t view)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
if (view->nested)
|
||||
self->first_shown_index = 0;
|
||||
}
|
||||
|
||||
static struct grub_gui_component_ops list_comp_ops =
|
||||
{
|
||||
.destroy = list_destroy,
|
||||
.get_id = list_get_id,
|
||||
.is_instance = list_is_instance,
|
||||
.paint = list_paint,
|
||||
.set_parent = list_set_parent,
|
||||
.get_parent = list_get_parent,
|
||||
.set_bounds = list_set_bounds,
|
||||
.get_bounds = list_get_bounds,
|
||||
.get_minimal_size = list_get_minimal_size,
|
||||
.set_property = list_set_property
|
||||
};
|
||||
|
||||
static struct grub_gui_list_ops list_ops =
|
||||
{
|
||||
.set_view_info = list_set_view_info,
|
||||
.refresh_list = list_refresh_info
|
||||
};
|
||||
|
||||
grub_gui_component_t
|
||||
grub_gui_list_new (void)
|
||||
{
|
||||
list_impl_t self;
|
||||
grub_font_t default_font;
|
||||
grub_video_rgba_color_t default_fg_color;
|
||||
|
||||
self = grub_zalloc (sizeof (*self));
|
||||
if (! self)
|
||||
return 0;
|
||||
|
||||
self->list.ops = &list_ops;
|
||||
self->list.component.ops = &list_comp_ops;
|
||||
|
||||
self->visible = 1;
|
||||
|
||||
default_font = grub_font_get ("Unknown Regular 16");
|
||||
default_fg_color = grub_video_rgba_color_rgb (0, 0, 0);
|
||||
|
||||
self->icon_width = 32;
|
||||
self->icon_height = 32;
|
||||
self->item_height = 42;
|
||||
self->item_padding = 14;
|
||||
self->item_icon_space = 4;
|
||||
self->item_spacing = 16;
|
||||
self->item_font = default_font;
|
||||
self->selected_item_font_inherit = 1; /* Default to using the item_font. */
|
||||
self->selected_item_font = default_font;
|
||||
self->item_color = default_fg_color;
|
||||
self->selected_item_color_inherit = 1; /* Default to using the item_color. */
|
||||
self->selected_item_color = default_fg_color;
|
||||
|
||||
self->draw_scrollbar = 1;
|
||||
self->need_to_recreate_scrollbar = 1;
|
||||
self->scrollbar_frame = 0;
|
||||
self->scrollbar_thumb = 0;
|
||||
self->scrollbar_frame_pattern = 0;
|
||||
self->scrollbar_thumb_pattern = 0;
|
||||
self->scrollbar_thumb_overlay = 0;
|
||||
self->scrollbar_width = 16;
|
||||
self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
|
||||
self->scrollbar_left_pad = 2;
|
||||
self->scrollbar_right_pad = 0;
|
||||
self->scrollbar_top_pad = 0;
|
||||
self->scrollbar_bottom_pad = 0;
|
||||
|
||||
self->first_shown_index = 0;
|
||||
|
||||
self->need_to_recreate_boxes = 0;
|
||||
self->theme_dir = 0;
|
||||
self->menu_box_pattern = 0;
|
||||
self->item_box_pattern = 0;
|
||||
self->selected_item_box_pattern_inherit = 1;/*Default to using the item_box.*/
|
||||
self->selected_item_box_pattern = 0;
|
||||
self->menu_box = grub_gfxmenu_create_box (0, 0);
|
||||
self->item_box = grub_gfxmenu_create_box (0, 0);
|
||||
self->selected_item_box = grub_gfxmenu_create_box (0, 0);
|
||||
|
||||
self->icon_manager = grub_gfxmenu_icon_manager_new ();
|
||||
if (! self->icon_manager)
|
||||
{
|
||||
self->list.component.ops->destroy (self);
|
||||
return 0;
|
||||
}
|
||||
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||
self->icon_width,
|
||||
self->icon_height);
|
||||
return (grub_gui_component_t) self;
|
||||
}
|
@ -0,0 +1,250 @@
|
||||
/* env.c - Environment variables */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/env.h>
|
||||
#include <grub/env_private.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
/* The initial context. */
|
||||
static struct grub_env_context initial_context;
|
||||
|
||||
/* The current context. */
|
||||
struct grub_env_context *grub_current_context = &initial_context;
|
||||
|
||||
static grub_env_read_hook_t vtoy_menu_lang_read_hook;
|
||||
|
||||
/* Return the hash representation of the string S. */
|
||||
static unsigned int
|
||||
grub_env_hashval (const char *s)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
/* XXX: This can be done much more efficiently. */
|
||||
while (*s)
|
||||
i += 5 * *(s++);
|
||||
|
||||
return i % HASHSZ;
|
||||
}
|
||||
|
||||
static struct grub_env_var *
|
||||
grub_env_find (const char *name)
|
||||
{
|
||||
struct grub_env_var *var;
|
||||
int idx = grub_env_hashval (name);
|
||||
|
||||
/* Look for the variable in the current context. */
|
||||
for (var = grub_current_context->vars[idx]; var; var = var->next)
|
||||
if (grub_strcmp (var->name, name) == 0)
|
||||
return var;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_env_insert (struct grub_env_context *context,
|
||||
struct grub_env_var *var)
|
||||
{
|
||||
int idx = grub_env_hashval (var->name);
|
||||
|
||||
/* Insert the variable into the hashtable. */
|
||||
var->prevp = &context->vars[idx];
|
||||
var->next = context->vars[idx];
|
||||
if (var->next)
|
||||
var->next->prevp = &(var->next);
|
||||
context->vars[idx] = var;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_env_remove (struct grub_env_var *var)
|
||||
{
|
||||
/* Remove the entry from the variable table. */
|
||||
*var->prevp = var->next;
|
||||
if (var->next)
|
||||
var->next->prevp = var->prevp;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_env_set (const char *name, const char *val)
|
||||
{
|
||||
struct grub_env_var *var;
|
||||
|
||||
/* If the variable does already exist, just update the variable. */
|
||||
var = grub_env_find (name);
|
||||
if (var)
|
||||
{
|
||||
char *old = var->value;
|
||||
|
||||
if (var->write_hook)
|
||||
var->value = var->write_hook (var, val);
|
||||
else
|
||||
var->value = grub_strdup (val);
|
||||
|
||||
if (! var->value)
|
||||
{
|
||||
var->value = old;
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_free (old);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* The variable does not exist, so create a new one. */
|
||||
var = grub_zalloc (sizeof (*var));
|
||||
if (! var)
|
||||
return grub_errno;
|
||||
|
||||
var->name = grub_strdup (name);
|
||||
if (! var->name)
|
||||
goto fail;
|
||||
|
||||
var->value = grub_strdup (val);
|
||||
if (! var->value)
|
||||
goto fail;
|
||||
|
||||
grub_env_insert (grub_current_context, var);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
fail:
|
||||
grub_free (var->name);
|
||||
grub_free (var->value);
|
||||
grub_free (var);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
const char *
|
||||
grub_env_get (const char *name)
|
||||
{
|
||||
struct grub_env_var *var;
|
||||
|
||||
if (name && vtoy_menu_lang_read_hook && grub_strncmp(name, "VTLANG_", 7) == 0)
|
||||
return vtoy_menu_lang_read_hook(NULL, name);
|
||||
|
||||
var = grub_env_find (name);
|
||||
if (! var)
|
||||
return 0;
|
||||
|
||||
if (var->read_hook)
|
||||
return var->read_hook (var, var->value);
|
||||
|
||||
return var->value;
|
||||
}
|
||||
|
||||
void
|
||||
grub_env_unset (const char *name)
|
||||
{
|
||||
struct grub_env_var *var;
|
||||
|
||||
var = grub_env_find (name);
|
||||
if (! var)
|
||||
return;
|
||||
|
||||
if (var->read_hook || var->write_hook)
|
||||
{
|
||||
grub_env_set (name, "");
|
||||
return;
|
||||
}
|
||||
|
||||
grub_env_remove (var);
|
||||
|
||||
grub_free (var->name);
|
||||
grub_free (var->value);
|
||||
grub_free (var);
|
||||
}
|
||||
|
||||
struct grub_env_var *
|
||||
grub_env_update_get_sorted (void)
|
||||
{
|
||||
struct grub_env_var *sorted_list = 0;
|
||||
int i;
|
||||
|
||||
/* Add variables associated with this context into a sorted list. */
|
||||
for (i = 0; i < HASHSZ; i++)
|
||||
{
|
||||
struct grub_env_var *var;
|
||||
|
||||
for (var = grub_current_context->vars[i]; var; var = var->next)
|
||||
{
|
||||
struct grub_env_var *p, **q;
|
||||
|
||||
for (q = &sorted_list, p = *q; p; q = &((*q)->sorted_next), p = *q)
|
||||
{
|
||||
if (grub_strcmp (p->name, var->name) > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
var->sorted_next = *q;
|
||||
*q = var;
|
||||
}
|
||||
}
|
||||
|
||||
return sorted_list;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_register_variable_hook (const char *name,
|
||||
grub_env_read_hook_t read_hook,
|
||||
grub_env_write_hook_t write_hook)
|
||||
{
|
||||
struct grub_env_var *var = grub_env_find (name);
|
||||
|
||||
if (! var)
|
||||
{
|
||||
if (grub_env_set (name, "") != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
var = grub_env_find (name);
|
||||
/* XXX Insert an assertion? */
|
||||
}
|
||||
|
||||
var->read_hook = read_hook;
|
||||
var->write_hook = write_hook;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_register_vtoy_menu_lang_hook(grub_env_read_hook_t read_hook)
|
||||
{
|
||||
vtoy_menu_lang_read_hook = read_hook;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_env_export (const char *name)
|
||||
{
|
||||
struct grub_env_var *var;
|
||||
|
||||
var = grub_env_find (name);
|
||||
if (! var)
|
||||
{
|
||||
grub_err_t err;
|
||||
|
||||
err = grub_env_set (name, "");
|
||||
if (err)
|
||||
return err;
|
||||
var = grub_env_find (name);
|
||||
}
|
||||
var->global = 1;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/misc.h>
|
||||
#include <grub/script_sh.h>
|
||||
#include <grub/parser.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/charset.h>
|
||||
|
||||
grub_script_function_t grub_script_function_list;
|
||||
|
||||
grub_script_function_t
|
||||
grub_script_function_create (struct grub_script_arg *functionname_arg,
|
||||
struct grub_script *cmd)
|
||||
{
|
||||
grub_script_function_t func;
|
||||
grub_script_function_t *p;
|
||||
|
||||
func = (grub_script_function_t) grub_malloc (sizeof (*func));
|
||||
if (! func)
|
||||
return 0;
|
||||
|
||||
func->name = grub_strdup (functionname_arg->str);
|
||||
if (! func->name)
|
||||
{
|
||||
grub_free (func);
|
||||
return 0;
|
||||
}
|
||||
|
||||
func->func = cmd;
|
||||
|
||||
/* Keep the list sorted for simplicity. */
|
||||
p = &grub_script_function_list;
|
||||
while (*p)
|
||||
{
|
||||
if (grub_strcmp ((*p)->name, func->name) >= 0)
|
||||
break;
|
||||
|
||||
p = &((*p)->next);
|
||||
}
|
||||
|
||||
/* If the function already exists, overwrite the old function. */
|
||||
if (*p && grub_strcmp ((*p)->name, func->name) == 0)
|
||||
{
|
||||
grub_script_function_t q;
|
||||
|
||||
q = *p;
|
||||
grub_script_free (q->func);
|
||||
q->func = cmd;
|
||||
grub_free (func);
|
||||
func = q;
|
||||
}
|
||||
else
|
||||
{
|
||||
func->next = *p;
|
||||
*p = func;
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
void
|
||||
grub_script_function_remove (const char *name)
|
||||
{
|
||||
grub_script_function_t *p, q;
|
||||
|
||||
for (p = &grub_script_function_list, q = *p; q; p = &(q->next), q = q->next)
|
||||
if (grub_strcmp (name, q->name) == 0)
|
||||
{
|
||||
*p = q->next;
|
||||
grub_free (q->name);
|
||||
grub_script_free (q->func);
|
||||
grub_free (q);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
grub_script_function_t
|
||||
grub_script_function_find (char *functionname)
|
||||
{
|
||||
grub_script_function_t func;
|
||||
|
||||
for (func = grub_script_function_list; func; func = func->next)
|
||||
if (grub_strcmp (functionname, func->name) == 0)
|
||||
break;
|
||||
|
||||
if (! func)
|
||||
{
|
||||
char tmp[64];
|
||||
grub_strncpy (tmp, functionname, 63);
|
||||
tmp[63] = 0;
|
||||
/* Avoid truncating inside UTF-8 character. */
|
||||
tmp[grub_getend (tmp, tmp + grub_strlen (tmp))] = 0;
|
||||
grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("can't find command `%s'"), tmp);
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/api.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define GRUB_EFI_SIMPLE_POINTER_GUID \
|
||||
{ 0x31878c87, 0x0b75, 0x11d5, \
|
||||
{ 0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_efi_int32_t x;
|
||||
grub_efi_int32_t y;
|
||||
grub_efi_int32_t z;
|
||||
grub_efi_boolean_t left;
|
||||
grub_efi_boolean_t right;
|
||||
} grub_efi_mouse_state;
|
||||
|
||||
grub_efi_mouse_state no_move = {0, 0, 0, 0, 0};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_efi_uint64_t x;
|
||||
grub_efi_uint64_t y;
|
||||
grub_efi_uint64_t z;
|
||||
grub_efi_boolean_t left;
|
||||
grub_efi_boolean_t right;
|
||||
} grub_efi_mouse_mode;
|
||||
|
||||
struct grub_efi_simple_pointer_protocol
|
||||
{
|
||||
grub_efi_status_t (*reset) (struct grub_efi_simple_pointer_protocol *this,
|
||||
grub_efi_boolean_t extended_verification);
|
||||
grub_efi_status_t (*get_state) (struct grub_efi_simple_pointer_protocol *this,
|
||||
grub_efi_mouse_state *state);
|
||||
grub_efi_event_t *wait_for_input;
|
||||
grub_efi_mouse_mode *mode;
|
||||
};
|
||||
typedef struct grub_efi_simple_pointer_protocol grub_efi_simple_pointer_protocol_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_efi_uintn_t count;
|
||||
grub_efi_simple_pointer_protocol_t **mouse;
|
||||
} grub_efi_mouse_prot_t;
|
||||
|
||||
static grub_int32_t
|
||||
mouse_div (grub_int32_t a, grub_uint64_t b)
|
||||
{
|
||||
grub_int32_t s = 1, q, ret;
|
||||
grub_uint64_t n = a;
|
||||
if (!b)
|
||||
return 0;
|
||||
if (a < 0)
|
||||
{
|
||||
s = -1;
|
||||
n = -a;
|
||||
}
|
||||
q = grub_divmod64 (n, b, NULL);
|
||||
ret = s * (q > 0 ? q : -q);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_efi_mouse_prot_t *
|
||||
grub_efi_mouse_prot_init (void)
|
||||
{
|
||||
grub_efi_status_t status;
|
||||
grub_efi_guid_t mouse_guid = GRUB_EFI_SIMPLE_POINTER_GUID;
|
||||
grub_efi_mouse_prot_t *mouse_input = NULL;
|
||||
grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
|
||||
grub_efi_handle_t *buf;
|
||||
grub_efi_uintn_t count;
|
||||
grub_efi_uintn_t i;
|
||||
|
||||
status = efi_call_5 (b->locate_handle_buffer, GRUB_EFI_BY_PROTOCOL,
|
||||
&mouse_guid, NULL, &count, &buf);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
{
|
||||
#ifdef MOUSE_DEBUG
|
||||
grub_printf ("ERROR: SimplePointerProtocol not found.\n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mouse_input = grub_malloc (sizeof (grub_efi_mouse_prot_t));
|
||||
if (!mouse_input)
|
||||
goto end;
|
||||
mouse_input->mouse = grub_malloc (count
|
||||
* sizeof (grub_efi_simple_pointer_protocol_t *));
|
||||
if (!mouse_input->mouse)
|
||||
{
|
||||
grub_free (mouse_input);
|
||||
mouse_input = NULL;
|
||||
goto end;
|
||||
}
|
||||
mouse_input->count = count;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
efi_call_3 (b->handle_protocol,
|
||||
buf[i], &mouse_guid, (void **)&mouse_input->mouse[i]);
|
||||
#ifdef MOUSE_DEBUG
|
||||
grub_printf ("%d %p ", (int)i, mouse_input->mouse[i]);
|
||||
#endif
|
||||
efi_call_2 (mouse_input->mouse[i]->reset, mouse_input->mouse[i], 1);
|
||||
#ifdef MOUSE_DEBUG
|
||||
grub_printf
|
||||
("[%"PRIuGRUB_UINT64_T"] [%"PRIuGRUB_UINT64_T"] [%"PRIuGRUB_UINT64_T"]\n",
|
||||
mouse_input->mouse[i]->mode->x,
|
||||
mouse_input->mouse[i]->mode->y, mouse_input->mouse[i]->mode->z);
|
||||
#endif
|
||||
}
|
||||
|
||||
end:
|
||||
efi_call_1(b->free_pool, buf);
|
||||
|
||||
return mouse_input;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_efi_mouse_input_init (struct grub_term_input *term)
|
||||
{
|
||||
grub_efi_mouse_prot_t *mouse_input = NULL;
|
||||
if (term->data)
|
||||
return 0;
|
||||
mouse_input = grub_efi_mouse_prot_init ();
|
||||
if (!mouse_input)
|
||||
return GRUB_ERR_BAD_OS;
|
||||
|
||||
term->data = (void *)mouse_input;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
grub_mouse_getkey (struct grub_term_input *term)
|
||||
{
|
||||
grub_efi_mouse_state cur;
|
||||
grub_efi_mouse_prot_t *mouse = term->data;
|
||||
//int x;
|
||||
int y;
|
||||
int delta = 0;
|
||||
const char *env;
|
||||
grub_efi_uintn_t i;
|
||||
if (!mouse)
|
||||
return GRUB_TERM_NO_KEY;
|
||||
|
||||
env = grub_env_get("mouse_delta");
|
||||
if (env)
|
||||
delta = (int)grub_strtol(env, NULL, 10);
|
||||
|
||||
for (i = 0; i < mouse->count; i++)
|
||||
{
|
||||
efi_call_2 (mouse->mouse[i]->get_state, mouse->mouse[i], &cur);
|
||||
if (grub_memcmp (&cur, &no_move, sizeof (grub_efi_mouse_state)) != 0)
|
||||
{
|
||||
y = mouse_div (cur.y, mouse->mouse[i]->mode->y);
|
||||
if (cur.left)
|
||||
return 0x0d;
|
||||
if (cur.right)
|
||||
return GRUB_TERM_ESC;
|
||||
if (y > delta)
|
||||
return GRUB_TERM_KEY_DOWN;
|
||||
if (y < -delta)
|
||||
return GRUB_TERM_KEY_UP;
|
||||
}
|
||||
}
|
||||
return GRUB_TERM_NO_KEY;
|
||||
}
|
||||
|
||||
#ifdef MOUSE_DEBUG
|
||||
static grub_err_t
|
||||
grub_cmd_mouse_test (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
|
||||
{
|
||||
grub_efi_mouse_state cur;
|
||||
int x = 0, y = 0, z = 0;
|
||||
grub_efi_uintn_t i;
|
||||
grub_efi_mouse_prot_t *mouse = NULL;
|
||||
|
||||
mouse = grub_efi_mouse_prot_init ();
|
||||
if (!mouse)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "mouse not found.\n");
|
||||
grub_printf ("Press [1] to exit.\n");
|
||||
while (1)
|
||||
{
|
||||
if (grub_getkey_noblock () == '1')
|
||||
break;
|
||||
for (i = 0; i < mouse->count; i++)
|
||||
{
|
||||
efi_call_2 (mouse->mouse[i]->get_state, mouse->mouse[i], &cur);
|
||||
if (grub_memcmp (&cur, &no_move, sizeof (grub_efi_mouse_state)) != 0)
|
||||
{
|
||||
x = mouse_div (cur.x, mouse->mouse[i]->mode->x);
|
||||
y = mouse_div (cur.y, mouse->mouse[i]->mode->y);
|
||||
z = mouse_div (cur.z, mouse->mouse[i]->mode->z);
|
||||
grub_printf ("[ID=%d] X=%d Y=%d Z=%d L=%d R=%d\n",
|
||||
(int)i, x, y, z, cur.left, cur.right);
|
||||
}
|
||||
}
|
||||
grub_refresh ();
|
||||
}
|
||||
grub_free (mouse->mouse);
|
||||
grub_free (mouse);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
static grub_command_t cmd;
|
||||
#endif
|
||||
|
||||
static struct grub_term_input grub_mouse_term_input =
|
||||
{
|
||||
.name = "mouse",
|
||||
.getkey = grub_mouse_getkey,
|
||||
.init = grub_efi_mouse_input_init,
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(mouse)
|
||||
{
|
||||
grub_term_register_input ("mouse", &grub_mouse_term_input);
|
||||
#ifdef MOUSE_DEBUG
|
||||
cmd = grub_register_command ("mouse_test", grub_cmd_mouse_test, 0,
|
||||
N_("UEFI mouse test."));
|
||||
#endif
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(mouse)
|
||||
{
|
||||
grub_term_unregister_input (&grub_mouse_term_input);
|
||||
#ifdef MOUSE_DEBUG
|
||||
grub_unregister_command (cmd);
|
||||
#endif
|
||||
}
|
@ -0,0 +1,652 @@
|
||||
/******************************************************************************
|
||||
* ventoy_browser.c
|
||||
*
|
||||
* Copyright (c) 2022, longpanda <admin@ventoy.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/datetime.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/ventoy.h>
|
||||
#include "ventoy_def.h"
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define BROWSER_MENU_BUF 65536
|
||||
|
||||
static const char *g_vtoy_dev = NULL;
|
||||
static grub_fs_t g_menu_fs = NULL;
|
||||
static char *g_menu_device = NULL;
|
||||
static grub_device_t g_menu_dev = NULL;
|
||||
static char g_menu_path_buf[1024];
|
||||
static int g_menu_path_len = 0;
|
||||
static browser_node *g_browser_list = NULL;
|
||||
|
||||
static int ventoy_browser_strcmp(char *str1, char *str2)
|
||||
{
|
||||
char *s1, *s2;
|
||||
int c1 = 0;
|
||||
int c2 = 0;
|
||||
|
||||
for (s1 = str1, s2 = str2; *s1 && *s2; s1++, s2++)
|
||||
{
|
||||
c1 = *s1;
|
||||
c2 = *s2;
|
||||
|
||||
if (0 == g_sort_case_sensitive)
|
||||
{
|
||||
if (grub_islower(c1))
|
||||
{
|
||||
c1 = c1 - 'a' + 'A';
|
||||
}
|
||||
|
||||
if (grub_islower(c2))
|
||||
{
|
||||
c2 = c2 - 'a' + 'A';
|
||||
}
|
||||
}
|
||||
|
||||
if (c1 != c2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (c1 - c2);
|
||||
}
|
||||
|
||||
static int ventoy_browser_mbuf_alloc(browser_mbuf *mbuf)
|
||||
{
|
||||
grub_memset(mbuf, 0, sizeof(browser_mbuf));
|
||||
mbuf->buf = grub_malloc(BROWSER_MENU_BUF);
|
||||
if (!mbuf->buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mbuf->pos = 0;
|
||||
mbuf->max = BROWSER_MENU_BUF;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void ventoy_browser_mbuf_free(browser_mbuf *mbuf)
|
||||
{
|
||||
if (mbuf)
|
||||
grub_check_free(mbuf->buf)
|
||||
}
|
||||
|
||||
static inline int ventoy_browser_mbuf_extend(browser_mbuf *mbuf)
|
||||
{
|
||||
if (mbuf->max - mbuf->pos <= VTOY_SIZE_1KB)
|
||||
{
|
||||
mbuf->max += BROWSER_MENU_BUF;
|
||||
mbuf->buf = grub_realloc(mbuf->buf, mbuf->max);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static browser_node * ventoy_browser_find_top_node(int dir)
|
||||
{
|
||||
browser_node *node = NULL;
|
||||
browser_node *sel = NULL;
|
||||
|
||||
for (node = g_browser_list; node; node = node->next)
|
||||
{
|
||||
if (node->dir == dir)
|
||||
{
|
||||
if (sel)
|
||||
{
|
||||
if (ventoy_browser_strcmp(sel->filename, node->filename) > 0)
|
||||
{
|
||||
sel = node;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sel = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sel;
|
||||
}
|
||||
|
||||
static int ventoy_browser_iterate_partition(struct grub_disk *disk, const grub_partition_t partition, void *data)
|
||||
{
|
||||
char partname[64];
|
||||
char title[256];
|
||||
grub_device_t dev;
|
||||
grub_fs_t fs;
|
||||
char *Label = NULL;
|
||||
browser_mbuf *mbuf = (browser_mbuf *)data;
|
||||
|
||||
(void)data;
|
||||
|
||||
if (partition->number == 1 && g_vtoy_dev && grub_strcmp(disk->name, g_vtoy_dev) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_snprintf(partname, sizeof(partname) - 1, "%s,%d", disk->name, partition->number + 1);
|
||||
|
||||
dev = grub_device_open(partname);
|
||||
if (!dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
fs = grub_fs_probe(dev);
|
||||
if (!fs)
|
||||
{
|
||||
grub_device_close(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fs->fs_label(dev, &Label);
|
||||
|
||||
if (ventoy_check_file_exist("(%s)/.ventoyignore", partname))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_tree_view_menu_style == 0)
|
||||
{
|
||||
grub_snprintf(title, sizeof(title), "%-10s (%s,%s%d) [%s] %s %s",
|
||||
"DISK", disk->name, partition->msdostype == 0xee ? "gpt" : "msdos",
|
||||
partition->number + 1, (Label ? Label : ""), fs->name,
|
||||
grub_get_human_size(partition->len << disk->log_sector_size, GRUB_HUMAN_SIZE_SHORT));
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_snprintf(title, sizeof(title), "(%s,%s%d) [%s] %s %s",
|
||||
disk->name, partition->msdostype == 0xee ? "gpt" : "msdos",
|
||||
partition->number + 1, (Label ? Label : ""), fs->name,
|
||||
grub_get_human_size(partition->len << disk->log_sector_size, GRUB_HUMAN_SIZE_SHORT));
|
||||
}
|
||||
|
||||
if (ventoy_get_fs_type(fs->name) >= ventoy_fs_max)
|
||||
{
|
||||
browser_ssprintf(mbuf, "menuentry \"%s\" --class=vtoydisk {\n"
|
||||
" echo \"unsupported file system type!\" \n"
|
||||
" ventoy_pause\n"
|
||||
"}\n",
|
||||
title);
|
||||
}
|
||||
else
|
||||
{
|
||||
browser_ssprintf(mbuf, "menuentry \"%s\" --class=vtoydisk {\n"
|
||||
" vt_browser_dir %s,%d 0x%lx /\n"
|
||||
"}\n",
|
||||
title, disk->name, partition->number + 1, (ulong)fs);
|
||||
}
|
||||
|
||||
ventoy_browser_mbuf_extend(mbuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_browser_iterate_disk(const char *name, void *data)
|
||||
{
|
||||
grub_disk_t disk;
|
||||
|
||||
if (name[0] != 'h')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
disk = grub_disk_open(name);
|
||||
if (disk)
|
||||
{
|
||||
grub_partition_iterate(disk, ventoy_browser_iterate_partition, data);
|
||||
grub_disk_close(disk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_browser_valid_dirname(const char *name, int len)
|
||||
{
|
||||
if ((len == 1 && name[0] == '.') ||
|
||||
(len == 2 && name[0] == '.' && name[1] == '.'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!ventoy_img_name_valid(name, len))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_filt_trash_dir)
|
||||
{
|
||||
if (0 == grub_strncmp(name, ".trash-", 7) ||
|
||||
0 == grub_strcmp(name, ".Trashes"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (name[0] == '$')
|
||||
{
|
||||
if (0 == grub_strncmp(name, "$RECYCLE.BIN", 12) ||
|
||||
0 == grub_strncasecmp(name, "$Extend", 7))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (len == 25 && grub_strncmp(name, "System Volume Information", 25) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ventoy_browser_valid_filename(const char *filename, int len, int *type)
|
||||
{
|
||||
if (len < 4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (FILE_FLT(ISO) && 0 == grub_strcasecmp(filename + len - 4, ".iso"))
|
||||
{
|
||||
*type = img_type_iso;
|
||||
}
|
||||
else if (FILE_FLT(WIM) && g_wimboot_enable && (0 == grub_strcasecmp(filename + len - 4, ".wim")))
|
||||
{
|
||||
*type = img_type_wim;
|
||||
}
|
||||
else if (FILE_FLT(VHD) && g_vhdboot_enable && (0 == grub_strcasecmp(filename + len - 4, ".vhd") ||
|
||||
(len >= 5 && 0 == grub_strcasecmp(filename + len - 5, ".vhdx"))))
|
||||
{
|
||||
*type = img_type_vhd;
|
||||
}
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
else if (FILE_FLT(EFI) && 0 == grub_strcasecmp(filename + len - 4, ".efi"))
|
||||
{
|
||||
*type = img_type_efi;
|
||||
}
|
||||
#endif
|
||||
else if (FILE_FLT(IMG) && 0 == grub_strcasecmp(filename + len - 4, ".img"))
|
||||
{
|
||||
if (len == 18 && grub_strncmp(filename, "ventoy_", 7) == 0)
|
||||
{
|
||||
if (grub_strncmp(filename + 7, "wimboot", 7) == 0 ||
|
||||
grub_strncmp(filename + 7, "vhdboot", 7) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
*type = img_type_img;
|
||||
}
|
||||
else if (FILE_FLT(VTOY) && len >= 5 && 0 == grub_strcasecmp(filename + len - 5, ".vtoy"))
|
||||
{
|
||||
*type = img_type_vtoy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_filt_dot_underscore_file && filename[0] == '.' && filename[1] == '_')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ventoy_browser_check_ignore(const char *device, const char *root, const char *dir)
|
||||
{
|
||||
grub_file_t file;
|
||||
char fullpath[1024] = {0};
|
||||
|
||||
grub_snprintf(fullpath, 1023, "(%s)%s/%s/.ventoyignore", device, root, dir);
|
||||
file = grub_file_open(fullpath, GRUB_FILE_TYPE_NONE);
|
||||
if (!file)
|
||||
{
|
||||
grub_errno = 0;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int ventoy_browser_iterate_dir(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
int type;
|
||||
int len;
|
||||
browser_node *node;
|
||||
|
||||
(void)data;
|
||||
|
||||
len = grub_strlen(filename);
|
||||
|
||||
if (info->dir)
|
||||
{
|
||||
if (!ventoy_browser_valid_dirname(filename, len))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ventoy_browser_check_ignore(g_menu_device, g_menu_path_buf, filename))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
node = grub_zalloc(sizeof(browser_node));
|
||||
if (!node)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
node->dir = 1;
|
||||
grub_strncpy(node->filename, filename, sizeof(node->filename));
|
||||
|
||||
if (g_tree_view_menu_style == 0)
|
||||
{
|
||||
grub_snprintf(node->menuentry, sizeof(node->menuentry),
|
||||
"menuentry \"%-10s [%s]\" --class=vtoydir {\n"
|
||||
" vt_browser_dir %s 0x%lx \"%s/%s\"\n"
|
||||
"}\n",
|
||||
"DIR", filename, g_menu_device, (ulong)g_menu_fs, g_menu_path_buf, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_snprintf(node->menuentry, sizeof(node->menuentry),
|
||||
"menuentry \"[%s]\" --class=vtoydir {\n"
|
||||
" vt_browser_dir %s 0x%lx \"%s/%s\"\n"
|
||||
"}\n",
|
||||
filename, g_menu_device, (ulong)g_menu_fs, g_menu_path_buf, filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_uint64_t fsize = info->size;
|
||||
|
||||
if (!ventoy_browser_valid_filename(filename, len, &type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (grub_file_is_vlnk_suffix(filename, len))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
node = grub_zalloc(sizeof(browser_node));
|
||||
if (!node)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fsize == 0)
|
||||
{
|
||||
struct grub_file file;
|
||||
|
||||
grub_memset(&file, 0, sizeof(file));
|
||||
file.device = g_menu_dev;
|
||||
grub_snprintf(node->menuentry, sizeof(node->menuentry), "%s/%s", g_menu_path_buf, filename);
|
||||
if (g_menu_fs->fs_open(&file, node->menuentry) == GRUB_ERR_NONE)
|
||||
{
|
||||
fsize = file.size;
|
||||
g_menu_fs->fs_close(&file);
|
||||
}
|
||||
}
|
||||
|
||||
node->dir = 0;
|
||||
grub_strncpy(node->filename, filename, sizeof(node->filename));
|
||||
|
||||
if (g_tree_view_menu_style == 0)
|
||||
{
|
||||
grub_snprintf(node->menuentry, sizeof(node->menuentry),
|
||||
"menuentry \"%-10s %s\" --class=%s {\n"
|
||||
" vt_set_fake_vlnk \"(%s)%s/%s\" %s %llu\n"
|
||||
" %s_common_menuentry\n"
|
||||
" vt_reset_fake_vlnk\n"
|
||||
"}\n",
|
||||
grub_get_human_size(fsize, GRUB_HUMAN_SIZE_SHORT), filename, g_menu_class[type],
|
||||
g_menu_device, g_menu_path_buf, filename, g_menu_prefix[type], (ulonglong)fsize,
|
||||
g_menu_prefix[type]);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_snprintf(node->menuentry, sizeof(node->menuentry),
|
||||
"menuentry \"%s\" --class=%s {\n"
|
||||
" vt_set_fake_vlnk \"(%s)%s/%s\" %s %llu\n"
|
||||
" %s_common_menuentry\n"
|
||||
" vt_reset_fake_vlnk\n"
|
||||
"}\n",
|
||||
filename, g_menu_class[type],
|
||||
g_menu_device, g_menu_path_buf, filename, g_menu_prefix[type], (ulonglong)fsize,
|
||||
g_menu_prefix[type]);
|
||||
}
|
||||
}
|
||||
|
||||
node->prev = NULL;
|
||||
node->next = g_browser_list;
|
||||
if (g_browser_list)
|
||||
{
|
||||
g_browser_list->prev = node;
|
||||
}
|
||||
g_browser_list = node;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_browser_iso_part(void)
|
||||
{
|
||||
char cfgfile[64];
|
||||
char *buffer = NULL;
|
||||
int pos = 0;
|
||||
int buflen = 0;
|
||||
int cfglen = 0;
|
||||
|
||||
cfglen = g_tree_script_pos - g_tree_script_pre;
|
||||
buflen = cfglen + 512;
|
||||
buffer = grub_malloc(buflen);
|
||||
if (!buffer)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_tree_view_menu_style == 0)
|
||||
{
|
||||
pos = grub_snprintf(buffer, buflen, "menuentry \"%-10s [../]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n}\n", "<--");
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = grub_snprintf(buffer, buflen, "menuentry \"[../]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n}\n");
|
||||
}
|
||||
|
||||
grub_memcpy(buffer + pos, g_tree_script_buf + g_tree_script_pre, cfglen);
|
||||
pos += cfglen;
|
||||
|
||||
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)buffer, pos);
|
||||
grub_script_execute_sourcecode(cfgfile);
|
||||
|
||||
grub_free(buffer);
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_browser_dir(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
grub_fs_t fs;
|
||||
grub_device_t dev;
|
||||
char cfgfile[64];
|
||||
browser_node *node;
|
||||
browser_mbuf mbuf;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
if (args[2][0] == '/' && args[2][1] == 0)
|
||||
{
|
||||
grub_snprintf(cfgfile, sizeof(cfgfile), "(%s)", args[0]);
|
||||
if (grub_strcmp(cfgfile, g_iso_path) == 0)
|
||||
{
|
||||
return ventoy_browser_iso_part();
|
||||
}
|
||||
}
|
||||
|
||||
if (!ventoy_browser_mbuf_alloc(&mbuf))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fs = (grub_fs_t)grub_strtoul(args[1], NULL, 16);
|
||||
if (!fs)
|
||||
{
|
||||
debug("Invalid fs %s\n", args[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev = grub_device_open(args[0]);
|
||||
if (!dev)
|
||||
{
|
||||
debug("Failed to open device %s\n", args[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_menu_fs = fs;
|
||||
g_menu_device = args[0];
|
||||
g_menu_dev = dev;
|
||||
g_browser_list = NULL;
|
||||
|
||||
if (args[2][0] == '/' && args[2][1] == 0)
|
||||
{
|
||||
g_menu_path_len = 0;
|
||||
g_menu_path_buf[0] = 0;
|
||||
fs->fs_dir(dev, "/", ventoy_browser_iterate_dir, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_menu_path_len = grub_snprintf(g_menu_path_buf, sizeof(g_menu_path_buf), "%s", args[2]);
|
||||
fs->fs_dir(dev, g_menu_path_buf, ventoy_browser_iterate_dir, NULL);
|
||||
}
|
||||
grub_device_close(dev);
|
||||
|
||||
if (g_tree_view_menu_style == 0)
|
||||
{
|
||||
browser_ssprintf(&mbuf, "menuentry \"%-10s [(%s)%s/..]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n}\n", "<--", args[0], g_menu_path_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
browser_ssprintf(&mbuf, "menuentry \"[(%s)%s/..]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n}\n", args[0], g_menu_path_buf);
|
||||
}
|
||||
|
||||
for (i = 1; i >= 0; i--)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
node = ventoy_browser_find_top_node(i);
|
||||
if (node)
|
||||
{
|
||||
browser_ssprintf(&mbuf, "%s", node->menuentry);
|
||||
ventoy_browser_mbuf_extend(&mbuf);
|
||||
|
||||
if (node->prev)
|
||||
{
|
||||
node->prev->next = node->next;
|
||||
}
|
||||
if (node->next)
|
||||
{
|
||||
node->next->prev = node->prev;
|
||||
}
|
||||
|
||||
if (node == g_browser_list)
|
||||
{
|
||||
g_browser_list = node->next;
|
||||
}
|
||||
grub_free(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_browser_list = NULL;
|
||||
|
||||
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)mbuf.buf, mbuf.pos);
|
||||
grub_script_execute_sourcecode(cfgfile);
|
||||
|
||||
ventoy_browser_mbuf_free(&mbuf);
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
char cfgfile[64];
|
||||
browser_mbuf mbuf;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (!ventoy_browser_mbuf_alloc(&mbuf))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_vtoy_dev = grub_env_get("vtoydev");
|
||||
|
||||
if (g_tree_view_menu_style == 0)
|
||||
{
|
||||
browser_ssprintf(&mbuf, "menuentry \"%-10s [%s]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n}\n", "<--",
|
||||
ventoy_get_vmenu_title("VTLANG_BROWER_RETURN"));
|
||||
}
|
||||
else
|
||||
{
|
||||
browser_ssprintf(&mbuf, "menuentry \"[%s]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n}\n",
|
||||
ventoy_get_vmenu_title("VTLANG_BROWER_RETURN"));
|
||||
}
|
||||
|
||||
grub_disk_dev_iterate(ventoy_browser_iterate_disk, &mbuf);
|
||||
|
||||
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)mbuf.buf, mbuf.pos);
|
||||
grub_script_execute_sourcecode(cfgfile);
|
||||
|
||||
ventoy_browser_mbuf_free(&mbuf);
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,329 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_CHARSET_HEADER
|
||||
#define GRUB_CHARSET_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_UINT8_1_LEADINGBIT 0x80
|
||||
#define GRUB_UINT8_2_LEADINGBITS 0xc0
|
||||
#define GRUB_UINT8_3_LEADINGBITS 0xe0
|
||||
#define GRUB_UINT8_4_LEADINGBITS 0xf0
|
||||
#define GRUB_UINT8_5_LEADINGBITS 0xf8
|
||||
#define GRUB_UINT8_6_LEADINGBITS 0xfc
|
||||
#define GRUB_UINT8_7_LEADINGBITS 0xfe
|
||||
|
||||
#define GRUB_UINT8_1_TRAILINGBIT 0x01
|
||||
#define GRUB_UINT8_2_TRAILINGBITS 0x03
|
||||
#define GRUB_UINT8_3_TRAILINGBITS 0x07
|
||||
#define GRUB_UINT8_4_TRAILINGBITS 0x0f
|
||||
#define GRUB_UINT8_5_TRAILINGBITS 0x1f
|
||||
#define GRUB_UINT8_6_TRAILINGBITS 0x3f
|
||||
|
||||
#define GRUB_MAX_UTF8_PER_UTF16 4
|
||||
/* You need at least one UTF-8 byte to have one UTF-16 word.
|
||||
You need at least three UTF-8 bytes to have 2 UTF-16 words (surrogate pairs).
|
||||
*/
|
||||
#define GRUB_MAX_UTF16_PER_UTF8 1
|
||||
#define GRUB_MAX_UTF8_PER_CODEPOINT 4
|
||||
|
||||
#define GRUB_UCS2_LIMIT 0x10000
|
||||
#define GRUB_UTF16_UPPER_SURROGATE(code) \
|
||||
(0xD800 | ((((code) - GRUB_UCS2_LIMIT) >> 10) & 0x3ff))
|
||||
#define GRUB_UTF16_LOWER_SURROGATE(code) \
|
||||
(0xDC00 | (((code) - GRUB_UCS2_LIMIT) & 0x3ff))
|
||||
|
||||
/* Process one character from UTF8 sequence.
|
||||
At beginning set *code = 0, *count = 0. Returns 0 on failure and
|
||||
1 on success. *count holds the number of trailing bytes. */
|
||||
static inline int
|
||||
grub_utf8_process (grub_uint8_t c, grub_uint32_t *code, int *count)
|
||||
{
|
||||
if (*count)
|
||||
{
|
||||
if ((c & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
|
||||
{
|
||||
*count = 0;
|
||||
/* invalid */
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*code <<= 6;
|
||||
*code |= (c & GRUB_UINT8_6_TRAILINGBITS);
|
||||
(*count)--;
|
||||
/* Overlong. */
|
||||
if ((*count == 1 && *code <= 0x1f)
|
||||
|| (*count == 2 && *code <= 0xf))
|
||||
{
|
||||
*code = 0;
|
||||
*count = 0;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((c & GRUB_UINT8_1_LEADINGBIT) == 0)
|
||||
{
|
||||
*code = c;
|
||||
return 1;
|
||||
}
|
||||
if ((c & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS)
|
||||
{
|
||||
*count = 1;
|
||||
*code = c & GRUB_UINT8_5_TRAILINGBITS;
|
||||
/* Overlong */
|
||||
if (*code <= 1)
|
||||
{
|
||||
*count = 0;
|
||||
*code = 0;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if ((c & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS)
|
||||
{
|
||||
*count = 2;
|
||||
*code = c & GRUB_UINT8_4_TRAILINGBITS;
|
||||
return 1;
|
||||
}
|
||||
if ((c & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS)
|
||||
{
|
||||
*count = 3;
|
||||
*code = c & GRUB_UINT8_3_TRAILINGBITS;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE
|
||||
bytes (if SRCSIZE is -1, it is ignored) in length to a UTF-16 string.
|
||||
Return the number of characters converted. DEST must be able to hold
|
||||
at least DESTSIZE characters. If an invalid sequence is found, return -1.
|
||||
If SRCEND is not NULL, then *SRCEND is set to the next byte after the
|
||||
last byte used in SRC. */
|
||||
static inline grub_size_t
|
||||
grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
|
||||
const grub_uint8_t *src, grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend)
|
||||
{
|
||||
grub_uint16_t *p = dest;
|
||||
int count = 0;
|
||||
grub_uint32_t code = 0;
|
||||
|
||||
if (srcend)
|
||||
*srcend = src;
|
||||
|
||||
while (srcsize && destsize)
|
||||
{
|
||||
int was_count = count;
|
||||
if (srcsize != (grub_size_t)-1)
|
||||
srcsize--;
|
||||
if (!grub_utf8_process (*src++, &code, &count))
|
||||
{
|
||||
code = '?';
|
||||
count = 0;
|
||||
/* Character c may be valid, don't eat it. */
|
||||
if (was_count)
|
||||
src--;
|
||||
}
|
||||
if (count != 0)
|
||||
continue;
|
||||
if (code == 0)
|
||||
break;
|
||||
if (destsize < 2 && code >= GRUB_UCS2_LIMIT)
|
||||
break;
|
||||
if (code >= GRUB_UCS2_LIMIT)
|
||||
{
|
||||
*p++ = GRUB_UTF16_UPPER_SURROGATE (code);
|
||||
*p++ = GRUB_UTF16_LOWER_SURROGATE (code);
|
||||
destsize -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = code;
|
||||
destsize--;
|
||||
}
|
||||
}
|
||||
|
||||
if (srcend)
|
||||
*srcend = src;
|
||||
return p - dest;
|
||||
}
|
||||
|
||||
/* Determine the last position where the UTF-8 string [beg, end) can
|
||||
be safely cut. */
|
||||
static inline grub_size_t
|
||||
grub_getend (const char *beg, const char *end)
|
||||
{
|
||||
const char *ptr;
|
||||
for (ptr = end - 1; ptr >= beg; ptr--)
|
||||
if ((*ptr & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
|
||||
break;
|
||||
if (ptr < beg)
|
||||
return 0;
|
||||
if ((*ptr & GRUB_UINT8_1_LEADINGBIT) == 0)
|
||||
return ptr + 1 - beg;
|
||||
if ((*ptr & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS
|
||||
&& ptr + 2 <= end)
|
||||
return ptr + 2 - beg;
|
||||
if ((*ptr & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS
|
||||
&& ptr + 3 <= end)
|
||||
return ptr + 3 - beg;
|
||||
if ((*ptr & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS
|
||||
&& ptr + 4 <= end)
|
||||
return ptr + 4 - beg;
|
||||
/* Invalid character or incomplete. Cut before it. */
|
||||
return ptr - beg;
|
||||
}
|
||||
|
||||
/* Convert UTF-16 to UTF-8. */
|
||||
static inline grub_uint8_t *
|
||||
grub_utf16_to_utf8 (grub_uint8_t *dest, const grub_uint16_t *src,
|
||||
grub_size_t size)
|
||||
{
|
||||
grub_uint32_t code_high = 0;
|
||||
|
||||
while (size--)
|
||||
{
|
||||
grub_uint32_t code = *src++;
|
||||
|
||||
if (code_high)
|
||||
{
|
||||
if (code >= 0xDC00 && code <= 0xDFFF)
|
||||
{
|
||||
/* Surrogate pair. */
|
||||
code = ((code_high - 0xD800) << 10) + (code - 0xDC00) + 0x10000;
|
||||
|
||||
*dest++ = (code >> 18) | 0xF0;
|
||||
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Error... */
|
||||
*dest++ = '?';
|
||||
/* *src may be valid. Don't eat it. */
|
||||
src--;
|
||||
}
|
||||
|
||||
code_high = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (code <= 0x007F)
|
||||
*dest++ = code;
|
||||
else if (code <= 0x07FF)
|
||||
{
|
||||
*dest++ = (code >> 6) | 0xC0;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else if (code >= 0xD800 && code <= 0xDBFF)
|
||||
{
|
||||
code_high = code;
|
||||
continue;
|
||||
}
|
||||
else if (code >= 0xDC00 && code <= 0xDFFF)
|
||||
{
|
||||
/* Error... */
|
||||
*dest++ = '?';
|
||||
}
|
||||
else if (code < 0x10000)
|
||||
{
|
||||
*dest++ = (code >> 12) | 0xE0;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dest++ = (code >> 18) | 0xF0;
|
||||
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
#define GRUB_MAX_UTF8_PER_LATIN1 2
|
||||
|
||||
/* Convert Latin1 to UTF-8. */
|
||||
static inline grub_uint8_t *
|
||||
grub_latin1_to_utf8 (grub_uint8_t *dest, const grub_uint8_t *src,
|
||||
grub_size_t size)
|
||||
{
|
||||
while (size--)
|
||||
{
|
||||
if (!(*src & 0x80))
|
||||
*dest++ = *src;
|
||||
else
|
||||
{
|
||||
*dest++ = (*src >> 6) | 0xC0;
|
||||
*dest++ = (*src & 0x3F) | 0x80;
|
||||
}
|
||||
src++;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* Convert UCS-4 to UTF-8. */
|
||||
char *grub_ucs4_to_utf8_alloc (const grub_uint32_t *src, grub_size_t size);
|
||||
|
||||
int
|
||||
grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
|
||||
|
||||
grub_ssize_t grub_utf8_to_ucs4_alloc (const char *msg,
|
||||
grub_uint32_t **unicode_msg,
|
||||
grub_uint32_t **last_position);
|
||||
|
||||
/* Returns the number of bytes the string src would occupy is converted
|
||||
to UTF-8, excluding \0. */
|
||||
grub_size_t
|
||||
grub_get_num_of_utf8_bytes (const grub_uint32_t *src, grub_size_t size);
|
||||
|
||||
/* Converts UCS-4 to UTF-8. Returns the number of bytes effectively written
|
||||
excluding the trailing \0. */
|
||||
grub_size_t
|
||||
grub_ucs4_to_utf8 (const grub_uint32_t *src, grub_size_t size,
|
||||
grub_uint8_t *dest, grub_size_t destsize);
|
||||
grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
|
||||
const grub_uint8_t *src, grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend);
|
||||
/* Returns -2 if not enough space, -1 on invalid character. */
|
||||
grub_ssize_t
|
||||
grub_encode_utf8_character (grub_uint8_t *dest, grub_uint8_t *destend,
|
||||
grub_uint32_t code);
|
||||
|
||||
const grub_uint32_t *
|
||||
grub_unicode_get_comb_start (const grub_uint32_t *str,
|
||||
const grub_uint32_t *cur);
|
||||
|
||||
int
|
||||
grub_utf8_get_num_code (const char *src, grub_size_t srcsize);
|
||||
|
||||
const char *
|
||||
grub_utf8_offset_code (const char *src, grub_size_t srcsize, int num);
|
||||
|
||||
#endif
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2005,2006,2007,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_ENV_HEADER
|
||||
#define GRUB_ENV_HEADER 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/menu.h>
|
||||
|
||||
struct grub_env_var;
|
||||
|
||||
typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
|
||||
const char *val);
|
||||
typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
|
||||
const char *val);
|
||||
|
||||
struct grub_env_var
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
grub_env_read_hook_t read_hook;
|
||||
grub_env_write_hook_t write_hook;
|
||||
struct grub_env_var *next;
|
||||
struct grub_env_var **prevp;
|
||||
struct grub_env_var *sorted_next;
|
||||
int global;
|
||||
};
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
|
||||
const char *EXPORT_FUNC(grub_env_get) (const char *name);
|
||||
void EXPORT_FUNC(grub_env_unset) (const char *name);
|
||||
struct grub_env_var *EXPORT_FUNC(grub_env_update_get_sorted) (void);
|
||||
|
||||
#define FOR_SORTED_ENV(var) for (var = grub_env_update_get_sorted (); var; var = var->sorted_next)
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
|
||||
grub_env_read_hook_t read_hook,
|
||||
grub_env_write_hook_t write_hook);
|
||||
grub_err_t EXPORT_FUNC(grub_register_vtoy_menu_lang_hook) (grub_env_read_hook_t read_hook);
|
||||
|
||||
grub_err_t grub_env_context_open (void);
|
||||
grub_err_t grub_env_context_close (void);
|
||||
grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
|
||||
|
||||
void grub_env_unset_menu (void);
|
||||
grub_menu_t grub_env_get_menu (void);
|
||||
void grub_env_set_menu (grub_menu_t nmenu);
|
||||
|
||||
grub_err_t
|
||||
grub_env_extractor_open (int source);
|
||||
|
||||
grub_err_t
|
||||
grub_env_extractor_close (int source);
|
||||
|
||||
|
||||
#endif /* ! GRUB_ENV_HEADER */
|
@ -0,0 +1,128 @@
|
||||
/* gfxmenu_view.h - gfxmenu view interface. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_GFXMENU_VIEW_HEADER
|
||||
#define GRUB_GFXMENU_VIEW_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
|
||||
struct grub_gfxmenu_view; /* Forward declaration of opaque type. */
|
||||
typedef struct grub_gfxmenu_view *grub_gfxmenu_view_t;
|
||||
|
||||
|
||||
grub_gfxmenu_view_t grub_gfxmenu_view_new (const char *theme_path,
|
||||
int width, int height);
|
||||
|
||||
void grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view);
|
||||
|
||||
/* Set properties on the view based on settings from the specified
|
||||
theme file. */
|
||||
grub_err_t grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view,
|
||||
const char *theme_path);
|
||||
|
||||
grub_err_t grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
|
||||
const char *pattern, const char *theme_dir);
|
||||
|
||||
void grub_gfxmenu_view_draw (grub_gfxmenu_view_t view);
|
||||
|
||||
void
|
||||
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view);
|
||||
|
||||
void
|
||||
grub_gfxmenu_redraw_timeout (grub_gfxmenu_view_t view);
|
||||
|
||||
void
|
||||
grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
|
||||
const grub_video_rect_t *region);
|
||||
|
||||
void
|
||||
grub_gfxmenu_clear_timeout (void *data);
|
||||
void
|
||||
grub_gfxmenu_print_timeout (int timeout, void *data);
|
||||
void
|
||||
grub_gfxmenu_set_chosen_entry (int entry, void *data);
|
||||
void
|
||||
grub_gfxmenu_scroll_chosen_entry (void *data, int diren);
|
||||
|
||||
grub_err_t grub_font_draw_string (const char *str,
|
||||
grub_font_t font,
|
||||
grub_video_color_t color,
|
||||
int left_x, int baseline_y);
|
||||
int grub_font_get_string_width (grub_font_t font,
|
||||
const char *str);
|
||||
|
||||
|
||||
/* Implementation details -- this should not be used outside of the
|
||||
view itself. */
|
||||
|
||||
#include <grub/video.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/icon_manager.h>
|
||||
|
||||
/* Definition of the private representation of the view. */
|
||||
struct grub_gfxmenu_view
|
||||
{
|
||||
grub_video_rect_t screen;
|
||||
|
||||
int need_to_check_sanity;
|
||||
grub_video_rect_t terminal_rect;
|
||||
int terminal_border;
|
||||
|
||||
grub_font_t title_font;
|
||||
grub_font_t message_font;
|
||||
char *terminal_font_name;
|
||||
grub_video_rgba_color_t title_color;
|
||||
grub_video_rgba_color_t message_color;
|
||||
grub_video_rgba_color_t message_bg_color;
|
||||
struct grub_video_bitmap *raw_desktop_image;
|
||||
struct grub_video_bitmap *scaled_desktop_image;
|
||||
grub_video_bitmap_selection_method_t desktop_image_scale_method;
|
||||
grub_video_bitmap_h_align_t desktop_image_h_align;
|
||||
grub_video_bitmap_v_align_t desktop_image_v_align;
|
||||
grub_video_rgba_color_t desktop_color;
|
||||
grub_gfxmenu_box_t terminal_box;
|
||||
char *title_text;
|
||||
char *progress_message_text;
|
||||
char *theme_path;
|
||||
|
||||
grub_gui_container_t canvas;
|
||||
|
||||
int double_repaint;
|
||||
|
||||
int selected;
|
||||
|
||||
grub_video_rect_t progress_message_frame;
|
||||
|
||||
grub_menu_t menu;
|
||||
|
||||
int nested;
|
||||
|
||||
int first_timeout;
|
||||
|
||||
int *menu_title_offset;
|
||||
};
|
||||
|
||||
#endif /* ! GRUB_GFXMENU_VIEW_HEADER */
|
@ -0,0 +1,49 @@
|
||||
/* menu_viewer.h - Interface to menu viewer implementations. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_MENU_VIEWER_HEADER
|
||||
#define GRUB_MENU_VIEWER_HEADER 1
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
struct grub_menu_viewer
|
||||
{
|
||||
struct grub_menu_viewer *next;
|
||||
void *data;
|
||||
void (*set_chosen_entry) (int entry, void *data);
|
||||
void (*scroll_chosen_entry) (void *data, int diren);
|
||||
void (*print_timeout) (int timeout, void *data);
|
||||
void (*clear_timeout) (void *data);
|
||||
void (*fini) (void *fini);
|
||||
};
|
||||
|
||||
void grub_menu_register_viewer (struct grub_menu_viewer *viewer);
|
||||
|
||||
grub_err_t
|
||||
grub_menu_try_text (struct grub_term_output *term,
|
||||
int entry, grub_menu_t menu, int nested);
|
||||
|
||||
extern grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
|
||||
int nested);
|
||||
|
||||
#endif /* GRUB_MENU_VIEWER_HEADER */
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_SMBIOS_HEADER
|
||||
#define GRUB_SMBIOS_HEADER 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_SMBIOS_TYPE_END_OF_TABLE ((grub_uint8_t)127)
|
||||
|
||||
struct grub_smbios_ieps
|
||||
{
|
||||
grub_uint8_t anchor[5]; /* "_DMI_" */
|
||||
grub_uint8_t checksum;
|
||||
grub_uint16_t table_length;
|
||||
grub_uint32_t table_address;
|
||||
grub_uint16_t structures;
|
||||
grub_uint8_t revision;
|
||||
} GRUB_PACKED;
|
||||
|
||||
struct grub_smbios_eps
|
||||
{
|
||||
grub_uint8_t anchor[4]; /* "_SM_" */
|
||||
grub_uint8_t checksum;
|
||||
grub_uint8_t length; /* 0x1f */
|
||||
grub_uint8_t version_major;
|
||||
grub_uint8_t version_minor;
|
||||
grub_uint16_t maximum_structure_size;
|
||||
grub_uint8_t revision;
|
||||
grub_uint8_t formatted[5];
|
||||
struct grub_smbios_ieps intermediate;
|
||||
} GRUB_PACKED;
|
||||
|
||||
struct grub_smbios_eps3
|
||||
{
|
||||
grub_uint8_t anchor[5]; /* "_SM3_" */
|
||||
grub_uint8_t checksum;
|
||||
grub_uint8_t length; /* 0x18 */
|
||||
grub_uint8_t version_major;
|
||||
grub_uint8_t version_minor;
|
||||
grub_uint8_t docrev;
|
||||
grub_uint8_t revision;
|
||||
grub_uint8_t reserved;
|
||||
grub_uint32_t maximum_table_length;
|
||||
grub_uint64_t table_address;
|
||||
} GRUB_PACKED;
|
||||
|
||||
extern struct grub_smbios_eps *grub_machine_smbios_get_eps (void);
|
||||
extern struct grub_smbios_eps3 *grub_machine_smbios_get_eps3 (void);
|
||||
|
||||
extern struct grub_smbios_eps *EXPORT_FUNC (grub_smbios_get_eps) (void);
|
||||
|
||||
#endif /* ! GRUB_SMBIOS_HEADER */
|
Binary file not shown.
After Width: | Height: | Size: 437 KiB |
@ -0,0 +1,4 @@
|
||||
for i in 1 2; do
|
||||
if [ $i -eq 2 ]; then
|
||||
/ventoy/busybox/sh /ventoy/hook/alpine/udev_disk_hook.sh
|
||||
fi
|
@ -0,0 +1,32 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "wait for disk ..."
|
||||
$SLEEP 3
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
@ -0,0 +1,22 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/maybe_break *premount/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/chimera/disk_hook.sh" -i /init
|
@ -0,0 +1,43 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
NEWROOT=$(grep switch_root /init | awk '{print $3}')
|
||||
|
||||
for i in 'usr/bin' 'usr/sbin'; do
|
||||
if [ -f $NEWROOT/$i/udevadm ]; then
|
||||
UPATH=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
blkdev_num=$(dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
||||
sed "s#UPATH=.*#UPATH=/$UPATH#" -i /ventoy/hook/clear/udevadm
|
||||
sed "s#DM=.*#DM=$vtDM#" -i /ventoy/hook/clear/udevadm
|
||||
|
||||
|
||||
mv $NEWROOT/$UPATH/udevadm $NEWROOT/$UPATH/udevadm_bk
|
||||
cp -a /ventoy/hook/clear/udevadm $NEWROOT/$UPATH/udevadm
|
||||
chmod 777 $NEWROOT/$UPATH/udevadm
|
||||
|
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
UPATH=/usr/bin
|
||||
DM=dm-0
|
||||
|
||||
rm -f $UPATH/udevadm
|
||||
mv $UPATH/udevadm_bk $UPATH/udevadm
|
||||
|
||||
echo 1 > /tmp/vthidden
|
||||
mount --bind /tmp/vthidden /sys/block/$DM/hidden
|
||||
|
||||
exec $UPATH/udevadm "$@"
|
@ -0,0 +1,82 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
|
||||
ventoy_os_install_dmsetup_by_fuse() {
|
||||
vtlog "ventoy_os_install_dmsetup_by_fuse $*"
|
||||
|
||||
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs
|
||||
|
||||
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
||||
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
|
||||
|
||||
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
|
||||
mount -t squashfs $VTOY_PATH/mnt/iso/minios/0*-core*.sb $VTOY_PATH/mnt/squashfs
|
||||
|
||||
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
|
||||
vtlog "insmod $KoName"
|
||||
insmod $KoName
|
||||
|
||||
umount $VTOY_PATH/mnt/squashfs
|
||||
umount $VTOY_PATH/mnt/iso
|
||||
umount $VTOY_PATH/mnt/fuse
|
||||
}
|
||||
|
||||
|
||||
ventoy_os_install_dmsetup() {
|
||||
vtlog "ventoy_os_install_dmsetup"
|
||||
|
||||
if grep -q 'device-mapper' /proc/devices; then
|
||||
vtlog "device-mapper module already loaded"
|
||||
return;
|
||||
fi
|
||||
|
||||
vtKerVer=$(uname -r)
|
||||
|
||||
if modprobe fuse 2>>$VTLOG; then
|
||||
ventoy_os_install_dmsetup_by_fuse $1 $vtKerVer
|
||||
fi
|
||||
}
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if check_usb_disk_ready "$vtdiskname"; then
|
||||
vtlog "check_usb_disk_ready ok"
|
||||
else
|
||||
vtlog "check_usb_disk_ready error"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_os_install_dmsetup $vtdiskname
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
PATH=$VTPATH_OLD
|
@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
if [ -f /lib/livekitlib ] && $GREP -q 'debug_log.*find_data_try' /lib/livekitlib; then
|
||||
$SED "/debug_log.*find_data_try/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/minios-disk.sh" -i /lib/livekitlib
|
||||
else
|
||||
$SED "/find_data/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/minios-disk.sh" -i /init
|
||||
fi
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue