Compare commits
866 Commits
v0.1.2
...
feature/mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7da34dbffb | ||
|
|
90a0eb3c53 | ||
|
|
d1ddbd2cf1 | ||
|
|
81b331e5da | ||
|
|
1ebee17880 | ||
|
|
4649d5f77b | ||
|
|
d3c1d6cc34 | ||
|
|
ee24ec8d5c | ||
|
|
372325fab7 | ||
|
|
8f036d9293 | ||
|
|
e345cdd1a7 | ||
|
|
fca570a163 | ||
|
|
ff64d1989f | ||
|
|
d3f5db2479 | ||
|
|
fa587060f1 | ||
|
|
b137c75eb2 | ||
|
|
05c1361283 | ||
|
|
c6835dad70 | ||
|
|
e7fa1dde97 | ||
|
|
eb62588b79 | ||
|
|
29332cbd45 | ||
|
|
172eb70551 | ||
|
|
7322df98f5 | ||
| 70af5a31cd | |||
| 0ab2f59fe8 | |||
| ab84cdb790 | |||
| da9041823b | |||
| 2d7cfc6c59 | |||
| cee4fe67fc | |||
| 53f90f5a1d | |||
| bab2dd5c69 | |||
| 3b9efc11d0 | |||
| 182d3b0a6a | |||
|
|
ed38e989b1 | ||
|
|
1bc6f422c5 | ||
|
|
4909d15c20 | ||
|
|
e725795a17 | ||
|
|
d8a21608c3 | ||
|
|
396fc131e0 | ||
|
|
40130076b2 | ||
|
|
9f54927a82 | ||
|
|
f7ea46e49e | ||
|
|
bc46c9a7d5 | ||
|
|
a1e2c58afc | ||
|
|
4e73e933db | ||
|
|
9f8e75f680 | ||
|
|
e17119254b | ||
|
|
17261622c6 | ||
|
|
dff9e53658 | ||
|
|
0bf709a339 | ||
|
|
c245949ea4 | ||
|
|
c27f8baa31 | ||
|
|
f51f519c31 | ||
|
|
55a485ee67 | ||
|
|
ba6e8e1349 | ||
|
|
75d30fb56d | ||
|
|
4abcf238a0 | ||
|
|
c05b4211fa | ||
|
|
337b8bb36b | ||
|
|
97433fc7d1 | ||
|
|
fc16ed54b3 | ||
|
|
8cbde13139 | ||
|
|
646a534dfd | ||
|
|
eda816ad90 | ||
|
|
c4bb60299e | ||
|
|
3cfd0cf86b | ||
|
|
8b3fa3ed01 | ||
|
|
a0f91ed0fd | ||
|
|
77590b31a6 | ||
|
|
ce27749705 | ||
|
|
b239bb6df2 | ||
|
|
28379dc0f6 | ||
|
|
c86c0f2ae6 | ||
|
|
bbe27c6b53 | ||
|
|
21916ab869 | ||
|
|
778e766f6b | ||
|
|
5d1fdd0e81 | ||
|
|
f5208d1641 | ||
|
|
a7beb0df18 | ||
|
|
1ec46ee641 | ||
|
|
3ba0600694 | ||
|
|
a449a88395 | ||
|
|
4bf03266a9 | ||
|
|
4bceac3d56 | ||
|
|
350396d70f | ||
|
|
ad3afae315 | ||
|
|
0dc86f2a0d | ||
|
|
2b3c276f33 | ||
|
|
8bf2425c4a | ||
|
|
72530ccb15 | ||
|
|
da14fd123e | ||
|
|
f215b98f74 | ||
|
|
b5662bfd25 | ||
|
|
3b3857548c | ||
|
|
1e2e154747 | ||
|
|
2d8d4fd200 | ||
|
|
459b40ad57 | ||
|
|
90cf1e2220 | ||
|
|
692e0d8656 | ||
|
|
3ab1a6b170 | ||
|
|
069bc63d1f | ||
|
|
373121c455 | ||
|
|
936b12a977 | ||
|
|
2a4c286f2b | ||
|
|
bfab4f085e | ||
|
|
201e7191ef | ||
|
|
9fa588566f | ||
|
|
ed95574c24 | ||
|
|
0c777bc62f | ||
|
|
1d7d5e8015 | ||
|
|
95627ba43c | ||
|
|
841ac41e36 | ||
|
|
a46d8bce37 | ||
|
|
4052911ac4 | ||
|
|
3a7a18011c | ||
|
|
15e2f8abf3 | ||
|
|
6b43ddc8d7 | ||
|
|
508058c3d7 | ||
|
|
4c9ff44b1c | ||
|
|
c092e07832 | ||
|
|
abe7fe37d0 | ||
|
|
cca8e8b3ad | ||
|
|
7c194950bb | ||
|
|
723f7d0330 | ||
|
|
274891854f | ||
|
|
94b2a79f79 | ||
|
|
d2a6113fb7 | ||
|
|
55c88dd943 | ||
|
|
42db1e8899 | ||
|
|
38ca7004a6 | ||
|
|
8817766469 | ||
|
|
e250aaef30 | ||
|
|
7b29ba7d23 | ||
|
|
dc30437ce7 | ||
|
|
2c2398b549 | ||
|
|
bce01591f3 | ||
|
|
847ef1ccfe | ||
|
|
6fa9b33ac0 | ||
|
|
df6d5b3b16 | ||
|
|
4884a624d9 | ||
|
|
ea587076ed | ||
|
|
0eddb002f0 | ||
|
|
8f968f4954 | ||
|
|
094b54d728 | ||
|
|
4125175870 | ||
|
|
1cb8f1258d | ||
|
|
f05a1d3310 | ||
|
|
71069cb38b | ||
|
|
393db1e792 | ||
|
|
0a097ec7d3 | ||
|
|
ada660deeb | ||
|
|
118ee73ff1 | ||
|
|
6a6b75b418 | ||
|
|
9297017688 | ||
|
|
359ee035d8 | ||
|
|
8966380ef9 | ||
|
|
ab31825ab3 | ||
|
|
aba45b9b67 | ||
|
|
86d458fc6c | ||
|
|
eba0127645 | ||
|
|
61199d2f80 | ||
|
|
72db77fb58 | ||
|
|
7771584a18 | ||
|
|
8b29680850 | ||
|
|
933e4e8040 | ||
|
|
5ea5978ee8 | ||
|
|
e2e1696b7e | ||
|
|
6f7dd7fc05 | ||
|
|
1f15d2ef49 | ||
|
|
66abcc57a2 | ||
|
|
6ef15a2721 | ||
|
|
5a3e0ba541 | ||
|
|
3af2d41a7f | ||
|
|
1b0c0b6dbe | ||
|
|
e93f48e2f7 | ||
|
|
7150e11ed0 | ||
|
|
28cd3bb625 | ||
|
|
6ac4ec601d | ||
|
|
99b59393fe | ||
|
|
8c1bb593ce | ||
|
|
372bc1d2e6 | ||
|
|
6583744532 | ||
|
|
2703080df2 | ||
|
|
194776d226 | ||
|
|
c02aa084d1 | ||
|
|
516f4f1920 | ||
|
|
b8323f7e0e | ||
|
|
f5f2076db5 | ||
|
|
1a04310f80 | ||
|
|
e830a3d37b | ||
|
|
c9bcc87511 | ||
|
|
9ac4e51224 | ||
|
|
41bb97b179 | ||
|
|
531e160136 | ||
|
|
ba0ce13fe3 | ||
|
|
48e3f9f9d2 | ||
|
|
19791d1d7f | ||
|
|
d04b2ae315 | ||
|
|
6b20f1fb19 | ||
|
|
e90647d498 | ||
|
|
11b61ab345 | ||
|
|
7b8fd76af0 | ||
|
|
a2b876825a | ||
|
|
9f981ada41 | ||
|
|
b4f13d694f | ||
|
|
5c26308b23 | ||
|
|
7fd39e91c1 | ||
|
|
1d4c66a9a0 | ||
|
|
e2f4dad288 | ||
|
|
31c2053c1c | ||
|
|
d759aae318 | ||
|
|
bb0d30610e | ||
|
|
24f324552a | ||
|
|
5c3943bf38 | ||
|
|
90663a674a | ||
|
|
cca07d97b5 | ||
|
|
1cc22e78e2 | ||
|
|
95252e793c | ||
|
|
54aef00913 | ||
|
|
e2eaf43b4a | ||
|
|
e7ccccad7f | ||
|
|
d08e5dabe4 | ||
|
|
df8eb43074 | ||
|
|
8b5aedd463 | ||
|
|
b0c0dc53b1 | ||
|
|
17dcb961ec | ||
|
|
ef307e8ec6 | ||
|
|
b8684777e0 | ||
|
|
446025fb65 | ||
|
|
19105542e5 | ||
|
|
467c2408c4 | ||
|
|
f87a4fcd4e | ||
|
|
9120318594 | ||
|
|
982442eb00 | ||
|
|
40274f5fac | ||
|
|
a03804b09d | ||
|
|
a9f40cf608 | ||
|
|
82025bacad | ||
|
|
2640cea175 | ||
|
|
63265728d4 | ||
|
|
69a3b6dad7 | ||
|
|
30aed15090 | ||
|
|
f7ae2e2220 | ||
|
|
f93d80b8d2 | ||
|
|
a6632625f4 | ||
|
|
b353d68193 | ||
|
|
b46b6363ff | ||
|
|
3be4b103a2 | ||
|
|
dc5efeecbb | ||
|
|
6dea9a4b63 | ||
|
|
4e5a796e50 | ||
|
|
9620f040cb | ||
|
|
d20c77c618 | ||
|
|
ba610864c7 | ||
|
|
d7bf156b30 | ||
|
|
195b635f74 | ||
|
|
c0ae77cd64 | ||
|
|
57b2d6dbd8 | ||
|
|
4e3ba66b0c | ||
|
|
278876c19d | ||
|
|
68a6007fd9 | ||
|
|
346c172b32 | ||
|
|
5ddac353a0 | ||
|
|
4545256b49 | ||
|
|
db23e4966e | ||
|
|
5146429d19 | ||
|
|
0e80c19d3d | ||
|
|
401e662f0b | ||
|
|
ad5ebae304 | ||
|
|
7d5feb943f | ||
|
|
b6d4fb698c | ||
|
|
e3ecd73cd8 | ||
|
|
5dfc6ae62e | ||
|
|
343622d4e5 | ||
|
|
9945ebab34 | ||
|
|
42774d94c0 | ||
|
|
dd535158f2 | ||
|
|
a7245116b6 | ||
|
|
2aef7176ab | ||
|
|
5e1e056623 | ||
|
|
da5c1e9833 | ||
|
|
b6218a1121 | ||
|
|
17ca402aa0 | ||
|
|
cd037aca15 | ||
|
|
bdae812274 | ||
|
|
f1246f84e0 | ||
|
|
9b75acf0b5 | ||
|
|
42d7f4245d | ||
|
|
fd25d3babc | ||
|
|
3f8dfbd5b2 | ||
|
|
0394f29f70 | ||
|
|
0a07a7af01 | ||
|
|
a30ef5b3dc | ||
|
|
2750ec8ef9 | ||
|
|
850999727c | ||
|
|
3dd029b1ac | ||
|
|
75e7fe941b | ||
|
|
cbd2d9d625 | ||
|
|
1d30322820 | ||
|
|
e0246df26b | ||
|
|
e845379b1e | ||
|
|
c631ec5ef5 | ||
|
|
44d3918e4f | ||
|
|
19f9496889 | ||
|
|
2dd78beb92 | ||
|
|
7bb6b21c65 | ||
|
|
11eef8d892 | ||
|
|
4d9b33ecd4 | ||
|
|
421fe33dc0 | ||
|
|
5c82e5ba1b | ||
|
|
b3aaddadc8 | ||
|
|
939022bb5e | ||
|
|
950360fddc | ||
|
|
2ff7a0864b | ||
|
|
488f2df869 | ||
|
|
6877944d17 | ||
|
|
5083d3d13e | ||
|
|
eeef23c2b7 | ||
|
|
a3fff889d1 | ||
|
|
9f3e682b89 | ||
|
|
411c8c4cb3 | ||
|
|
c1d9b35e7c | ||
|
|
cd9b85b555 | ||
|
|
5f88f5ed02 | ||
|
|
a6ec294f63 | ||
|
|
4d5ed8157c | ||
|
|
042f061d86 | ||
|
|
99de8454cd | ||
|
|
348b64ebb0 | ||
|
|
3c44bf55eb | ||
|
|
af7b9bde29 | ||
|
|
1fb47318c0 | ||
|
|
13b39ae730 | ||
|
|
037e42da1d | ||
|
|
25522a8450 | ||
|
|
300bf9c2c5 | ||
|
|
cade24a7ce | ||
|
|
fd93023440 | ||
|
|
762e755b13 | ||
|
|
c536da7279 | ||
|
|
f250a33e9b | ||
|
|
c23a1bfabb | ||
|
|
d60f8ed8d5 | ||
|
|
6317e3ad00 | ||
|
|
7d8535af22 | ||
|
|
c9d713fc7f | ||
|
|
186724e751 | ||
|
|
80f815c020 | ||
|
|
28068ed36d | ||
|
|
f79fe2e056 | ||
|
|
e19177d3ed | ||
|
|
75b5d11181 | ||
|
|
03d4a9ba3c | ||
|
|
8f529046a9 | ||
|
|
d36b2d8057 | ||
|
|
4dc9675a6c | ||
|
|
2b16b69afa | ||
|
|
76beee62c3 | ||
|
|
59d7271fb5 | ||
|
|
d675d6e54b | ||
|
|
ea9d20a250 | ||
|
|
fce22b0d35 | ||
|
|
363d30eadc | ||
|
|
5e2cfab7ba | ||
|
|
5524ca5b25 | ||
|
|
1802c5ea2e | ||
|
|
269324c553 | ||
|
|
ec9e34c970 | ||
|
|
b88cd1d41f | ||
|
|
0b2df134ce | ||
|
|
12e893e11f | ||
|
|
972a35bdef | ||
|
|
edfc5ab8b4 | ||
|
|
37e385e783 | ||
|
|
746291dc67 | ||
|
|
c07c39f8ed | ||
|
|
9fbbd8b954 | ||
|
|
910fde3b2c | ||
|
|
82333ceb82 | ||
|
|
ec58d1c309 | ||
|
|
e408142ca5 | ||
|
|
55c9faaa79 | ||
|
|
0ae489f49d | ||
|
|
e05e05b13a | ||
|
|
6190b05a13 | ||
|
|
19a799656a | ||
|
|
4436145eaf | ||
|
|
6a41446185 | ||
|
|
2d6987341c | ||
|
|
257158fd95 | ||
|
|
f9a967caf7 | ||
|
|
cf22ed57a2 | ||
|
|
b6772ac2ea | ||
|
|
f0025dbc47 | ||
|
|
2a347942bc | ||
|
|
36da65e15b | ||
|
|
214ff3eff0 | ||
|
|
8c0d52d0fe | ||
|
|
793bba95b5 | ||
|
|
2d4a65c654 | ||
|
|
872f178d94 | ||
|
|
70d6094f46 | ||
|
|
31289436f5 | ||
|
|
5e7792c11f | ||
|
|
e73064a438 | ||
|
|
72787c0652 | ||
|
|
c88170f6e0 | ||
|
|
a65ecb157d | ||
|
|
eb8a3c0e09 | ||
|
|
572fade7ff | ||
|
|
b5885ae35f | ||
|
|
335bc01185 | ||
|
|
c87563a520 | ||
|
|
e4aafca7c3 | ||
|
|
fe05d45cde | ||
|
|
b3861decc3 | ||
|
|
b3f59acf7e | ||
|
|
4f8e35e409 | ||
|
|
b898949ffc | ||
|
|
2244764777 | ||
|
|
e4c8a36577 | ||
|
|
41eb45402e | ||
|
|
33ed95bd8e | ||
|
|
4985b2d1f4 | ||
|
|
68a2250886 | ||
|
|
8575939b20 | ||
|
|
634a1c5f6a | ||
|
|
c364e30240 | ||
|
|
3595c3a440 | ||
|
|
c3dd65457d | ||
|
|
3aa909b917 | ||
|
|
35d8d2ab2d | ||
|
|
e3ebaeb2c8 | ||
|
|
71dc332dae | ||
|
|
211a3c2358 | ||
|
|
16b9d4fd8b | ||
|
|
c0f304559f | ||
|
|
8d325184ad | ||
|
|
0df93eaa98 | ||
|
|
aae18fd035 | ||
|
|
fd8552ca3a | ||
|
|
452457412b | ||
|
|
521df1f4b7 | ||
|
|
0ae2f935af | ||
|
|
3282a3ae34 | ||
|
|
cb612c36ea | ||
|
|
14aad62e02 | ||
|
|
847d7ab38d | ||
|
|
99ef9166ae | ||
|
|
0305830e32 | ||
|
|
9f342dff49 | ||
|
|
02766d82eb | ||
|
|
3e372faf5e | ||
|
|
786b4ea8c0 | ||
|
|
20ff0ed30b | ||
|
|
2a490a1bbc | ||
|
|
89391e5be1 | ||
|
|
c3cb41f78a | ||
|
|
c3a0266354 | ||
|
|
55a5c97034 | ||
|
|
dcb8a3f3fb | ||
|
|
3dffe564af | ||
|
|
1820972fb7 | ||
|
|
67534faa78 | ||
|
|
12605843ce | ||
|
|
8dbdebff3f | ||
|
|
61845b8761 | ||
|
|
1ba44c99d1 | ||
|
|
6716ab251f | ||
|
|
e3b9c0140a | ||
|
|
d1c0723b44 | ||
|
|
14ed6af433 | ||
|
|
1325706c7c | ||
|
|
f5ab00a055 | ||
|
|
dcdfc30c45 | ||
|
|
a0d165c79b | ||
|
|
7b23310d8b | ||
|
|
e477dea5c7 | ||
|
|
dccb136c99 | ||
|
|
6af29a7181 | ||
| 7ca3a19eed | |||
| 7fcb4efab6 | |||
| a8024d3dd3 | |||
| 8bb78c95a8 | |||
| 19cbf1ca67 | |||
|
|
e70eb5a926 | ||
| 7bdde2d359 | |||
|
|
3daa07e311 | ||
|
|
47fab631d0 | ||
| 2e3d7b1656 | |||
| bf600a7608 | |||
| 6b00805d04 | |||
| 82b7082fc5 | |||
| 8bb9e22218 | |||
| 2ad90dcb5c | |||
| 97ea77bd27 | |||
| 1904e240cf | |||
| 4ccaa2dfea | |||
| da38006f44 | |||
| 87b0a93d32 | |||
| ff78c951f0 | |||
| 2d44e8112b | |||
| f7f8bb3f45 | |||
| 67ebc58812 | |||
| 13aee1755e | |||
| 0e0975e5f6 | |||
| d4283731e4 | |||
| 6780ab1b67 | |||
| 41eac2764a | |||
| 113d14c440 | |||
| abe523be77 | |||
| 1b392a0551 | |||
| deb2fa0a09 | |||
| 671a0ce0fb | |||
| ac67111b83 | |||
| 09575370ce | |||
| 9aa08a70cf | |||
| ca7f78565d | |||
| dcb4d1823f | |||
| e8564c755b | |||
| 9dee5e4138 | |||
| 245f260d67 | |||
| 5f27727e52 | |||
| 1238608430 | |||
| 71cd7af17b | |||
| 8490472581 | |||
| 8534d8d3c5 | |||
| 53d260cc6e | |||
| 53a4682418 | |||
| 42455873ff | |||
| 724b846ee4 | |||
| f27b133089 | |||
| 773617cbf3 | |||
| 44e29b3c4a | |||
| 95a35cd0bf | |||
| 28b800a497 | |||
| 838776d7df | |||
| e19fa377d7 | |||
| d63a30728c | |||
| 4819920b4e | |||
| bbb9aae198 | |||
| 0d94776c46 | |||
| 565a5ee960 | |||
| e7f9d8f1d7 | |||
| 55bc49598e | |||
| 579eaaf4a0 | |||
| b98334db28 | |||
| e1b1b5d357 | |||
| cf582c4ce4 | |||
| 911b4c0b10 | |||
| 94c1f0d3fc | |||
| 73221dfe34 | |||
| 4ffd4949ca | |||
| 3f137805bc | |||
| 6a00057817 | |||
| 58bc5acb1e | |||
| d3e9d92466 | |||
| ae3290c53d | |||
| 4cf222a5bb | |||
| c3abe035c8 | |||
| ef5c333030 | |||
| f4cbb9498f | |||
| 794c86f9b4 | |||
|
|
8687fe3786 | ||
|
|
0a28d2db07 | ||
|
|
6c468a134b | ||
|
|
9b67f87062 | ||
|
|
b4adc29d7f | ||
|
|
a10aca573d | ||
|
|
ea1224e213 | ||
|
|
64ad65fa1b | ||
|
|
b881b2639d | ||
|
|
a5f72edf82 | ||
|
|
ea2a3e6f16 | ||
|
|
2125f043b6 | ||
|
|
655b5c88d4 | ||
|
|
88b090fe94 | ||
|
|
c6c3a556b3 | ||
|
|
67b5f33d46 | ||
|
|
b675dfd014 | ||
|
|
fc2b884af9 | ||
|
|
cbd19fa070 | ||
|
|
83b330bf2b | ||
|
|
cc9cde9bfe | ||
|
|
774f6fc334 | ||
|
|
bfd13e7a9b | ||
|
|
35b1d37df0 | ||
|
|
fc3d919f25 | ||
|
|
75641a4394 | ||
|
|
ce0bcbd3b6 | ||
|
|
3194b460cc | ||
|
|
e1d148a34d | ||
|
|
b491a09686 | ||
|
|
6a538ad4f3 | ||
|
|
6ccc172f33 | ||
|
|
66ca3a3f9b | ||
|
|
4f4a35a7be | ||
|
|
c9722a07f3 | ||
|
|
42dfa6ccfe | ||
|
|
2adef874ee | ||
|
|
a6e4995963 | ||
|
|
2bd91c2d94 | ||
|
|
c713f4ff6f | ||
|
|
21b0b08908 | ||
|
|
88ace0a99f | ||
|
|
10c8f6e4b5 | ||
|
|
9aa749e877 | ||
|
|
f78a99927a | ||
|
|
ec794f4f99 | ||
|
|
884182217c | ||
|
|
d94907ae79 | ||
|
|
4accfd136e | ||
|
|
1a223d6ef5 | ||
|
|
36b3ad8154 | ||
|
|
460973954e | ||
|
|
303a78065e | ||
|
|
93f0b70eba | ||
|
|
6f5a2a3d3f | ||
|
|
ec563ea8e4 | ||
|
|
570638bba6 | ||
|
|
f627ea7de0 | ||
|
|
521c132801 | ||
|
|
bc5115b9ea | ||
|
|
6963304c01 | ||
|
|
ae651a4fcd | ||
|
|
17c2fe6e4e | ||
|
|
f066ac3ffd | ||
|
|
edcf633e84 | ||
|
|
d09a454b8b | ||
|
|
d6329ea9bf | ||
|
|
83897048ab | ||
|
|
7cc59770b8 | ||
|
|
b056d95920 | ||
|
|
19cd01ef8d | ||
|
|
b3f88bbe02 | ||
|
|
f57f38edbd | ||
|
|
12377ae730 | ||
|
|
bb93dcef44 | ||
|
|
678a12dc90 | ||
|
|
c3dacb2906 | ||
|
|
3a68ec439d | ||
|
|
7ce418aabc | ||
|
|
8ee5091f41 | ||
|
|
6285517ef7 | ||
|
|
2b0cd6f2f2 | ||
|
|
a653c55941 | ||
|
|
ce035d2a43 | ||
|
|
2d54eb5143 | ||
|
|
b9c8edb657 | ||
|
|
88315c25a5 | ||
|
|
806bfd1fbf | ||
|
|
910b5116f4 | ||
|
|
6302e8b73a | ||
|
|
fd1adc0262 | ||
|
|
070be0b005 | ||
|
|
5034ffbe59 | ||
|
|
cd13b88540 | ||
|
|
e050d6f151 | ||
|
|
863555ec6b | ||
|
|
c605793a9d | ||
|
|
8375870af6 | ||
|
|
11a53e792f | ||
|
|
ca2362f858 | ||
|
|
5cdbedd4d1 | ||
|
|
ee6d69bcd2 | ||
|
|
f9193b4602 | ||
|
|
979e5f036e | ||
|
|
39baec852b | ||
|
|
ed3f9410a6 | ||
|
|
b18243f098 | ||
|
|
9472dab522 | ||
|
|
9067f8d298 | ||
|
|
866073ae8a | ||
|
|
91cb00fde2 | ||
|
|
c435bcfb67 | ||
|
|
7fe1b7d1f5 | ||
|
|
39524b2b9f | ||
|
|
c592f5f537 | ||
|
|
94c491d286 | ||
|
|
645938a194 | ||
|
|
73756820bd | ||
|
|
33374ab257 | ||
|
|
bf8286d15f | ||
|
|
6410c898c5 | ||
|
|
be007c6278 | ||
|
|
f7558e3d18 | ||
|
|
97e8f2c69a | ||
|
|
49bdf47514 | ||
|
|
81162f30dc | ||
|
|
4379256c11 | ||
|
|
870ca1db45 | ||
|
|
74a5c301f8 | ||
|
|
2955e6c9c1 | ||
|
|
cd2ccb4e06 | ||
|
|
722ee4c52c | ||
|
|
67b9f45004 | ||
|
|
2035fffa1c | ||
|
|
97ac3c09fa | ||
|
|
241e1dacb0 | ||
|
|
ac19d3f532 | ||
|
|
194527e0fe | ||
|
|
28cf5562ac | ||
|
|
8cdc39fdee | ||
|
|
626eec4a31 | ||
|
|
5901237fee | ||
|
|
24316ca0c4 | ||
|
|
f9d964cccb | ||
|
|
a9ac30b991 | ||
|
|
61df9cf32c | ||
|
|
bbd31929ba | ||
|
|
ec20e9f3d9 | ||
|
|
3bcd83f5a3 | ||
|
|
341ba5146a | ||
|
|
83b37ef536 | ||
|
|
1965197ccd | ||
|
|
29747f4891 | ||
|
|
aca442ee87 | ||
|
|
8e85ae5318 | ||
|
|
8c32471e0d | ||
|
|
79711be46a | ||
|
|
863e5bda15 | ||
|
|
d19cedb12a | ||
|
|
f2d39f7df8 | ||
|
|
579f6f64e6 | ||
|
|
a71af1be96 | ||
|
|
237c242f96 | ||
|
|
c4dc52c06c | ||
|
|
e1d8dd3124 | ||
|
|
38a1197d9e | ||
|
|
bc01a37452 | ||
|
|
acdca19f59 | ||
|
|
a1fe745a53 | ||
|
|
73df20d195 | ||
|
|
7e1933d79b | ||
|
|
8d23fac6cc | ||
|
|
0f8efdb55e | ||
|
|
523d0b3b8c | ||
|
|
591ca7c83c | ||
|
|
dffdcc095d | ||
|
|
229c1e4965 | ||
|
|
d8399e3c07 | ||
|
|
f1bb3556eb | ||
|
|
cef0a71bce | ||
|
|
a9d72b8102 | ||
|
|
d469482a7f | ||
|
|
c67c1bd6a2 | ||
|
|
5e6769036c | ||
|
|
482b9f50fc | ||
|
|
f4e7eaeb40 | ||
|
|
8c2ff33c40 | ||
|
|
1308864061 | ||
|
|
62c559043d | ||
|
|
c2f85ce61b | ||
|
|
5808599005 | ||
|
|
fafe582802 | ||
|
|
593cda3ee8 | ||
|
|
d5c44645eb | ||
|
|
e7a509176d | ||
|
|
3a39d9440a | ||
|
|
cabfec3f1e | ||
|
|
956efabd8f | ||
|
|
f146a96298 | ||
|
|
585abe9a18 | ||
|
|
3d0b262435 | ||
|
|
3f264b4490 | ||
|
|
1758ee4215 | ||
|
|
dc40c2f6ad | ||
|
|
2fb92e8592 | ||
|
|
57829e1b79 | ||
|
|
bc26d7d01d | ||
|
|
b93519e06f | ||
|
|
5d861d243a | ||
|
|
f1b84ab370 | ||
|
|
d5b8902d8f | ||
|
|
799fbbdd10 | ||
|
|
d33f1bc6f2 | ||
|
|
28a90e550e | ||
|
|
647801f096 | ||
|
|
1664566bd2 | ||
|
|
cd09c17d71 | ||
|
|
f74f3f03d1 | ||
|
|
23006b2b43 | ||
|
|
7f69a6c9b1 | ||
|
|
1726d10554 | ||
|
|
757bc21550 | ||
|
|
e187679f93 | ||
|
|
2597e2002b | ||
|
|
e6f819ed90 | ||
|
|
0c8bcb2400 | ||
|
|
c5761cc51e | ||
|
|
24ccf65aba | ||
|
|
814d6f1de6 | ||
|
|
bfaab294e6 | ||
|
|
0ddcf668cb | ||
|
|
4005e9e791 | ||
|
|
abaa007c54 | ||
|
|
87d80f84c2 | ||
|
|
3fdf246a22 | ||
|
|
79b95d0045 | ||
|
|
1e66e5cd82 | ||
|
|
193d9939f0 | ||
|
|
81fc559802 | ||
|
|
0d75cc999c | ||
|
|
a5da56d02f | ||
|
|
a7e20fd390 | ||
|
|
9f38e7e5f5 | ||
|
|
93e60cc136 | ||
|
|
5f7ec50055 | ||
|
|
ff0019841f | ||
|
|
7eeeced2ca | ||
|
|
0fc369789e | ||
|
|
09f72f5ac6 | ||
|
|
716109bab5 | ||
|
|
0684fcf7e9 | ||
|
|
289104cde0 | ||
|
|
c9277e4b12 | ||
|
|
08125fc2a5 | ||
|
|
d06dd2ef43 | ||
|
|
8ae3eea19c | ||
|
|
a1bc76f305 | ||
|
|
045bede481 | ||
|
|
0a231f2e0e | ||
|
|
87e7c5f00a | ||
|
|
7ded9fe219 | ||
|
|
b389e75d33 | ||
|
|
9128bfc5f1 | ||
|
|
bb227d2c37 | ||
|
|
954da93301 | ||
|
|
1dce0f265d | ||
|
|
0f54630725 | ||
|
|
712cd69242 | ||
|
|
ff3bd640f0 | ||
|
|
abb347e1a8 | ||
|
|
949c9c0b8c | ||
|
|
627a9f7972 | ||
|
|
cce892e92f | ||
|
|
97fb8ef653 | ||
|
|
649d6169c9 | ||
|
|
9efb97c2a7 | ||
|
|
d876aa141c | ||
|
|
f64efad057 | ||
|
|
20edb87505 | ||
|
|
34156c55ae | ||
|
|
569bc243f1 | ||
|
|
bc6a42735c | ||
|
|
b2f2a9c721 | ||
|
|
8a00b9c77d | ||
|
|
d7506b6aaf | ||
|
|
3a86e89116 | ||
|
|
0e71bdab65 | ||
|
|
0c553b3406 | ||
|
|
33012f35ef | ||
|
|
a6b915f6b4 | ||
|
|
772c981c39 | ||
|
|
05905f8c3c | ||
|
|
9542bd8a44 | ||
|
|
d9fe457b44 | ||
|
|
59700b07db | ||
|
|
428e4563d0 | ||
|
|
6c3bbaa686 | ||
|
|
7009bb6d05 | ||
|
|
23a5692d59 | ||
|
|
2d4e7cfdee | ||
|
|
99222d8ab9 | ||
|
|
a845fee689 | ||
|
|
cfecf4f1d4 |
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
Language: Cpp
|
|
||||||
BasedOnStyle: LLVM
|
|
||||||
|
|
||||||
ColumnLimit: 100
|
|
||||||
IndentWidth: 4
|
|
||||||
TabWidth: 4
|
|
||||||
UseTab: Always
|
|
||||||
|
|
||||||
AccessModifierOffset: -4
|
|
||||||
|
|
||||||
AlignEscapedNewlinesLeft: true
|
|
||||||
|
|
||||||
AllowShortIfStatementsOnASingleLine: true
|
|
||||||
AllowShortLoopsOnASingleLine: true
|
|
||||||
|
|
||||||
AlwaysBreakAfterReturnType: AllDefinitions
|
|
||||||
AlwaysBreakBeforeMultilineStrings: true
|
|
||||||
AlwaysBreakTemplateDeclarations: true
|
|
||||||
|
|
||||||
BreakBeforeBraces: Linux
|
|
||||||
11
.git-commit-template
Normal file
11
.git-commit-template
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[section] Imperative-voiced title in less than 50
|
||||||
|
|
||||||
|
# Body describes what was done, and why. New obviously-needed features
|
||||||
|
# don't necessarily require a why.
|
||||||
|
|
||||||
|
# Links to relevant bugs or web pages
|
||||||
|
See: Github bug #242
|
||||||
|
See: [frobozz blog post](https://jsix.dev/posts/frobozz/)
|
||||||
|
|
||||||
|
# Tags and keywords useful for searching
|
||||||
|
Tags:
|
||||||
56
.github/workflows/sphinx_deploy.yml
vendored
Normal file
56
.github/workflows/sphinx_deploy.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: Deploy docs site with Sphinx
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||||
|
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||||
|
concurrency:
|
||||||
|
group: "pages"
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
# Default to bash
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Setup Pages
|
||||||
|
id: pages
|
||||||
|
uses: actions/configure-pages@v4
|
||||||
|
- name: Sphinx build
|
||||||
|
uses: jsix-os/sphinx-action@master
|
||||||
|
with:
|
||||||
|
docs-folder: "docs/"
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-pages-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ./docs/_build/html
|
||||||
|
|
||||||
|
# Deployment job
|
||||||
|
deploy:
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
id: deployment
|
||||||
|
uses: actions/deploy-pages@v4
|
||||||
19
.gitignore
vendored
19
.gitignore
vendored
@@ -1,6 +1,19 @@
|
|||||||
|
.cache
|
||||||
.lock*
|
.lock*
|
||||||
build
|
/build*
|
||||||
*.bak
|
*.bak
|
||||||
tags
|
tags
|
||||||
.gdbinit
|
*.log
|
||||||
popcorn.log
|
*.out
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
sysroot
|
||||||
|
.gdb_history
|
||||||
|
.peru
|
||||||
|
__pycache__
|
||||||
|
/venv
|
||||||
|
compile_commands.json
|
||||||
|
buddy_allocs.txt
|
||||||
|
frame_allocs.txt
|
||||||
|
heap_allocs.txt
|
||||||
|
/docs/_build
|
||||||
|
|||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "external/gnu-efi"]
|
|
||||||
path = external/gnu-efi
|
|
||||||
url = https://github.com/justinian/gnu-efi.git
|
|
||||||
|
|||||||
19
.vscode/c_cpp_properties.json
vendored
Normal file
19
.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/src/libraries/**",
|
||||||
|
"${workspaceFolder}/build/**",
|
||||||
|
"${workspaceFolder}/sysroot/include"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"compilerPath": "/usr/bin/clang",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"intelliSenseMode": "linux-clang-x64",
|
||||||
|
"compileCommands": "${workspaceFolder}/compile_commands.json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
32
.vscode/launch.json
vendored
Normal file
32
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "QEMU Debug Server",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/build/jsix.elf",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"logging": {
|
||||||
|
//"engineLogging": true,
|
||||||
|
"programOutput": true
|
||||||
|
},
|
||||||
|
"stopAtConnect": true,
|
||||||
|
"stopAtEntry": false,
|
||||||
|
|
||||||
|
"setupCommands": [
|
||||||
|
{"text": "dashboard -enabled off", "ignoreFailures": true}
|
||||||
|
],
|
||||||
|
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerServerAddress": "localhost:1234",
|
||||||
|
"debugServerPath": "${workspaceFolder}/qemu.sh",
|
||||||
|
"debugServerArgs": "--debug --no-build",
|
||||||
|
"serverLaunchTimeout": 5000,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
45
.vscode/tasks.json
vendored
45
.vscode/tasks.json
vendored
@@ -1,28 +1,41 @@
|
|||||||
{
|
{
|
||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
// for the documentation about the tasks.json format
|
// for the documentation about the tasks.json format
|
||||||
"version": "0.1.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"taskName": "make",
|
"label": "Ninja",
|
||||||
"command": "make.bat",
|
"type": "shell",
|
||||||
"isBuildCommand": true
|
"command": "source ${workspaceFolder}/venv/bin/activate.fish; ninja",
|
||||||
|
"detail": "Build the project",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}/build"
|
||||||
|
},
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"taskName": "clean",
|
"label": "Run QEMU",
|
||||||
"command": "make.bat",
|
"command": "./qemu.sh",
|
||||||
"args": [ "clean" ],
|
"args": [ "--no-build", "--kvm" ],
|
||||||
"isShellCommand": true
|
"dependsOn": ["Ninja"],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"taskName": "qemu (windowed)",
|
"label": "clean",
|
||||||
"command": "qemu-win.bat",
|
"command": "${workspaceFolder}/venv/bin/ninja",
|
||||||
"showOutput": "never",
|
"options": {
|
||||||
"isTestCommand": true
|
"cwd": "${workspaceFolder}/build"
|
||||||
},
|
},
|
||||||
{
|
"args": [
|
||||||
"taskName": "qemu",
|
"-t",
|
||||||
"command": "qemu.bat"
|
"clean"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
354
LICENSE.md
Normal file
354
LICENSE.md
Normal file
@@ -0,0 +1,354 @@
|
|||||||
|
# License
|
||||||
|
|
||||||
|
jsix is (c) 2017-2019 Justin C Miller, and distributed under the terms of the
|
||||||
|
Mozilla Public License 2.0.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Mozilla Public License Version 2.0
|
||||||
|
|
||||||
|
### 1. Definitions
|
||||||
|
|
||||||
|
#### 1.1. "Contributor"
|
||||||
|
|
||||||
|
means each individual or legal entity that creates, contributes to the creation
|
||||||
|
of, or owns Covered Software.
|
||||||
|
|
||||||
|
#### 1.2. "Contributor Version"
|
||||||
|
|
||||||
|
means the combination of the Contributions of others (if any) used by a
|
||||||
|
Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
|
#### 1.3. "Contribution
|
||||||
|
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
#### 1.4. "Covered Software"
|
||||||
|
|
||||||
|
means Source Code Form to which the initial Contributor has attached the notice
|
||||||
|
in Exhibit A, the Executable Form of such Source Code Form, and Modifications
|
||||||
|
of such Source Code Form, in each case including portions thereof.
|
||||||
|
|
||||||
|
#### 1.5. "Incompatible With Secondary Licenses"
|
||||||
|
|
||||||
|
means
|
||||||
|
|
||||||
|
* **(a)** that the initial Contributor has attached the notice described in
|
||||||
|
Exhibit B to the Covered Software; or
|
||||||
|
* **(b)** that the Covered Software was made available under the terms of
|
||||||
|
version 1.1 or earlier of the License, but not also under the terms of a
|
||||||
|
Secondary License.
|
||||||
|
|
||||||
|
#### 1.6. "Executable Form"
|
||||||
|
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
#### 1.7. "Larger Work"
|
||||||
|
|
||||||
|
means a work that combines Covered Software with other material, in a separate
|
||||||
|
file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
#### 1.8. "License"
|
||||||
|
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
#### 1.9. "Licensable"
|
||||||
|
|
||||||
|
means having the right to grant, to the maximum extent possible, whether at the
|
||||||
|
time of the initial grant or subsequently, any and all of the rights conveyed
|
||||||
|
by this License.
|
||||||
|
|
||||||
|
#### 1.10. "Modifications"
|
||||||
|
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
* **(a)** any file in Source Code Form that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered Software; or
|
||||||
|
* **(b)** any new file in Source Code Form that contains any Covered Software.
|
||||||
|
|
||||||
|
#### 1.11. "Patent Claims" of a Contributor
|
||||||
|
|
||||||
|
means any patent claim(s), including without limitation, method, process, and
|
||||||
|
apparatus claims, in any patent Licensable by such Contributor that would be
|
||||||
|
infringed, but for the grant of the License, by the making, using, selling,
|
||||||
|
offering for sale, having made, import, or transfer of either its Contributions
|
||||||
|
or its Contributor Version.
|
||||||
|
|
||||||
|
#### 1.12. "Secondary License"
|
||||||
|
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||||
|
General Public License, Version 2.1, the GNU Affero General Public License,
|
||||||
|
Version 3.0, or any later versions of those licenses.
|
||||||
|
|
||||||
|
#### 1.13. "Source Code Form"
|
||||||
|
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
#### 1.14. "You" (or "Your")
|
||||||
|
|
||||||
|
means an individual or a legal entity exercising rights under this License. For
|
||||||
|
legal entities, "You" includes any entity that controls, is controlled by, or
|
||||||
|
is under common control with You. For purposes of this definition, "control"
|
||||||
|
means **(a)** the power, direct or indirect, to cause the direction or
|
||||||
|
management of such entity, whether by contract or otherwise, or **(b)**
|
||||||
|
ownership of more than fifty percent (50%) of the outstanding shares or
|
||||||
|
beneficial ownership of such entity.
|
||||||
|
|
||||||
|
|
||||||
|
### 2. License Grants and Conditions
|
||||||
|
|
||||||
|
#### 2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive
|
||||||
|
license:
|
||||||
|
|
||||||
|
* **(a)** under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available, modify,
|
||||||
|
display, perform, distribute, and otherwise exploit its Contributions, either
|
||||||
|
on an unmodified basis, with Modifications, or as part of a Larger Work; and
|
||||||
|
* **(b)** under Patent Claims of such Contributor to make, use, sell, offer for
|
||||||
|
sale, have made, import, and otherwise transfer either its Contributions or
|
||||||
|
its Contributor Version.
|
||||||
|
|
||||||
|
#### 2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution become
|
||||||
|
effective for each Contribution on the date the Contributor first distributes
|
||||||
|
such Contribution.
|
||||||
|
|
||||||
|
#### 2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under this
|
||||||
|
License. No additional rights or licenses will be implied from the distribution
|
||||||
|
or licensing of Covered Software under this License. Notwithstanding Section
|
||||||
|
2.1(b) above, no patent license is granted by a Contributor:
|
||||||
|
|
||||||
|
* **(a)** for any code that a Contributor has removed from Covered Software; or
|
||||||
|
* **(b)** for infringements caused by: **(i)** Your and any other third party's
|
||||||
|
modifications of Covered Software, or **(ii)** the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
* **(c)** under Patent Claims infringed by Covered Software in the absence of
|
||||||
|
its Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks, or
|
||||||
|
logos of any Contributor (except as may be necessary to comply with the notice
|
||||||
|
requirements in Section 3.4).
|
||||||
|
|
||||||
|
#### 2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to distribute
|
||||||
|
the Covered Software under a subsequent version of this License (see Section
|
||||||
|
10.2) or under the terms of a Secondary License (if permitted under the terms
|
||||||
|
of Section 3.3).
|
||||||
|
|
||||||
|
#### 2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its Contributions are
|
||||||
|
its original creation(s) or it has sufficient rights to grant the rights to its
|
||||||
|
Contributions conveyed by this License.
|
||||||
|
|
||||||
|
#### 2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under applicable
|
||||||
|
copyright doctrines of fair use, fair dealing, or other equivalents.
|
||||||
|
|
||||||
|
#### 2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||||
|
Section 2.1.
|
||||||
|
|
||||||
|
|
||||||
|
### 3. Responsibilities
|
||||||
|
|
||||||
|
#### 3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under the
|
||||||
|
terms of this License. You must inform recipients that the Source Code Form of
|
||||||
|
the Covered Software is governed by the terms of this License, and how they can
|
||||||
|
obtain a copy of this License. You may not attempt to alter or restrict the
|
||||||
|
recipients' rights in the Source Code Form.
|
||||||
|
|
||||||
|
#### 3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
* **(a)** such Covered Software must also be made available in Source Code
|
||||||
|
Form, as described in Section 3.1, and You must inform recipients of the
|
||||||
|
Executable Form how they can obtain a copy of such Source Code Form by
|
||||||
|
reasonable means in a timely manner, at a charge no more than the cost of
|
||||||
|
distribution to the recipient; and
|
||||||
|
* **(b)** You may distribute such Executable Form under the terms of this
|
||||||
|
License, or sublicense it under different terms, provided that the license
|
||||||
|
for the Executable Form does not attempt to limit or alter the recipients'
|
||||||
|
rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
#### 3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for the
|
||||||
|
Covered Software. If the Larger Work is a combination of Covered Software with
|
||||||
|
a work governed by one or more Secondary Licenses, and the Covered Software is
|
||||||
|
not Incompatible With Secondary Licenses, this License permits You to
|
||||||
|
additionally distribute such Covered Software under the terms of such Secondary
|
||||||
|
License(s), so that the recipient of the Larger Work may, at their option,
|
||||||
|
further distribute the Covered Software under the terms of either this License
|
||||||
|
or such Secondary License(s).
|
||||||
|
|
||||||
|
#### 3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices (including
|
||||||
|
copyright notices, patent notices, disclaimers of warranty, or limitations of
|
||||||
|
liability) contained within the Source Code Form of the Covered Software,
|
||||||
|
except that You may alter any license notices to the extent required to remedy
|
||||||
|
known factual inaccuracies.
|
||||||
|
|
||||||
|
#### 3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support, indemnity
|
||||||
|
or liability obligations to one or more recipients of Covered Software.
|
||||||
|
However, You may do so only on Your own behalf, and not on behalf of any
|
||||||
|
Contributor. You must make it absolutely clear that any such warranty, support,
|
||||||
|
indemnity, or liability obligation is offered by You alone, and You hereby
|
||||||
|
agree to indemnify every Contributor for any liability incurred by such
|
||||||
|
Contributor as a result of warranty, support, indemnity or liability terms You
|
||||||
|
offer. You may include additional disclaimers of warranty and limitations of
|
||||||
|
liability specific to any jurisdiction.
|
||||||
|
|
||||||
|
|
||||||
|
### 4. Inability to Comply Due to Statute or Regulation
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this License
|
||||||
|
with respect to some or all of the Covered Software due to statute, judicial
|
||||||
|
order, or regulation then You must: **(a)** comply with the terms of this
|
||||||
|
License to the maximum extent possible; and **(b)** describe the limitations
|
||||||
|
and the code they affect. Such description must be placed in a text file
|
||||||
|
included with all distributions of the Covered Software under this License.
|
||||||
|
Except to the extent prohibited by statute or regulation, such description must
|
||||||
|
be sufficiently detailed for a recipient of ordinary skill to be able to
|
||||||
|
understand it.
|
||||||
|
|
||||||
|
|
||||||
|
### 5. Termination
|
||||||
|
|
||||||
|
**5.1.** The rights granted under this License will terminate automatically if
|
||||||
|
You fail to comply with any of its terms. However, if You become compliant,
|
||||||
|
then the rights granted under this License from a particular Contributor are
|
||||||
|
reinstated **(a)** provisionally, unless and until such Contributor explicitly
|
||||||
|
and finally terminates Your grants, and **(b)** on an ongoing basis, if such
|
||||||
|
Contributor fails to notify You of the non-compliance by some reasonable means
|
||||||
|
prior to 60 days after You have come back into compliance. Moreover, Your
|
||||||
|
grants from a particular Contributor are reinstated on an ongoing basis if such
|
||||||
|
Contributor notifies You of the non-compliance by some reasonable means, this
|
||||||
|
is the first time You have received notice of non-compliance with this License
|
||||||
|
from such Contributor, and You become compliant prior to 30 days after Your
|
||||||
|
receipt of the notice.
|
||||||
|
|
||||||
|
**5.2.** If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions, counter-claims, and
|
||||||
|
cross-claims) alleging that a Contributor Version directly or indirectly
|
||||||
|
infringes any patent, then the rights granted to You by any and all
|
||||||
|
Contributors for the Covered Software under Section 2.1 of this License shall
|
||||||
|
terminate.
|
||||||
|
|
||||||
|
**5.3.** In the event of termination under Sections 5.1 or 5.2 above, all end
|
||||||
|
user license agreements (excluding distributors and resellers) which have been
|
||||||
|
validly granted by You or Your distributors under this License prior to
|
||||||
|
termination shall survive termination.
|
||||||
|
|
||||||
|
|
||||||
|
### 6. Disclaimer of Warranty
|
||||||
|
|
||||||
|
> Covered Software is provided under this License on an "as is" basis, without
|
||||||
|
> warranty of any kind, either expressed, implied, or statutory, including,
|
||||||
|
> without limitation, warranties that the Covered Software is free of defects,
|
||||||
|
> merchantable, fit for a particular purpose or non-infringing. The entire risk
|
||||||
|
> as to the quality and performance of the Covered Software is with You.
|
||||||
|
> Should any Covered Software prove defective in any respect, You (not any
|
||||||
|
> Contributor) assume the cost of any necessary servicing, repair, or
|
||||||
|
> correction. This disclaimer of warranty constitutes an essential part of this
|
||||||
|
> License. No use of any Covered Software is authorized under this License
|
||||||
|
> except under this disclaimer.
|
||||||
|
|
||||||
|
### 7. Limitation of Liability
|
||||||
|
|
||||||
|
> Under no circumstances and under no legal theory, whether tort (including
|
||||||
|
> negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||||
|
> distributes Covered Software as permitted above, be liable to You for any
|
||||||
|
> direct, indirect, special, incidental, or consequential damages of any
|
||||||
|
> character including, without limitation, damages for lost profits, loss of
|
||||||
|
> goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||||
|
> other commercial damages or losses, even if such party shall have been
|
||||||
|
> informed of the possibility of such damages. This limitation of liability
|
||||||
|
> shall not apply to liability for death or personal injury resulting from such
|
||||||
|
> party's negligence to the extent applicable law prohibits such limitation.
|
||||||
|
> Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||||
|
> consequential damages, so this exclusion and limitation may not apply to You.
|
||||||
|
|
||||||
|
|
||||||
|
### 8. Litigation
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the courts of a
|
||||||
|
jurisdiction where the defendant maintains its principal place of business and
|
||||||
|
such litigation shall be governed by laws of that jurisdiction, without
|
||||||
|
reference to its conflict-of-law provisions. Nothing in this Section shall
|
||||||
|
prevent a party's ability to bring cross-claims or counter-claims.
|
||||||
|
|
||||||
|
|
||||||
|
### 9. Miscellaneous
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject matter
|
||||||
|
hereof. If any provision of this License is held to be unenforceable, such
|
||||||
|
provision shall be reformed only to the extent necessary to make it
|
||||||
|
enforceable. Any law or regulation which provides that the language of a
|
||||||
|
contract shall be construed against the drafter shall not be used to construe
|
||||||
|
this License against a Contributor.
|
||||||
|
|
||||||
|
|
||||||
|
### 10. Versions of the License
|
||||||
|
|
||||||
|
#### 10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section 10.3,
|
||||||
|
no one other than the license steward has the right to modify or publish new
|
||||||
|
versions of this License. Each version will be given a distinguishing version
|
||||||
|
number.
|
||||||
|
|
||||||
|
#### 10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version of the
|
||||||
|
License under which You originally received the Covered Software, or under the
|
||||||
|
terms of any subsequent version published by the license steward.
|
||||||
|
|
||||||
|
#### 10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to create a
|
||||||
|
new license for such software, you may create and use a modified version of
|
||||||
|
this License if you rename the license and remove any references to the name of
|
||||||
|
the license steward (except to note that such modified license differs from
|
||||||
|
this License).
|
||||||
|
|
||||||
|
#### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||||
|
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the notice
|
||||||
|
described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
### Exhibit A - Source Code Form License Notice
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular file, then
|
||||||
|
You may include the notice in a location (such as a LICENSE file in a relevant
|
||||||
|
directory) where a recipient would be likely to look for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
### Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
|
||||||
|
This Source Code Form is "Incompatible With Secondary Licenses", as defined
|
||||||
|
by the Mozilla Public License, v. 2.0.
|
||||||
|
|
||||||
236
Makefile
236
Makefile
@@ -1,236 +0,0 @@
|
|||||||
ARCH ?= x86_64
|
|
||||||
|
|
||||||
include src/arch/$(ARCH)/config.mk
|
|
||||||
|
|
||||||
BUILD_D := build
|
|
||||||
KERN_D := src/kernel
|
|
||||||
ARCH_D := src/arch/$(ARCH)
|
|
||||||
VERSION ?= $(shell git describe --dirty --always)
|
|
||||||
GITSHA ?= $(shell git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
KERNEL_FILENAME:= popcorn.elf
|
|
||||||
KERNEL_FONT := assets/fonts/tamsyn8x16r.psf
|
|
||||||
|
|
||||||
MODULES := kutil
|
|
||||||
|
|
||||||
|
|
||||||
EFI_DIR := external/gnu-efi
|
|
||||||
EFI_DATA := $(EFI_DIR)/gnuefi
|
|
||||||
EFI_LDS := $(EFI_DATA)/elf_$(ARCH)_efi.lds
|
|
||||||
EFI_ARCH_DIR := $(EFI_DIR)/$(ARCH)
|
|
||||||
EFI_ARCH_DATA := $(EFI_ARCH_DIR)/gnuefi
|
|
||||||
EFI_CRT_OBJ := $(EFI_ARCH_DATA)/crt0-efi-$(ARCH).o
|
|
||||||
EFI_LIB := $(EFI_ARCH_DIR)/lib/libefi.a
|
|
||||||
EFI_INCLUDES := $(EFI_DIR)/inc
|
|
||||||
|
|
||||||
DEPENDFLAGS := -MMD
|
|
||||||
|
|
||||||
INCLUDES := -I $(ARCH_D)
|
|
||||||
INCLUDES += -I src/modules
|
|
||||||
INCLUDES += -I src/include
|
|
||||||
INCLUDES += -isystem $(EFI_INCLUDES)
|
|
||||||
INCLUDES += -isystem $(EFI_INCLUDES)/$(ARCH)
|
|
||||||
INCLUDES += -isystem $(EFI_INCLUDES)/protocol
|
|
||||||
|
|
||||||
BASEFLAGS := -ggdb -nostdlib
|
|
||||||
BASEFLAGS += -ffreestanding -nodefaultlibs
|
|
||||||
BASEFLAGS += -fno-builtin -fomit-frame-pointer
|
|
||||||
BASEFLAGS += -mno-red-zone -fno-stack-protector
|
|
||||||
|
|
||||||
ifdef CPU
|
|
||||||
BASEFLAGS += -mcpu=$(CPU)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Removed Flags:: -Wcast-align
|
|
||||||
WARNFLAGS += -Wformat=2 -Winit-self -Wfloat-equal -Winline
|
|
||||||
WARNFLAGS += -Winvalid-pch -Wmissing-format-attribute
|
|
||||||
WARNFLAGS += -Wmissing-include-dirs -Wswitch -Wundef
|
|
||||||
WARNFLAGS += -Wdisabled-optimization -Wpointer-arith
|
|
||||||
|
|
||||||
WARNFLAGS += -Wno-attributes -Wno-sign-compare -Wno-multichar
|
|
||||||
WARNFLAGS += -Wno-div-by-zero -Wno-endif-labels -Wno-pragmas
|
|
||||||
WARNFLAGS += -Wno-format-extra-args -Wno-unused-result
|
|
||||||
WARNFLAGS += -Wno-deprecated-declarations -Wno-unused-function
|
|
||||||
|
|
||||||
ASFLAGS ?=
|
|
||||||
ASFLAGS += -p $(BUILD_D)/versions.s
|
|
||||||
|
|
||||||
CFLAGS := $(INCLUDES) $(DEPENDFLAGS) $(BASEFLAGS) $(WARNFLAGS)
|
|
||||||
CFLAGS += -DGIT_VERSION="\"$(VERSION)\""
|
|
||||||
CFLAGS += -std=c11 -mcmodel=large
|
|
||||||
|
|
||||||
CXXFLAGS := $(INCLUDES) $(DEPENDFLAGS) $(BASEFLAGS) $(WARNFLAGS)
|
|
||||||
CXXFLAGS += -DGIT_VERSION="\"$(VERSION)\""
|
|
||||||
CXXFLAGS += -std=c++14 -mcmodel=large
|
|
||||||
CXXFLAGS += -fno-exceptions -fno-rtti
|
|
||||||
|
|
||||||
BOOT_CFLAGS := $(INCLUDES) $(DEPENDFLAGS) $(BASEFLAGS) $(WARNFLAGS)
|
|
||||||
BOOT_CFLAGS += -std=c11 -I src/boot -fPIC -fshort-wchar
|
|
||||||
BOOT_CFLAGS += -DKERNEL_FILENAME="L\"$(KERNEL_FILENAME)\""
|
|
||||||
BOOT_CFLAGS += -DGIT_VERSION_WIDE="L\"$(VERSION)\""
|
|
||||||
BOOT_CFLAGS += -DGNU_EFI_USE_MS_ABI -DHAVE_USE_MS_ABI
|
|
||||||
BOOT_CFLAGS += -DEFI_DEBUG=0 -DEFI_DEBUG_CLEAR_MEMORY=0
|
|
||||||
#BOOT_CFLAGS += -DEFI_FUNCTION_WRAPPER
|
|
||||||
|
|
||||||
ifdef MAX_HRES
|
|
||||||
BOOT_CFLAGS += -DMAX_HRES=$(MAX_HRES)
|
|
||||||
endif
|
|
||||||
|
|
||||||
LDFLAGS := -L $(BUILD_D) -g
|
|
||||||
LDFLAGS += -nostdlib -znocombreloc -Bsymbolic -nostartfiles
|
|
||||||
|
|
||||||
BOOT_LDFLAGS := $(LDFLAGS) -shared
|
|
||||||
BOOT_LDFLAGS += -L $(EFI_ARCH_DIR)/lib -L $(EFI_ARCH_DIR)/gnuefi
|
|
||||||
|
|
||||||
AS ?= $(CROSS)nasm
|
|
||||||
AR ?= $(CROSS)ar
|
|
||||||
CC ?= $(CROSS)gcc
|
|
||||||
CXX ?= $(CROSS)g++
|
|
||||||
LD ?= $(CROSS)ld
|
|
||||||
OBJC := $(CROSS)objcopy
|
|
||||||
OBJD := $(CROSS)objdump
|
|
||||||
|
|
||||||
INIT_DEP := $(BUILD_D)/.builddir
|
|
||||||
|
|
||||||
BOOT_SRCS := $(wildcard src/boot/*.c)
|
|
||||||
BOBJS += $(patsubst src/boot/%,$(BUILD_D)/boot/%,$(patsubst %,%.o,$(BOOT_SRCS)))
|
|
||||||
|
|
||||||
KERN_SRCS := $(wildcard $(KERN_D)/*.s)
|
|
||||||
KERN_SRCS += $(wildcard $(KERN_D)/*.c)
|
|
||||||
KERN_SRCS += $(wildcard $(KERN_D)/*.cpp)
|
|
||||||
KERN_SRCS += $(wildcard $(ARCH_D)/*.s)
|
|
||||||
KERN_SRCS += $(wildcard $(ARCH_D)/*.c)
|
|
||||||
|
|
||||||
KERN_OBJS := $(patsubst src/%, $(BUILD_D)/%, $(patsubst %,%.o,$(KERN_SRCS)))
|
|
||||||
|
|
||||||
MOD_TARGETS :=
|
|
||||||
|
|
||||||
PARTED ?= /sbin/parted
|
|
||||||
QEMU ?= qemu-system-x86_64
|
|
||||||
GDBPORT ?= 27006
|
|
||||||
CPUS ?= 1
|
|
||||||
OVMF ?= assets/ovmf/x64/OVMF.fd
|
|
||||||
|
|
||||||
QEMUOPTS := -pflash $(BUILD_D)/flash.img
|
|
||||||
QEMUOPTS += -drive file=$(BUILD_D)/fs.img,format=raw
|
|
||||||
QEMUOPTS += -smp $(CPUS) -m 512
|
|
||||||
QEMUOPTS += -d mmu,guest_errors,int -D popcorn.log
|
|
||||||
QEMUOPTS += -no-reboot
|
|
||||||
QEMUOPTS += $(QEMUEXTRA)
|
|
||||||
|
|
||||||
|
|
||||||
all: $(BUILD_D)/fs.img
|
|
||||||
init: $(INIT_DEP)
|
|
||||||
|
|
||||||
$(INIT_DEP):
|
|
||||||
mkdir -p $(BUILD_D) $(patsubst %,$(BUILD_D)/d.%,$(MODULES))
|
|
||||||
mkdir -p $(BUILD_D)/boot
|
|
||||||
mkdir -p $(patsubst src/%,$(BUILD_D)/%,$(ARCH_D))
|
|
||||||
mkdir -p $(patsubst src/%,$(BUILD_D)/%,$(KERN_D))
|
|
||||||
touch $(INIT_DEP)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf $(BUILD_D)/* $(BUILD_D)/.version $(BUILD_D)/.builddir
|
|
||||||
|
|
||||||
vars:
|
|
||||||
@echo "KERN_SRCS: " $(KERN_SRCS)
|
|
||||||
@echo "KERN_OBJS: " $(KERN_OBJS)
|
|
||||||
|
|
||||||
dist-clean: clean
|
|
||||||
make -C external/gnu-efi clean
|
|
||||||
|
|
||||||
.PHONY: all clean dist-clean init vars
|
|
||||||
|
|
||||||
$(BUILD_D)/.version:
|
|
||||||
echo '$(VERSION)' | cmp -s - $@ || echo '$(VERSION)' > $@
|
|
||||||
|
|
||||||
$(BUILD_D)/versions.s:
|
|
||||||
./parse_version.py "$(VERSION)" "$(GITSHA)" > $@
|
|
||||||
|
|
||||||
-include x $(patsubst %,src/modules/%/module.mk,$(MODULES))
|
|
||||||
-include x $(shell find $(BUILD_D) -type f -name '*.d')
|
|
||||||
|
|
||||||
$(EFI_LIB):
|
|
||||||
make -C external/gnu-efi all
|
|
||||||
|
|
||||||
$(BUILD_D)/boot.elf: $(BOBJS) $(EFI_LIB)
|
|
||||||
$(LD) $(BOOT_LDFLAGS) -T $(EFI_LDS) -o $@ \
|
|
||||||
$(EFI_CRT_OBJ) $(BOBJS) -lefi -lgnuefi
|
|
||||||
|
|
||||||
$(BUILD_D)/boot.efi: $(BUILD_D)/boot.elf
|
|
||||||
$(OBJC) -j .text -j .sdata -j .data -j .dynamic \
|
|
||||||
-j .dynsym -j .rel -j .rela -j .reloc \
|
|
||||||
--target=efi-app-$(ARCH) $^ $@
|
|
||||||
|
|
||||||
$(BUILD_D)/boot.debug.efi: $(BUILD_D)/boot.elf
|
|
||||||
$(OBJC) -j .text -j .sdata -j .data -j .dynamic \
|
|
||||||
-j .dynsym -j .rel -j .rela -j .reloc \
|
|
||||||
-j .debug_info -j .debug_abbrev -j .debug_loc -j .debug_str \
|
|
||||||
-j .debug_aranges -j .debug_line -j .debug_macinfo \
|
|
||||||
--target=efi-app-$(ARCH) $^ $@
|
|
||||||
|
|
||||||
$(BUILD_D)/boot.dump: $(BUILD_D)/boot.efi
|
|
||||||
$(OBJD) -D -S $< > $@
|
|
||||||
|
|
||||||
$(BUILD_D)/boot/%.s.o: src/boot/%.s $(BUILD_D)/versions.s $(INIT_DEP)
|
|
||||||
$(AS) $(ASFLAGS) -i src/boot/ -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD_D)/boot/%.c.o: src/boot/%.c $(INIT_DEP)
|
|
||||||
$(CC) $(BOOT_CFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD_D)/kernel.elf: $(KERN_OBJS) $(MOD_TARGETS) $(ARCH_D)/kernel.ld
|
|
||||||
$(LD) $(LDFLAGS) -u _header -T $(ARCH_D)/kernel.ld -o $@ $(KERN_OBJS) $(patsubst %,-l%,$(MODULES))
|
|
||||||
$(OBJC) --only-keep-debug $@ $@.sym
|
|
||||||
$(OBJD) -D -S $@ > $@.dump
|
|
||||||
|
|
||||||
$(BUILD_D)/%.s.o: src/%.s $(BUILD_D)/versions.s $(INIT_DEP)
|
|
||||||
$(AS) $(ASFLAGS) -i $(ARCH_D)/ -i $(KERN_D)/ -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD_D)/%.c.o: src/%.c $(INIT_DEP)
|
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD_D)/%.cpp.o: src/%.cpp $(INIT_DEP)
|
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD_D)/flash.img: $(OVMF)
|
|
||||||
cp $^ $@
|
|
||||||
|
|
||||||
$(BUILD_D)/screenfont.psf: $(KERNEL_FONT)
|
|
||||||
cp $^ $@
|
|
||||||
|
|
||||||
$(BUILD_D)/fs.img: $(BUILD_D)/boot.efi $(BUILD_D)/kernel.elf $(BUILD_D)/screenfont.psf
|
|
||||||
$(eval TEMPFILE := $(shell mktemp --suffix=.img))
|
|
||||||
dd if=/dev/zero of=$@.tmp bs=512 count=93750
|
|
||||||
$(PARTED) $@.tmp -s -a minimal mklabel gpt
|
|
||||||
$(PARTED) $@.tmp -s -a minimal mkpart EFI FAT16 2048s 93716s
|
|
||||||
$(PARTED) $@.tmp -s -a minimal toggle 1 boot
|
|
||||||
dd if=/dev/zero of=$(TEMPFILE) bs=512 count=91669
|
|
||||||
mformat -i $(TEMPFILE) -h 32 -t 32 -n 64 -c 1
|
|
||||||
mmd -i $(TEMPFILE) ::/EFI
|
|
||||||
mmd -i $(TEMPFILE) ::/EFI/BOOT
|
|
||||||
mcopy -i $(TEMPFILE) $(BUILD_D)/boot.efi ::/EFI/BOOT/BOOTX64.efi
|
|
||||||
mcopy -i $(TEMPFILE) $(BUILD_D)/kernel.elf ::$(KERNEL_FILENAME)
|
|
||||||
mcopy -i $(TEMPFILE) $(BUILD_D)/screenfont.psf ::screenfont.psf
|
|
||||||
mlabel -i $(TEMPFILE) ::Popcorn_OS
|
|
||||||
dd if=$(TEMPFILE) of=$@.tmp bs=512 count=91669 seek=2048 conv=notrunc
|
|
||||||
rm $(TEMPFILE)
|
|
||||||
mv $@.tmp $@
|
|
||||||
|
|
||||||
$(BUILD_D)/fs.iso: $(BUILD_D)/fs.img
|
|
||||||
mkdir -p $(BUILD_D)/iso
|
|
||||||
cp $< $(BUILD_D)/iso/
|
|
||||||
xorriso -as mkisofs -R -f -e fs.img -no-emul-boot -o $@ $(BUILD_D)/iso
|
|
||||||
|
|
||||||
qemu: $(BUILD_D)/fs.img $(BUILD_D)/flash.img
|
|
||||||
-rm popcorn.log
|
|
||||||
"$(QEMU)" $(QEMUOPTS) -nographic
|
|
||||||
|
|
||||||
qemu-window: $(BUILD_D)/fs.img $(BUILD_D)/flash.img
|
|
||||||
-rm popcorn.log
|
|
||||||
"$(QEMU)" $(QEMUOPTS)
|
|
||||||
|
|
||||||
qemu-gdb: $(BUILD_D)/fs.img $(BUILD_D)/boot.debug.efi $(BUILD_D)/flash.img $(BUILD_D)/kernel.elf
|
|
||||||
-rm popcorn.log
|
|
||||||
"$(QEMU)" $(QEMUOPTS) -s -nographic
|
|
||||||
|
|
||||||
# vim: ft=make ts=4
|
|
||||||
9
NOTES.md
9
NOTES.md
@@ -1,9 +0,0 @@
|
|||||||
# Design / WIP notes
|
|
||||||
|
|
||||||
## TODO
|
|
||||||
|
|
||||||
- Better page-allocation model
|
|
||||||
- Allow for more than one IOAPIC in ACPI module
|
|
||||||
- Slab allocator for kernel structures
|
|
||||||
- mark kernel memory pages global
|
|
||||||
|
|
||||||
184
README.md
184
README.md
@@ -1,7 +1,181 @@
|
|||||||
# popcorn: A toy microkernel x64 UEFI OS
|

|
||||||
|
|
||||||
**popcorn** is a hobby OS for x64 UEFI environments to play with building a
|
# The jsix operating system
|
||||||
microkenerl architecture. It's far from finished, or even being usable - for
|
|
||||||
now, it's a sandbox for me to explore the UEFI architecture, microkernels, and
|
|
||||||
OS-related concepts that I want to play with.
|
|
||||||
|
|
||||||
|
**jsix** is a custom multi-core x64 operating system that I am building from
|
||||||
|
scratch. It's far from finished, or even being usable (see the *Status and
|
||||||
|
Roadmap* section, below) but all currently-planned major kernel features are
|
||||||
|
now implemented to at least a passable level.
|
||||||
|
|
||||||
|
The design goals of the project are:
|
||||||
|
|
||||||
|
* Modernity - I'm not interested in designing for legacy systems, or running on
|
||||||
|
all hardware out there. My target is only 64 bit architectures, and modern
|
||||||
|
commodity hardware. Currently that means x64 systems with Nehalem or newer
|
||||||
|
CPUs and UEFI firmware. (See [this list][cpu_features] for the currently
|
||||||
|
required CPU features.) Eventually I'd like to work on an AArch64 port,
|
||||||
|
partly to force myself to factor out the architecture-dependent pieces of the
|
||||||
|
code base.
|
||||||
|
|
||||||
|
* Modularity - I'd like to pull as much of the system out into separate
|
||||||
|
processes as possible, in the microkernel fashion. A sub-goal of this is to
|
||||||
|
explore where the bottlenecks of such a microkernel are now, and whether
|
||||||
|
eschewing legacy hardware will let me design a system that's less bogged down
|
||||||
|
by the traditional microkernel problems.
|
||||||
|
|
||||||
|
* Exploration - I'm really mostly doing this to have fun learning and exploring
|
||||||
|
modern OS development. Initial feature implementations may temporarily throw
|
||||||
|
away modular design to allow for exploration of the related hardware.
|
||||||
|
|
||||||
|
A note on the name: This kernel was originally named Popcorn, but I have since
|
||||||
|
discovered that the Popcorn Linux project is also developing a kernel with that
|
||||||
|
name, started around the same time as this project. So I've renamed this kernel
|
||||||
|
jsix (Always styled _jsix_ or `j6`, never capitalized) as an homage to L4, xv6,
|
||||||
|
and my wonderful wife.
|
||||||
|
|
||||||
|
[cpu_features]: https://github.com/justinian/jsix/blob/master/src/libraries/cpu/include/cpu/features.inc
|
||||||
|
|
||||||
|
## Status and Roadmap
|
||||||
|
|
||||||
|
The following major feature areas are targets for jsix development:
|
||||||
|
|
||||||
|
#### UEFI boot loader
|
||||||
|
|
||||||
|
_Done._ The bootloader loads the kernel and initial userspace programs, and
|
||||||
|
sets up necessary kernel arguments about the memory map and EFI GOP
|
||||||
|
framebuffer. Possible future ideas:
|
||||||
|
|
||||||
|
- take over more init-time functions from the kernel
|
||||||
|
- rewrite it in Zig
|
||||||
|
|
||||||
|
#### Memory
|
||||||
|
|
||||||
|
_Virtual memory: Sufficient._ The kernel manages virtual memory with a number
|
||||||
|
of kinds of `vm_area` objects representing mapped areas, which can belong to
|
||||||
|
one or more `vm_space` objects which represent a whole virtual memory space.
|
||||||
|
(Each process has a `vm_space`, and so does the kernel itself.)
|
||||||
|
|
||||||
|
Remaining to do:
|
||||||
|
|
||||||
|
- TLB shootdowns
|
||||||
|
- Page swapping
|
||||||
|
- Large / huge page support
|
||||||
|
|
||||||
|
_Physical page allocation: Sufficient._ The current physical page allocator
|
||||||
|
implementation uses a group of blocks representing up-to-1GiB areas of usable
|
||||||
|
memory as defined by the bootloader. Each block has a three-level bitmap
|
||||||
|
denoting free/used pages.
|
||||||
|
|
||||||
|
Future work:
|
||||||
|
|
||||||
|
- Align blocks so that their first page is 1GiB-aligned, making finding free
|
||||||
|
large/huge pages easier.
|
||||||
|
|
||||||
|
#### Multitasking
|
||||||
|
|
||||||
|
_Sufficient._ The global scheduler object keeps separate ready/blocked lists
|
||||||
|
per core. Cores periodically attempt to balance load via work stealing.
|
||||||
|
|
||||||
|
User-space tasks are able to create threads as well as other processes.
|
||||||
|
|
||||||
|
#### API
|
||||||
|
|
||||||
|
_Syscalls: Sufficient._ User-space tasks are able to make syscalls to the
|
||||||
|
kernel via fast SYSCALL/SYSRET instructions. Syscalls made via `libj6` look to
|
||||||
|
both the callee and the caller like standard SysV ABI function calls. The
|
||||||
|
implementations are wrapped in generated wrapper functions which validate the
|
||||||
|
request, check capabilities, and find the appropriate kernel objects or handles
|
||||||
|
before calling the implementation functions.
|
||||||
|
|
||||||
|
_IPC: Working, needs optimization._ The current IPC primitives are:
|
||||||
|
|
||||||
|
- _Mailboxes_: endpoints for asynchronously-delivered small messages. Currently
|
||||||
|
these messages are double-copied - once from the caller into a kernel buffer,
|
||||||
|
and once from the kernel to the receiver. This works and is not a major cause
|
||||||
|
of slowdown, but will need to be optimized in the future.
|
||||||
|
- _Channels_: endpoints for asynchronous uni-directional streams of bytes.
|
||||||
|
Currently these also suffer from a double-copy problem, and should probably
|
||||||
|
be replaced eventually by userspace shared memory communication.
|
||||||
|
- _Events_: objects that can be signalled to send asynchronous notifications to
|
||||||
|
waiting threads.
|
||||||
|
|
||||||
|
#### Hardware Support
|
||||||
|
|
||||||
|
- Framebuffer driver: _In progress._ Currently on machines with a video
|
||||||
|
device accessible by UEFI, jsix starts a user-space framebuffer driver that
|
||||||
|
only prints out kernel logs.
|
||||||
|
- Serial driver: _In progress._ The current UART currently only exposes COM1
|
||||||
|
as an output channel, but no input or other serial ports are exposed.
|
||||||
|
- USB driver: _To do_
|
||||||
|
- AHCI (SATA) driver: _To do_
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
jsix uses the [Ninja][] build tool, and generates the build files for it with
|
||||||
|
the `configure` script. The build also relies on a custom toolchain sysroot, which can be
|
||||||
|
downloaded or built using the scripts in [jsix-os/toolchain][].
|
||||||
|
|
||||||
|
[Ninja]: https://ninja-build.org
|
||||||
|
[jsix-os/toolchain]: https://github.com/jsix-os/toolchain
|
||||||
|
|
||||||
|
Other build dependencies:
|
||||||
|
|
||||||
|
* [clang][]: the C/C++ compiler
|
||||||
|
* [nasm][]: the assembler
|
||||||
|
* [lld][]: the linker
|
||||||
|
* [mtools][]: for creating the FAT image
|
||||||
|
|
||||||
|
[clang]: https://clang.llvm.org
|
||||||
|
[nasm]: https://www.nasm.us
|
||||||
|
[lld]: https://lld.llvm.org
|
||||||
|
[mtools]: https://www.gnu.org/software/mtools/
|
||||||
|
|
||||||
|
The `configure` script has some Python dependencies - these can be installed via
|
||||||
|
`pip`, though doing so in a python virtual environment is recommended.
|
||||||
|
Installing via `pip` will also install `ninja`.
|
||||||
|
|
||||||
|
A Debian 11 (Bullseye) system can be configured with the necessary build
|
||||||
|
dependencies by running the following commands from the jsix repository root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install clang lld nasm mtools python3-pip python3-venv
|
||||||
|
python3 -m venv ./venv
|
||||||
|
source venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
peru sync
|
||||||
|
```
|
||||||
|
|
||||||
|
### Setting up the sysroot
|
||||||
|
|
||||||
|
Build or download the toolchain sysroot as mentioned above with
|
||||||
|
[jsix-os/toolchain][], and symlink the built toolchain directory as `sysroot`
|
||||||
|
at the root of this project.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Example if both the toolchain and this project are cloned under ~/src
|
||||||
|
ln -s ~/src/toolchain/toolchains/llvm-13 ~/src/jsix/sysroot
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building and running jsix
|
||||||
|
|
||||||
|
Once the toolchain has been set up, running the `./configure` script (see
|
||||||
|
`./configure --help` for available options) will set up the build configuration,
|
||||||
|
and `ninja -C build` (or wherever you put the build directory) will actually run
|
||||||
|
the build. If you have `qemu-system-x86_64` installed, the `qemu.sh` script will
|
||||||
|
to run jsix in QEMU `-nographic` mode.
|
||||||
|
|
||||||
|
I personally run this either from a real debian amd64 bullseye machine or
|
||||||
|
a windows WSL debian bullseye installation. Your mileage may vary with other
|
||||||
|
setups and distros.
|
||||||
|
|
||||||
|
### Running the test suite
|
||||||
|
|
||||||
|
jsix now has the `test_runner` userspace program that runs various automated
|
||||||
|
tests. It is not included in the default build, but if you use the `test.yml`
|
||||||
|
manifest it will be built, and can be run with the `test.sh` script or the
|
||||||
|
`qemu.sh` script.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./configure --manifest=assets/manifests/test.yml
|
||||||
|
if ./test.sh; then echo "All tests passed!"; else echo "Failed."; fi
|
||||||
|
```
|
||||||
|
|||||||
9
assets/build/amd64/config.debug.yaml
Normal file
9
assets/build/amd64/config.debug.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
ccflags: [
|
||||||
|
"-g3",
|
||||||
|
"-ggdb",
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-g",
|
||||||
|
]
|
||||||
3
assets/build/amd64/config.release.yaml
Normal file
3
assets/build/amd64/config.release.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ccflags: [
|
||||||
|
"-O3",
|
||||||
|
]
|
||||||
39
assets/build/amd64/global.yaml
Normal file
39
assets/build/amd64/global.yaml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
cc: "${source_root}/sysroot/bin/clang"
|
||||||
|
cxx: "${source_root}/sysroot/bin/clang++"
|
||||||
|
ld: "${source_root}/sysroot/bin/ld.lld"
|
||||||
|
ar: ar
|
||||||
|
nasm: nasm
|
||||||
|
objcopy: objcopy
|
||||||
|
|
||||||
|
ccflags: [
|
||||||
|
"-I${source_root}/src/include",
|
||||||
|
"-fcolor-diagnostics",
|
||||||
|
"-U__STDCPP_THREADS__",
|
||||||
|
"-D_LIBCPP_HAS_NO_THREADS",
|
||||||
|
"-D__jsix_config=${build_config}",
|
||||||
|
"-D__jsix_config_${build_config}",
|
||||||
|
"-DVERSION_MAJOR=${version_major}",
|
||||||
|
"-DVERSION_MINOR=${version_minor}",
|
||||||
|
"-DVERSION_PATCH=${version_patch}",
|
||||||
|
"-DVERSION_GITSHA=0x${version_sha}",
|
||||||
|
'-DGIT_VERSION=\"${version_major}.${version_minor}.${version_patch}+${version_sha}\"',
|
||||||
|
'-DGIT_VERSION_WIDE=L\"${version_major}.${version_minor}.${version_patch}+${version_sha}\"',
|
||||||
|
|
||||||
|
"-Wformat=2", "-Winit-self", "-Winline", "-Wmissing-format-attribute",
|
||||||
|
"-Wmissing-include-dirs", "-Wswitch", "-Wundef", "-Wdisabled-optimization",
|
||||||
|
"-Wpointer-arith", "-Wno-attributes", "-Wno-sign-compare", "-Wno-multichar",
|
||||||
|
"-Wno-div-by-zero", "-Wno-endif-labels", "-Wno-pragmas", "-Wno-format-extra-args",
|
||||||
|
"-Wno-unused-result", "-Wno-deprecated-declarations", "-Wno-unused-function",
|
||||||
|
"-Wno-address-of-packed-member", "-Wno-invalid-offsetof", "-Wno-format-nonliteral",
|
||||||
|
"-Werror" ]
|
||||||
|
|
||||||
|
asflags: [
|
||||||
|
"-DVERSION_MAJOR=${version_major}",
|
||||||
|
"-DVERSION_MINOR=${version_minor}",
|
||||||
|
"-DVERSION_PATCH=${version_patch}",
|
||||||
|
"-DVERSION_GITSHA=0x${version_sha}",
|
||||||
|
"-I${source_root}/src/include" ]
|
||||||
|
|
||||||
|
cflags: [ "-std=c11" ]
|
||||||
|
cxxflags: [ "-std=c++17" ]
|
||||||
91
assets/build/amd64/rules.ninja
Normal file
91
assets/build/amd64/rules.ninja
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
rule compile.c
|
||||||
|
command = $cc -MMD -MF $out.d $cflags $ccflags -o $out -c $in
|
||||||
|
description = Compiling [$target]:$name
|
||||||
|
depfile = $out.d
|
||||||
|
deps = gcc
|
||||||
|
|
||||||
|
rule dump_c_defs
|
||||||
|
command = echo | $cc $ccflags $cflags -dM -E - > $out
|
||||||
|
description = Dumping C defines for $target
|
||||||
|
|
||||||
|
rule dump_c_run
|
||||||
|
command = echo '#!/bin/bash' > $out; echo '$cc $ccflags $cflags $$*' >> $
|
||||||
|
$out; chmod a+x $out
|
||||||
|
description = Dumping C arguments for $target
|
||||||
|
|
||||||
|
rule compile.cpp
|
||||||
|
command = $cxx -MMD -MF $out.d $cxxflags $ccflags -o $out -c $in
|
||||||
|
description = Compiling [$target]:$name
|
||||||
|
depfile = $out.d
|
||||||
|
deps = gcc
|
||||||
|
|
||||||
|
rule dump_cpp_defs
|
||||||
|
command = echo | $cxx -x c++ $ccflags $cxxflags -dM -E - > $out
|
||||||
|
description = Dumping C++ defines for $target
|
||||||
|
|
||||||
|
rule dump_cpp_run
|
||||||
|
command = echo '#!/bin/bash' > $out; echo '$cxx $ccflags $cxxflags $$*' $
|
||||||
|
>> $out; chmod a+x $out
|
||||||
|
description = Dumping C++ arguments for $target
|
||||||
|
|
||||||
|
rule compile.s
|
||||||
|
command = $nasm -o $out -felf64 -MD $out.d $asflags $in
|
||||||
|
description = Assembling [$target]:$name
|
||||||
|
depfile = $out.d
|
||||||
|
deps = gcc
|
||||||
|
|
||||||
|
rule parse.cog
|
||||||
|
command = cog -o $out -d -D target=$target $cogflags $in
|
||||||
|
description = Parsing [$target]:$name
|
||||||
|
|
||||||
|
rule exe
|
||||||
|
command = $ld $ldflags -o $out $in $libs
|
||||||
|
description = Linking exe [$target]:$name
|
||||||
|
|
||||||
|
rule driver
|
||||||
|
command = $ld $ldflags -o $out $in $libs
|
||||||
|
description = Linking driver [$target]:$name
|
||||||
|
|
||||||
|
rule lib
|
||||||
|
command = $ld -shared -soname $soname $ldflags -o $out $in $libs
|
||||||
|
description = Linking [$target]:$name
|
||||||
|
|
||||||
|
rule lib_static
|
||||||
|
command = $ar qcs $out $in
|
||||||
|
description = Archiving [$target]:$name
|
||||||
|
|
||||||
|
rule cp
|
||||||
|
command = cp $in $out
|
||||||
|
description = Copying [$target]:$name
|
||||||
|
|
||||||
|
rule dump
|
||||||
|
command = objdump -DSC -M intel $in > $out
|
||||||
|
description = Dumping decompiled $name
|
||||||
|
|
||||||
|
rule makest
|
||||||
|
description = Making symbol table
|
||||||
|
command = nm -n -S --demangle $in | ${source_root}/scripts/build_symbol_table.py $out
|
||||||
|
|
||||||
|
rule makeinitrd
|
||||||
|
description = Creating $name
|
||||||
|
command = ${source_root}/scripts/mkj6romfs.py -c $format $in $out
|
||||||
|
|
||||||
|
rule makefat
|
||||||
|
description = Creating $name
|
||||||
|
command = $
|
||||||
|
cp $in $out; $
|
||||||
|
mcopy -s -D o -i $out@@1M ${build_root}/fatroot/* ::/
|
||||||
|
|
||||||
|
rule strip
|
||||||
|
description = Stripping $name
|
||||||
|
command = $
|
||||||
|
cp $in $out; $
|
||||||
|
objcopy --only-keep-debug $out $debug; $
|
||||||
|
strip --discard-all -g $out; $
|
||||||
|
objcopy --add-gnu-debuglink=$debug $out
|
||||||
|
|
||||||
|
rule touch
|
||||||
|
command = touch $out
|
||||||
|
|
||||||
|
rule compdb
|
||||||
|
command = ninja -t compdb > $out
|
||||||
26
assets/build/amd64/target.boot.yaml
Normal file
26
assets/build/amd64/target.boot.yaml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
ld: clang++
|
||||||
|
|
||||||
|
ccflags: [
|
||||||
|
"-nostdlib",
|
||||||
|
"-nodefaultlibs",
|
||||||
|
"-fno-builtin",
|
||||||
|
|
||||||
|
"-I${source_root}/external",
|
||||||
|
"--target=x86_64-unknown-windows",
|
||||||
|
"-ffreestanding",
|
||||||
|
"-mno-red-zone",
|
||||||
|
"-fshort-wchar",
|
||||||
|
"-fno-omit-frame-pointer",
|
||||||
|
]
|
||||||
|
|
||||||
|
cxxflags: [ "-fno-exceptions", "-fno-rtti" ]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"--target=x86_64-unknown-windows",
|
||||||
|
"-nostdlib",
|
||||||
|
"-Wl,-entry:efi_main",
|
||||||
|
"-Wl,-subsystem:efi_application",
|
||||||
|
"-fuse-ld=lld-link",
|
||||||
|
]
|
||||||
|
|
||||||
40
assets/build/amd64/target.init.yaml
Normal file
40
assets/build/amd64/target.init.yaml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
ccflags: [
|
||||||
|
"--target=x86_64-jsix-elf",
|
||||||
|
"-fno-omit-frame-pointer",
|
||||||
|
"-fno-stack-protector",
|
||||||
|
|
||||||
|
"-fvisibility=hidden",
|
||||||
|
"-fvisibility-inlines-hidden",
|
||||||
|
|
||||||
|
"-D__ELF__",
|
||||||
|
"-D__jsix__",
|
||||||
|
"-U__linux",
|
||||||
|
"-U__linux__",
|
||||||
|
|
||||||
|
"-DMSPACES",
|
||||||
|
|
||||||
|
"--sysroot='${source_root}/sysroot'"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
cxxflags: [
|
||||||
|
"-fno-exceptions",
|
||||||
|
"-fno-rtti",
|
||||||
|
"-isystem", "${source_root}/sysroot/include/c++/v1",
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-Bstatic",
|
||||||
|
"-m", "elf_x86_64",
|
||||||
|
"--sysroot='${source_root}/sysroot'",
|
||||||
|
"--no-eh-frame-hdr",
|
||||||
|
"-L", "${source_root}/sysroot/lib",
|
||||||
|
"-z", "separate-code",
|
||||||
|
"-lc++", "-lc++abi", "-lunwind",
|
||||||
|
"--no-dependent-libraries",
|
||||||
|
]
|
||||||
|
|
||||||
|
libs: [
|
||||||
|
"${target_dir}/crt0.o",
|
||||||
|
]
|
||||||
52
assets/build/amd64/target.kernel.yaml
Normal file
52
assets/build/amd64/target.kernel.yaml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
---
|
||||||
|
asflags: [ "-I${source_root}/src/kernel/" ]
|
||||||
|
|
||||||
|
ccflags: [
|
||||||
|
"--target=x86_64-jsix-elf",
|
||||||
|
"-fno-stack-protector",
|
||||||
|
|
||||||
|
"-I${source_root}/external",
|
||||||
|
|
||||||
|
"-nostdinc",
|
||||||
|
"-nostdlib",
|
||||||
|
"-ffreestanding",
|
||||||
|
"-nodefaultlibs",
|
||||||
|
"-fno-builtin",
|
||||||
|
"-fno-plt",
|
||||||
|
|
||||||
|
"-mno-sse",
|
||||||
|
"-fno-omit-frame-pointer",
|
||||||
|
"-mno-red-zone",
|
||||||
|
"-mcmodel=kernel",
|
||||||
|
"-fvisibility=hidden",
|
||||||
|
"-fvisibility-inlines-hidden",
|
||||||
|
|
||||||
|
"-D__ELF__",
|
||||||
|
"-D__jsix__",
|
||||||
|
"-D__j6kernel",
|
||||||
|
"-U__linux",
|
||||||
|
"-U__linux__",
|
||||||
|
"-DPRINTF_ALIAS_STANDARD_FUNCTION_NAMES=1",
|
||||||
|
"-DPRINTF_INCLUDE_CONFIG_H=1",
|
||||||
|
|
||||||
|
"--sysroot='${source_root}/sysroot'"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
cflags: [ '-nostdinc' ]
|
||||||
|
|
||||||
|
cxxflags: [
|
||||||
|
"-fno-exceptions",
|
||||||
|
"-fno-rtti",
|
||||||
|
"-nostdinc",
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-m", "elf_x86_64",
|
||||||
|
"-nostdlib",
|
||||||
|
"-Bstatic",
|
||||||
|
"--no-eh-frame-hdr",
|
||||||
|
"-z", "norelro",
|
||||||
|
"-z", "separate-code"
|
||||||
|
]
|
||||||
|
|
||||||
15
assets/build/amd64/target.user.exe.yaml
Normal file
15
assets/build/amd64/target.user.exe.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
ccflags: [
|
||||||
|
"-fpie"
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-pie",
|
||||||
|
"--dynamic-linker", "/jsix/lib/ld.so",
|
||||||
|
"--push-state", "--as-needed", "-Bstatic", "-lc++", "-lc++abi", "-lunwind", "--pop-state",
|
||||||
|
]
|
||||||
|
|
||||||
|
libs: [
|
||||||
|
"${target_dir}/crt0.o",
|
||||||
|
]
|
||||||
7
assets/build/amd64/target.user.shared.yaml
Normal file
7
assets/build/amd64/target.user.shared.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
ccflags: [
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-shared",
|
||||||
|
]
|
||||||
34
assets/build/amd64/target.user.yaml
Normal file
34
assets/build/amd64/target.user.yaml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
asflags: []
|
||||||
|
|
||||||
|
ccflags: [
|
||||||
|
"--target=x86_64-jsix-elf",
|
||||||
|
"-fno-omit-frame-pointer",
|
||||||
|
"-fno-stack-protector",
|
||||||
|
|
||||||
|
"-fvisibility=hidden",
|
||||||
|
"-fvisibility-inlines-hidden",
|
||||||
|
|
||||||
|
"-D__ELF__",
|
||||||
|
"-D__jsix__",
|
||||||
|
"-U__linux",
|
||||||
|
"-U__linux__",
|
||||||
|
|
||||||
|
"--sysroot='${source_root}/sysroot'",
|
||||||
|
"-fpic",
|
||||||
|
]
|
||||||
|
|
||||||
|
cxxflags: [
|
||||||
|
"-fno-exceptions",
|
||||||
|
"-fno-rtti",
|
||||||
|
"-isystem", "${source_root}/sysroot/include/c++/v1",
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-m", "elf_x86_64",
|
||||||
|
"--sysroot='${source_root}/sysroot'",
|
||||||
|
"--no-eh-frame-hdr",
|
||||||
|
"-L", "${source_root}/sysroot/lib",
|
||||||
|
"-z", "separate-code",
|
||||||
|
"--no-dependent-libraries",
|
||||||
|
]
|
||||||
9
assets/build/linux/config.debug.yaml
Normal file
9
assets/build/linux/config.debug.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
ccflags: [
|
||||||
|
"-g3",
|
||||||
|
"-ggdb",
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-g",
|
||||||
|
]
|
||||||
3
assets/build/linux/config.release.yaml
Normal file
3
assets/build/linux/config.release.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ccflags: [
|
||||||
|
"-O3",
|
||||||
|
]
|
||||||
39
assets/build/linux/global.yaml
Normal file
39
assets/build/linux/global.yaml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
cc: "clang-16"
|
||||||
|
cxx: "clang++-16"
|
||||||
|
ld: "ld.lld-16"
|
||||||
|
ar: ar
|
||||||
|
nasm: nasm
|
||||||
|
objcopy: objcopy
|
||||||
|
|
||||||
|
ccflags: [
|
||||||
|
"-I${source_root}/src/include",
|
||||||
|
"-I${source_root}/sysroot/include/c++/v1",
|
||||||
|
"-fcolor-diagnostics",
|
||||||
|
"-U__STDCPP_THREADS__",
|
||||||
|
"-D__jsix_config=${build_config}",
|
||||||
|
"-D__jsix_config_${build_config}",
|
||||||
|
"-DVERSION_MAJOR=${version_major}",
|
||||||
|
"-DVERSION_MINOR=${version_minor}",
|
||||||
|
"-DVERSION_PATCH=${version_patch}",
|
||||||
|
"-DVERSION_GITSHA=0x${version_sha}",
|
||||||
|
'-DGIT_VERSION=\"${version_major}.${version_minor}.${version_patch}+${version_sha}\"',
|
||||||
|
'-DGIT_VERSION_WIDE=L\"${version_major}.${version_minor}.${version_patch}+${version_sha}\"',
|
||||||
|
|
||||||
|
"-Wformat=2", "-Winit-self", "-Winline", "-Wmissing-format-attribute",
|
||||||
|
"-Wmissing-include-dirs", "-Wswitch", "-Wundef", "-Wdisabled-optimization",
|
||||||
|
"-Wpointer-arith", "-Wno-attributes", "-Wno-sign-compare", "-Wno-multichar",
|
||||||
|
"-Wno-div-by-zero", "-Wno-endif-labels", "-Wno-pragmas", "-Wno-format-extra-args",
|
||||||
|
"-Wno-unused-result", "-Wno-deprecated-declarations", "-Wno-unused-function",
|
||||||
|
"-Wno-address-of-packed-member", "-Wno-invalid-offsetof", "-Wno-format-nonliteral",
|
||||||
|
"-Werror" ]
|
||||||
|
|
||||||
|
asflags: [
|
||||||
|
"-DVERSION_MAJOR=${version_major}",
|
||||||
|
"-DVERSION_MINOR=${version_minor}",
|
||||||
|
"-DVERSION_PATCH=${version_patch}",
|
||||||
|
"-DVERSION_GITSHA=0x${version_sha}",
|
||||||
|
"-I${source_root}/src/include" ]
|
||||||
|
|
||||||
|
cflags: [ "-std=c11" ]
|
||||||
|
cxxflags: [ "-std=c++17" ]
|
||||||
91
assets/build/linux/rules.ninja
Normal file
91
assets/build/linux/rules.ninja
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
rule compile.c
|
||||||
|
command = $cc -MMD -MF $out.d $cflags $ccflags -o $out -c $in
|
||||||
|
description = Compiling [$target]:$name
|
||||||
|
depfile = $out.d
|
||||||
|
deps = gcc
|
||||||
|
|
||||||
|
rule dump_c_defs
|
||||||
|
command = echo | $cc $ccflags $cflags -dM -E - > $out
|
||||||
|
description = Dumping C defines for $target
|
||||||
|
|
||||||
|
rule dump_c_run
|
||||||
|
command = echo '#!/bin/bash' > $out; echo '$cc $ccflags $cflags $$*' >> $
|
||||||
|
$out; chmod a+x $out
|
||||||
|
description = Dumping C arguments for $target
|
||||||
|
|
||||||
|
rule compile.cpp
|
||||||
|
command = $cxx -MMD -MF $out.d $cxxflags $ccflags -o $out -c $in
|
||||||
|
description = Compiling [$target]:$name
|
||||||
|
depfile = $out.d
|
||||||
|
deps = gcc
|
||||||
|
|
||||||
|
rule dump_cpp_defs
|
||||||
|
command = echo | $cxx -x c++ $ccflags $cxxflags -dM -E - > $out
|
||||||
|
description = Dumping C++ defines for $target
|
||||||
|
|
||||||
|
rule dump_cpp_run
|
||||||
|
command = echo '#!/bin/bash' > $out; echo '$cxx $ccflags $cxxflags $$*' $
|
||||||
|
>> $out; chmod a+x $out
|
||||||
|
description = Dumping C++ arguments for $target
|
||||||
|
|
||||||
|
rule compile.s
|
||||||
|
command = $nasm -o $out -felf64 -MD $out.d $asflags $in
|
||||||
|
description = Assembling [$target]:$name
|
||||||
|
depfile = $out.d
|
||||||
|
deps = gcc
|
||||||
|
|
||||||
|
rule parse.cog
|
||||||
|
command = cog -o $out -d -D target=$target $cogflags $in
|
||||||
|
description = Parsing [$target]:$name
|
||||||
|
|
||||||
|
rule exe
|
||||||
|
command = $ld $ldflags -o $out $in $libs
|
||||||
|
description = Linking exe [$target]:$name
|
||||||
|
|
||||||
|
rule driver
|
||||||
|
command = $ld $ldflags -o $out $in $libs
|
||||||
|
description = Linking driver [$target]:$name
|
||||||
|
|
||||||
|
rule lib
|
||||||
|
command = $ld -shared -soname $soname $ldflags -o $out $in $libs
|
||||||
|
description = Linking [$target]:$name
|
||||||
|
|
||||||
|
rule lib_static
|
||||||
|
command = $ar qcs $out $in
|
||||||
|
description = Archiving [$target]:$name
|
||||||
|
|
||||||
|
rule cp
|
||||||
|
command = cp $in $out
|
||||||
|
description = Copying [$target]:$name
|
||||||
|
|
||||||
|
rule dump
|
||||||
|
command = objdump -DSC -M intel $in > $out
|
||||||
|
description = Dumping decompiled $name
|
||||||
|
|
||||||
|
rule makest
|
||||||
|
description = Making symbol table
|
||||||
|
command = nm -n -S --demangle $in | ${source_root}/scripts/build_symbol_table.py $out
|
||||||
|
|
||||||
|
rule makeinitrd
|
||||||
|
description = Creating $name
|
||||||
|
command = ${source_root}/scripts/mkj6romfs.py -c $format $in $out
|
||||||
|
|
||||||
|
rule makefat
|
||||||
|
description = Creating $name
|
||||||
|
command = $
|
||||||
|
cp $in $out; $
|
||||||
|
mcopy -s -D o -i $out@@1M ${build_root}/fatroot/* ::/
|
||||||
|
|
||||||
|
rule strip
|
||||||
|
description = Stripping $name
|
||||||
|
command = $
|
||||||
|
cp $in $out; $
|
||||||
|
objcopy --only-keep-debug $out $debug; $
|
||||||
|
strip --discard-all -g $out; $
|
||||||
|
objcopy --add-gnu-debuglink=$debug $out
|
||||||
|
|
||||||
|
rule touch
|
||||||
|
command = touch $out
|
||||||
|
|
||||||
|
rule compdb
|
||||||
|
command = ninja -t compdb > $out
|
||||||
39
assets/build/linux/target.init.yaml
Normal file
39
assets/build/linux/target.init.yaml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
ccflags: [
|
||||||
|
"--target=x86_64-jsix-elf",
|
||||||
|
"-fno-omit-frame-pointer",
|
||||||
|
"-fno-stack-protector",
|
||||||
|
|
||||||
|
"-fvisibility=hidden",
|
||||||
|
"-fvisibility-inlines-hidden",
|
||||||
|
|
||||||
|
"-D__ELF__",
|
||||||
|
"-D__jsix__",
|
||||||
|
"-U__linux",
|
||||||
|
"-U__linux__",
|
||||||
|
|
||||||
|
"-DMSPACES",
|
||||||
|
|
||||||
|
"--sysroot='${source_root}/sysroot'"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
cxxflags: [
|
||||||
|
"-fno-exceptions",
|
||||||
|
"-fno-rtti",
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-Bstatic",
|
||||||
|
"-m", "elf_x86_64",
|
||||||
|
"--sysroot='${source_root}/sysroot'",
|
||||||
|
"--no-eh-frame-hdr",
|
||||||
|
"-L", "${source_root}/sysroot/lib",
|
||||||
|
"-z", "separate-code",
|
||||||
|
"-lc++", "-lc++abi", "-lunwind",
|
||||||
|
"--no-dependent-libraries",
|
||||||
|
]
|
||||||
|
|
||||||
|
libs: [
|
||||||
|
"${target_dir}/crt0.o",
|
||||||
|
]
|
||||||
16
assets/build/linux/target.user.exe.yaml
Normal file
16
assets/build/linux/target.user.exe.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
ccflags: [
|
||||||
|
"-fpie"
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-pie",
|
||||||
|
"-rpath", "${target_dir}",
|
||||||
|
"--dynamic-linker", "/lib64/ld-linux-x86-64.so.2",
|
||||||
|
"--push-state", "--as-needed", "-Bstatic", "-lc++", "-lc++abi", "-lunwind", "--pop-state",
|
||||||
|
]
|
||||||
|
|
||||||
|
libs: [
|
||||||
|
"${target_dir}/crt0.o",
|
||||||
|
]
|
||||||
7
assets/build/linux/target.user.shared.yaml
Normal file
7
assets/build/linux/target.user.shared.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
ccflags: [
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-shared",
|
||||||
|
]
|
||||||
33
assets/build/linux/target.user.yaml
Normal file
33
assets/build/linux/target.user.yaml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
asflags: []
|
||||||
|
|
||||||
|
ccflags: [
|
||||||
|
"--target=x86_64-jsix-elf",
|
||||||
|
"-fno-omit-frame-pointer",
|
||||||
|
"-fno-stack-protector",
|
||||||
|
|
||||||
|
"-fvisibility=hidden",
|
||||||
|
"-fvisibility-inlines-hidden",
|
||||||
|
|
||||||
|
"-D__ELF__",
|
||||||
|
"-D__jsix__",
|
||||||
|
"-U__linux",
|
||||||
|
"-U__linux__",
|
||||||
|
|
||||||
|
"--sysroot='${source_root}/sysroot'",
|
||||||
|
"-fpic",
|
||||||
|
]
|
||||||
|
|
||||||
|
cxxflags: [
|
||||||
|
"-fno-exceptions",
|
||||||
|
"-fno-rtti",
|
||||||
|
]
|
||||||
|
|
||||||
|
ldflags: [
|
||||||
|
"-m", "elf_x86_64",
|
||||||
|
"--sysroot='${source_root}/sysroot'",
|
||||||
|
"--no-eh-frame-hdr",
|
||||||
|
"-L", "${source_root}/sysroot/lib",
|
||||||
|
"-z", "separate-code",
|
||||||
|
"--no-dependent-libraries",
|
||||||
|
]
|
||||||
541
assets/debugging/jsix.elf-gdb.py
Normal file
541
assets/debugging/jsix.elf-gdb.py
Normal file
@@ -0,0 +1,541 @@
|
|||||||
|
import gdb
|
||||||
|
import gdb.printing
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append('./scripts')
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
Capability = namedtuple("Capability", ["id", "parent", "refcount", "caps", "type", "koid"])
|
||||||
|
LogEntry = namedtuple("LogHeader", ["id", "bytes", "severity", "area", "message"])
|
||||||
|
|
||||||
|
class PrintStackCommand(gdb.Command):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("j6stack", gdb.COMMAND_DATA)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
args = gdb.string_to_argv(arg)
|
||||||
|
|
||||||
|
base = "$rsp"
|
||||||
|
if len(args) > 0:
|
||||||
|
base = args[0]
|
||||||
|
base = int(gdb.parse_and_eval(base))
|
||||||
|
|
||||||
|
depth = 22
|
||||||
|
if len(args) > 1:
|
||||||
|
depth = int(args[1])
|
||||||
|
|
||||||
|
for i in range(depth-1, -1, -1):
|
||||||
|
try:
|
||||||
|
offset = i * 8
|
||||||
|
value = gdb.parse_and_eval(f"*(uint64_t*)({base:#x} + {offset:#x})")
|
||||||
|
print("{:016x} (+{:04x}): {:016x}".format(base + offset, offset, int(value)))
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
def stack_walk(frame, depth):
|
||||||
|
for i in range(depth-1, -1, -1):
|
||||||
|
ret = gdb.parse_and_eval(f"*(uint64_t*)({frame:#x} + 0x8)")
|
||||||
|
|
||||||
|
name = ""
|
||||||
|
try:
|
||||||
|
block = gdb.block_for_pc(int(ret))
|
||||||
|
if block:
|
||||||
|
name = block.function or ""
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
print("{:016x}: {:016x} {}".format(int(frame), int(ret), name))
|
||||||
|
frame = int(gdb.parse_and_eval(f"*(uint64_t*)({frame:#x})"))
|
||||||
|
except gdb.MemoryError:
|
||||||
|
return
|
||||||
|
|
||||||
|
if frame == 0 or ret == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class PrintBacktraceCommand(gdb.Command):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("j6bt", gdb.COMMAND_DATA)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
args = gdb.string_to_argv(arg)
|
||||||
|
|
||||||
|
frame = "$rbp"
|
||||||
|
if len(args) > 0:
|
||||||
|
frame = args[0]
|
||||||
|
|
||||||
|
frame = int(gdb.parse_and_eval(f"{frame}"))
|
||||||
|
|
||||||
|
depth = 30
|
||||||
|
if len(args) > 1:
|
||||||
|
depth = int(gdb.parse_and_eval(args[1]))
|
||||||
|
|
||||||
|
stack_walk(frame, depth)
|
||||||
|
|
||||||
|
|
||||||
|
class TableWalkCommand(gdb.Command):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("j6tw", gdb.COMMAND_DATA)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
args = gdb.string_to_argv(arg)
|
||||||
|
if len(args) < 2:
|
||||||
|
raise Exception("Must be: j6tw <pml4> <addr>")
|
||||||
|
|
||||||
|
pml4 = int(gdb.parse_and_eval(args[0]))
|
||||||
|
addr = int(gdb.parse_and_eval(args[1]))
|
||||||
|
|
||||||
|
indices = [
|
||||||
|
(addr >> 39) & 0x1ff,
|
||||||
|
(addr >> 30) & 0x1ff,
|
||||||
|
(addr >> 21) & 0x1ff,
|
||||||
|
(addr >> 12) & 0x1ff,
|
||||||
|
]
|
||||||
|
|
||||||
|
names = ["PML4", "PDP", "PD", "PT"]
|
||||||
|
|
||||||
|
table_flags = [
|
||||||
|
(0x0001, "present"),
|
||||||
|
(0x0002, "write"),
|
||||||
|
(0x0004, "user"),
|
||||||
|
(0x0008, "pwt"),
|
||||||
|
(0x0010, "pcd"),
|
||||||
|
(0x0020, "accessed"),
|
||||||
|
(0x0040, "dirty"),
|
||||||
|
(0x0080, "largepage"),
|
||||||
|
(0x0100, "global"),
|
||||||
|
(0x1080, "pat"),
|
||||||
|
((1<<63), "xd"),
|
||||||
|
]
|
||||||
|
|
||||||
|
page_flags = [
|
||||||
|
(0x0001, "present"),
|
||||||
|
(0x0002, "write"),
|
||||||
|
(0x0004, "user"),
|
||||||
|
(0x0008, "pwt"),
|
||||||
|
(0x0010, "pcd"),
|
||||||
|
(0x0020, "accessed"),
|
||||||
|
(0x0040, "dirty"),
|
||||||
|
(0x0080, "pat"),
|
||||||
|
(0x0100, "global"),
|
||||||
|
((1<<63), "xd"),
|
||||||
|
]
|
||||||
|
|
||||||
|
flagsets = [table_flags, table_flags, table_flags, page_flags]
|
||||||
|
|
||||||
|
table = pml4
|
||||||
|
entry = 0
|
||||||
|
for i in range(len(indices)):
|
||||||
|
entry = int(gdb.parse_and_eval(f'((uint64_t*)0x{table:x})[0x{indices[i]:x}]'))
|
||||||
|
flagset = flagsets[i]
|
||||||
|
flag_names = " | ".join([f[1] for f in flagset if (entry & f[0]) == f[0]])
|
||||||
|
|
||||||
|
print(f"{names[i]:>4}: {table:016x}")
|
||||||
|
print(f" index: {indices[i]:3} {entry:016x}")
|
||||||
|
print(f" flags: {flag_names}")
|
||||||
|
|
||||||
|
if (entry & 1) == 0 or (i < 3 and (entry & 0x80)):
|
||||||
|
break
|
||||||
|
|
||||||
|
table = (entry & 0x7ffffffffffffe00) | 0xffffc00000000000
|
||||||
|
|
||||||
|
|
||||||
|
class GetThreadsCommand(gdb.Command):
|
||||||
|
FLAGS = {
|
||||||
|
"ready": 0x01,
|
||||||
|
"loading": 0x02,
|
||||||
|
"exited": 0x04,
|
||||||
|
"constant": 0x80,
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("j6threads", gdb.COMMAND_DATA)
|
||||||
|
|
||||||
|
def get_flags(self, bitset):
|
||||||
|
flags = []
|
||||||
|
for k, v in GetThreadsCommand.FLAGS.items():
|
||||||
|
if bitset & v:
|
||||||
|
flags.append(k)
|
||||||
|
return " ".join(flags)
|
||||||
|
|
||||||
|
def print_thread(self, addr):
|
||||||
|
if addr == 0:
|
||||||
|
print(" <no thread>\n")
|
||||||
|
return
|
||||||
|
|
||||||
|
tcb = f"((TCB*){addr:#x})"
|
||||||
|
thread = f"({tcb}->thread)"
|
||||||
|
stack = int(gdb.parse_and_eval(f"{tcb}->kernel_stack"))
|
||||||
|
rsp = int(gdb.parse_and_eval(f"{tcb}->rsp"))
|
||||||
|
pri = int(gdb.parse_and_eval(f"{tcb}->priority"))
|
||||||
|
flags = int(gdb.parse_and_eval(f"{thread}->m_state"))
|
||||||
|
koid = int(gdb.parse_and_eval(f"{thread}->m_obj_id"))
|
||||||
|
proc = int(gdb.parse_and_eval(f"{thread}->m_parent.m_obj_id"))
|
||||||
|
|
||||||
|
creator = int(gdb.parse_and_eval(f"{thread}->m_creator"))
|
||||||
|
if creator != 0:
|
||||||
|
creator_koid = int(gdb.parse_and_eval(f"{thread}->m_creator->m_obj_id"))
|
||||||
|
creator = f"{creator_koid:x}"
|
||||||
|
else:
|
||||||
|
creator = "<no thread>"
|
||||||
|
|
||||||
|
print(f" Thread {proc:x}:{koid:x}")
|
||||||
|
print(f" creator: {creator}")
|
||||||
|
print(f" priority: {pri}")
|
||||||
|
print(f" flags: {self.get_flags(flags)}")
|
||||||
|
print(f" kstack: {stack:#x}")
|
||||||
|
print(f" rsp: {rsp:#x}")
|
||||||
|
|
||||||
|
if stack == 0: return 0
|
||||||
|
return int(gdb.parse_and_eval(f"{tcb}->rsp"))
|
||||||
|
|
||||||
|
|
||||||
|
def print_thread_list(self, addr, name):
|
||||||
|
if addr == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
print(f"=== {name} ===")
|
||||||
|
|
||||||
|
while addr != 0:
|
||||||
|
rsp = self.print_thread(addr)
|
||||||
|
if rsp != 0:
|
||||||
|
print("------------------------------------")
|
||||||
|
stack_walk(rsp + 5*8, 5)
|
||||||
|
|
||||||
|
addr = int(gdb.parse_and_eval(f"((tcb_node*){addr:#x})->m_next"))
|
||||||
|
print()
|
||||||
|
|
||||||
|
def print_cpudata(self, index):
|
||||||
|
cpu = f"(g_cpu_data[{index}])"
|
||||||
|
tss = f"{cpu}->tss"
|
||||||
|
tss_rsp0 = int(gdb.parse_and_eval(f"{tss}->m_rsp[0]"))
|
||||||
|
tss_ist = [int(gdb.parse_and_eval(f"{tss}->m_ist[{i}]")) for i in range(8)]
|
||||||
|
print(f" tss rsp0: {tss_rsp0:#x}")
|
||||||
|
for i in range(1,8):
|
||||||
|
if tss_ist[i] == 0: continue
|
||||||
|
print(f" tss ist{i}: {tss_ist[i]:#x}")
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
args = gdb.string_to_argv(arg)
|
||||||
|
if len(args) > 1:
|
||||||
|
raise RuntimeError("Usage: j6threads [cpu]")
|
||||||
|
|
||||||
|
ncpus = int(gdb.parse_and_eval("g_num_cpus"))
|
||||||
|
cpus = list(range(ncpus))
|
||||||
|
if len(args) == 1:
|
||||||
|
cpus = [int(args[0])]
|
||||||
|
|
||||||
|
for cpu in cpus:
|
||||||
|
runlist = f"scheduler::s_instance->m_run_queues.m_elements[{cpu:#x}]"
|
||||||
|
|
||||||
|
print(f"=== CPU {cpu:2}: CURRENT ===")
|
||||||
|
current = int(gdb.parse_and_eval(f"{runlist}.current"))
|
||||||
|
self.print_thread(current)
|
||||||
|
self.print_cpudata(cpu)
|
||||||
|
|
||||||
|
previous = int(gdb.parse_and_eval(f"{runlist}.prev"))
|
||||||
|
print(f" prev: {previous:x}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
for pri in range(8):
|
||||||
|
ready = int(gdb.parse_and_eval(f"{runlist}.ready[{pri:#x}].m_head"))
|
||||||
|
self.print_thread_list(ready, f"CPU {cpu:2}: PRIORITY {pri}")
|
||||||
|
|
||||||
|
blocked = int(gdb.parse_and_eval(f"{runlist}.blocked.m_head"))
|
||||||
|
self.print_thread_list(blocked, f"CPU {cpu:2}: BLOCKED")
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
class PrintProfilesCommand(gdb.Command):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("j6prof", gdb.COMMAND_DATA)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
args = gdb.string_to_argv(arg)
|
||||||
|
if len(args) != 1:
|
||||||
|
raise RuntimeError("Usage: j6prof <profiler class>")
|
||||||
|
|
||||||
|
profclass = args[0]
|
||||||
|
root_type = f"profile_class<{profclass}>"
|
||||||
|
|
||||||
|
try:
|
||||||
|
baseclass = gdb.lookup_type(root_type)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return
|
||||||
|
|
||||||
|
results = {}
|
||||||
|
max_len = 0
|
||||||
|
count = gdb.parse_and_eval(f"{profclass}::count")
|
||||||
|
for i in range(count):
|
||||||
|
name = gdb.parse_and_eval(f"{root_type}::function_names[{i:#x}]")
|
||||||
|
if name == 0: continue
|
||||||
|
|
||||||
|
call_counts = gdb.parse_and_eval(f"{root_type}::call_counts[{i:#x}]")
|
||||||
|
call_durations = gdb.parse_and_eval(f"{root_type}::call_durations[{i:#x}]")
|
||||||
|
results[name.string()] = float(call_durations) / float(call_counts)
|
||||||
|
max_len = max(max_len, len(name.string()))
|
||||||
|
|
||||||
|
for name, avg in results.items():
|
||||||
|
print(f"{name:>{max_len}}: {avg:15.3f}")
|
||||||
|
|
||||||
|
|
||||||
|
class DumpLogCommand(gdb.Command):
|
||||||
|
level_names = ["", "fatal", "error", "warn", "info", "verbose", "spam"]
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("j6log", gdb.COMMAND_DATA)
|
||||||
|
|
||||||
|
from memory import Layout
|
||||||
|
layout = Layout("definitions/memory_layout.yaml")
|
||||||
|
for region in layout.regions:
|
||||||
|
if region.name == "logs":
|
||||||
|
self.base_addr = region.start
|
||||||
|
break
|
||||||
|
|
||||||
|
self.areas = []
|
||||||
|
area_re = re.compile(r"LOG\(\s*(\w+).*")
|
||||||
|
with open("src/libraries/j6/include/j6/tables/log_areas.inc", 'r') as areas_inc:
|
||||||
|
for line in areas_inc:
|
||||||
|
m = area_re.match(line)
|
||||||
|
if m:
|
||||||
|
self.areas.append(m.group(1))
|
||||||
|
|
||||||
|
def get_entry(self, addr):
|
||||||
|
addr = int(addr)
|
||||||
|
size = int(gdb.parse_and_eval(f"((j6_log_entry*){addr:#x})->bytes"))
|
||||||
|
mlen = size - 8
|
||||||
|
|
||||||
|
return LogEntry(
|
||||||
|
int(gdb.parse_and_eval(f"((j6_log_entry*){addr:#x})->id")),
|
||||||
|
size,
|
||||||
|
int(gdb.parse_and_eval(f"((j6_log_entry*){addr:#x})->severity")),
|
||||||
|
int(gdb.parse_and_eval(f"((j6_log_entry*){addr:#x})->area")),
|
||||||
|
gdb.parse_and_eval(f"((j6_log_entry*){addr:#x})->message").string(length=mlen))
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
start = gdb.parse_and_eval("g_logger.m_start & (g_logger.m_buffer.count - 1)")
|
||||||
|
end = gdb.parse_and_eval("g_logger.m_end & (g_logger.m_buffer.count - 1)")
|
||||||
|
if end < start:
|
||||||
|
end += gdb.parse_and_eval("g_logger.m_buffer.count")
|
||||||
|
|
||||||
|
print(f"Logs are {start} -> {end}")
|
||||||
|
|
||||||
|
addr = self.base_addr + start
|
||||||
|
end += self.base_addr
|
||||||
|
while addr < end:
|
||||||
|
entry = self.get_entry(addr)
|
||||||
|
if entry.bytes < 8:
|
||||||
|
print(f"Bad log header size: {entry.bytes}")
|
||||||
|
break
|
||||||
|
addr += entry.bytes
|
||||||
|
area = "??"
|
||||||
|
if entry.area < len(self.areas):
|
||||||
|
area = self.areas[entry.area]
|
||||||
|
level = self.level_names[entry.severity]
|
||||||
|
print(f"{area:>7}:{level:7} {entry.message}")
|
||||||
|
|
||||||
|
|
||||||
|
class ShowCurrentProcessCommand(gdb.Command):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("j6current", gdb.COMMAND_DATA)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
def get_obj_and_id(name):
|
||||||
|
obj = int(gdb.parse_and_eval(f"((cpu_data*)$gs_base)->{name}"))
|
||||||
|
oid = -1
|
||||||
|
if obj != 0:
|
||||||
|
oid = int(gdb.parse_and_eval(f"((obj::kobject*){obj:#x})->m_obj_id"))
|
||||||
|
return obj, oid
|
||||||
|
|
||||||
|
process, pid = get_obj_and_id("process")
|
||||||
|
thread, tid = get_obj_and_id("thread")
|
||||||
|
print(f"{pid:02x}/{tid:02x} [ {process:x} / {thread:x} ]")
|
||||||
|
|
||||||
|
|
||||||
|
class CapTablePrinter:
|
||||||
|
def __init__(self, val):
|
||||||
|
node_map = val["m_caps"]
|
||||||
|
self.nodes = node_map["m_nodes"]
|
||||||
|
self.count = int(node_map["m_count"])
|
||||||
|
self.capacity = int(node_map["m_capacity"])
|
||||||
|
|
||||||
|
class _iterator:
|
||||||
|
def __init__(self, nodes, capacity):
|
||||||
|
self.nodes = []
|
||||||
|
|
||||||
|
for i in range(capacity):
|
||||||
|
node = nodes[i]
|
||||||
|
|
||||||
|
node_id = int(node["id"])
|
||||||
|
if node_id == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.nodes.append(Capability(
|
||||||
|
id = node_id,
|
||||||
|
parent = int(node["parent"]),
|
||||||
|
refcount = int(node["holders"]),
|
||||||
|
caps = int(node["caps"]),
|
||||||
|
type = str(node["type"])[14:],
|
||||||
|
koid = node['object']['m_obj_id']))
|
||||||
|
|
||||||
|
self.nodes.sort(key=lambda n: n.id, reverse=True)
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __next__(self):
|
||||||
|
if not self.nodes:
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
node = self.nodes.pop()
|
||||||
|
|
||||||
|
desc = f'p:{node.parent:016x} refs:{node.refcount:2} caps:{node.caps:04x} {node.type:14} {node.koid}'
|
||||||
|
return (f"{node.id:016x}", desc)
|
||||||
|
|
||||||
|
def to_string(self):
|
||||||
|
return f"Cap table with {self.count}/{self.capacity} nodes.\n"
|
||||||
|
|
||||||
|
def children(self):
|
||||||
|
return self._iterator(self.nodes, self.capacity)
|
||||||
|
|
||||||
|
|
||||||
|
class VectorPrinter:
|
||||||
|
def __init__(self, vector):
|
||||||
|
self.name = vector.type.tag
|
||||||
|
self.count = vector["m_size"]
|
||||||
|
self.array = vector["m_elements"]
|
||||||
|
|
||||||
|
class _iterator:
|
||||||
|
def __init__(self, array, count, deref):
|
||||||
|
self.array = array
|
||||||
|
self.count = count
|
||||||
|
self.deref = deref
|
||||||
|
self.index = 0
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __next__(self):
|
||||||
|
if self.index >= self.count:
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
item = self.array[self.index]
|
||||||
|
if self.deref:
|
||||||
|
item = item.dereference()
|
||||||
|
|
||||||
|
result = (f"{self.index:3}", item)
|
||||||
|
self.index += 1
|
||||||
|
return result
|
||||||
|
|
||||||
|
def to_string(self):
|
||||||
|
return f"{self.name} [{self.count}]"
|
||||||
|
|
||||||
|
def children(self):
|
||||||
|
deref = self.count > 0 and self.array[0].type.code == gdb.TYPE_CODE_PTR
|
||||||
|
return self._iterator(self.array, int(self.count), deref)
|
||||||
|
|
||||||
|
|
||||||
|
class HandleSetPrinter:
|
||||||
|
def __init__(self, nodeset):
|
||||||
|
self.node_map = nodeset['m_map']
|
||||||
|
self.count = self.node_map['m_count']
|
||||||
|
self.capacity = self.node_map['m_capacity']
|
||||||
|
|
||||||
|
class _iterator:
|
||||||
|
def __init__(self, nodes, capacity):
|
||||||
|
self.items = []
|
||||||
|
self.index = 0
|
||||||
|
for i in range(capacity):
|
||||||
|
item = nodes[i]
|
||||||
|
if int(item) != 0:
|
||||||
|
self.items.append(int(item))
|
||||||
|
self.items.sort()
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __next__(self):
|
||||||
|
if self.index >= len(self.items):
|
||||||
|
raise StopIteration
|
||||||
|
result = (f"{self.index}", f"{self.items[self.index]:016x}")
|
||||||
|
self.index += 1
|
||||||
|
return result
|
||||||
|
|
||||||
|
def to_string(self):
|
||||||
|
return f"node_set[{self.count} / {self.capacity}]:"
|
||||||
|
|
||||||
|
def children(self):
|
||||||
|
return self._iterator(self.node_map['m_nodes'], self.capacity)
|
||||||
|
|
||||||
|
|
||||||
|
class LinkedListPrinter:
|
||||||
|
def __init__(self, llist):
|
||||||
|
self.name = llist.type.tag
|
||||||
|
self.head = llist['m_head']
|
||||||
|
self.tail = llist['m_tail']
|
||||||
|
|
||||||
|
self.items = []
|
||||||
|
current = self.head
|
||||||
|
while current:
|
||||||
|
item = current.dereference()
|
||||||
|
self.items.append((str(len(self.items)), item))
|
||||||
|
current = item['m_next']
|
||||||
|
|
||||||
|
class _iterator:
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __next__(self):
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
def to_string(self):
|
||||||
|
return f"{self.name}[{len(self.items)}]"
|
||||||
|
|
||||||
|
def children(self):
|
||||||
|
return self.items
|
||||||
|
|
||||||
|
|
||||||
|
class IsRunning(gdb.Function):
|
||||||
|
def __init__(self):
|
||||||
|
super(IsRunning, self).__init__("is_running")
|
||||||
|
|
||||||
|
def invoke(self):
|
||||||
|
inferior = gdb.selected_inferior()
|
||||||
|
return \
|
||||||
|
inferior is not None and \
|
||||||
|
inferior.is_valid() and \
|
||||||
|
len(inferior.threads()) > 0
|
||||||
|
|
||||||
|
|
||||||
|
def build_pretty_printers():
|
||||||
|
pp = gdb.printing.RegexpCollectionPrettyPrinter("jsix")
|
||||||
|
pp.add_printer("cap table", '^cap_table$', CapTablePrinter)
|
||||||
|
pp.add_printer("handle set", '^util::node_set<unsigned long, 0, heap_allocated>$', HandleSetPrinter)
|
||||||
|
pp.add_printer("vector", '^util::vector<.*>$', VectorPrinter)
|
||||||
|
pp.add_printer("linked list", '^util::linked_list<.*>$', LinkedListPrinter)
|
||||||
|
return pp
|
||||||
|
|
||||||
|
gdb.printing.register_pretty_printer(
|
||||||
|
gdb.current_objfile(),
|
||||||
|
build_pretty_printers())
|
||||||
|
|
||||||
|
PrintStackCommand()
|
||||||
|
PrintBacktraceCommand()
|
||||||
|
TableWalkCommand()
|
||||||
|
GetThreadsCommand()
|
||||||
|
PrintProfilesCommand()
|
||||||
|
DumpLogCommand()
|
||||||
|
ShowCurrentProcessCommand()
|
||||||
|
IsRunning()
|
||||||
|
|
||||||
|
gdb.execute("display/i $rip")
|
||||||
|
gdb.execute("define hook-quit\nif $is_running()\n kill\nend\nend")
|
||||||
|
if not gdb.selected_inferior().was_attached:
|
||||||
|
gdb.execute("add-symbol-file build/panic.serial.elf")
|
||||||
|
gdb.execute("target remote :1234")
|
||||||
BIN
assets/diskbase.img
Normal file
BIN
assets/diskbase.img
Normal file
Binary file not shown.
BIN
assets/floppy.img
Normal file
BIN
assets/floppy.img
Normal file
Binary file not shown.
49
assets/grammars/definitions.g
Normal file
49
assets/grammars/definitions.g
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
start: import_statement* (object|interface)+
|
||||||
|
|
||||||
|
import_statement: "import" PATH
|
||||||
|
|
||||||
|
object: description? "object" name options? super? "{" uid cname? capabilities? method* "}"
|
||||||
|
|
||||||
|
interface: description? "interface" name options? "{" uid interface_param* "}"
|
||||||
|
|
||||||
|
?interface_param: expose | function
|
||||||
|
|
||||||
|
expose: "expose" type
|
||||||
|
|
||||||
|
uid: "uid" UID
|
||||||
|
|
||||||
|
cname: "cname" IDENTIFIER
|
||||||
|
|
||||||
|
capabilities: "capabilities" "[" IDENTIFIER+ "]"
|
||||||
|
|
||||||
|
super: ":" name
|
||||||
|
|
||||||
|
function: description? "function" name options? ("{" param* "}")?
|
||||||
|
|
||||||
|
method: description? "method" name options? ("{" param* "}")?
|
||||||
|
|
||||||
|
param: "param" name type options? description?
|
||||||
|
|
||||||
|
?type: PRIMITIVE | object_name | struct_name
|
||||||
|
|
||||||
|
object_name: "ref" name
|
||||||
|
|
||||||
|
struct_name: "struct" name
|
||||||
|
|
||||||
|
id: NUMBER
|
||||||
|
name: IDENTIFIER
|
||||||
|
options: "[" ( OPTION | IDENTIFIER )+ "]"
|
||||||
|
description: COMMENT+
|
||||||
|
|
||||||
|
PRIMITIVE: INT_TYPE "*"? | "size" | "string" | "buffer" | "address"
|
||||||
|
INT_TYPE: /u?int(8|16|32|64)?/
|
||||||
|
NUMBER: /(0x)?[0-9a-fA-F]+/
|
||||||
|
UID: /[0-9a-fA-F]{16}/
|
||||||
|
OPTION.2: IDENTIFIER ":" IDENTIFIER
|
||||||
|
COMMENT: /#.*/
|
||||||
|
PATH: /"[^"]*"/
|
||||||
|
|
||||||
|
%import common.LETTER
|
||||||
|
%import common.CNAME -> IDENTIFIER
|
||||||
|
%import common.WS
|
||||||
|
%ignore WS
|
||||||
1
assets/jsix.svg
Executable file
1
assets/jsix.svg
Executable file
@@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!-- Generator: Gravit.io --><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="176.562 356.069 211.11 113" width="211.11pt" height="113pt"><g><g><rect x="176.562" y="356.069" width="211.11" height="113" transform="matrix(1,0,0,1,0,0)" fill="rgb(255,255,255)"/><g><path d=" M 212.981 372.36 L 219.564 376.16 L 226.147 379.961 L 226.147 387.563 L 226.147 395.164 L 219.564 398.965 L 212.981 402.766 L 206.398 398.965 L 199.815 395.164 L 199.815 387.563 L 199.815 379.961 L 206.398 376.16 L 212.981 372.36 L 212.981 372.36 L 212.981 372.36 Z M 256.292 397.366 L 262.875 401.166 L 269.458 404.967 L 269.458 412.569 L 269.458 420.17 L 262.875 423.971 L 256.292 427.772 L 249.709 423.971 L 243.126 420.17 L 243.126 412.569 L 243.126 404.967 L 249.709 401.166 L 256.292 397.366 L 256.292 397.366 Z M 183.622 387.283 L 205.52 374.64 L 227.418 361.997 L 249.316 374.64 L 271.214 387.283 L 271.214 412.569 L 271.214 437.854 L 249.316 450.497 L 227.418 463.14 L 205.52 450.497 L 183.622 437.854 L 183.622 412.569 L 183.622 387.283 L 183.622 387.283 L 183.622 387.283 Z M 241.855 372.36 L 248.438 376.16 L 255.021 379.961 L 255.021 387.563 L 255.021 395.164 L 248.438 398.965 L 241.855 402.766 L 235.272 398.965 L 228.689 395.164 L 228.689 387.563 L 228.689 379.961 L 235.272 376.16 L 241.855 372.36 Z " fill-rule="evenodd" fill="rgb(49,79,128)"/><path d=" M 298.642 379.579 L 291.621 379.579 L 291.621 372.558 L 298.642 372.558 L 298.642 379.579 Z M 285.214 446.718 L 285.214 441.452 L 287.32 441.452 L 287.32 441.452 Q 289.339 441.452 290.524 440.092 L 290.524 440.092 L 290.524 440.092 Q 291.708 438.731 291.708 436.625 L 291.708 436.625 L 291.708 387.039 L 298.729 387.039 L 298.729 436.011 L 298.729 436.011 Q 298.729 440.925 295.921 443.822 L 295.921 443.822 L 295.921 443.822 Q 293.113 446.718 288.286 446.718 L 288.286 446.718 L 285.214 446.718 Z M 306.628 432.676 L 306.628 427.41 L 314.088 427.41 L 314.088 427.41 Q 317.862 427.41 319.573 425.347 L 319.573 425.347 L 319.573 425.347 Q 321.285 423.285 321.285 419.95 L 321.285 419.95 L 321.285 419.95 Q 321.285 417.317 319.705 415.474 L 319.705 415.474 L 319.705 415.474 Q 318.125 413.631 314.966 411.174 L 314.966 411.174 L 314.966 411.174 Q 312.245 408.98 310.621 407.356 L 310.621 407.356 L 310.621 407.356 Q 308.998 405.732 307.813 403.319 L 307.813 403.319 L 307.813 403.319 Q 306.628 400.905 306.628 397.746 L 306.628 397.746 L 306.628 397.746 Q 306.628 393.095 309.744 390.067 L 309.744 390.067 L 309.744 390.067 Q 312.859 387.039 318.125 387.039 L 318.125 387.039 L 325.76 387.039 L 325.76 392.305 L 319.441 392.305 L 319.441 392.305 Q 313.21 392.305 313.21 398.185 L 313.21 398.185 L 313.21 398.185 Q 313.21 400.467 314.615 402.134 L 314.615 402.134 L 314.615 402.134 Q 316.019 403.802 319.003 406.083 L 319.003 406.083 L 319.003 406.083 Q 321.723 408.19 323.479 409.901 L 323.479 409.901 L 323.479 409.901 Q 325.234 411.613 326.463 414.202 L 326.463 414.202 L 326.463 414.202 Q 327.691 416.791 327.691 420.301 L 327.691 420.301 L 327.691 420.301 Q 327.691 426.532 324.4 429.604 L 324.4 429.604 L 324.4 429.604 Q 321.109 432.676 315.141 432.676 L 315.141 432.676 L 306.628 432.676 Z M 342.611 379.579 L 335.59 379.579 L 335.59 372.558 L 342.611 372.558 L 342.611 379.579 Z M 342.611 432.676 L 335.59 432.676 L 335.59 387.039 L 342.611 387.039 L 342.611 432.676 Z M 356.126 432.676 L 348.754 432.676 L 361.392 409.77 L 349.632 387.039 L 356.39 387.039 L 364.639 403.187 L 372.977 387.039 L 379.735 387.039 L 367.974 409.77 L 380.612 432.676 L 373.24 432.676 L 364.639 416.001 L 356.126 432.676 Z " fill="rgb(49,79,128)"/></g></g></g></svg>
|
||||||
|
After Width: | Height: | Size: 3.6 KiB |
16
assets/manifests/default.yaml
Normal file
16
assets/manifests/default.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
location: jsix
|
||||||
|
init: srv.init
|
||||||
|
initrd:
|
||||||
|
name: initrd.dat
|
||||||
|
format: zstd
|
||||||
|
panic:
|
||||||
|
- panic.serial
|
||||||
|
services:
|
||||||
|
- srv.logger
|
||||||
|
- testapp
|
||||||
|
drivers:
|
||||||
|
- drv.uart
|
||||||
|
- drv.uefi_fb
|
||||||
|
libs:
|
||||||
|
- ld.so
|
||||||
14
assets/manifests/minimal.yaml
Normal file
14
assets/manifests/minimal.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
location: jsix
|
||||||
|
init: srv.init
|
||||||
|
initrd:
|
||||||
|
name: initrd.dat
|
||||||
|
format: zstd
|
||||||
|
panic:
|
||||||
|
- panic.serial
|
||||||
|
services:
|
||||||
|
- srv.logger
|
||||||
|
drivers:
|
||||||
|
- drv.uart
|
||||||
|
libs:
|
||||||
|
- ld.so
|
||||||
14
assets/manifests/shell.yaml
Normal file
14
assets/manifests/shell.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
location: jsix
|
||||||
|
init: srv.init
|
||||||
|
initrd:
|
||||||
|
name: initrd.dat
|
||||||
|
format: zstd
|
||||||
|
panic:
|
||||||
|
- panic.serial
|
||||||
|
services:
|
||||||
|
- 6s
|
||||||
|
drivers:
|
||||||
|
- drv.uart
|
||||||
|
libs:
|
||||||
|
- ld.so
|
||||||
11
assets/manifests/test.yaml
Normal file
11
assets/manifests/test.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
location: jsix
|
||||||
|
init: srv.init
|
||||||
|
initrd:
|
||||||
|
name: initrd.dat
|
||||||
|
format: zstd
|
||||||
|
flags: ["test"]
|
||||||
|
panic:
|
||||||
|
- panic.serial
|
||||||
|
services:
|
||||||
|
- test_runner
|
||||||
Binary file not shown.
Binary file not shown.
BIN
assets/ovmf/x64/ovmf_code.fd
Normal file
BIN
assets/ovmf/x64/ovmf_code.fd
Normal file
Binary file not shown.
BIN
assets/ovmf/x64/ovmf_vars.fd
Normal file
BIN
assets/ovmf/x64/ovmf_vars.fd
Normal file
Binary file not shown.
BIN
assets/ovmf/x64/ovmf_vars_d.fd
Normal file
BIN
assets/ovmf/x64/ovmf_vars_d.fd
Normal file
Binary file not shown.
82
configure
vendored
Executable file
82
configure
vendored
Executable file
@@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
def generate(output, config, arch, manifest):
|
||||||
|
from os import makedirs
|
||||||
|
from glob import iglob
|
||||||
|
from pathlib import Path
|
||||||
|
from bonnibel.module import Module, ModuleList
|
||||||
|
from bonnibel.project import Project
|
||||||
|
|
||||||
|
root = Path(__file__).parent.resolve()
|
||||||
|
project = Project(root)
|
||||||
|
|
||||||
|
output = root / output
|
||||||
|
manifest = root / manifest
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
str(root / "src/**/*.module"),
|
||||||
|
str(root / "external/*.module"),
|
||||||
|
]
|
||||||
|
|
||||||
|
modules = ModuleList(arch)
|
||||||
|
for source in sources:
|
||||||
|
for modfile in iglob(source, recursive=True):
|
||||||
|
modfile = Path(modfile)
|
||||||
|
path = modfile.parent
|
||||||
|
|
||||||
|
def module_init(name, **kwargs):
|
||||||
|
if not "root" in kwargs:
|
||||||
|
kwargs["root"] = path
|
||||||
|
m = Module(name, modfile, **kwargs)
|
||||||
|
modules.add(m)
|
||||||
|
return m
|
||||||
|
|
||||||
|
glo = {
|
||||||
|
"module": module_init,
|
||||||
|
"source_root": root,
|
||||||
|
"build_root": output,
|
||||||
|
"module_root": path,
|
||||||
|
"config": config,
|
||||||
|
"arch": arch,
|
||||||
|
}
|
||||||
|
code = compile(open(modfile, 'r').read(), modfile, "exec")
|
||||||
|
|
||||||
|
loc = {}
|
||||||
|
exec(code, glo, loc)
|
||||||
|
|
||||||
|
makedirs(output.resolve(), exist_ok=True)
|
||||||
|
project.generate(root, output, modules, config, arch, manifest)
|
||||||
|
modules.generate(output)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
sys.path.insert(0, str(Path(__file__).parent / "scripts"))
|
||||||
|
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
from bonnibel import BonnibelError
|
||||||
|
|
||||||
|
default_arch = "amd64"
|
||||||
|
|
||||||
|
p = ArgumentParser(description="Generate jsix build files")
|
||||||
|
p.add_argument("--manifest", "-m", metavar="FILE", default="assets/manifests/default.yaml",
|
||||||
|
help="File to use as the system manifest")
|
||||||
|
p.add_argument("--conf", "-c", metavar="NAME", default="debug",
|
||||||
|
help="Configuration to build (eg, 'debug' or 'release')")
|
||||||
|
p.add_argument("--arch", "-a", metavar="NAME", default=default_arch,
|
||||||
|
help="Architecture to build (eg, 'amd64' or 'linux')")
|
||||||
|
p.add_argument("--verbose", "-v", action='count', default=0,
|
||||||
|
help="More verbose log output")
|
||||||
|
p.add_argument("output", metavar="DIR", default=None, nargs='?',
|
||||||
|
help="Where to create the build root")
|
||||||
|
|
||||||
|
args = p.parse_args()
|
||||||
|
|
||||||
|
output = args.output or f"build.{args.arch}"
|
||||||
|
try:
|
||||||
|
generate(output, args.conf, args.arch, args.manifest)
|
||||||
|
|
||||||
|
except BonnibelError as be:
|
||||||
|
import sys
|
||||||
|
print(f"Error: {be}", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
38
definitions/memory_layout.yaml
Normal file
38
definitions/memory_layout.yaml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
- name: linear
|
||||||
|
desc: Linearly-mapped physical memory
|
||||||
|
size: 64T
|
||||||
|
shared: true
|
||||||
|
|
||||||
|
- name: bitmap
|
||||||
|
desc: Used/free page tracking bitmap
|
||||||
|
size: 1T
|
||||||
|
shared: true
|
||||||
|
|
||||||
|
- name: heapmap
|
||||||
|
desc: Kernel heap accounting structures
|
||||||
|
size: 32G
|
||||||
|
|
||||||
|
- name: heap
|
||||||
|
desc: Kernel heap
|
||||||
|
size: 32G
|
||||||
|
|
||||||
|
- name: capsmap
|
||||||
|
desc: Capabilities accounting structures
|
||||||
|
size: 32G
|
||||||
|
|
||||||
|
- name: caps
|
||||||
|
desc: Capabilities
|
||||||
|
size: 32G
|
||||||
|
|
||||||
|
- name: stacks
|
||||||
|
desc: Kernel thread stacks
|
||||||
|
size: 64G
|
||||||
|
|
||||||
|
- name: buffers
|
||||||
|
desc: Kernel buffers
|
||||||
|
size: 64G
|
||||||
|
|
||||||
|
- name: logs
|
||||||
|
desc: Kernel logs circular buffer
|
||||||
|
size: 2G
|
||||||
25
definitions/objects/event.def
Normal file
25
definitions/objects/event.def
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# An ``event`` is a simple synchronization object. It contains up to 64 signals
|
||||||
|
# that threads can wait for and signal in parallel.
|
||||||
|
|
||||||
|
object event : object {
|
||||||
|
uid f441e03da5516b1a
|
||||||
|
|
||||||
|
capabilities [
|
||||||
|
signal
|
||||||
|
wait
|
||||||
|
]
|
||||||
|
|
||||||
|
method create [constructor]
|
||||||
|
|
||||||
|
# Signal events on this object
|
||||||
|
method signal [cap:signal] {
|
||||||
|
param signals uint64 # A bitset of which events to signal
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wait for signaled events on this object
|
||||||
|
method wait [cap:wait] {
|
||||||
|
param signals uint64 [out] # A bitset of which events were signaled
|
||||||
|
param timeout uint64 # Wait timeout in nanoseconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
41
definitions/objects/mailbox.def
Normal file
41
definitions/objects/mailbox.def
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Mailboxes are objects that enable synchronous IPC via arbitrary
|
||||||
|
# message-passing of tagged data and/or handles. Not as efficient
|
||||||
|
# as shared memory channels, but more flexible.
|
||||||
|
|
||||||
|
object mailbox : object {
|
||||||
|
uid 99934ad04ece1e07
|
||||||
|
|
||||||
|
capabilities [
|
||||||
|
send
|
||||||
|
receive
|
||||||
|
close
|
||||||
|
]
|
||||||
|
|
||||||
|
method create [constructor]
|
||||||
|
method close [destructor cap:close]
|
||||||
|
|
||||||
|
# Send a message to the reciever, and block until a response is
|
||||||
|
# sent. Note that getting this response does not require the
|
||||||
|
# receive capability.
|
||||||
|
method call [cap:send] {
|
||||||
|
param tag uint64 [inout]
|
||||||
|
param data buffer [optional inout]
|
||||||
|
param data_size size # number of total bytes in data buffer
|
||||||
|
param handles ref object [optional inout handle list]
|
||||||
|
param handles_size size # total size of handles buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
# Respond to a message sent using call, and wait for another
|
||||||
|
# message to arrive. Note that this does not require the send
|
||||||
|
# capability. A reply tag of 0 skips the reply and goes directly
|
||||||
|
# to waiting for a new message.
|
||||||
|
method respond [cap:receive] {
|
||||||
|
param tag uint64 [inout]
|
||||||
|
param data buffer [optional inout]
|
||||||
|
param data_size size # number of total bytes in data buffer
|
||||||
|
param handles ref object [optional inout handle list]
|
||||||
|
param handles_size size # total size of handles buffer
|
||||||
|
param reply_tag uint64 [inout]
|
||||||
|
param flags uint64
|
||||||
|
}
|
||||||
|
}
|
||||||
16
definitions/objects/object.def
Normal file
16
definitions/objects/object.def
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# All kernel-exposed objects inherit from the base ``object`` type, so the
|
||||||
|
# ``object`` syscalls can be used with any object's handle.
|
||||||
|
|
||||||
|
object object [virtual] {
|
||||||
|
uid 667f61fb2cd57bb4
|
||||||
|
cname kobject
|
||||||
|
|
||||||
|
capabilities [
|
||||||
|
clone
|
||||||
|
]
|
||||||
|
|
||||||
|
# Get the internal kernel object id of an object
|
||||||
|
method koid {
|
||||||
|
param koid uint64 [out]
|
||||||
|
}
|
||||||
|
}
|
||||||
32
definitions/objects/process.def
Normal file
32
definitions/objects/process.def
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import "objects/object.def"
|
||||||
|
|
||||||
|
# A ``process`` object represents a process running on the system, and allows
|
||||||
|
# control over the threads, handles, and virtual memory space of that process.
|
||||||
|
|
||||||
|
object process : object {
|
||||||
|
uid 0c69ee0b7502ba31
|
||||||
|
|
||||||
|
capabilities [
|
||||||
|
kill
|
||||||
|
create_thread
|
||||||
|
]
|
||||||
|
|
||||||
|
# Create a new empty process
|
||||||
|
method create [constructor] {
|
||||||
|
param name string
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop all threads and exit the given process
|
||||||
|
method kill [destructor cap:kill]
|
||||||
|
|
||||||
|
# Stop all threads and exit the current process
|
||||||
|
method exit [static noreturn] {
|
||||||
|
param result int64 # The result to retrun to the parent process
|
||||||
|
}
|
||||||
|
|
||||||
|
# Give the given process a handle that points to the same
|
||||||
|
# object as the specified handle.
|
||||||
|
method give_handle {
|
||||||
|
param target ref object [handle] # A handle in the caller process to send
|
||||||
|
}
|
||||||
|
}
|
||||||
42
definitions/objects/system.def
Normal file
42
definitions/objects/system.def
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# The singular ``system`` object represents a handle to kernel functionality
|
||||||
|
# needed by drivers and other priviledged services.
|
||||||
|
|
||||||
|
object system : object {
|
||||||
|
uid fa72506a2cf71a30
|
||||||
|
|
||||||
|
capabilities [
|
||||||
|
get_log
|
||||||
|
bind_irq
|
||||||
|
map_phys
|
||||||
|
change_iopl
|
||||||
|
]
|
||||||
|
|
||||||
|
# Get the next log line from the kernel log
|
||||||
|
method get_log [cap:get_log] {
|
||||||
|
param seen uint64 # Last seen log id
|
||||||
|
param buffer buffer [out zero_ok] # Buffer for the log message data structure
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ask the kernel to send this process messages whenever
|
||||||
|
# the given IRQ fires
|
||||||
|
method bind_irq [cap:bind_irq] {
|
||||||
|
param dest ref event # Event object that will receive messages
|
||||||
|
param irq uint # IRQ number to bind
|
||||||
|
param signal uint # Signal number on the event to bind to
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a VMA and map an area of physical memory into it,
|
||||||
|
# also mapping that VMA into the current process
|
||||||
|
method map_phys [cap:map_phys] {
|
||||||
|
param area ref vma [out] # Receives a handle to the VMA created
|
||||||
|
param phys address # The physical address of the area
|
||||||
|
param size size # Size of the area, in bytes
|
||||||
|
param flags uint32 # Flags to apply to the created VMA
|
||||||
|
}
|
||||||
|
|
||||||
|
# Request the kernel change the IOPL for this process. The only values
|
||||||
|
# that make sense are 0 and 3.
|
||||||
|
method request_iopl [cap:change_iopl] {
|
||||||
|
param iopl uint # The IOPL to set for this process
|
||||||
|
}
|
||||||
|
}
|
||||||
30
definitions/objects/thread.def
Normal file
30
definitions/objects/thread.def
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# A ``thread`` object represents a thread of execution within a process running
|
||||||
|
# on the system. The actual thread does not need to be currently running to
|
||||||
|
# hold a handle to it.
|
||||||
|
|
||||||
|
object thread : object {
|
||||||
|
uid 11f23e593d5761bd
|
||||||
|
|
||||||
|
capabilities [
|
||||||
|
kill
|
||||||
|
join
|
||||||
|
]
|
||||||
|
|
||||||
|
method create [constructor] {
|
||||||
|
param process ref process [optional cap:create_thread]
|
||||||
|
param stack_top address
|
||||||
|
param entrypoint address
|
||||||
|
param arg0 uint64
|
||||||
|
param arg1 uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
method kill [destructor cap:kill]
|
||||||
|
|
||||||
|
method join [cap:join]
|
||||||
|
|
||||||
|
method exit [static]
|
||||||
|
|
||||||
|
method sleep [static] {
|
||||||
|
param duration uint64
|
||||||
|
}
|
||||||
|
}
|
||||||
41
definitions/objects/vma.def
Normal file
41
definitions/objects/vma.def
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import "objects/process.def"
|
||||||
|
|
||||||
|
# A ``vma`` object represents a single virtual memory area, which may be shared
|
||||||
|
# between several processes. A process having a handle to a ``vma`` does not
|
||||||
|
# necessarily mean that it is mapped into that process' virtual memory space.
|
||||||
|
|
||||||
|
object vma : object {
|
||||||
|
uid d6a12b63b3ed3937
|
||||||
|
cname vm_area
|
||||||
|
|
||||||
|
capabilities [
|
||||||
|
map
|
||||||
|
unmap
|
||||||
|
resize
|
||||||
|
]
|
||||||
|
|
||||||
|
method create [constructor] {
|
||||||
|
param size size
|
||||||
|
param flags uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
method create_map [constructor cap:map] {
|
||||||
|
param size size
|
||||||
|
param address address [inout]
|
||||||
|
param flags uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
method map [cap:map] {
|
||||||
|
param process ref process [optional]
|
||||||
|
param address address [inout]
|
||||||
|
param flags uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
method unmap [cap:unmap] {
|
||||||
|
param process ref process [optional]
|
||||||
|
}
|
||||||
|
|
||||||
|
method resize [cap:resize] {
|
||||||
|
param size size [inout] # New size for the VMA, or 0 to query the current size without changing
|
||||||
|
}
|
||||||
|
}
|
||||||
69
definitions/syscalls.def
Normal file
69
definitions/syscalls.def
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import "objects/object.def"
|
||||||
|
|
||||||
|
import "objects/event.def"
|
||||||
|
import "objects/mailbox.def"
|
||||||
|
import "objects/process.def"
|
||||||
|
import "objects/system.def"
|
||||||
|
import "objects/thread.def"
|
||||||
|
import "objects/vma.def"
|
||||||
|
|
||||||
|
interface syscalls [syscall] {
|
||||||
|
uid 01d9b6a948961097
|
||||||
|
|
||||||
|
expose ref object
|
||||||
|
|
||||||
|
expose ref event
|
||||||
|
expose ref mailbox
|
||||||
|
expose ref process
|
||||||
|
expose ref system
|
||||||
|
expose ref thread
|
||||||
|
expose ref vma
|
||||||
|
|
||||||
|
# Simple no-op syscall for testing
|
||||||
|
function noop
|
||||||
|
|
||||||
|
# Write a message to the kernel log
|
||||||
|
function log {
|
||||||
|
param area uint8
|
||||||
|
param severity uint8
|
||||||
|
param message string
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get a list of handles owned by this process. If the
|
||||||
|
# supplied list is not big enough, will set the size
|
||||||
|
# needed in `size` and return j6_err_insufficient
|
||||||
|
function handle_list {
|
||||||
|
param handles struct handle_descriptor [list inout zero_ok] # A list of handles to be filled
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a clone of an existing handle, possibly with
|
||||||
|
# some capabilities masked out.
|
||||||
|
function handle_clone {
|
||||||
|
param orig ref object [handle cap:clone] # The handle to clone
|
||||||
|
param clone ref object [out] # The new handle
|
||||||
|
param mask uint32 # The capability bitmask
|
||||||
|
}
|
||||||
|
|
||||||
|
# Close the handle to an object
|
||||||
|
function handle_close {
|
||||||
|
param hnd ref object [handle] # The handle to close
|
||||||
|
}
|
||||||
|
|
||||||
|
# Block waiting on a futex
|
||||||
|
function futex_wait [static] {
|
||||||
|
param address uint32* # Address of the futex value
|
||||||
|
param current uint32 # Current value of the futex
|
||||||
|
param timeout uint64 # Wait timeout in nanoseconds
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wake threads waiting on a futex
|
||||||
|
function futex_wake [static] {
|
||||||
|
param address uint32* # Address of the futex value
|
||||||
|
param count uint64 # Number of threads to wake, or 0 for all
|
||||||
|
}
|
||||||
|
|
||||||
|
# Testing mode only: Have the kernel finish and exit QEMU with the given exit code
|
||||||
|
function test_finish [test] {
|
||||||
|
param exit_code uint32
|
||||||
|
}
|
||||||
|
}
|
||||||
34
definitions/sysconf.yaml
Normal file
34
definitions/sysconf.yaml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
address: 0x6a360000
|
||||||
|
vars:
|
||||||
|
- name: version_major
|
||||||
|
section: kernel
|
||||||
|
type: uint8_t
|
||||||
|
|
||||||
|
- name: version_minor
|
||||||
|
section: kernel
|
||||||
|
type: uint8_t
|
||||||
|
|
||||||
|
- name: version_patch
|
||||||
|
section: kernel
|
||||||
|
type: uint16_t
|
||||||
|
|
||||||
|
- name: version_gitsha
|
||||||
|
section: kernel
|
||||||
|
type: uint32_t
|
||||||
|
|
||||||
|
- name: page_size
|
||||||
|
section: sys
|
||||||
|
type: size_t
|
||||||
|
|
||||||
|
- name: large_page_size
|
||||||
|
section: sys
|
||||||
|
type: size_t
|
||||||
|
|
||||||
|
- name: huge_page_size
|
||||||
|
section: sys
|
||||||
|
type: size_t
|
||||||
|
|
||||||
|
- name: num_cpus
|
||||||
|
section: sys
|
||||||
|
type: uint32_t
|
||||||
23
docs/Makefile
Normal file
23
docs/Makefile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Minimal makefile for Sphinx documentation
|
||||||
|
#
|
||||||
|
|
||||||
|
# You can set these variables from the command line, and also
|
||||||
|
# from the environment for the first two.
|
||||||
|
SPHINXOPTS ?=
|
||||||
|
SPHINXBUILD ?= sphinx-build
|
||||||
|
SOURCEDIR = .
|
||||||
|
BUILDDIR = _build
|
||||||
|
ROOTDIR = $(SOURCEDIR)/..
|
||||||
|
|
||||||
|
# Put it first so that "make" without argument is like "make help".
|
||||||
|
help:
|
||||||
|
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
|
|
||||||
|
.PHONY: help Makefile
|
||||||
|
|
||||||
|
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||||
|
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||||
|
%: Makefile
|
||||||
|
PYTHONPATH=$(ROOTDIR)/scripts cog -r -D definitions_path=$(ROOTDIR)/definitions -c syscall_interface.rst
|
||||||
|
PYTHONPATH=$(ROOTDIR)/scripts cog -r -D definitions_path=$(ROOTDIR)/definitions -c kernel_memory.rst
|
||||||
|
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
254
docs/_static/custom.css
vendored
Normal file
254
docs/_static/custom.css
vendored
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
/* custom.css - jsix version */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--background-color: #181820;
|
||||||
|
--link-color: #7070e0;
|
||||||
|
--link-hover-color: #9090ff;
|
||||||
|
--text-color: #3d3d3d;
|
||||||
|
--text-literal-color: #d26a98;
|
||||||
|
}
|
||||||
|
.wy-nav-side {
|
||||||
|
background: var(--background-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1100px) {
|
||||||
|
.wy-nav-content-wrap {
|
||||||
|
background: var(--background-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: var(--link-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: var(--link-hover-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
a:visited {
|
||||||
|
color: var(--link-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rst-content {
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rst-content code.literal {
|
||||||
|
color: var(--text-literal-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rst-content tt.literal {
|
||||||
|
color: var(--text-literal-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rst-content .note {
|
||||||
|
color: #003274;
|
||||||
|
background: #ccddf3;
|
||||||
|
padding: 1rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rst-content .note .admonition-title {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rst-content .warning {
|
||||||
|
color: #605000;
|
||||||
|
background: #fcf4cc;
|
||||||
|
padding: 1rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rst-content .warning .admonition-title {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rst-content .highlight {
|
||||||
|
background: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-side-scroll {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-side-nav-search {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-side-nav-search input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 0px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-color: var(--background-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical a {
|
||||||
|
font-size: 100%;
|
||||||
|
color: #d9d9d9;
|
||||||
|
padding-top: 0.6rem;
|
||||||
|
padding-bottom: 0.6rem;
|
||||||
|
background-color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical a:hover {
|
||||||
|
background-color: unset;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.current > a {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.current > a span.toctree-expand {
|
||||||
|
display: block;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.current > a span.toctree-expand:before {
|
||||||
|
display: block;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.current > a span.toctree-expand:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.current > a:hover {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.current > a:hover span.toctree-expand {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical .toctree-l1 {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical .toctree-l1:hover {
|
||||||
|
opacity: 1;
|
||||||
|
background-color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l1.current {
|
||||||
|
opacity: 1;
|
||||||
|
background-color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l1.current > a {
|
||||||
|
border: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical .toctree-l2:hover {
|
||||||
|
background-color: #566673;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2.current > a {
|
||||||
|
background-color: #566673;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2.current li.toctree-l3 > a {
|
||||||
|
background-color: #e4e7ea;
|
||||||
|
color: #838383;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2.current li.toctree-l3 > a:hover {
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2.current li.toctree-l3 > a:hover span.toctree-expand {
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2.current li.toctree-l3.current > a {
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2 a {
|
||||||
|
border: 0px;
|
||||||
|
background-color: #566673;
|
||||||
|
color: #d9d9d9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2 a span.toctree-expand {
|
||||||
|
display: block;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2 a span.toctree-expand:before {
|
||||||
|
display: block;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2 a span.toctree-expand:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2 a:hover {
|
||||||
|
color: white;
|
||||||
|
background-color: #566673;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l2 a:hover span.toctree-expand {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l3.current > a {
|
||||||
|
background-color: #e4e7ea;
|
||||||
|
color: #838383;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l3.current li.toctree-l4 > a {
|
||||||
|
background-color: #e4e7ea;
|
||||||
|
color: #838383;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-menu-vertical li.toctree-l3.current li.toctree-l4.current > a {
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wy-nav-top {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: var(--text-color);
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
vertical-align: middle;
|
||||||
|
cursor: pointer;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
padding: 0.375rem 0.75rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
border-radius: 0;
|
||||||
|
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
||||||
|
box-shadow: unset;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-neutral {
|
||||||
|
background: unset !important;
|
||||||
|
color: #838383 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-neutral:active {
|
||||||
|
padding: 0.375rem 0.75rem;
|
||||||
|
box-shadow: unset;
|
||||||
|
}
|
||||||
50
docs/conf.py
Normal file
50
docs/conf.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Configuration file for the Sphinx documentation builder.
|
||||||
|
#
|
||||||
|
# For the full list of built-in configuration values, see the documentation:
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||||
|
|
||||||
|
# -- Project information -----------------------------------------------------
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||||
|
|
||||||
|
project = 'jsix'
|
||||||
|
copyright = '2024, Justin C. Miller'
|
||||||
|
author = 'Justin C. Miller'
|
||||||
|
release = '0.8'
|
||||||
|
|
||||||
|
# -- General configuration ---------------------------------------------------
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||||
|
|
||||||
|
extensions = ['sphinx.ext.todo']
|
||||||
|
primary_domain = 'cpp'
|
||||||
|
todo_include_todos = True
|
||||||
|
|
||||||
|
templates_path = ['_templates']
|
||||||
|
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for HTML output -------------------------------------------------
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||||
|
|
||||||
|
html_theme = 'renku'
|
||||||
|
html_title = 'jsix'
|
||||||
|
html_logo = 'jsix_transparent.svg'
|
||||||
|
html_static_path = ['_static']
|
||||||
|
html_css_files = ['custom.css']
|
||||||
|
html_theme_options = {
|
||||||
|
"description": "The jsix description",
|
||||||
|
"github_repo": "https://github.com/justinian/jsix",
|
||||||
|
"logo_only": True,
|
||||||
|
"footer_icons": [
|
||||||
|
{
|
||||||
|
"name": "GitHub",
|
||||||
|
"url": "https://github.com/justinian/jsix",
|
||||||
|
"html": """
|
||||||
|
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
|
||||||
|
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
|
||||||
|
</svg>
|
||||||
|
""",
|
||||||
|
"class": "",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
81
docs/index.rst
Normal file
81
docs/index.rst
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
.. jsix documentation master file
|
||||||
|
.. |amd64| replace:: :abbr:`amd64 (aka x86_64)`
|
||||||
|
|
||||||
|
The jsix Operating System
|
||||||
|
=========================
|
||||||
|
Introduction
|
||||||
|
------------
|
||||||
|
|
||||||
|
**jsix** is a custom multi-core x64 operating system being built from scratch,
|
||||||
|
supporting modern [#]_ Intel or AMD CPUs, and UEFI firmware. It was initially
|
||||||
|
created out of a desire to explore UEFI and to explore what's possible with a
|
||||||
|
microkernel architecture on modern 64-bit architectures.
|
||||||
|
|
||||||
|
Most of jsix is written in C++ (C++17, using `LLVM <https://llvm.org>`_), but
|
||||||
|
you'll also find some assembly (in `NASM <https://nasm.us>`_ syntax) and Python
|
||||||
|
for development tooling.
|
||||||
|
|
||||||
|
jsix can be found `on GitHub <https://github.com/justinian/jsix>`_, and is
|
||||||
|
released under the terms of the `MPL 2.0 <https://mozilla.org/MPL/2.0/>`_.
|
||||||
|
|
||||||
|
.. admonition:: A note on the name
|
||||||
|
|
||||||
|
This kernel was originally named Popcorn, but I have since discovered that
|
||||||
|
the Popcorn Linux project is also developing a kernel with that name,
|
||||||
|
started around the same time as this project. So I've renamed this kernel
|
||||||
|
jsix as an homage to L4, xv6, and my wonderful wife.
|
||||||
|
|
||||||
|
The name jsix is always styled *jsix* or ``j6``, never capitalized.
|
||||||
|
|
||||||
|
.. [#] jsix aims to support amd64 (x86_64) CPUs released in the last 10 years.
|
||||||
|
|
||||||
|
Current Features
|
||||||
|
----------------
|
||||||
|
|
||||||
|
The jsix kernel is quite far along now, but the userland systems are still lacking.
|
||||||
|
|
||||||
|
- Platform: |amd64|
|
||||||
|
- UEFI bootloader
|
||||||
|
- Multi-core & multi-tasking microkernel
|
||||||
|
|
||||||
|
- Work-stealing SMP scheduler
|
||||||
|
- Pluggable panic handler modules
|
||||||
|
|
||||||
|
- Capability-style object-oriented syscall API
|
||||||
|
|
||||||
|
- Custom IDL for specifying and documenting syscalls
|
||||||
|
|
||||||
|
- Virtual memory based on sharable Virtual Memory Area objects (VMAs)
|
||||||
|
- Kernel API library (libj6), also provides features built on kernel primitives:
|
||||||
|
|
||||||
|
- Channels (async stream IPC) built on shared memory and futexes
|
||||||
|
- Ring buffers via doubly-mapped pages
|
||||||
|
|
||||||
|
- Custom libc
|
||||||
|
- Runtime dynamic linker
|
||||||
|
- Init service
|
||||||
|
|
||||||
|
- Built-in VFS service for the initrd
|
||||||
|
- ELF loader
|
||||||
|
- Service-lookup protocol service
|
||||||
|
|
||||||
|
- Userland UART driver
|
||||||
|
- Userland UEFI framebuffer driver
|
||||||
|
- Userland kernel log output service
|
||||||
|
- Userland unit test runner
|
||||||
|
- Build configuration system (bonnibel)
|
||||||
|
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
:caption: Site Contents:
|
||||||
|
|
||||||
|
syscall_interface
|
||||||
|
kernel_memory
|
||||||
|
process_initialization
|
||||||
|
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`search`
|
||||||
|
|
||||||
|
|
||||||
12
docs/jsix_transparent.svg
Normal file
12
docs/jsix_transparent.svg
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Generator: Gravit.io -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="176.562 356.069 211.11 113" width="211.11pt" height="113pt">
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path d=" M 212.981 372.36 L 219.564 376.16 L 226.147 379.961 L 226.147 387.563 L 226.147 395.164 L 219.564 398.965 L 212.981 402.766 L 206.398 398.965 L 199.815 395.164 L 199.815 387.563 L 199.815 379.961 L 206.398 376.16 L 212.981 372.36 L 212.981 372.36 L 212.981 372.36 Z M 256.292 397.366 L 262.875 401.166 L 269.458 404.967 L 269.458 412.569 L 269.458 420.17 L 262.875 423.971 L 256.292 427.772 L 249.709 423.971 L 243.126 420.17 L 243.126 412.569 L 243.126 404.967 L 249.709 401.166 L 256.292 397.366 L 256.292 397.366 Z M 183.622 387.283 L 205.52 374.64 L 227.418 361.997 L 249.316 374.64 L 271.214 387.283 L 271.214 412.569 L 271.214 437.854 L 249.316 450.497 L 227.418 463.14 L 205.52 450.497 L 183.622 437.854 L 183.622 412.569 L 183.622 387.283 L 183.622 387.283 L 183.622 387.283 Z M 241.855 372.36 L 248.438 376.16 L 255.021 379.961 L 255.021 387.563 L 255.021 395.164 L 248.438 398.965 L 241.855 402.766 L 235.272 398.965 L 228.689 395.164 L 228.689 387.563 L 228.689 379.961 L 235.272 376.16 L 241.855 372.36 Z " fill-rule="evenodd" fill="rgb(49,79,128)"/>
|
||||||
|
<path d=" M 298.642 379.579 L 291.621 379.579 L 291.621 372.558 L 298.642 372.558 L 298.642 379.579 Z M 285.214 446.718 L 285.214 441.452 L 287.32 441.452 L 287.32 441.452 Q 289.339 441.452 290.524 440.092 L 290.524 440.092 L 290.524 440.092 Q 291.708 438.731 291.708 436.625 L 291.708 436.625 L 291.708 387.039 L 298.729 387.039 L 298.729 436.011 L 298.729 436.011 Q 298.729 440.925 295.921 443.822 L 295.921 443.822 L 295.921 443.822 Q 293.113 446.718 288.286 446.718 L 288.286 446.718 L 285.214 446.718 Z M 306.628 432.676 L 306.628 427.41 L 314.088 427.41 L 314.088 427.41 Q 317.862 427.41 319.573 425.347 L 319.573 425.347 L 319.573 425.347 Q 321.285 423.285 321.285 419.95 L 321.285 419.95 L 321.285 419.95 Q 321.285 417.317 319.705 415.474 L 319.705 415.474 L 319.705 415.474 Q 318.125 413.631 314.966 411.174 L 314.966 411.174 L 314.966 411.174 Q 312.245 408.98 310.621 407.356 L 310.621 407.356 L 310.621 407.356 Q 308.998 405.732 307.813 403.319 L 307.813 403.319 L 307.813 403.319 Q 306.628 400.905 306.628 397.746 L 306.628 397.746 L 306.628 397.746 Q 306.628 393.095 309.744 390.067 L 309.744 390.067 L 309.744 390.067 Q 312.859 387.039 318.125 387.039 L 318.125 387.039 L 325.76 387.039 L 325.76 392.305 L 319.441 392.305 L 319.441 392.305 Q 313.21 392.305 313.21 398.185 L 313.21 398.185 L 313.21 398.185 Q 313.21 400.467 314.615 402.134 L 314.615 402.134 L 314.615 402.134 Q 316.019 403.802 319.003 406.083 L 319.003 406.083 L 319.003 406.083 Q 321.723 408.19 323.479 409.901 L 323.479 409.901 L 323.479 409.901 Q 325.234 411.613 326.463 414.202 L 326.463 414.202 L 326.463 414.202 Q 327.691 416.791 327.691 420.301 L 327.691 420.301 L 327.691 420.301 Q 327.691 426.532 324.4 429.604 L 324.4 429.604 L 324.4 429.604 Q 321.109 432.676 315.141 432.676 L 315.141 432.676 L 306.628 432.676 Z M 342.611 379.579 L 335.59 379.579 L 335.59 372.558 L 342.611 372.558 L 342.611 379.579 Z M 342.611 432.676 L 335.59 432.676 L 335.59 387.039 L 342.611 387.039 L 342.611 432.676 Z M 356.126 432.676 L 348.754 432.676 L 361.392 409.77 L 349.632 387.039 L 356.39 387.039 L 364.639 403.187 L 372.977 387.039 L 379.735 387.039 L 367.974 409.77 L 380.612 432.676 L 373.24 432.676 L 364.639 416.001 L 356.126 432.676 Z " fill="rgb(49,79,128)"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.6 KiB |
178
docs/kernel_memory.rst
Normal file
178
docs/kernel_memory.rst
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
.. jsix syscall interface.
|
||||||
|
.. Automatically updated from the definition files using cog!
|
||||||
|
|
||||||
|
.. [[[cog code generation
|
||||||
|
.. from os.path import join
|
||||||
|
.. from memory import Layout, unit
|
||||||
|
..
|
||||||
|
.. layout = Layout(join(definitions_path, "memory_layout.yaml"))
|
||||||
|
.. l = max([len(r.name) for r in layout.regions])
|
||||||
|
.. ]]]
|
||||||
|
.. [[[end]]] (checksum: d41d8cd98f00b204e9800998ecf8427e)
|
||||||
|
|
||||||
|
Kernel memory
|
||||||
|
=============
|
||||||
|
|
||||||
|
While jsix probably should eventually use KASLR to randomize its memory layout,
|
||||||
|
currently the layout is mostly fixed. (Kernel code locations are not consistent
|
||||||
|
but aren't explicitly randomized.)
|
||||||
|
|
||||||
|
.. [[[cog code generation
|
||||||
|
.. line_size = 128 * 1024**3 # Each line represents up to 32 GiB
|
||||||
|
.. max_lines = 32
|
||||||
|
.. totals = sum([r.size for r in layout.regions])
|
||||||
|
.. remain = unit((128 * 1024**4) - totals)
|
||||||
|
..
|
||||||
|
.. def split(val):
|
||||||
|
.. return f"0x {val >> 48:04x} {(val >> 32) & 0xffff:04x} {(val >> 16) & 0xffff:04x} {val & 0xffff:04x}"
|
||||||
|
..
|
||||||
|
.. cog.outl()
|
||||||
|
.. cog.outl(f"+-+-----------------------------+----------+---------------------------------------+")
|
||||||
|
.. cog.outl(f"| | Address | Size | Use |")
|
||||||
|
.. cog.outl(f"+=+=============================+==========+=======================================+")
|
||||||
|
..
|
||||||
|
.. for region in layout.regions:
|
||||||
|
.. cog.outl(f"| | ``{split(region.start)}`` | {unit(region.size):>8} | {region.desc:37} |")
|
||||||
|
.. lines = min(max_lines, region.size // line_size)
|
||||||
|
.. for i in range(1, lines):
|
||||||
|
.. cog.outl(f"+-+ | | |")
|
||||||
|
.. cog.outl(f"| | | | |")
|
||||||
|
.. cog.outl(f"+-+-----------------------------+----------+---------------------------------------+")
|
||||||
|
..
|
||||||
|
.. cog.outl(f"| | ... | | |")
|
||||||
|
.. cog.outl(f"+-+-----------------------------+----------+---------------------------------------+")
|
||||||
|
.. cog.outl(f"| | ``0x ffff 0000 0000 0000`` | | Kernel code / headers |")
|
||||||
|
.. cog.outl(f"+-+-----------------------------+----------+---------------------------------------+")
|
||||||
|
.. cog.outl("")
|
||||||
|
.. cog.outl("")
|
||||||
|
.. cog.outl(f"Un-reserved virtual memory address space in the higher half: {remain}")
|
||||||
|
.. cog.outl("")
|
||||||
|
..
|
||||||
|
.. ]]]
|
||||||
|
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | Address | Size | Use |
|
||||||
|
+=+=============================+==========+=======================================+
|
||||||
|
| | ``0x ffff c000 0000 0000`` | 64 TiB | Linearly-mapped physical memory |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff bf00 0000 0000`` | 1 TiB | Used/free page tracking bitmap |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff be00 0000 0000`` | 1 TiB | Per-page state tracking structures |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+ | | |
|
||||||
|
| | | | |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff bdf8 0000 0000`` | 32 GiB | Kernel heap accounting structures |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff bdf0 0000 0000`` | 32 GiB | Kernel heap |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff bde8 0000 0000`` | 32 GiB | Capabilities accounting structures |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff bde0 0000 0000`` | 32 GiB | Capabilities |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff bdd0 0000 0000`` | 64 GiB | Kernel thread stacks |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff bdc0 0000 0000`` | 64 GiB | Kernel buffers |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff bdbf 8000 0000`` | 2 GiB | Kernel logs circular buffer |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ... | | |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
| | ``0x ffff 0000 0000 0000`` | | Kernel code / headers |
|
||||||
|
+-+-----------------------------+----------+---------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
Un-reserved virtual memory address space in the higher half: 61 TiB
|
||||||
|
|
||||||
|
.. [[[end]]] (checksum: 8c336cc8151beba1a79c8d3b653f1109)
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`search`
|
||||||
|
|
||||||
7
docs/modd.conf
Normal file
7
docs/modd.conf
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
** !_build/** ../definitions/**.def {
|
||||||
|
prep: rm -rf _build; make html
|
||||||
|
}
|
||||||
|
|
||||||
|
_build/html/** {
|
||||||
|
daemon: devd -m _build/html
|
||||||
|
}
|
||||||
42
docs/process_initialization.rst
Normal file
42
docs/process_initialization.rst
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
.. jsix process initialization in userspace
|
||||||
|
|
||||||
|
Process Initialization
|
||||||
|
======================
|
||||||
|
|
||||||
|
jsix follows the `System V ABI`_ on the ``amd64`` architecture. All arguments
|
||||||
|
needed for program initialization are passed to the program's initial thread on
|
||||||
|
the stack.
|
||||||
|
|
||||||
|
Note that jsix adds a number of additional auxiliary vector entry types for
|
||||||
|
passing jsix-specific data to a program. The jsix-specific auxiliary vector type
|
||||||
|
codes (what the ABI document refers to as ``a_type``) start from ``0xf000``. See
|
||||||
|
the header file ``<j6/init.h>`` for more detail.
|
||||||
|
|
||||||
|
.. _System V ABI: https://gitlab.com/x86-psABIs/x86-64-ABI
|
||||||
|
|
||||||
|
The initial stack frame
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
============== ==================== ============ =======
|
||||||
|
Address Value Bytes Notes
|
||||||
|
============== ==================== ============ =======
|
||||||
|
``top`` Stack top (out of stack bounds)
|
||||||
|
``top`` - 16 0 16 Stack sentinel
|
||||||
|
\ ``envp`` string data ?
|
||||||
|
\ ``argv`` string data ?
|
||||||
|
\ ... ? Possible padding
|
||||||
|
\ 0, 0 (``AT_NULL``) 16 Aux vector sentinel
|
||||||
|
\ Aux vectors 16 * `m` ``AT_NULL``-terminated array of Aux vectors
|
||||||
|
\ 0 8 Environment sentinel
|
||||||
|
\ ``envp`` 8 * `n` 0-terminated array of environment
|
||||||
|
string pointers
|
||||||
|
\ 0 8 Args sentinel
|
||||||
|
\ ``argv`` 8 * ``argc`` Pointers to argument strings
|
||||||
|
``rsp`` ``argc`` 8 Number of elements in argv
|
||||||
|
============== ==================== ============ =======
|
||||||
|
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`search`
|
||||||
|
|
||||||
|
|
||||||
5
docs/requirements.txt
Normal file
5
docs/requirements.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
cogapp >= 3
|
||||||
|
pyyaml >= 5.4
|
||||||
|
lark == 0.12.0
|
||||||
|
sphinx
|
||||||
|
renku-sphinx-theme
|
||||||
444
docs/syscall_interface.rst
Normal file
444
docs/syscall_interface.rst
Normal file
@@ -0,0 +1,444 @@
|
|||||||
|
.. jsix syscall interface.
|
||||||
|
.. Automatically updated from the definition files using cog!
|
||||||
|
|
||||||
|
.. [[[cog code generation
|
||||||
|
.. from textwrap import indent
|
||||||
|
.. from definitions.context import Context
|
||||||
|
..
|
||||||
|
.. ctx = Context(definitions_path)
|
||||||
|
.. ctx.parse("syscalls.def")
|
||||||
|
.. syscalls = ctx.interfaces["syscalls"]
|
||||||
|
..
|
||||||
|
.. def caplist(caps):
|
||||||
|
.. return ', '.join([f"``{c}``" for c in caps])
|
||||||
|
.. ]]]
|
||||||
|
.. [[[end]]] (checksum: d41d8cd98f00b204e9800998ecf8427e)
|
||||||
|
|
||||||
|
Syscall interface
|
||||||
|
=================
|
||||||
|
|
||||||
|
The jsix kernel's syscall design is based around object handles. Object handles
|
||||||
|
are also a collection of capabilities, encoding certain rights over the object
|
||||||
|
they reference.
|
||||||
|
|
||||||
|
Very few syscalls in jsix can be made without some handle, and most of them are
|
||||||
|
requests to the kernel to create a given kind of object. This is analogous to
|
||||||
|
methods on an object in an object-oriented programming language.
|
||||||
|
|
||||||
|
.. [[[cog code generation
|
||||||
|
.. cog.outl()
|
||||||
|
.. for obj in syscalls.exposes:
|
||||||
|
.. cog.outl(f"``{obj.name}`` syscalls")
|
||||||
|
.. cog.outl(f"-------------------------")
|
||||||
|
.. desc = obj.desc or "Undocumented"
|
||||||
|
.. cog.outl(desc)
|
||||||
|
.. cog.outl()
|
||||||
|
.. cog.outl(f":capabilites: {caplist(obj.caps)}")
|
||||||
|
.. cog.outl()
|
||||||
|
.. for method in obj.methods:
|
||||||
|
.. args = []
|
||||||
|
.. if method.constructor:
|
||||||
|
.. args.append("j6_handle_t *self")
|
||||||
|
.. elif not method.static:
|
||||||
|
.. args.append("j6_handle_t self")
|
||||||
|
..
|
||||||
|
.. for param in method.params:
|
||||||
|
.. for type, suffix in param.type.c_names(param.options):
|
||||||
|
.. args.append(f"{type} {param.name}{suffix}")
|
||||||
|
..
|
||||||
|
.. cog.outl(f".. cpp:function:: j6_result_t j6_{obj.name}_{method.name} ({', '.join(args)})")
|
||||||
|
.. cog.outl()
|
||||||
|
.. desc = method.desc or "Undocumented"
|
||||||
|
.. cog.outl(indent(desc, " "))
|
||||||
|
.. cog.outl()
|
||||||
|
.. if "cap" in method.options:
|
||||||
|
.. cog.outl(f" :capabilities: {caplist(method.options['cap'])}")
|
||||||
|
.. cog.outl()
|
||||||
|
.. if method.constructor:
|
||||||
|
.. cog.outl(f" :param self: *[out]* Handle to the new {obj.name} object")
|
||||||
|
.. elif not method.static:
|
||||||
|
.. cog.outl(f" :param self: Handle to the {obj.name} object")
|
||||||
|
.. for param in method.params:
|
||||||
|
.. opts = param.options and f"*[{', '.join(param.options)}]*" or ""
|
||||||
|
.. desc = param.desc or 'Undocumented'
|
||||||
|
.. cog.outl(f" :param {param.name}: {opts} {desc}")
|
||||||
|
.. cog.outl()
|
||||||
|
.. ]]]
|
||||||
|
|
||||||
|
``object`` syscalls
|
||||||
|
-------------------------
|
||||||
|
All kernel-exposed objects inherit from the base ``object`` type, so the
|
||||||
|
``object`` syscalls can be used with any object's handle.
|
||||||
|
|
||||||
|
:capabilites: ``clone``
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_object_koid (j6_handle_t self, uint64_t * koid)
|
||||||
|
|
||||||
|
Get the internal kernel object id of an object
|
||||||
|
|
||||||
|
:param self: Handle to the object object
|
||||||
|
:param koid: *[out]* Undocumented
|
||||||
|
|
||||||
|
``event`` syscalls
|
||||||
|
-------------------------
|
||||||
|
An ``event`` is a simple synchronization object. It contains up to 64 signals
|
||||||
|
that threads can wait for and signal in parallel.
|
||||||
|
|
||||||
|
:capabilites: ``signal``, ``wait``
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_event_create (j6_handle_t *self)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:param self: *[out]* Handle to the new event object
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_event_signal (j6_handle_t self, uint64_t signals)
|
||||||
|
|
||||||
|
Signal events on this object
|
||||||
|
|
||||||
|
:capabilities: ``signal``
|
||||||
|
|
||||||
|
:param self: Handle to the event object
|
||||||
|
:param signals: A bitset of which events to signal
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_event_wait (j6_handle_t self, uint64_t * signals, uint64_t timeout)
|
||||||
|
|
||||||
|
Wait for signaled events on this object
|
||||||
|
|
||||||
|
:capabilities: ``wait``
|
||||||
|
|
||||||
|
:param self: Handle to the event object
|
||||||
|
:param signals: *[out]* A bitset of which events were signaled
|
||||||
|
:param timeout: Wait timeout in nanoseconds
|
||||||
|
|
||||||
|
``mailbox`` syscalls
|
||||||
|
-------------------------
|
||||||
|
Mailboxes are objects that enable synchronous IPC via arbitrary
|
||||||
|
message-passing of tagged data and/or handles. Not as efficient
|
||||||
|
as shared memory channels, but more flexible.
|
||||||
|
|
||||||
|
:capabilites: ``send``, ``receive``, ``close``
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_mailbox_create (j6_handle_t *self)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:param self: *[out]* Handle to the new mailbox object
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_mailbox_close (j6_handle_t self)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:capabilities: ``close``
|
||||||
|
|
||||||
|
:param self: Handle to the mailbox object
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_mailbox_call (j6_handle_t self, uint64_t * tag, void * data, size_t * data_len, size_t data_size, j6_handle_t * handles, size_t * handles_count, size_t handles_size)
|
||||||
|
|
||||||
|
Send a message to the reciever, and block until a response is
|
||||||
|
sent. Note that getting this response does not require the
|
||||||
|
receive capability.
|
||||||
|
|
||||||
|
:capabilities: ``send``
|
||||||
|
|
||||||
|
:param self: Handle to the mailbox object
|
||||||
|
:param tag: *[inout]* Undocumented
|
||||||
|
:param data: *[optional, inout]* Undocumented
|
||||||
|
:param data_size: number of total bytes in data buffer
|
||||||
|
:param handles: *[optional, inout, handle, list]* Undocumented
|
||||||
|
:param handles_size: total size of handles buffer
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_mailbox_respond (j6_handle_t self, uint64_t * tag, void * data, size_t * data_len, size_t data_size, j6_handle_t * handles, size_t * handles_count, size_t handles_size, uint64_t * reply_tag, uint64_t flags)
|
||||||
|
|
||||||
|
Respond to a message sent using call, and wait for another
|
||||||
|
message to arrive. Note that this does not require the send
|
||||||
|
capability. A reply tag of 0 skips the reply and goes directly
|
||||||
|
to waiting for a new message.
|
||||||
|
|
||||||
|
:capabilities: ``receive``
|
||||||
|
|
||||||
|
:param self: Handle to the mailbox object
|
||||||
|
:param tag: *[inout]* Undocumented
|
||||||
|
:param data: *[optional, inout]* Undocumented
|
||||||
|
:param data_size: number of total bytes in data buffer
|
||||||
|
:param handles: *[optional, inout, handle, list]* Undocumented
|
||||||
|
:param handles_size: total size of handles buffer
|
||||||
|
:param reply_tag: *[inout]* Undocumented
|
||||||
|
:param flags: Undocumented
|
||||||
|
|
||||||
|
``process`` syscalls
|
||||||
|
-------------------------
|
||||||
|
A ``process`` object represents a process running on the system, and allows
|
||||||
|
control over the threads, handles, and virtual memory space of that process.
|
||||||
|
|
||||||
|
:capabilites: ``kill``, ``create_thread``
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_process_create (j6_handle_t *self)
|
||||||
|
|
||||||
|
Create a new empty process
|
||||||
|
|
||||||
|
:param self: *[out]* Handle to the new process object
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_process_kill (j6_handle_t self)
|
||||||
|
|
||||||
|
Stop all threads and exit the given process
|
||||||
|
|
||||||
|
:capabilities: ``kill``
|
||||||
|
|
||||||
|
:param self: Handle to the process object
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_process_exit (int64_t result)
|
||||||
|
|
||||||
|
Stop all threads and exit the current process
|
||||||
|
|
||||||
|
:param result: The result to retrun to the parent process
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_process_give_handle (j6_handle_t self, j6_handle_t target)
|
||||||
|
|
||||||
|
Give the given process a handle that points to the same
|
||||||
|
object as the specified handle.
|
||||||
|
|
||||||
|
:param self: Handle to the process object
|
||||||
|
:param target: *[handle]* A handle in the caller process to send
|
||||||
|
|
||||||
|
``system`` syscalls
|
||||||
|
-------------------------
|
||||||
|
The singular ``system`` object represents a handle to kernel functionality
|
||||||
|
needed by drivers and other priviledged services.
|
||||||
|
|
||||||
|
:capabilites: ``get_log``, ``bind_irq``, ``map_phys``, ``change_iopl``
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_system_get_log (j6_handle_t self, uint64_t seen, void * buffer, size_t * buffer_len)
|
||||||
|
|
||||||
|
Get the next log line from the kernel log
|
||||||
|
|
||||||
|
:capabilities: ``get_log``
|
||||||
|
|
||||||
|
:param self: Handle to the system object
|
||||||
|
:param seen: Last seen log id
|
||||||
|
:param buffer: *[out, zero_ok]* Buffer for the log message data structure
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_system_bind_irq (j6_handle_t self, j6_handle_t dest, unsigned irq, unsigned signal)
|
||||||
|
|
||||||
|
Ask the kernel to send this process messages whenever
|
||||||
|
the given IRQ fires
|
||||||
|
|
||||||
|
:capabilities: ``bind_irq``
|
||||||
|
|
||||||
|
:param self: Handle to the system object
|
||||||
|
:param dest: Event object that will receive messages
|
||||||
|
:param irq: IRQ number to bind
|
||||||
|
:param signal: Signal number on the event to bind to
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_system_map_phys (j6_handle_t self, j6_handle_t * area, uintptr_t phys, size_t size, uint32_t flags)
|
||||||
|
|
||||||
|
Create a VMA and map an area of physical memory into it,
|
||||||
|
also mapping that VMA into the current process
|
||||||
|
|
||||||
|
:capabilities: ``map_phys``
|
||||||
|
|
||||||
|
:param self: Handle to the system object
|
||||||
|
:param area: *[out]* Receives a handle to the VMA created
|
||||||
|
:param phys: The physical address of the area
|
||||||
|
:param size: Size of the area, in bytes
|
||||||
|
:param flags: Flags to apply to the created VMA
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_system_request_iopl (j6_handle_t self, unsigned iopl)
|
||||||
|
|
||||||
|
Request the kernel change the IOPL for this process. The only values
|
||||||
|
that make sense are 0 and 3.
|
||||||
|
|
||||||
|
:capabilities: ``change_iopl``
|
||||||
|
|
||||||
|
:param self: Handle to the system object
|
||||||
|
:param iopl: The IOPL to set for this process
|
||||||
|
|
||||||
|
``thread`` syscalls
|
||||||
|
-------------------------
|
||||||
|
A ``thread`` object represents a thread of execution within a process running
|
||||||
|
on the system. The actual thread does not need to be currently running to
|
||||||
|
hold a handle to it.
|
||||||
|
|
||||||
|
:capabilites: ``kill``, ``join``
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_thread_create (j6_handle_t *self, j6_handle_t process, uintptr_t stack_top, uintptr_t entrypoint, uint64_t arg0, uint64_t arg1)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:param self: *[out]* Handle to the new thread object
|
||||||
|
:param process: *[optional, cap]* Undocumented
|
||||||
|
:param stack_top: Undocumented
|
||||||
|
:param entrypoint: Undocumented
|
||||||
|
:param arg0: Undocumented
|
||||||
|
:param arg1: Undocumented
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_thread_kill (j6_handle_t self)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:capabilities: ``kill``
|
||||||
|
|
||||||
|
:param self: Handle to the thread object
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_thread_join (j6_handle_t self)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:capabilities: ``join``
|
||||||
|
|
||||||
|
:param self: Handle to the thread object
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_thread_exit ()
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_thread_sleep (uint64_t duration)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:param duration: Undocumented
|
||||||
|
|
||||||
|
``vma`` syscalls
|
||||||
|
-------------------------
|
||||||
|
A ``vma`` object represents a single virtual memory area, which may be shared
|
||||||
|
between several processes. A process having a handle to a ``vma`` does not
|
||||||
|
necessarily mean that it is mapped into that process' virtual memory space.
|
||||||
|
|
||||||
|
:capabilites: ``map``, ``unmap``, ``resize``
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_vma_create (j6_handle_t *self, size_t size, uint32_t flags)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:param self: *[out]* Handle to the new vma object
|
||||||
|
:param size: Undocumented
|
||||||
|
:param flags: Undocumented
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_vma_create_map (j6_handle_t *self, size_t size, uintptr_t * address, uint32_t flags)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:capabilities: ``map``
|
||||||
|
|
||||||
|
:param self: *[out]* Handle to the new vma object
|
||||||
|
:param size: Undocumented
|
||||||
|
:param address: *[inout]* Undocumented
|
||||||
|
:param flags: Undocumented
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_vma_map (j6_handle_t self, j6_handle_t process, uintptr_t * address, uint32_t flags)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:capabilities: ``map``
|
||||||
|
|
||||||
|
:param self: Handle to the vma object
|
||||||
|
:param process: *[optional]* Undocumented
|
||||||
|
:param address: *[inout]* Undocumented
|
||||||
|
:param flags: Undocumented
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_vma_unmap (j6_handle_t self, j6_handle_t process)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:capabilities: ``unmap``
|
||||||
|
|
||||||
|
:param self: Handle to the vma object
|
||||||
|
:param process: *[optional]* Undocumented
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_vma_resize (j6_handle_t self, size_t * size)
|
||||||
|
|
||||||
|
Undocumented
|
||||||
|
|
||||||
|
:capabilities: ``resize``
|
||||||
|
|
||||||
|
:param self: Handle to the vma object
|
||||||
|
:param size: *[inout]* New size for the VMA, or 0 to query the current size without changing
|
||||||
|
|
||||||
|
.. [[[end]]] (checksum: cb17f54e443d1d3b85995870f3e8dbf2)
|
||||||
|
|
||||||
|
Non-object syscalls
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
The following are the system calls that aren't constructors for objects, and
|
||||||
|
either do not require an object handle, or operate generically on handles.
|
||||||
|
|
||||||
|
.. [[[cog code generation
|
||||||
|
.. cog.outl()
|
||||||
|
.. for func in syscalls.functions:
|
||||||
|
.. args = []
|
||||||
|
.. for param in func.params:
|
||||||
|
.. for type, suffix in param.type.c_names(param.options):
|
||||||
|
.. args.append(f"{type} {param.name}{suffix}")
|
||||||
|
..
|
||||||
|
.. cog.outl(f".. cpp:function:: j6_result_t j6_{func.name} ({', '.join(args)})")
|
||||||
|
.. cog.outl()
|
||||||
|
.. desc = func.desc or "Undocumented"
|
||||||
|
.. cog.outl(indent(desc, " "))
|
||||||
|
.. cog.outl()
|
||||||
|
.. for param in func.params:
|
||||||
|
.. opts = param.options and f"*[{', '.join(param.options)}]*" or ""
|
||||||
|
.. desc = param.desc or 'Undocumented'
|
||||||
|
.. cog.outl(f" :param {param.name}: {opts} {desc}")
|
||||||
|
.. cog.outl()
|
||||||
|
.. ]]]
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_noop ()
|
||||||
|
|
||||||
|
Simple no-op syscall for testing
|
||||||
|
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_log (uint8_t area, uint8_t severity, const char * message)
|
||||||
|
|
||||||
|
Write a message to the kernel log
|
||||||
|
|
||||||
|
:param area: Undocumented
|
||||||
|
:param severity: Undocumented
|
||||||
|
:param message: Undocumented
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_handle_list (struct j6_handle_descriptor * handles, size_t * handles_size)
|
||||||
|
|
||||||
|
Get a list of handles owned by this process. If the
|
||||||
|
supplied list is not big enough, will set the size
|
||||||
|
needed in `size` and return j6_err_insufficient
|
||||||
|
|
||||||
|
:param handles: *[list, inout, zero_ok]* A list of handles to be filled
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_handle_clone (j6_handle_t orig, j6_handle_t * clone, uint32_t mask)
|
||||||
|
|
||||||
|
Create a clone of an existing handle, possibly with
|
||||||
|
some capabilities masked out.
|
||||||
|
|
||||||
|
:param orig: *[handle, cap]* The handle to clone
|
||||||
|
:param clone: *[out]* The new handle
|
||||||
|
:param mask: The capability bitmask
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_handle_close (j6_handle_t hnd)
|
||||||
|
|
||||||
|
Close the handle to an object
|
||||||
|
|
||||||
|
:param hnd: *[handle]* The handle to close
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_futex_wait (const uint32_t * address, uint32_t current, uint64_t timeout)
|
||||||
|
|
||||||
|
Block waiting on a futex
|
||||||
|
|
||||||
|
:param address: Address of the futex value
|
||||||
|
:param current: Current value of the futex
|
||||||
|
:param timeout: Wait timeout in nanoseconds
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_futex_wake (const uint32_t * address, uint64_t count)
|
||||||
|
|
||||||
|
Wake threads waiting on a futex
|
||||||
|
|
||||||
|
:param address: Address of the futex value
|
||||||
|
:param count: Number of threads to wake, or 0 for all
|
||||||
|
|
||||||
|
.. cpp:function:: j6_result_t j6_test_finish (uint32_t exit_code)
|
||||||
|
|
||||||
|
Testing mode only: Have the kernel finish and exit QEMU with the given exit code
|
||||||
|
|
||||||
|
:param exit_code: Undocumented
|
||||||
|
|
||||||
|
.. [[[end]]] (checksum: 0b9d051972abcbb6de408f411331785f)
|
||||||
|
|
||||||
17802
external/catch/catch.hpp
vendored
Normal file
17802
external/catch/catch.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
external/gnu-efi
vendored
1
external/gnu-efi
vendored
Submodule external/gnu-efi deleted from fc5af9e47f
103
external/uefi/boot_services.h
vendored
Normal file
103
external/uefi/boot_services.h
vendored
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_boot_services_h_
|
||||||
|
#define _uefi_boot_services_h_
|
||||||
|
|
||||||
|
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||||
|
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||||
|
// not distributed with this file, You can obtain one at
|
||||||
|
// http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <uefi/tables.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace bs_impl {
|
||||||
|
using allocate_pages = status (*)(allocate_type, memory_type, size_t, void**);
|
||||||
|
using free_pages = status (*)(void*, size_t);
|
||||||
|
using get_memory_map = status (*)(size_t*, memory_descriptor*, size_t*, size_t*, uint32_t*);
|
||||||
|
using allocate_pool = status (*)(memory_type, uint64_t, void**);
|
||||||
|
using free_pool = status (*)(void*);
|
||||||
|
using handle_protocol = status (*)(handle, const guid*, void**);
|
||||||
|
using create_event = status (*)(evt, tpl, event_notify, void*, event*);
|
||||||
|
using exit_boot_services = status (*)(handle, size_t);
|
||||||
|
using locate_protocol = status (*)(const guid*, void*, void**);
|
||||||
|
using copy_mem = void (*)(void*, const void*, size_t);
|
||||||
|
using set_mem = void (*)(void*, uint64_t, uint8_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct boot_services {
|
||||||
|
static constexpr uint64_t signature = 0x56524553544f4f42ull;
|
||||||
|
|
||||||
|
table_header header;
|
||||||
|
|
||||||
|
// Task Priority Level management
|
||||||
|
void *raise_tpl;
|
||||||
|
void *restore_tpl;
|
||||||
|
|
||||||
|
// Memory Services
|
||||||
|
bs_impl::allocate_pages allocate_pages;
|
||||||
|
bs_impl::free_pages free_pages;
|
||||||
|
bs_impl::get_memory_map get_memory_map;
|
||||||
|
bs_impl::allocate_pool allocate_pool;
|
||||||
|
bs_impl::free_pool free_pool;
|
||||||
|
|
||||||
|
// Event & Timer Services
|
||||||
|
bs_impl::create_event create_event;
|
||||||
|
void *set_timer;
|
||||||
|
void *wait_for_event;
|
||||||
|
void *signal_event;
|
||||||
|
void *close_event;
|
||||||
|
void *check_event;
|
||||||
|
|
||||||
|
// Protocol Handler Services
|
||||||
|
void *install_protocol_interface;
|
||||||
|
void *reinstall_protocol_interface;
|
||||||
|
void *uninstall_protocol_interface;
|
||||||
|
bs_impl::handle_protocol handle_protocol;
|
||||||
|
void *_reserved;
|
||||||
|
void *register_protocol_notify;
|
||||||
|
void *locate_handle;
|
||||||
|
void *locate_device_path;
|
||||||
|
void *install_configuration_table;
|
||||||
|
|
||||||
|
// Image Services
|
||||||
|
void *load_image;
|
||||||
|
void *start_image;
|
||||||
|
void *exit;
|
||||||
|
void *unload_image;
|
||||||
|
bs_impl::exit_boot_services exit_boot_services;
|
||||||
|
|
||||||
|
// Miscellaneous Services
|
||||||
|
void *get_next_monotonic_count;
|
||||||
|
void *stall;
|
||||||
|
void *set_watchdog_timer;
|
||||||
|
|
||||||
|
// DriverSupport Services
|
||||||
|
void *connect_controller;
|
||||||
|
void *disconnect_controller;
|
||||||
|
|
||||||
|
// Open and Close Protocol Services
|
||||||
|
void *open_protocol;
|
||||||
|
void *close_protocol;
|
||||||
|
void *open_protocol_information;
|
||||||
|
|
||||||
|
// Library Services
|
||||||
|
void *protocols_per_handle;
|
||||||
|
void *locate_handle_buffer;
|
||||||
|
bs_impl::locate_protocol locate_protocol;
|
||||||
|
void *install_multiple_protocol_interfaces;
|
||||||
|
void *uninstall_multiple_protocol_interfaces;
|
||||||
|
|
||||||
|
// 32-bit CRC Services
|
||||||
|
void *calculate_crc32;
|
||||||
|
|
||||||
|
// Miscellaneous Services
|
||||||
|
bs_impl::copy_mem copy_mem;
|
||||||
|
bs_impl::set_mem set_mem;
|
||||||
|
void *create_event_ex;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif
|
||||||
39
external/uefi/errors.inc
vendored
Normal file
39
external/uefi/errors.inc
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
STATUS_WARNING( warn_unknown_glyph, 1)
|
||||||
|
STATUS_WARNING( warn_delete_failure, 2)
|
||||||
|
STATUS_WARNING( warn_write_failure, 3)
|
||||||
|
STATUS_WARNING( warn_buffer_too_small,4)
|
||||||
|
STATUS_WARNING( warn_stale_data, 5)
|
||||||
|
STATUS_WARNING( warn_file_system, 6)
|
||||||
|
|
||||||
|
STATUS_ERROR( load_error, 1)
|
||||||
|
STATUS_ERROR( invalid_parameter, 2)
|
||||||
|
STATUS_ERROR( unsupported, 3)
|
||||||
|
STATUS_ERROR( bad_buffer_size, 4)
|
||||||
|
STATUS_ERROR( buffer_too_small, 5)
|
||||||
|
STATUS_ERROR( not_ready, 6)
|
||||||
|
STATUS_ERROR( device_error, 7)
|
||||||
|
STATUS_ERROR( write_protected, 8)
|
||||||
|
STATUS_ERROR( out_of_resources, 9)
|
||||||
|
STATUS_ERROR( volume_corrupted, 10)
|
||||||
|
STATUS_ERROR( volume_full, 11)
|
||||||
|
STATUS_ERROR( no_media, 12)
|
||||||
|
STATUS_ERROR( media_changed, 13)
|
||||||
|
STATUS_ERROR( not_found, 14)
|
||||||
|
STATUS_ERROR( access_denied, 15)
|
||||||
|
STATUS_ERROR( no_response, 16)
|
||||||
|
STATUS_ERROR( no_mapping, 17)
|
||||||
|
STATUS_ERROR( timeout, 18)
|
||||||
|
STATUS_ERROR( not_started, 19)
|
||||||
|
STATUS_ERROR( already_started, 20)
|
||||||
|
STATUS_ERROR( aborted, 21)
|
||||||
|
STATUS_ERROR( icmp_error, 22)
|
||||||
|
STATUS_ERROR( tftp_error, 23)
|
||||||
|
STATUS_ERROR( protocol_error, 24)
|
||||||
|
STATUS_ERROR( incompatible_version, 25)
|
||||||
|
STATUS_ERROR( security_violation, 26)
|
||||||
|
STATUS_ERROR( crc_error, 27)
|
||||||
|
STATUS_ERROR( end_of_media, 28)
|
||||||
|
STATUS_ERROR( end_of_file, 31)
|
||||||
|
STATUS_ERROR( invalid_language, 32)
|
||||||
|
STATUS_ERROR( compromised_data, 33)
|
||||||
|
STATUS_ERROR( http_error, 35)
|
||||||
92
external/uefi/graphics.h
vendored
Normal file
92
external/uefi/graphics.h
vendored
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_graphics_h_
|
||||||
|
#define _uefi_graphics_h_
|
||||||
|
|
||||||
|
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||||
|
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||||
|
// not distributed with this file, You can obtain one at
|
||||||
|
// http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
|
||||||
|
struct text_output_mode
|
||||||
|
{
|
||||||
|
int32_t max_mode;
|
||||||
|
int32_t mode;
|
||||||
|
int32_t attribute;
|
||||||
|
int32_t cursor_column;
|
||||||
|
int32_t cursor_row;
|
||||||
|
bool cursor_visible;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pixel_bitmask
|
||||||
|
{
|
||||||
|
uint32_t red_mask;
|
||||||
|
uint32_t green_mask;
|
||||||
|
uint32_t blue_mask;
|
||||||
|
uint32_t reserved_mask;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class pixel_format
|
||||||
|
{
|
||||||
|
rgb8,
|
||||||
|
bgr8,
|
||||||
|
bitmask,
|
||||||
|
blt_only
|
||||||
|
};
|
||||||
|
|
||||||
|
struct graphics_output_mode_info
|
||||||
|
{
|
||||||
|
uint32_t version;
|
||||||
|
uint32_t horizontal_resolution;
|
||||||
|
uint32_t vertical_resolution;
|
||||||
|
pixel_format pixel_format;
|
||||||
|
pixel_bitmask pixel_information;
|
||||||
|
uint32_t pixels_per_scanline;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct graphics_output_mode
|
||||||
|
{
|
||||||
|
uint32_t max_mode;
|
||||||
|
uint32_t mode;
|
||||||
|
graphics_output_mode_info *info;
|
||||||
|
uint64_t size_of_info;
|
||||||
|
uintptr_t frame_buffer_base;
|
||||||
|
uint64_t frame_buffer_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class attribute : uint64_t
|
||||||
|
{
|
||||||
|
black,
|
||||||
|
blue,
|
||||||
|
green,
|
||||||
|
cyan,
|
||||||
|
red,
|
||||||
|
magenta,
|
||||||
|
brown,
|
||||||
|
light_gray,
|
||||||
|
dark_gray,
|
||||||
|
light_blue,
|
||||||
|
light_green,
|
||||||
|
light_cyan,
|
||||||
|
light_red,
|
||||||
|
light_magenta,
|
||||||
|
yellow,
|
||||||
|
white,
|
||||||
|
|
||||||
|
background_black = 0x00,
|
||||||
|
background_blue = 0x10,
|
||||||
|
background_green = 0x20,
|
||||||
|
background_cyan = 0x30,
|
||||||
|
background_red = 0x40,
|
||||||
|
background_magenta = 0x50,
|
||||||
|
background_brown = 0x60,
|
||||||
|
background_light_gray = 0x70,
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif
|
||||||
29
external/uefi/guid.h
vendored
Normal file
29
external/uefi/guid.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_guid_h_
|
||||||
|
#define _uefi_guid_h_
|
||||||
|
|
||||||
|
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||||
|
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||||
|
// not distributed with this file, You can obtain one at
|
||||||
|
// http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
|
||||||
|
struct guid
|
||||||
|
{
|
||||||
|
uint32_t data1;
|
||||||
|
uint16_t data2;
|
||||||
|
uint16_t data3;
|
||||||
|
uint8_t data4[8];
|
||||||
|
|
||||||
|
inline bool operator==(const guid &other) const {
|
||||||
|
return reinterpret_cast<const uint64_t*>(this)[0] == reinterpret_cast<const uint64_t*>(&other)[0]
|
||||||
|
&& reinterpret_cast<const uint64_t*>(this)[1] == reinterpret_cast<const uint64_t*>(&other)[1];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif
|
||||||
390
external/uefi/networking.h
vendored
Normal file
390
external/uefi/networking.h
vendored
Normal file
@@ -0,0 +1,390 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_networking_h_
|
||||||
|
#define _uefi_networking_h_
|
||||||
|
|
||||||
|
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||||
|
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||||
|
// not distributed with this file, You can obtain one at
|
||||||
|
// http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
|
||||||
|
//
|
||||||
|
// IPv4 definitions
|
||||||
|
//
|
||||||
|
struct ipv4_address
|
||||||
|
{
|
||||||
|
uint8_t addr[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// IPv6 definitions
|
||||||
|
//
|
||||||
|
struct ipv6_address
|
||||||
|
{
|
||||||
|
uint8_t addr[16];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_address_info
|
||||||
|
{
|
||||||
|
ipv6_address address;
|
||||||
|
uint8_t prefix_length;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_route_table
|
||||||
|
{
|
||||||
|
ipv6_address gateway;
|
||||||
|
ipv6_address destination;
|
||||||
|
uint8_t prefix_length;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ip6_neighbor_state : int {
|
||||||
|
incomplete,
|
||||||
|
reachable,
|
||||||
|
stale,
|
||||||
|
delay,
|
||||||
|
probe,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ip6_neighbor_cache
|
||||||
|
{
|
||||||
|
ipv6_address neighbor;
|
||||||
|
mac_address link_address;
|
||||||
|
ip6_neighbor_state state;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class icmpv6_type : uint8_t
|
||||||
|
{
|
||||||
|
dest_unreachable = 0x1,
|
||||||
|
packet_too_big = 0x2,
|
||||||
|
time_exceeded = 0x3,
|
||||||
|
parameter_problem = 0x4,
|
||||||
|
echo_request = 0x80,
|
||||||
|
echo_reply = 0x81,
|
||||||
|
listener_query = 0x82,
|
||||||
|
listener_report = 0x83,
|
||||||
|
listener_done = 0x84,
|
||||||
|
router_solicit = 0x85,
|
||||||
|
router_advertise = 0x86,
|
||||||
|
neighbor_solicit = 0x87,
|
||||||
|
neighbor_advertise = 0x88,
|
||||||
|
redirect = 0x89,
|
||||||
|
listener_report_2 = 0x8f,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class icmpv6_code : uint8_t
|
||||||
|
{
|
||||||
|
// codes for icmpv6_type::dest_unreachable
|
||||||
|
no_route_to_dest = 0x0,
|
||||||
|
comm_prohibited = 0x1,
|
||||||
|
beyond_scope = 0x2,
|
||||||
|
addr_unreachable = 0x3,
|
||||||
|
port_unreachable = 0x4,
|
||||||
|
source_addr_failed = 0x5,
|
||||||
|
route_rejected = 0x6,
|
||||||
|
|
||||||
|
// codes for icmpv6_type::time_exceeded
|
||||||
|
timeout_hop_limit = 0x0,
|
||||||
|
timeout_reassemble = 0x1,
|
||||||
|
|
||||||
|
// codes for icmpv6_type::parameter_problem
|
||||||
|
erroneous_header = 0x0,
|
||||||
|
unrecognize_next_hdr = 0x1,
|
||||||
|
unrecognize_option = 0x2,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_icmp_type
|
||||||
|
{
|
||||||
|
icmpv6_type type;
|
||||||
|
icmpv6_code code;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_config_data
|
||||||
|
{
|
||||||
|
uint8_t default_protocol;
|
||||||
|
bool accept_any_protocol;
|
||||||
|
bool accept_icmp_errors;
|
||||||
|
bool accept_promiscuous;
|
||||||
|
ipv6_address destination_address;
|
||||||
|
ipv6_address station_address;
|
||||||
|
uint8_t traffic_class;
|
||||||
|
uint8_t hop_limit;
|
||||||
|
uint32_t flow_label;
|
||||||
|
uint32_t receive_timeout;
|
||||||
|
uint32_t transmit_timeout;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_mode_data
|
||||||
|
{
|
||||||
|
bool is_started;
|
||||||
|
uint32_t max_packet_size;
|
||||||
|
ip6_config_data config_data;
|
||||||
|
bool is_configured;
|
||||||
|
uint32_t address_count;
|
||||||
|
ip6_address_info * address_list;
|
||||||
|
uint32_t group_count;
|
||||||
|
ipv6_address * group_table;
|
||||||
|
uint32_t route_count;
|
||||||
|
ip6_route_table * route_table;
|
||||||
|
uint32_t neighbor_count;
|
||||||
|
ip6_neighbor_cache * neighbor_cache;
|
||||||
|
uint32_t prefix_count;
|
||||||
|
ip6_address_info * prefix_table;
|
||||||
|
uint32_t icmp_type_count;
|
||||||
|
* icmp_type_list;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_header
|
||||||
|
{
|
||||||
|
uint8_t traffic_class_h : 4;
|
||||||
|
uint8_t version : 4;
|
||||||
|
uint8_t flow_label_h : 4;
|
||||||
|
uint8_t traffic_class_l : 4;
|
||||||
|
uint16_t flow_label_l;
|
||||||
|
uint16_t payload_length;
|
||||||
|
uint8_t next_header;
|
||||||
|
uint8_t hop_limit;
|
||||||
|
ipv6_address source_address;
|
||||||
|
ipv6_address destination_address;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct ip6_fragment_data
|
||||||
|
{
|
||||||
|
uint32_t fragment_length;
|
||||||
|
void *fragment_buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_override_data
|
||||||
|
{
|
||||||
|
uint8_t protocol;
|
||||||
|
uint8_t hop_limit;
|
||||||
|
uint32_t flow_label;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_receive_data
|
||||||
|
{
|
||||||
|
time time_stamp;
|
||||||
|
event recycle_signal;
|
||||||
|
uint32_t header_length;
|
||||||
|
ip6_header *header;
|
||||||
|
uint32_t data_length;
|
||||||
|
uint32_t fragment_count;
|
||||||
|
ip6_fragment_data fragment_table[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_transmit_data
|
||||||
|
{
|
||||||
|
ipv6_address destination_address;
|
||||||
|
ip6_override_data *override_data;
|
||||||
|
|
||||||
|
uint32_t ext_hdrs_length;
|
||||||
|
void *ext_hdrs;
|
||||||
|
uint8_t next_header;
|
||||||
|
uint32_t data_length;
|
||||||
|
uint32_t fragment_count;
|
||||||
|
ip6_fragment_data fragment_table[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_completion_token
|
||||||
|
{
|
||||||
|
event event;
|
||||||
|
status status;
|
||||||
|
union {
|
||||||
|
ip6_receive_data *rx_data;
|
||||||
|
ip6_transmit_data *tx_data;
|
||||||
|
} packet;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ip6_config_data_type : int
|
||||||
|
{
|
||||||
|
interface_info,
|
||||||
|
alt_interface_id,
|
||||||
|
policy,
|
||||||
|
dup_addr_detect_transmits,
|
||||||
|
manual_address,
|
||||||
|
gateway,
|
||||||
|
dns_server,
|
||||||
|
maximum
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_config_interface_info
|
||||||
|
{
|
||||||
|
wchar_t name[32];
|
||||||
|
uint8_t if_type;
|
||||||
|
uint32_t hw_address_size;
|
||||||
|
mac_address hw_address;
|
||||||
|
uint32_t address_info_count;
|
||||||
|
ip6_address_info *address_info;
|
||||||
|
uint32_t route_count;
|
||||||
|
ip6_route_table *route_table;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_config_interface_id
|
||||||
|
{
|
||||||
|
uint8_t id[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ip6_config_policy : int
|
||||||
|
{
|
||||||
|
manual,
|
||||||
|
automatic
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_config_dup_addr_detect_transmits
|
||||||
|
{
|
||||||
|
uint32_t dup_addr_detect_transmits;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ip6_config_manual_address
|
||||||
|
{
|
||||||
|
ipv6_address address;
|
||||||
|
bool is_anycast;
|
||||||
|
uint8_t prefix_length;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// IP definitions
|
||||||
|
//
|
||||||
|
union ip_address
|
||||||
|
{
|
||||||
|
uint8_t addr[4];
|
||||||
|
ipv4_address v4;
|
||||||
|
ipv6_address v6;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// HTTP definitions
|
||||||
|
//
|
||||||
|
struct httpv4_access_point
|
||||||
|
{
|
||||||
|
bool use_default_address;
|
||||||
|
ipv4_address local_address;
|
||||||
|
ipv4_address local_subnet;
|
||||||
|
uint16_t local_port;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct httpv6_access_point
|
||||||
|
{
|
||||||
|
ipv6_address local_address;
|
||||||
|
uint16_t local_port;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class http_version : int {
|
||||||
|
v10,
|
||||||
|
v11,
|
||||||
|
unsupported,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct http_config_data
|
||||||
|
{
|
||||||
|
http_version http_version;
|
||||||
|
uint32_t time_out_millisec;
|
||||||
|
bool local_address_is_ipv6;
|
||||||
|
union {
|
||||||
|
httpv4_access_point *ipv4_node;
|
||||||
|
httpv6_access_point *ipv6_node;
|
||||||
|
} access_point;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class http_method : int {
|
||||||
|
get,
|
||||||
|
post,
|
||||||
|
patch,
|
||||||
|
options,
|
||||||
|
connect,
|
||||||
|
head,
|
||||||
|
put,
|
||||||
|
delete_,
|
||||||
|
trace,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct http_request_data
|
||||||
|
{
|
||||||
|
http_method method;
|
||||||
|
wchar_t *url;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class http_status_code : int {
|
||||||
|
unsupported,
|
||||||
|
continue_,
|
||||||
|
switching_protocols,
|
||||||
|
ok,
|
||||||
|
created,
|
||||||
|
accepted,
|
||||||
|
non_authoritative_information,
|
||||||
|
no_content,
|
||||||
|
reset_content,
|
||||||
|
partial_content,
|
||||||
|
multiple_choices,
|
||||||
|
moved_permanently,
|
||||||
|
found,
|
||||||
|
see_other,
|
||||||
|
not_modified,
|
||||||
|
use_proxy,
|
||||||
|
temporary_redirect,
|
||||||
|
bad_request,
|
||||||
|
unauthorized,
|
||||||
|
payment_required,
|
||||||
|
forbidden,
|
||||||
|
not_found,
|
||||||
|
method_not_allowed,
|
||||||
|
not_acceptable,
|
||||||
|
proxy_authentication_required,
|
||||||
|
request_time_out,
|
||||||
|
conflict,
|
||||||
|
gone,
|
||||||
|
length_required,
|
||||||
|
precondition_failed,
|
||||||
|
request_entity_too_large,
|
||||||
|
request_uri_too_large,
|
||||||
|
unsupported_media_type,
|
||||||
|
requested_range_not_satisfied,
|
||||||
|
expectation_failed,
|
||||||
|
internal_server_error,
|
||||||
|
not_implemented,
|
||||||
|
bad_gateway,
|
||||||
|
service_unavailable,
|
||||||
|
gateway_timeout,
|
||||||
|
http_version_not_supported,
|
||||||
|
permanent_redirect, // I hate your decisions, uefi.
|
||||||
|
};
|
||||||
|
|
||||||
|
struct http_response_data
|
||||||
|
{
|
||||||
|
http_status_code status_code;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct http_header
|
||||||
|
{
|
||||||
|
char *field_name;
|
||||||
|
char *field_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct http_message
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
http_request_data *request;
|
||||||
|
http_response_data *response;
|
||||||
|
} data;
|
||||||
|
|
||||||
|
size_t header_count;
|
||||||
|
http_header *headers;
|
||||||
|
|
||||||
|
size_t body_length;
|
||||||
|
void *body;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct http_token
|
||||||
|
{
|
||||||
|
event event;
|
||||||
|
status status;
|
||||||
|
http_message *message;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif
|
||||||
31
external/uefi/protos/device_path.h
vendored
Normal file
31
external/uefi/protos/device_path.h
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_device_path_h_
|
||||||
|
#define _uefi_protos_device_path_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct device_path;
|
||||||
|
|
||||||
|
struct device_path
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x09576e91,0x6d3f,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t sub_type;
|
||||||
|
uint16_t length;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_device_path_h_
|
||||||
126
external/uefi/protos/file.h
vendored
Normal file
126
external/uefi/protos/file.h
vendored
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_file_h_
|
||||||
|
#define _uefi_protos_file_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct file;
|
||||||
|
|
||||||
|
struct file
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status open(file ** new_handle, const wchar_t * file_name, file_mode open_mode, file_attr attributes) {
|
||||||
|
return _open(this, new_handle, file_name, open_mode, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status close() {
|
||||||
|
return _close(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status delete_file() {
|
||||||
|
return _delete_file(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status read(uint64_t * buffer_size, void * buffer) {
|
||||||
|
return _read(this, buffer_size, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status write(uint64_t * buffer_size, void * buffer) {
|
||||||
|
return _write(this, buffer_size, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status get_position(uint64_t * position) {
|
||||||
|
return _get_position(this, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status set_position(uint64_t position) {
|
||||||
|
return _set_position(this, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status get_info(const guid * info_type, uint64_t * buffer_size, void * buffer) {
|
||||||
|
return _get_info(this, info_type, buffer_size, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status set_info(const guid * info_type, uint64_t buffer_size, void * buffer) {
|
||||||
|
return _set_info(this, info_type, buffer_size, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status flush() {
|
||||||
|
return _flush(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status open_ex(file ** new_handle, const wchar_t * file_name, uint64_t open_mode, uint64_t attributes, file_io_token * token) {
|
||||||
|
return _open_ex(this, new_handle, file_name, open_mode, attributes, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status read_ex(file_io_token * token) {
|
||||||
|
return _read_ex(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status write_ex(file_io_token * token) {
|
||||||
|
return _write_ex(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status flush_ex(file_io_token * token) {
|
||||||
|
return _flush_ex(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t revision;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _open_def = uefi::status (*)(uefi::protos::file *, file **, const wchar_t *, file_mode, file_attr);
|
||||||
|
_open_def _open;
|
||||||
|
|
||||||
|
using _close_def = uefi::status (*)(uefi::protos::file *);
|
||||||
|
_close_def _close;
|
||||||
|
|
||||||
|
using _delete_file_def = uefi::status (*)(uefi::protos::file *);
|
||||||
|
_delete_file_def _delete_file;
|
||||||
|
|
||||||
|
using _read_def = uefi::status (*)(uefi::protos::file *, uint64_t *, void *);
|
||||||
|
_read_def _read;
|
||||||
|
|
||||||
|
using _write_def = uefi::status (*)(uefi::protos::file *, uint64_t *, void *);
|
||||||
|
_write_def _write;
|
||||||
|
|
||||||
|
using _get_position_def = uefi::status (*)(uefi::protos::file *, uint64_t *);
|
||||||
|
_get_position_def _get_position;
|
||||||
|
|
||||||
|
using _set_position_def = uefi::status (*)(uefi::protos::file *, uint64_t);
|
||||||
|
_set_position_def _set_position;
|
||||||
|
|
||||||
|
using _get_info_def = uefi::status (*)(uefi::protos::file *, const guid *, uint64_t *, void *);
|
||||||
|
_get_info_def _get_info;
|
||||||
|
|
||||||
|
using _set_info_def = uefi::status (*)(uefi::protos::file *, const guid *, uint64_t, void *);
|
||||||
|
_set_info_def _set_info;
|
||||||
|
|
||||||
|
using _flush_def = uefi::status (*)(uefi::protos::file *);
|
||||||
|
_flush_def _flush;
|
||||||
|
|
||||||
|
using _open_ex_def = uefi::status (*)(uefi::protos::file *, file **, const wchar_t *, uint64_t, uint64_t, file_io_token *);
|
||||||
|
_open_ex_def _open_ex;
|
||||||
|
|
||||||
|
using _read_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *);
|
||||||
|
_read_ex_def _read_ex;
|
||||||
|
|
||||||
|
using _write_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *);
|
||||||
|
_write_ex_def _write_ex;
|
||||||
|
|
||||||
|
using _flush_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *);
|
||||||
|
_flush_ex_def _flush_ex;
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_file_h_
|
||||||
36
external/uefi/protos/file_info.h
vendored
Normal file
36
external/uefi/protos/file_info.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_file_info_h_
|
||||||
|
#define _uefi_protos_file_info_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct file_info;
|
||||||
|
|
||||||
|
struct file_info
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x09576e92,0x6d3f,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t size;
|
||||||
|
uint64_t file_size;
|
||||||
|
uint64_t physical_size;
|
||||||
|
time create_time;
|
||||||
|
time last_access_time;
|
||||||
|
time modification_time;
|
||||||
|
uint64_t attribute;
|
||||||
|
wchar_t file_name[];
|
||||||
|
|
||||||
|
protected:
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_file_info_h_
|
||||||
51
external/uefi/protos/graphics_output.h
vendored
Normal file
51
external/uefi/protos/graphics_output.h
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_graphics_output_h_
|
||||||
|
#define _uefi_protos_graphics_output_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
#include <uefi/graphics.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct graphics_output;
|
||||||
|
|
||||||
|
struct graphics_output
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x9042a9de,0x23dc,0x4a38,{0x96,0xfb,0x7a,0xde,0xd0,0x80,0x51,0x6a} };
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status query_mode(uint32_t mode_number, uint64_t * size_of_info, uefi::graphics_output_mode_info ** info) {
|
||||||
|
return _query_mode(this, mode_number, size_of_info, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status set_mode(uint32_t mode_number) {
|
||||||
|
return _set_mode(this, mode_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status blt() {
|
||||||
|
return _blt(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _query_mode_def = uefi::status (*)(uefi::protos::graphics_output *, uint32_t, uint64_t *, uefi::graphics_output_mode_info **);
|
||||||
|
_query_mode_def _query_mode;
|
||||||
|
|
||||||
|
using _set_mode_def = uefi::status (*)(uefi::protos::graphics_output *, uint32_t);
|
||||||
|
_set_mode_def _set_mode;
|
||||||
|
|
||||||
|
using _blt_def = uefi::status (*)(uefi::protos::graphics_output *);
|
||||||
|
_blt_def _blt;
|
||||||
|
|
||||||
|
public:
|
||||||
|
uefi::graphics_output_mode * mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_graphics_output_h_
|
||||||
72
external/uefi/protos/http.h
vendored
Normal file
72
external/uefi/protos/http.h
vendored
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_http_h_
|
||||||
|
#define _uefi_protos_http_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
#include <uefi/networking.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct http;
|
||||||
|
|
||||||
|
struct http
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x7a59b29b,0x910b,0x4171,{0x82,0x42,0xa8,0x5a,0x0d,0xf2,0x5b,0x5b} };
|
||||||
|
static constexpr uefi::guid service_binding{ 0xbdc8e6af,0xd9bc,0x4379,{0xa7,0x2a,0xe0,0xc4,0xe7,0x5d,0xae,0x1c} };
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status get_mode_data(uefi::http_config_data * http_config_data) {
|
||||||
|
return _get_mode_data(this, http_config_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status configure(uefi::http_config_data * http_config_data) {
|
||||||
|
return _configure(this, http_config_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status request(uefi::http_token * token) {
|
||||||
|
return _request(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status cancel(uefi::http_token * token) {
|
||||||
|
return _cancel(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status response(uefi::http_token * token) {
|
||||||
|
return _response(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status poll() {
|
||||||
|
return _poll(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _get_mode_data_def = uefi::status (*)(uefi::protos::http *, uefi::http_config_data *);
|
||||||
|
_get_mode_data_def _get_mode_data;
|
||||||
|
|
||||||
|
using _configure_def = uefi::status (*)(uefi::protos::http *, uefi::http_config_data *);
|
||||||
|
_configure_def _configure;
|
||||||
|
|
||||||
|
using _request_def = uefi::status (*)(uefi::protos::http *, uefi::http_token *);
|
||||||
|
_request_def _request;
|
||||||
|
|
||||||
|
using _cancel_def = uefi::status (*)(uefi::protos::http *, uefi::http_token *);
|
||||||
|
_cancel_def _cancel;
|
||||||
|
|
||||||
|
using _response_def = uefi::status (*)(uefi::protos::http *, uefi::http_token *);
|
||||||
|
_response_def _response;
|
||||||
|
|
||||||
|
using _poll_def = uefi::status (*)(uefi::protos::http *);
|
||||||
|
_poll_def _poll;
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_http_h_
|
||||||
93
external/uefi/protos/ip6.h
vendored
Normal file
93
external/uefi/protos/ip6.h
vendored
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_ip6_h_
|
||||||
|
#define _uefi_protos_ip6_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
#include <uefi/networking.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct ip6;
|
||||||
|
|
||||||
|
struct ip6
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x2c8759d5,0x5c2d,0x66ef,{0x92,0x5f,0xb6,0x6c,0x10,0x19,0x57,0xe2} };
|
||||||
|
static constexpr uefi::guid service_binding{ 0xec835dd3,0xfe0f,0x617b,{0xa6,0x21,0xb3,0x50,0xc3,0xe1,0x33,0x88} };
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status get_mode_data(uefi::ip6_mode_data * ip6_mode_data, uefi::managed_network_config_data * mnp_config_data, uefi::simple_network_mode * snp_config_data) {
|
||||||
|
return _get_mode_data(this, ip6_mode_data, mnp_config_data, snp_config_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status configure(uefi::ip6_config_data * ip6_config_data) {
|
||||||
|
return _configure(this, ip6_config_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status groups(bool join_flag, uefi::ipv6_address * group_address) {
|
||||||
|
return _groups(this, join_flag, group_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status routes(bool delete_route, uefi::ipv6_address * destination, uint8_t prefix_length, uefi::ipv6_address * gateway_address) {
|
||||||
|
return _routes(this, delete_route, destination, prefix_length, gateway_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status neighbors(bool delete_flag, uefi::ipv6_address * target_ip6_address, uefi::mac_address * target_link_address, uint32_t timeout, bool override) {
|
||||||
|
return _neighbors(this, delete_flag, target_ip6_address, target_link_address, timeout, override);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status transmit(uefi::ip6_completion_token * token) {
|
||||||
|
return _transmit(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status receive(uefi::ip6_completion_token * token) {
|
||||||
|
return _receive(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status cancel(uefi::ip6_completion_token * token) {
|
||||||
|
return _cancel(this, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status poll() {
|
||||||
|
return _poll(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _get_mode_data_def = uefi::status (*)(uefi::protos::ip6 *, uefi::ip6_mode_data *, uefi::managed_network_config_data *, uefi::simple_network_mode *);
|
||||||
|
_get_mode_data_def _get_mode_data;
|
||||||
|
|
||||||
|
using _configure_def = uefi::status (*)(uefi::protos::ip6 *, uefi::ip6_config_data *);
|
||||||
|
_configure_def _configure;
|
||||||
|
|
||||||
|
using _groups_def = uefi::status (*)(uefi::protos::ip6 *, bool, uefi::ipv6_address *);
|
||||||
|
_groups_def _groups;
|
||||||
|
|
||||||
|
using _routes_def = uefi::status (*)(uefi::protos::ip6 *, bool, uefi::ipv6_address *, uint8_t, uefi::ipv6_address *);
|
||||||
|
_routes_def _routes;
|
||||||
|
|
||||||
|
using _neighbors_def = uefi::status (*)(uefi::protos::ip6 *, bool, uefi::ipv6_address *, uefi::mac_address *, uint32_t, bool);
|
||||||
|
_neighbors_def _neighbors;
|
||||||
|
|
||||||
|
using _transmit_def = uefi::status (*)(uefi::protos::ip6 *, uefi::ip6_completion_token *);
|
||||||
|
_transmit_def _transmit;
|
||||||
|
|
||||||
|
using _receive_def = uefi::status (*)(uefi::protos::ip6 *, uefi::ip6_completion_token *);
|
||||||
|
_receive_def _receive;
|
||||||
|
|
||||||
|
using _cancel_def = uefi::status (*)(uefi::protos::ip6 *, uefi::ip6_completion_token *);
|
||||||
|
_cancel_def _cancel;
|
||||||
|
|
||||||
|
using _poll_def = uefi::status (*)(uefi::protos::ip6 *);
|
||||||
|
_poll_def _poll;
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_ip6_h_
|
||||||
57
external/uefi/protos/ip6_config.h
vendored
Normal file
57
external/uefi/protos/ip6_config.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_ip6_config_h_
|
||||||
|
#define _uefi_protos_ip6_config_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
#include <uefi/networking.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct ip6_config;
|
||||||
|
|
||||||
|
struct ip6_config
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x937fe521,0x95ae,0x4d1a,{0x89,0x29,0x48,0xbc,0xd9,0x0a,0xd3,0x1a} };
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status set_data(uefi::ip6_config_data_type data_type, size_t data_size, void * data) {
|
||||||
|
return _set_data(this, data_type, data_size, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status get_data(uefi::ip6_config_data_type data_type, size_t data_size, void * data) {
|
||||||
|
return _get_data(this, data_type, data_size, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status register_data_notify(uefi::ip6_config_data_type data_type, uefi::event event) {
|
||||||
|
return _register_data_notify(this, data_type, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status unregister_data_notify(uefi::ip6_config_data_type data_type, uefi::event event) {
|
||||||
|
return _unregister_data_notify(this, data_type, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _set_data_def = uefi::status (*)(uefi::protos::ip6_config *, uefi::ip6_config_data_type, size_t, void *);
|
||||||
|
_set_data_def _set_data;
|
||||||
|
|
||||||
|
using _get_data_def = uefi::status (*)(uefi::protos::ip6_config *, uefi::ip6_config_data_type, size_t, void *);
|
||||||
|
_get_data_def _get_data;
|
||||||
|
|
||||||
|
using _register_data_notify_def = uefi::status (*)(uefi::protos::ip6_config *, uefi::ip6_config_data_type, uefi::event);
|
||||||
|
_register_data_notify_def _register_data_notify;
|
||||||
|
|
||||||
|
using _unregister_data_notify_def = uefi::status (*)(uefi::protos::ip6_config *, uefi::ip6_config_data_type, uefi::event);
|
||||||
|
_unregister_data_notify_def _unregister_data_notify;
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_ip6_config_h_
|
||||||
36
external/uefi/protos/load_file.h
vendored
Normal file
36
external/uefi/protos/load_file.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_load_file_h_
|
||||||
|
#define _uefi_protos_load_file_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
#include <uefi/protos/device_path.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct load_file;
|
||||||
|
|
||||||
|
struct load_file
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ {0x56ec3091,0x954c,0x11d2,{0x8e,0x3f,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status load_file(uefi::protos::device_path * file_path, bool boot_policy, size_t * buffer_size, void * buffer) {
|
||||||
|
return _load_file(this, file_path, boot_policy, buffer_size, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _load_file_def = uefi::status (*)(uefi::protos::load_file *, uefi::protos::device_path *, bool, size_t *, void *);
|
||||||
|
_load_file_def _load_file;
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_load_file_h_
|
||||||
49
external/uefi/protos/loaded_image.h
vendored
Normal file
49
external/uefi/protos/loaded_image.h
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_loaded_image_h_
|
||||||
|
#define _uefi_protos_loaded_image_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
#include <uefi/tables.h>
|
||||||
|
#include <uefi/protos/device_path.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct loaded_image;
|
||||||
|
|
||||||
|
struct loaded_image
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x5b1b31a1,0x9562,0x11d2,{0x8e,0x3f,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status unload(uefi::handle image_handle) {
|
||||||
|
return _unload(image_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t revision;
|
||||||
|
uefi::handle parent_handle;
|
||||||
|
uefi::system_table * system_table;
|
||||||
|
uefi::handle device_handle;
|
||||||
|
uefi::protos::device_path * file_path;
|
||||||
|
void * reserved;
|
||||||
|
uint32_t load_options_size;
|
||||||
|
void * load_options;
|
||||||
|
void * image_base;
|
||||||
|
uint64_t image_size;
|
||||||
|
uefi::memory_type image_code_type;
|
||||||
|
uefi::memory_type image_data_type;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _unload_def = uefi::status (*)(uefi::handle);
|
||||||
|
_unload_def _unload;
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_loaded_image_h_
|
||||||
41
external/uefi/protos/service_binding.h
vendored
Normal file
41
external/uefi/protos/service_binding.h
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_service_binding_h_
|
||||||
|
#define _uefi_protos_service_binding_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct service_binding;
|
||||||
|
|
||||||
|
struct service_binding
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status create_child(uefi::handle * child_handle) {
|
||||||
|
return _create_child(this, child_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status destroy_child(uefi::handle child_handle) {
|
||||||
|
return _destroy_child(this, child_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _create_child_def = uefi::status (*)(uefi::protos::service_binding *, uefi::handle *);
|
||||||
|
_create_child_def _create_child;
|
||||||
|
|
||||||
|
using _destroy_child_def = uefi::status (*)(uefi::protos::service_binding *, uefi::handle);
|
||||||
|
_destroy_child_def _destroy_child;
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_service_binding_h_
|
||||||
37
external/uefi/protos/simple_file_system.h
vendored
Normal file
37
external/uefi/protos/simple_file_system.h
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_simple_file_system_h_
|
||||||
|
#define _uefi_protos_simple_file_system_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
#include <uefi/protos/file.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct simple_file_system;
|
||||||
|
|
||||||
|
struct simple_file_system
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x0964e5b22,0x6459,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status open_volume(uefi::protos::file ** root) {
|
||||||
|
return _open_volume(this, root);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t revision;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _open_volume_def = uefi::status (*)(uefi::protos::simple_file_system *, uefi::protos::file **);
|
||||||
|
_open_volume_def _open_volume;
|
||||||
|
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_simple_file_system_h_
|
||||||
93
external/uefi/protos/simple_text_output.h
vendored
Normal file
93
external/uefi/protos/simple_text_output.h
vendored
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_protos_simple_text_output_h_
|
||||||
|
#define _uefi_protos_simple_text_output_h_
|
||||||
|
|
||||||
|
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||||
|
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||||
|
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
#include <uefi/graphics.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace protos {
|
||||||
|
struct simple_text_output;
|
||||||
|
|
||||||
|
struct simple_text_output
|
||||||
|
{
|
||||||
|
static constexpr uefi::guid guid{ 0x387477c2,0x69c7,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||||
|
|
||||||
|
|
||||||
|
inline uefi::status reset(bool extended_verification) {
|
||||||
|
return _reset(this, extended_verification);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status output_string(const wchar_t * string) {
|
||||||
|
return _output_string(this, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status test_string(const wchar_t * string) {
|
||||||
|
return _test_string(this, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status query_mode(uint64_t mode_number, uint64_t * columns, uint64_t * rows) {
|
||||||
|
return _query_mode(this, mode_number, columns, rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status set_mode(uint64_t mode_number) {
|
||||||
|
return _set_mode(this, mode_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status set_attribute(uefi::attribute attribute) {
|
||||||
|
return _set_attribute(this, attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status clear_screen() {
|
||||||
|
return _clear_screen(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status set_cursor_position(uint64_t column, uint64_t row) {
|
||||||
|
return _set_cursor_position(this, column, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uefi::status enable_cursor(bool visible) {
|
||||||
|
return _enable_cursor(this, visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
using _reset_def = uefi::status (*)(uefi::protos::simple_text_output *, bool);
|
||||||
|
_reset_def _reset;
|
||||||
|
|
||||||
|
using _output_string_def = uefi::status (*)(uefi::protos::simple_text_output *, const wchar_t *);
|
||||||
|
_output_string_def _output_string;
|
||||||
|
|
||||||
|
using _test_string_def = uefi::status (*)(uefi::protos::simple_text_output *, const wchar_t *);
|
||||||
|
_test_string_def _test_string;
|
||||||
|
|
||||||
|
using _query_mode_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t, uint64_t *, uint64_t *);
|
||||||
|
_query_mode_def _query_mode;
|
||||||
|
|
||||||
|
using _set_mode_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t);
|
||||||
|
_set_mode_def _set_mode;
|
||||||
|
|
||||||
|
using _set_attribute_def = uefi::status (*)(uefi::protos::simple_text_output *, uefi::attribute);
|
||||||
|
_set_attribute_def _set_attribute;
|
||||||
|
|
||||||
|
using _clear_screen_def = uefi::status (*)(uefi::protos::simple_text_output *);
|
||||||
|
_clear_screen_def _clear_screen;
|
||||||
|
|
||||||
|
using _set_cursor_position_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t, uint64_t);
|
||||||
|
_set_cursor_position_def _set_cursor_position;
|
||||||
|
|
||||||
|
using _enable_cursor_def = uefi::status (*)(uefi::protos::simple_text_output *, bool);
|
||||||
|
_enable_cursor_def _enable_cursor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
uefi::text_output_mode * mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace protos
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif // _uefi_protos_simple_text_output_h_
|
||||||
52
external/uefi/runtime_services.h
vendored
Normal file
52
external/uefi/runtime_services.h
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_runtime_services_h_
|
||||||
|
#define _uefi_runtime_services_h_
|
||||||
|
|
||||||
|
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||||
|
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||||
|
// not distributed with this file, You can obtain one at
|
||||||
|
// http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <uefi/tables.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
namespace rs_impl {
|
||||||
|
using convert_pointer = uefi::status (*)(uint64_t, void **);
|
||||||
|
using set_virtual_address_map = uefi::status (*)(size_t, size_t, uint32_t, memory_descriptor *);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct runtime_services {
|
||||||
|
static constexpr uint64_t signature = 0x56524553544e5552ull;
|
||||||
|
|
||||||
|
table_header header;
|
||||||
|
|
||||||
|
// Time Services
|
||||||
|
void *get_time;
|
||||||
|
void *set_time;
|
||||||
|
void *get_wakeup_time;
|
||||||
|
void *set_wakeup_time;
|
||||||
|
|
||||||
|
// Virtual Memory Services
|
||||||
|
rs_impl::set_virtual_address_map set_virtual_address_map;
|
||||||
|
rs_impl::convert_pointer convert_pointer;
|
||||||
|
|
||||||
|
// Variable Services
|
||||||
|
void *get_variable;
|
||||||
|
void *get_next_variable_name;
|
||||||
|
void *set_variable;
|
||||||
|
|
||||||
|
// Miscellaneous Services
|
||||||
|
void *get_next_high_monotonic_count;
|
||||||
|
void *reset_system;
|
||||||
|
|
||||||
|
// UEFI 2.0 Capsule Services
|
||||||
|
void *update_capsule;
|
||||||
|
void *query_capsule_capabilities;
|
||||||
|
|
||||||
|
// Miscellaneous UEFI 2.0 Service
|
||||||
|
void *query_variable_info;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace uefi
|
||||||
|
#endif
|
||||||
73
external/uefi/tables.h
vendored
Normal file
73
external/uefi/tables.h
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_tables_h_
|
||||||
|
#define _uefi_tables_h_
|
||||||
|
|
||||||
|
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||||
|
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||||
|
// not distributed with this file, You can obtain one at
|
||||||
|
// http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <uefi/guid.h>
|
||||||
|
#include <uefi/types.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
|
||||||
|
struct runtime_services;
|
||||||
|
struct boot_services;
|
||||||
|
namespace protos {
|
||||||
|
struct simple_text_input;
|
||||||
|
struct simple_text_output;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct table_header
|
||||||
|
{
|
||||||
|
uint64_t signature;
|
||||||
|
uint32_t revision;
|
||||||
|
uint32_t header_size;
|
||||||
|
uint32_t crc32;
|
||||||
|
uint32_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct configuration_table
|
||||||
|
{
|
||||||
|
guid vendor_guid;
|
||||||
|
void *vendor_table;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct system_table
|
||||||
|
{
|
||||||
|
table_header header;
|
||||||
|
|
||||||
|
char16_t *firmware_vendor;
|
||||||
|
uint32_t firmware_revision;
|
||||||
|
|
||||||
|
handle console_in_handle;
|
||||||
|
protos::simple_text_input *con_in;
|
||||||
|
handle console_out_handle;
|
||||||
|
protos::simple_text_output *con_out;
|
||||||
|
handle standard_error_handle;
|
||||||
|
protos::simple_text_output *std_err;
|
||||||
|
|
||||||
|
runtime_services *runtime_services;
|
||||||
|
boot_services *boot_services;
|
||||||
|
|
||||||
|
unsigned int number_of_table_entries;
|
||||||
|
configuration_table *configuration_table;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr uint32_t make_system_table_revision(int major, int minor) {
|
||||||
|
return (major << 16) | minor;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr uint64_t system_table_signature = 0x5453595320494249ull;
|
||||||
|
constexpr uint32_t system_table_revision = make_system_table_revision(2, 70);
|
||||||
|
constexpr uint32_t specification_revision = system_table_revision;
|
||||||
|
|
||||||
|
namespace vendor_guids {
|
||||||
|
constexpr guid acpi1{ 0xeb9d2d30,0x2d88,0x11d3,{0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d} };
|
||||||
|
constexpr guid acpi2{ 0x8868e871,0xe4f1,0x11d3,{0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81} };
|
||||||
|
} // namespace vendor_guids
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif
|
||||||
157
external/uefi/types.h
vendored
Normal file
157
external/uefi/types.h
vendored
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _uefi_types_h_
|
||||||
|
#define _uefi_types_h_
|
||||||
|
|
||||||
|
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||||
|
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||||
|
// not distributed with this file, You can obtain one at
|
||||||
|
// http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace uefi {
|
||||||
|
|
||||||
|
using handle = void *;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Error and status code definitions
|
||||||
|
//
|
||||||
|
constexpr uint64_t error_bit = 0x8000000000000000ull;
|
||||||
|
constexpr uint64_t make_error(uint64_t e) { return e|error_bit; }
|
||||||
|
|
||||||
|
enum class status : uint64_t
|
||||||
|
{
|
||||||
|
success = 0,
|
||||||
|
|
||||||
|
#define STATUS_WARNING(name, num) name = num,
|
||||||
|
#define STATUS_ERROR(name, num) name = make_error(num),
|
||||||
|
#include "uefi/errors.inc"
|
||||||
|
#undef STATUS_WARNING
|
||||||
|
#undef STATUS_ERROR
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool is_error(status s) { return static_cast<uint64_t>(s) & error_bit; }
|
||||||
|
inline bool is_warning(status s) { return !is_error(s) && s != status::success; }
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Time defitions
|
||||||
|
//
|
||||||
|
struct time
|
||||||
|
{
|
||||||
|
uint16_t year;
|
||||||
|
uint8_t month;
|
||||||
|
uint8_t day;
|
||||||
|
uint8_t hour;
|
||||||
|
uint8_t minute;
|
||||||
|
uint8_t second;
|
||||||
|
uint8_t _pad0;
|
||||||
|
uint32_t nanosecond;
|
||||||
|
int16_t time_zone;
|
||||||
|
uint8_t daylight;
|
||||||
|
uint8_t _pad1;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Memory and allocation defitions
|
||||||
|
//
|
||||||
|
enum class memory_type : uint32_t
|
||||||
|
{
|
||||||
|
reserved,
|
||||||
|
loader_code,
|
||||||
|
loader_data,
|
||||||
|
boot_services_code,
|
||||||
|
boot_services_data,
|
||||||
|
runtime_services_code,
|
||||||
|
runtime_services_data,
|
||||||
|
conventional_memory,
|
||||||
|
unusable_memory,
|
||||||
|
acpi_reclaim_memory,
|
||||||
|
acpi_memory_nvs,
|
||||||
|
memory_mapped_io,
|
||||||
|
memory_mapped_io_port_space,
|
||||||
|
pal_code,
|
||||||
|
persistent_memory,
|
||||||
|
max_memory_type
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class allocate_type : uint32_t
|
||||||
|
{
|
||||||
|
any_pages,
|
||||||
|
max_address,
|
||||||
|
address
|
||||||
|
};
|
||||||
|
|
||||||
|
struct memory_descriptor
|
||||||
|
{
|
||||||
|
memory_type type;
|
||||||
|
uintptr_t physical_start;
|
||||||
|
uintptr_t virtual_start;
|
||||||
|
uint64_t number_of_pages;
|
||||||
|
uint64_t attribute;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Event handling defitions
|
||||||
|
//
|
||||||
|
using event = void *;
|
||||||
|
|
||||||
|
enum class evt : uint32_t
|
||||||
|
{
|
||||||
|
notify_wait = 0x00000100,
|
||||||
|
notify_signal = 0x00000200,
|
||||||
|
|
||||||
|
signal_exit_boot_services = 0x00000201,
|
||||||
|
signal_virtual_address_change = 0x60000202,
|
||||||
|
|
||||||
|
runtime = 0x40000000,
|
||||||
|
timer = 0x80000000
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class tpl : uint64_t
|
||||||
|
{
|
||||||
|
application = 4,
|
||||||
|
callback = 8,
|
||||||
|
notify = 16,
|
||||||
|
high_level = 31
|
||||||
|
};
|
||||||
|
|
||||||
|
using event_notify = void (*)(event, void*);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// File IO defitions
|
||||||
|
//
|
||||||
|
struct file_io_token
|
||||||
|
{
|
||||||
|
event event;
|
||||||
|
status status;
|
||||||
|
uint64_t buffer_size;
|
||||||
|
void *buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class file_mode : uint64_t
|
||||||
|
{
|
||||||
|
read = 0x0000000000000001ull,
|
||||||
|
write = 0x0000000000000002ull,
|
||||||
|
|
||||||
|
create = 0x8000000000000000ull
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class file_attr : uint64_t
|
||||||
|
{
|
||||||
|
none = 0,
|
||||||
|
read_only = 0x0000000000000001ull,
|
||||||
|
hidden = 0x0000000000000002ull,
|
||||||
|
system = 0x0000000000000004ull,
|
||||||
|
reserved = 0x0000000000000008ull,
|
||||||
|
directory = 0x0000000000000010ull,
|
||||||
|
archive = 0x0000000000000020ull
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace uefi
|
||||||
|
|
||||||
|
#endif
|
||||||
33
external/zstd.module
vendored
Normal file
33
external/zstd.module
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# vim: ft=python
|
||||||
|
|
||||||
|
zstd = module("zstd",
|
||||||
|
root = "${source_root}/external/zstd",
|
||||||
|
kind = "lib",
|
||||||
|
copy_headers = True,
|
||||||
|
deps = [ "libc" ],
|
||||||
|
sources = [
|
||||||
|
"decompress/zstd_decompress.c",
|
||||||
|
"decompress/zstd_ddict.c",
|
||||||
|
"decompress/huf_decompress.c",
|
||||||
|
"decompress/zstd_decompress_block.c",
|
||||||
|
"common/threading.c",
|
||||||
|
"common/fse_decompress.c",
|
||||||
|
"common/debug.c",
|
||||||
|
"common/xxhash.c",
|
||||||
|
"common/pool.c",
|
||||||
|
"common/error_private.c",
|
||||||
|
"common/entropy_common.c",
|
||||||
|
"common/zstd_common.c",
|
||||||
|
],
|
||||||
|
public_headers = [
|
||||||
|
"zdict.h",
|
||||||
|
"zstd.h",
|
||||||
|
"zstd_errors.h",
|
||||||
|
])
|
||||||
|
|
||||||
|
zstd.variables['ccflags'] = [
|
||||||
|
"${ccflags}",
|
||||||
|
"-DXXH_NAMESPACE=ZSTD_",
|
||||||
|
"-DDEBUGLEVEL=0",
|
||||||
|
"-DZSTD_DISABLE_ASM",
|
||||||
|
]
|
||||||
3
external/zstd/.gitignore
vendored
Normal file
3
external/zstd/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# make install artefact
|
||||||
|
libzstd.pc
|
||||||
|
libzstd-nomt
|
||||||
232
external/zstd/BUCK
vendored
Normal file
232
external/zstd/BUCK
vendored
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
cxx_library(
|
||||||
|
name='zstd',
|
||||||
|
header_namespace='',
|
||||||
|
exported_headers=['zstd.h'],
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
deps=[
|
||||||
|
':common',
|
||||||
|
':compress',
|
||||||
|
':decompress',
|
||||||
|
':deprecated',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='compress',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('compress', 'zstd*.h'),
|
||||||
|
]),
|
||||||
|
srcs=glob(['compress/zstd*.c', 'compress/hist.c']),
|
||||||
|
deps=[':common'],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='decompress',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
headers=subdir_glob([
|
||||||
|
('decompress', '*_impl.h'),
|
||||||
|
]),
|
||||||
|
srcs=glob(['decompress/zstd*.c']),
|
||||||
|
deps=[
|
||||||
|
':common',
|
||||||
|
':legacy',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='deprecated',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('deprecated', '*.h'),
|
||||||
|
]),
|
||||||
|
srcs=glob(['deprecated/*.c']),
|
||||||
|
deps=[':common'],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='legacy',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('legacy', '*.h'),
|
||||||
|
]),
|
||||||
|
srcs=glob(['legacy/*.c']),
|
||||||
|
deps=[':common'],
|
||||||
|
exported_preprocessor_flags=[
|
||||||
|
'-DZSTD_LEGACY_SUPPORT=4',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='zdict',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=['zdict.h'],
|
||||||
|
headers=subdir_glob([
|
||||||
|
('dictBuilder', 'divsufsort.h'),
|
||||||
|
('dictBuilder', 'cover.h'),
|
||||||
|
]),
|
||||||
|
srcs=glob(['dictBuilder/*.c']),
|
||||||
|
deps=[':common'],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='compiler',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'compiler.h'),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='cpu',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'cpu.h'),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='bitstream',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'bitstream.h'),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='entropy',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'fse.h'),
|
||||||
|
('common', 'huf.h'),
|
||||||
|
]),
|
||||||
|
srcs=[
|
||||||
|
'common/entropy_common.c',
|
||||||
|
'common/fse_decompress.c',
|
||||||
|
'compress/fse_compress.c',
|
||||||
|
'compress/huf_compress.c',
|
||||||
|
'decompress/huf_decompress.c',
|
||||||
|
],
|
||||||
|
deps=[
|
||||||
|
':debug',
|
||||||
|
':bitstream',
|
||||||
|
':compiler',
|
||||||
|
':errors',
|
||||||
|
':mem',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='errors',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=[
|
||||||
|
'zstd_errors.h',
|
||||||
|
'common/error_private.h',
|
||||||
|
]
|
||||||
|
srcs=['common/error_private.c'],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='mem',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'mem.h'),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='pool',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'pool.h'),
|
||||||
|
]),
|
||||||
|
srcs=['common/pool.c'],
|
||||||
|
deps=[
|
||||||
|
':threading',
|
||||||
|
':zstd_common',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='threading',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'threading.h'),
|
||||||
|
]),
|
||||||
|
srcs=['common/threading.c'],
|
||||||
|
exported_preprocessor_flags=[
|
||||||
|
'-DZSTD_MULTITHREAD',
|
||||||
|
],
|
||||||
|
exported_linker_flags=[
|
||||||
|
'-pthread',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='xxhash',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'xxhash.h'),
|
||||||
|
]),
|
||||||
|
srcs=['common/xxhash.c'],
|
||||||
|
exported_preprocessor_flags=[
|
||||||
|
'-DXXH_NAMESPACE=ZSTD_',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='zstd_common',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('', 'zstd.h'),
|
||||||
|
('common', 'zstd_internal.h'),
|
||||||
|
]),
|
||||||
|
srcs=['common/zstd_common.c'],
|
||||||
|
deps=[
|
||||||
|
':compiler',
|
||||||
|
':errors',
|
||||||
|
':mem',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='debug',
|
||||||
|
header_namespace='',
|
||||||
|
visibility=['PUBLIC'],
|
||||||
|
exported_headers=subdir_glob([
|
||||||
|
('common', 'debug.h'),
|
||||||
|
]),
|
||||||
|
srcs=['common/debug.c'],
|
||||||
|
)
|
||||||
|
|
||||||
|
cxx_library(
|
||||||
|
name='common',
|
||||||
|
deps=[
|
||||||
|
':debug',
|
||||||
|
':bitstream',
|
||||||
|
':compiler',
|
||||||
|
':cpu',
|
||||||
|
':entropy',
|
||||||
|
':errors',
|
||||||
|
':mem',
|
||||||
|
':pool',
|
||||||
|
':threading',
|
||||||
|
':xxhash',
|
||||||
|
':zstd_common',
|
||||||
|
]
|
||||||
|
)
|
||||||
30
external/zstd/LICENSE
vendored
Normal file
30
external/zstd/LICENSE
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
BSD License
|
||||||
|
|
||||||
|
For Zstandard software
|
||||||
|
|
||||||
|
Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
* Neither the name Facebook, nor Meta, nor the names of its contributors may
|
||||||
|
be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
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 HOLDER 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.
|
||||||
357
external/zstd/Makefile
vendored
Normal file
357
external/zstd/Makefile
vendored
Normal file
@@ -0,0 +1,357 @@
|
|||||||
|
# ################################################################
|
||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under both the BSD-style license (found in the
|
||||||
|
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
# in the COPYING file in the root directory of this source tree).
|
||||||
|
# You may select, at your option, one of the above-listed licenses.
|
||||||
|
# ################################################################
|
||||||
|
|
||||||
|
# Modules
|
||||||
|
ZSTD_LIB_COMPRESSION ?= 1
|
||||||
|
ZSTD_LIB_DECOMPRESSION ?= 1
|
||||||
|
ZSTD_LIB_DICTBUILDER ?= 1
|
||||||
|
ZSTD_LIB_DEPRECATED ?= 0
|
||||||
|
|
||||||
|
# Input variables for libzstd.mk
|
||||||
|
ifeq ($(ZSTD_LIB_COMPRESSION), 0)
|
||||||
|
ZSTD_LIB_DICTBUILDER = 0
|
||||||
|
ZSTD_LIB_DEPRECATED = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
||||||
|
ZSTD_LEGACY_SUPPORT = 0
|
||||||
|
ZSTD_LIB_DEPRECATED = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
include libzstd.mk
|
||||||
|
|
||||||
|
ZSTD_FILES := $(ZSTD_COMMON_FILES) $(ZSTD_LEGACY_FILES)
|
||||||
|
|
||||||
|
ifneq ($(ZSTD_LIB_COMPRESSION), 0)
|
||||||
|
ZSTD_FILES += $(ZSTD_COMPRESS_FILES)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
||||||
|
ZSTD_FILES += $(ZSTD_DECOMPRESS_FILES)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ZSTD_LIB_DEPRECATED), 0)
|
||||||
|
ZSTD_FILES += $(ZSTD_DEPRECATED_FILES)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
|
||||||
|
ZSTD_FILES += $(ZSTD_DICTBUILDER_FILES)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ZSTD_LOCAL_SRC := $(notdir $(ZSTD_FILES))
|
||||||
|
ZSTD_LOCAL_OBJ0 := $(ZSTD_LOCAL_SRC:.c=.o)
|
||||||
|
ZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_OBJ0:.S=.o)
|
||||||
|
|
||||||
|
VERSION := $(ZSTD_VERSION)
|
||||||
|
|
||||||
|
# Note: by default, the static library is built single-threaded and dynamic library is built
|
||||||
|
# multi-threaded. It is possible to force multi or single threaded builds by appending
|
||||||
|
# -mt or -nomt to the build target (like lib-mt for multi-threaded, lib-nomt for single-threaded).
|
||||||
|
.PHONY: default
|
||||||
|
default: lib-release
|
||||||
|
|
||||||
|
CPPFLAGS_DYNLIB += -DZSTD_MULTITHREAD # dynamic library build defaults to multi-threaded
|
||||||
|
LDFLAGS_DYNLIB += -pthread
|
||||||
|
CPPFLAGS_STATLIB += # static library build defaults to single-threaded
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
||||||
|
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# macOS linker doesn't support -soname, and use different extension
|
||||||
|
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
||||||
|
ifeq ($(UNAME), Darwin)
|
||||||
|
SHARED_EXT = dylib
|
||||||
|
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
||||||
|
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
||||||
|
SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
|
||||||
|
else
|
||||||
|
ifeq ($(UNAME), AIX)
|
||||||
|
SONAME_FLAGS =
|
||||||
|
else
|
||||||
|
SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
|
||||||
|
endif
|
||||||
|
SHARED_EXT = so
|
||||||
|
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
|
||||||
|
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: lib
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: libzstd.a # must be run every time
|
||||||
|
libzstd.a: CPPFLAGS += $(CPPFLAGS_STATLIB)
|
||||||
|
|
||||||
|
SET_CACHE_DIRECTORY = \
|
||||||
|
+$(MAKE) --no-print-directory $@ \
|
||||||
|
BUILD_DIR=obj/$(HASH_DIR) \
|
||||||
|
CPPFLAGS="$(CPPFLAGS)" \
|
||||||
|
CFLAGS="$(CFLAGS)" \
|
||||||
|
LDFLAGS="$(LDFLAGS)"
|
||||||
|
|
||||||
|
ifndef BUILD_DIR
|
||||||
|
# determine BUILD_DIR from compilation flags
|
||||||
|
|
||||||
|
libzstd.a:
|
||||||
|
$(SET_CACHE_DIRECTORY)
|
||||||
|
|
||||||
|
else
|
||||||
|
# BUILD_DIR is defined
|
||||||
|
|
||||||
|
ZSTD_STATLIB_DIR := $(BUILD_DIR)/static
|
||||||
|
ZSTD_STATLIB := $(ZSTD_STATLIB_DIR)/libzstd.a
|
||||||
|
ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
||||||
|
$(ZSTD_STATLIB): ARFLAGS = rcs
|
||||||
|
$(ZSTD_STATLIB): | $(ZSTD_STATLIB_DIR)
|
||||||
|
$(ZSTD_STATLIB): $(ZSTD_STATLIB_OBJ)
|
||||||
|
# Check for multithread flag at target execution time
|
||||||
|
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
||||||
|
@echo compiling multi-threaded static library $(LIBVER),\
|
||||||
|
@echo compiling single-threaded static library $(LIBVER))
|
||||||
|
$(AR) $(ARFLAGS) $@ $^
|
||||||
|
|
||||||
|
libzstd.a: $(ZSTD_STATLIB)
|
||||||
|
cp -f $< $@
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
||||||
|
|
||||||
|
LIBZSTD = dll/libzstd.dll
|
||||||
|
$(LIBZSTD): $(ZSTD_FILES)
|
||||||
|
@echo compiling dynamic library $(LIBVER)
|
||||||
|
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@
|
||||||
|
|
||||||
|
else # not Windows
|
||||||
|
|
||||||
|
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
||||||
|
.PHONY: $(LIBZSTD) # must be run every time
|
||||||
|
$(LIBZSTD): CPPFLAGS += $(CPPFLAGS_DYNLIB)
|
||||||
|
$(LIBZSTD): CFLAGS += -fPIC -fvisibility=hidden
|
||||||
|
$(LIBZSTD): LDFLAGS += -shared $(LDFLAGS_DYNLIB)
|
||||||
|
|
||||||
|
ifndef BUILD_DIR
|
||||||
|
# determine BUILD_DIR from compilation flags
|
||||||
|
|
||||||
|
$(LIBZSTD):
|
||||||
|
$(SET_CACHE_DIRECTORY)
|
||||||
|
|
||||||
|
else
|
||||||
|
# BUILD_DIR is defined
|
||||||
|
|
||||||
|
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynamic
|
||||||
|
ZSTD_DYNLIB := $(ZSTD_DYNLIB_DIR)/$(LIBZSTD)
|
||||||
|
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
||||||
|
|
||||||
|
$(ZSTD_DYNLIB): | $(ZSTD_DYNLIB_DIR)
|
||||||
|
$(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ)
|
||||||
|
# Check for multithread flag at target execution time
|
||||||
|
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
||||||
|
@echo compiling multi-threaded dynamic library $(LIBVER),\
|
||||||
|
@echo compiling single-threaded dynamic library $(LIBVER))
|
||||||
|
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||||
|
@echo creating versioned links
|
||||||
|
ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
||||||
|
ln -sf $@ libzstd.$(SHARED_EXT)
|
||||||
|
|
||||||
|
$(LIBZSTD): $(ZSTD_DYNLIB)
|
||||||
|
cp -f $< $@
|
||||||
|
|
||||||
|
endif # ifndef BUILD_DIR
|
||||||
|
endif # if windows
|
||||||
|
|
||||||
|
.PHONY: libzstd
|
||||||
|
libzstd : $(LIBZSTD)
|
||||||
|
|
||||||
|
.PHONY: lib
|
||||||
|
lib : libzstd.a libzstd
|
||||||
|
|
||||||
|
|
||||||
|
# note : do not define lib-mt or lib-release as .PHONY
|
||||||
|
# make does not consider implicit pattern rule for .PHONY target
|
||||||
|
|
||||||
|
%-mt : CPPFLAGS_DYNLIB := -DZSTD_MULTITHREAD
|
||||||
|
%-mt : CPPFLAGS_STATLIB := -DZSTD_MULTITHREAD
|
||||||
|
%-mt : LDFLAGS_DYNLIB := -pthread
|
||||||
|
%-mt : %
|
||||||
|
@echo multi-threaded build completed
|
||||||
|
|
||||||
|
%-nomt : CPPFLAGS_DYNLIB :=
|
||||||
|
%-nomt : LDFLAGS_DYNLIB :=
|
||||||
|
%-nomt : CPPFLAGS_STATLIB :=
|
||||||
|
%-nomt : %
|
||||||
|
@echo single-threaded build completed
|
||||||
|
|
||||||
|
%-release : DEBUGFLAGS :=
|
||||||
|
%-release : %
|
||||||
|
@echo release build completed
|
||||||
|
|
||||||
|
|
||||||
|
# Generate .h dependencies automatically
|
||||||
|
|
||||||
|
DEPFLAGS = -MT $@ -MMD -MP -MF
|
||||||
|
|
||||||
|
$(ZSTD_DYNLIB_DIR)/%.o : %.c $(ZSTD_DYNLIB_DIR)/%.d | $(ZSTD_DYNLIB_DIR)
|
||||||
|
@echo CC $@
|
||||||
|
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
|
$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR)
|
||||||
|
@echo CC $@
|
||||||
|
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
|
$(ZSTD_DYNLIB_DIR)/%.o : %.S | $(ZSTD_DYNLIB_DIR)
|
||||||
|
@echo AS $@
|
||||||
|
$(COMPILE.S) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
|
$(ZSTD_STATLIB_DIR)/%.o : %.S | $(ZSTD_STATLIB_DIR)
|
||||||
|
@echo AS $@
|
||||||
|
$(COMPILE.S) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
|
MKDIR ?= mkdir
|
||||||
|
$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):
|
||||||
|
$(MKDIR) -p $@
|
||||||
|
|
||||||
|
DEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d)
|
||||||
|
$(DEPFILES):
|
||||||
|
|
||||||
|
include $(wildcard $(DEPFILES))
|
||||||
|
|
||||||
|
|
||||||
|
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
||||||
|
ZSTDMT_FILES = compress/zstdmt_compress.c
|
||||||
|
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
||||||
|
libzstd-nomt: CFLAGS += -fPIC -fvisibility=hidden
|
||||||
|
libzstd-nomt: LDFLAGS += -shared
|
||||||
|
libzstd-nomt: $(ZSTD_NOMT_FILES)
|
||||||
|
@echo compiling single-thread dynamic library $(LIBVER)
|
||||||
|
@echo files : $(ZSTD_NOMT_FILES)
|
||||||
|
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
$(RM) -r *.dSYM # macOS-specific
|
||||||
|
$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
||||||
|
$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
||||||
|
$(RM) -r obj/*
|
||||||
|
@echo Cleaning library completed
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# make install is validated only for below listed environments
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX))
|
||||||
|
|
||||||
|
lib: libzstd.pc
|
||||||
|
|
||||||
|
HAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,)
|
||||||
|
|
||||||
|
DESTDIR ?=
|
||||||
|
# directory variables : GNU conventions prefer lowercase
|
||||||
|
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
|
||||||
|
# support both lower and uppercase (BSD), use uppercase in script
|
||||||
|
prefix ?= /usr/local
|
||||||
|
PREFIX ?= $(prefix)
|
||||||
|
exec_prefix ?= $(PREFIX)
|
||||||
|
EXEC_PREFIX ?= $(exec_prefix)
|
||||||
|
libdir ?= $(EXEC_PREFIX)/lib
|
||||||
|
LIBDIR ?= $(libdir)
|
||||||
|
includedir ?= $(PREFIX)/include
|
||||||
|
INCLUDEDIR ?= $(includedir)
|
||||||
|
|
||||||
|
PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR))
|
||||||
|
PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR))
|
||||||
|
|
||||||
|
# If we successfully stripped off a prefix, we'll add a reference to the
|
||||||
|
# relevant pc variable.
|
||||||
|
PCINCPREFIX := $(if $(findstring $(INCLUDEDIR),$(PCINCDIR)),,$${prefix})
|
||||||
|
PCLIBPREFIX := $(if $(findstring $(LIBDIR),$(PCLIBDIR)),,$${exec_prefix})
|
||||||
|
|
||||||
|
# If no explicit EXEC_PREFIX was set by the caller, write it out as a reference
|
||||||
|
# to PREFIX, rather than as a resolved value.
|
||||||
|
PCEXEC_PREFIX := $(if $(HAS_EXPLICIT_EXEC_PREFIX),$(EXEC_PREFIX),$${prefix})
|
||||||
|
|
||||||
|
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
||||||
|
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
||||||
|
else
|
||||||
|
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(filter $(UNAME),SunOS))
|
||||||
|
INSTALL ?= ginstall
|
||||||
|
else
|
||||||
|
INSTALL ?= install
|
||||||
|
endif
|
||||||
|
|
||||||
|
INSTALL_PROGRAM ?= $(INSTALL)
|
||||||
|
INSTALL_DATA ?= $(INSTALL) -m 644
|
||||||
|
|
||||||
|
|
||||||
|
libzstd.pc: libzstd.pc.in
|
||||||
|
@echo creating pkgconfig
|
||||||
|
@sed \
|
||||||
|
-e 's|@PREFIX@|$(PREFIX)|' \
|
||||||
|
-e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \
|
||||||
|
-e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
|
||||||
|
-e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
|
||||||
|
-e 's|@VERSION@|$(VERSION)|' \
|
||||||
|
-e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \
|
||||||
|
$< >$@
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: install-pc install-static install-shared install-includes
|
||||||
|
@echo zstd static and shared library installed
|
||||||
|
|
||||||
|
.PHONY: install-pc
|
||||||
|
install-pc: libzstd.pc
|
||||||
|
[ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
||||||
|
$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
||||||
|
|
||||||
|
.PHONY: install-static
|
||||||
|
install-static:
|
||||||
|
# only generate libzstd.a if it's not already present
|
||||||
|
[ -e libzstd.a ] || $(MAKE) libzstd.a-release
|
||||||
|
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
||||||
|
@echo Installing static library
|
||||||
|
$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
||||||
|
|
||||||
|
.PHONY: install-shared
|
||||||
|
install-shared:
|
||||||
|
# only generate libzstd.so if it's not already present
|
||||||
|
[ -e $(LIBZSTD) ] || $(MAKE) libzstd-release
|
||||||
|
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
||||||
|
@echo Installing shared library
|
||||||
|
$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
|
||||||
|
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
||||||
|
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
||||||
|
|
||||||
|
.PHONY: install-includes
|
||||||
|
install-includes:
|
||||||
|
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
|
||||||
|
@echo Installing includes
|
||||||
|
$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
|
||||||
|
$(INSTALL_DATA) zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
|
||||||
|
$(INSTALL_DATA) zdict.h $(DESTDIR)$(INCLUDEDIR)
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall:
|
||||||
|
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
|
||||||
|
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
||||||
|
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
||||||
|
$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
|
||||||
|
$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
|
||||||
|
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
|
||||||
|
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
|
||||||
|
$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
||||||
|
@echo zstd libraries successfully uninstalled
|
||||||
|
|
||||||
|
endif
|
||||||
224
external/zstd/README.md
vendored
Normal file
224
external/zstd/README.md
vendored
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
Zstandard library files
|
||||||
|
================================
|
||||||
|
|
||||||
|
The __lib__ directory is split into several sub-directories,
|
||||||
|
in order to make it easier to select or exclude features.
|
||||||
|
|
||||||
|
|
||||||
|
#### Building
|
||||||
|
|
||||||
|
`Makefile` script is provided, supporting [Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions),
|
||||||
|
including commands variables, staged install, directory variables and standard targets.
|
||||||
|
- `make` : generates both static and dynamic libraries
|
||||||
|
- `make install` : install libraries and headers in target system directories
|
||||||
|
|
||||||
|
`libzstd` default scope is pretty large, including compression, decompression, dictionary builder,
|
||||||
|
and support for decoding legacy formats >= v0.5.0.
|
||||||
|
The scope can be reduced on demand (see paragraph _modular build_).
|
||||||
|
|
||||||
|
|
||||||
|
#### Multithreading support
|
||||||
|
|
||||||
|
When building with `make`, by default the dynamic library is multithreaded and static library is single-threaded (for compatibility reasons).
|
||||||
|
|
||||||
|
Enabling multithreading requires 2 conditions :
|
||||||
|
- set build macro `ZSTD_MULTITHREAD` (`-DZSTD_MULTITHREAD` for `gcc`)
|
||||||
|
- for POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc`)
|
||||||
|
|
||||||
|
For convenience, we provide a build target to generate multi and single threaded libraries:
|
||||||
|
- Force enable multithreading on both dynamic and static libraries by appending `-mt` to the target, e.g. `make lib-mt`.
|
||||||
|
- Force disable multithreading on both dynamic and static libraries by appending `-nomt` to the target, e.g. `make lib-nomt`.
|
||||||
|
- By default, as mentioned before, dynamic library is multithreaded, and static library is single-threaded, e.g. `make lib`.
|
||||||
|
|
||||||
|
When linking a POSIX program with a multithreaded version of `libzstd`,
|
||||||
|
note that it's necessary to invoke the `-pthread` flag during link stage.
|
||||||
|
|
||||||
|
Multithreading capabilities are exposed
|
||||||
|
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
|
||||||
|
|
||||||
|
|
||||||
|
#### API
|
||||||
|
|
||||||
|
Zstandard's stable API is exposed within [lib/zstd.h](zstd.h).
|
||||||
|
|
||||||
|
|
||||||
|
#### Advanced API
|
||||||
|
|
||||||
|
Optional advanced features are exposed via :
|
||||||
|
|
||||||
|
- `lib/zstd_errors.h` : translates `size_t` function results
|
||||||
|
into a `ZSTD_ErrorCode`, for accurate error handling.
|
||||||
|
|
||||||
|
- `ZSTD_STATIC_LINKING_ONLY` : if this macro is defined _before_ including `zstd.h`,
|
||||||
|
it unlocks access to the experimental API,
|
||||||
|
exposed in the second part of `zstd.h`.
|
||||||
|
All definitions in the experimental APIs are unstable,
|
||||||
|
they may still change in the future, or even be removed.
|
||||||
|
As a consequence, experimental definitions shall ___never be used with dynamic library___ !
|
||||||
|
Only static linking is allowed.
|
||||||
|
|
||||||
|
|
||||||
|
#### Modular build
|
||||||
|
|
||||||
|
It's possible to compile only a limited set of features within `libzstd`.
|
||||||
|
The file structure is designed to make this selection manually achievable for any build system :
|
||||||
|
|
||||||
|
- Directory `lib/common` is always required, for all variants.
|
||||||
|
|
||||||
|
- Compression source code lies in `lib/compress`
|
||||||
|
|
||||||
|
- Decompression source code lies in `lib/decompress`
|
||||||
|
|
||||||
|
- It's possible to include only `compress` or only `decompress`, they don't depend on each other.
|
||||||
|
|
||||||
|
- `lib/dictBuilder` : makes it possible to generate dictionaries from a set of samples.
|
||||||
|
The API is exposed in `lib/dictBuilder/zdict.h`.
|
||||||
|
This module depends on both `lib/common` and `lib/compress` .
|
||||||
|
|
||||||
|
- `lib/legacy` : makes it possible to decompress legacy zstd formats, starting from `v0.1.0`.
|
||||||
|
This module depends on `lib/common` and `lib/decompress`.
|
||||||
|
To enable this feature, define `ZSTD_LEGACY_SUPPORT` during compilation.
|
||||||
|
Specifying a number limits versions supported to that version onward.
|
||||||
|
For example, `ZSTD_LEGACY_SUPPORT=2` means : "support legacy formats >= v0.2.0".
|
||||||
|
Conversely, `ZSTD_LEGACY_SUPPORT=0` means "do __not__ support legacy formats".
|
||||||
|
By default, this build macro is set as `ZSTD_LEGACY_SUPPORT=5`.
|
||||||
|
Decoding supported legacy format is a transparent capability triggered within decompression functions.
|
||||||
|
It's also allowed to invoke legacy API directly, exposed in `lib/legacy/zstd_legacy.h`.
|
||||||
|
Each version does also provide its own set of advanced API.
|
||||||
|
For example, advanced API for version `v0.4` is exposed in `lib/legacy/zstd_v04.h` .
|
||||||
|
|
||||||
|
- While invoking `make libzstd`, it's possible to define build macros
|
||||||
|
`ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
|
||||||
|
and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
|
||||||
|
corresponding features. This will also disable compilation of all
|
||||||
|
dependencies (e.g. `ZSTD_LIB_COMPRESSION=0` will also disable
|
||||||
|
dictBuilder).
|
||||||
|
|
||||||
|
- There are a number of options that can help minimize the binary size of
|
||||||
|
`libzstd`.
|
||||||
|
|
||||||
|
The first step is to select the components needed (using the above-described
|
||||||
|
`ZSTD_LIB_COMPRESSION` etc.).
|
||||||
|
|
||||||
|
The next step is to set `ZSTD_LIB_MINIFY` to `1` when invoking `make`. This
|
||||||
|
disables various optional components and changes the compilation flags to
|
||||||
|
prioritize space-saving.
|
||||||
|
|
||||||
|
Detailed options: Zstandard's code and build environment is set up by default
|
||||||
|
to optimize above all else for performance. In pursuit of this goal, Zstandard
|
||||||
|
makes significant trade-offs in code size. For example, Zstandard often has
|
||||||
|
more than one implementation of a particular component, with each
|
||||||
|
implementation optimized for different scenarios. For example, the Huffman
|
||||||
|
decoder has complementary implementations that decode the stream one symbol at
|
||||||
|
a time or two symbols at a time. Zstd normally includes both (and dispatches
|
||||||
|
between them at runtime), but by defining `HUF_FORCE_DECOMPRESS_X1` or
|
||||||
|
`HUF_FORCE_DECOMPRESS_X2`, you can force the use of one or the other, avoiding
|
||||||
|
compilation of the other. Similarly, `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`
|
||||||
|
and `ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG` force the compilation and use of
|
||||||
|
only one or the other of two decompression implementations. The smallest
|
||||||
|
binary is achieved by using `HUF_FORCE_DECOMPRESS_X1` and
|
||||||
|
`ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT` (implied by `ZSTD_LIB_MINIFY`).
|
||||||
|
|
||||||
|
For squeezing the last ounce of size out, you can also define
|
||||||
|
`ZSTD_NO_INLINE`, which disables inlining, and `ZSTD_STRIP_ERROR_STRINGS`,
|
||||||
|
which removes the error messages that are otherwise returned by
|
||||||
|
`ZSTD_getErrorName` (implied by `ZSTD_LIB_MINIFY`).
|
||||||
|
|
||||||
|
Finally, when integrating into your application, make sure you're doing link-
|
||||||
|
time optimization and unused symbol garbage collection (via some combination of,
|
||||||
|
e.g., `-flto`, `-ffat-lto-objects`, `-fuse-linker-plugin`,
|
||||||
|
`-ffunction-sections`, `-fdata-sections`, `-fmerge-all-constants`,
|
||||||
|
`-Wl,--gc-sections`, `-Wl,-z,norelro`, and an archiver that understands
|
||||||
|
the compiler's intermediate representation, e.g., `AR=gcc-ar`). Consult your
|
||||||
|
compiler's documentation.
|
||||||
|
|
||||||
|
- While invoking `make libzstd`, the build macro `ZSTD_LEGACY_MULTITHREADED_API=1`
|
||||||
|
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
|
||||||
|
the shared library, which is now hidden by default.
|
||||||
|
|
||||||
|
- The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
|
||||||
|
which can detect at runtime the presence of BMI2 instructions, and use them only if present.
|
||||||
|
These instructions contribute to better performance, notably on the decoder side.
|
||||||
|
By default, this feature is automatically enabled on detecting
|
||||||
|
the right instruction set (x64) and compiler (clang or gcc >= 5).
|
||||||
|
It's obviously disabled for different cpus,
|
||||||
|
or when BMI2 instruction set is _required_ by the compiler command line
|
||||||
|
(in this case, only the BMI2 code path is generated).
|
||||||
|
Setting this macro will either force to generate the BMI2 dispatcher (1)
|
||||||
|
or prevent it (0). It overrides automatic detection.
|
||||||
|
|
||||||
|
- The build macro `ZSTD_NO_UNUSED_FUNCTIONS` can be defined to hide the definitions of functions
|
||||||
|
that zstd does not use. Not all unused functions are hidden, but they can be if needed.
|
||||||
|
Currently, this macro will hide function definitions in FSE and HUF that use an excessive
|
||||||
|
amount of stack space.
|
||||||
|
|
||||||
|
- The build macro `ZSTD_NO_INTRINSICS` can be defined to disable all explicit intrinsics.
|
||||||
|
Compiler builtins are still used.
|
||||||
|
|
||||||
|
- The build macro `ZSTD_DECODER_INTERNAL_BUFFER` can be set to control
|
||||||
|
the amount of extra memory used during decompression to store literals.
|
||||||
|
This defaults to 64kB. Reducing this value reduces the memory footprint of
|
||||||
|
`ZSTD_DCtx` decompression contexts,
|
||||||
|
but might also result in a small decompression speed cost.
|
||||||
|
|
||||||
|
- The C compiler macros `ZSTDLIB_VISIBLE`, `ZSTDERRORLIB_VISIBLE` and `ZDICTLIB_VISIBLE`
|
||||||
|
can be overridden to control the visibility of zstd's API. Additionally,
|
||||||
|
`ZSTDLIB_STATIC_API` and `ZDICTLIB_STATIC_API` can be overridden to control the visibility
|
||||||
|
of zstd's static API. Specifically, it can be set to `ZSTDLIB_HIDDEN` to hide the symbols
|
||||||
|
from the shared library. These macros default to `ZSTDLIB_VISIBILITY`,
|
||||||
|
`ZSTDERRORLIB_VSIBILITY`, and `ZDICTLIB_VISIBILITY` if unset, for backwards compatibility
|
||||||
|
with the old macro names.
|
||||||
|
|
||||||
|
#### Windows : using MinGW+MSYS to create DLL
|
||||||
|
|
||||||
|
DLL can be created using MinGW+MSYS with the `make libzstd` command.
|
||||||
|
This command creates `dll\libzstd.dll` and the import library `dll\libzstd.lib`.
|
||||||
|
The import library is only required with Visual C++.
|
||||||
|
The header file `zstd.h` and the dynamic library `dll\libzstd.dll` are required to
|
||||||
|
compile a project using gcc/MinGW.
|
||||||
|
The dynamic library has to be added to linking options.
|
||||||
|
It means that if a project that uses ZSTD consists of a single `test-dll.c`
|
||||||
|
file it should be linked with `dll\libzstd.dll`. For example:
|
||||||
|
```
|
||||||
|
gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\libzstd.dll
|
||||||
|
```
|
||||||
|
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
|
||||||
|
|
||||||
|
|
||||||
|
#### Advanced Build options
|
||||||
|
|
||||||
|
The build system requires a hash function in order to
|
||||||
|
separate object files created with different compilation flags.
|
||||||
|
By default, it tries to use `md5sum` or equivalent.
|
||||||
|
The hash function can be manually switched by setting the `HASH` variable.
|
||||||
|
For example : `make HASH=xxhsum`
|
||||||
|
The hash function needs to generate at least 64-bit using hexadecimal format.
|
||||||
|
When no hash function is found,
|
||||||
|
the Makefile just generates all object files into the same default directory,
|
||||||
|
irrespective of compilation flags.
|
||||||
|
This functionality only matters if `libzstd` is compiled multiple times
|
||||||
|
with different build flags.
|
||||||
|
|
||||||
|
The build directory, where object files are stored
|
||||||
|
can also be manually controlled using variable `BUILD_DIR`,
|
||||||
|
for example `make BUILD_DIR=objectDir/v1`.
|
||||||
|
In which case, the hash function doesn't matter.
|
||||||
|
|
||||||
|
|
||||||
|
#### Deprecated API
|
||||||
|
|
||||||
|
Obsolete API on their way out are stored in directory `lib/deprecated`.
|
||||||
|
At this stage, it contains older streaming prototypes, in `lib/deprecated/zbuff.h`.
|
||||||
|
These prototypes will be removed in some future version.
|
||||||
|
Consider migrating code towards supported streaming API exposed in `zstd.h`.
|
||||||
|
|
||||||
|
|
||||||
|
#### Miscellaneous
|
||||||
|
|
||||||
|
The other files are not source code. There are :
|
||||||
|
|
||||||
|
- `BUCK` : support for `buck` build system (https://buckbuild.com/)
|
||||||
|
- `Makefile` : `make` script to build and install zstd library (static and dynamic)
|
||||||
|
- `README.md` : this file
|
||||||
|
- `dll/` : resources directory for Windows compilation
|
||||||
|
- `libzstd.pc.in` : script for `pkg-config` (used in `make install`)
|
||||||
175
external/zstd/common/bits.h
vendored
Normal file
175
external/zstd/common/bits.h
vendored
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under both the BSD-style license (found in the
|
||||||
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
* in the COPYING file in the root directory of this source tree).
|
||||||
|
* You may select, at your option, one of the above-listed licenses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZSTD_BITS_H
|
||||||
|
#define ZSTD_BITS_H
|
||||||
|
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
|
||||||
|
{
|
||||||
|
assert(val != 0);
|
||||||
|
{
|
||||||
|
static const int DeBruijnBytePos[32] = {0, 1, 28, 2, 29, 14, 24, 3,
|
||||||
|
30, 22, 20, 15, 25, 17, 4, 8,
|
||||||
|
31, 27, 13, 23, 21, 19, 16, 7,
|
||||||
|
26, 12, 18, 6, 11, 5, 10, 9};
|
||||||
|
return DeBruijnBytePos[((U32) ((val & -(S32) val) * 0x077CB531U)) >> 27];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
|
||||||
|
{
|
||||||
|
assert(val != 0);
|
||||||
|
# if defined(_MSC_VER)
|
||||||
|
# if STATIC_BMI2 == 1
|
||||||
|
return _tzcnt_u32(val);
|
||||||
|
# else
|
||||||
|
if (val != 0) {
|
||||||
|
unsigned long r;
|
||||||
|
_BitScanForward(&r, val);
|
||||||
|
return (unsigned)r;
|
||||||
|
} else {
|
||||||
|
/* Should not reach this code path */
|
||||||
|
__assume(0);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
|
return (unsigned)__builtin_ctz(val);
|
||||||
|
# else
|
||||||
|
return ZSTD_countTrailingZeros32_fallback(val);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
|
||||||
|
assert(val != 0);
|
||||||
|
{
|
||||||
|
static const U32 DeBruijnClz[32] = {0, 9, 1, 10, 13, 21, 2, 29,
|
||||||
|
11, 14, 16, 18, 22, 25, 3, 30,
|
||||||
|
8, 12, 20, 28, 15, 17, 24, 7,
|
||||||
|
19, 27, 23, 6, 26, 5, 4, 31};
|
||||||
|
val |= val >> 1;
|
||||||
|
val |= val >> 2;
|
||||||
|
val |= val >> 4;
|
||||||
|
val |= val >> 8;
|
||||||
|
val |= val >> 16;
|
||||||
|
return 31 - DeBruijnClz[(val * 0x07C4ACDDU) >> 27];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
|
||||||
|
{
|
||||||
|
assert(val != 0);
|
||||||
|
# if defined(_MSC_VER)
|
||||||
|
# if STATIC_BMI2 == 1
|
||||||
|
return _lzcnt_u32(val);
|
||||||
|
# else
|
||||||
|
if (val != 0) {
|
||||||
|
unsigned long r;
|
||||||
|
_BitScanReverse(&r, val);
|
||||||
|
return (unsigned)(31 - r);
|
||||||
|
} else {
|
||||||
|
/* Should not reach this code path */
|
||||||
|
__assume(0);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
|
return (unsigned)__builtin_clz(val);
|
||||||
|
# else
|
||||||
|
return ZSTD_countLeadingZeros32_fallback(val);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
|
||||||
|
{
|
||||||
|
assert(val != 0);
|
||||||
|
# if defined(_MSC_VER) && defined(_WIN64)
|
||||||
|
# if STATIC_BMI2 == 1
|
||||||
|
return _tzcnt_u64(val);
|
||||||
|
# else
|
||||||
|
if (val != 0) {
|
||||||
|
unsigned long r;
|
||||||
|
_BitScanForward64(&r, val);
|
||||||
|
return (unsigned)r;
|
||||||
|
} else {
|
||||||
|
/* Should not reach this code path */
|
||||||
|
__assume(0);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
|
||||||
|
return (unsigned)__builtin_ctzll(val);
|
||||||
|
# else
|
||||||
|
{
|
||||||
|
U32 mostSignificantWord = (U32)(val >> 32);
|
||||||
|
U32 leastSignificantWord = (U32)val;
|
||||||
|
if (leastSignificantWord == 0) {
|
||||||
|
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
|
||||||
|
} else {
|
||||||
|
return ZSTD_countTrailingZeros32(leastSignificantWord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
|
||||||
|
{
|
||||||
|
assert(val != 0);
|
||||||
|
# if defined(_MSC_VER) && defined(_WIN64)
|
||||||
|
# if STATIC_BMI2 == 1
|
||||||
|
return _lzcnt_u64(val);
|
||||||
|
# else
|
||||||
|
if (val != 0) {
|
||||||
|
unsigned long r;
|
||||||
|
_BitScanReverse64(&r, val);
|
||||||
|
return (unsigned)(63 - r);
|
||||||
|
} else {
|
||||||
|
/* Should not reach this code path */
|
||||||
|
__assume(0);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
|
return (unsigned)(__builtin_clzll(val));
|
||||||
|
# else
|
||||||
|
{
|
||||||
|
U32 mostSignificantWord = (U32)(val >> 32);
|
||||||
|
U32 leastSignificantWord = (U32)val;
|
||||||
|
if (mostSignificantWord == 0) {
|
||||||
|
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
|
||||||
|
} else {
|
||||||
|
return ZSTD_countLeadingZeros32(mostSignificantWord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)
|
||||||
|
{
|
||||||
|
if (MEM_isLittleEndian()) {
|
||||||
|
if (MEM_64bits()) {
|
||||||
|
return ZSTD_countTrailingZeros64((U64)val) >> 3;
|
||||||
|
} else {
|
||||||
|
return ZSTD_countTrailingZeros32((U32)val) >> 3;
|
||||||
|
}
|
||||||
|
} else { /* Big Endian CPU */
|
||||||
|
if (MEM_64bits()) {
|
||||||
|
return ZSTD_countLeadingZeros64((U64)val) >> 3;
|
||||||
|
} else {
|
||||||
|
return ZSTD_countLeadingZeros32((U32)val) >> 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC unsigned ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
|
||||||
|
{
|
||||||
|
assert(val != 0);
|
||||||
|
return 31 - ZSTD_countLeadingZeros32(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ZSTD_BITS_H */
|
||||||
437
external/zstd/common/bitstream.h
vendored
Normal file
437
external/zstd/common/bitstream.h
vendored
Normal file
@@ -0,0 +1,437 @@
|
|||||||
|
/* ******************************************************************
|
||||||
|
* bitstream
|
||||||
|
* Part of FSE library
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* You can contact the author at :
|
||||||
|
* - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
||||||
|
*
|
||||||
|
* This source code is licensed under both the BSD-style license (found in the
|
||||||
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
* in the COPYING file in the root directory of this source tree).
|
||||||
|
* You may select, at your option, one of the above-listed licenses.
|
||||||
|
****************************************************************** */
|
||||||
|
#ifndef BITSTREAM_H_MODULE
|
||||||
|
#define BITSTREAM_H_MODULE
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* This API consists of small unitary functions, which must be inlined for best performance.
|
||||||
|
* Since link-time-optimization is not available for all compilers,
|
||||||
|
* these functions are defined into a .h to be included.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-****************************************
|
||||||
|
* Dependencies
|
||||||
|
******************************************/
|
||||||
|
#include "mem.h" /* unaligned access routines */
|
||||||
|
#include "compiler.h" /* UNLIKELY() */
|
||||||
|
#include "debug.h" /* assert(), DEBUGLOG(), RAWLOG() */
|
||||||
|
#include "error_private.h" /* error codes and messages */
|
||||||
|
#include "bits.h" /* ZSTD_highbit32 */
|
||||||
|
|
||||||
|
|
||||||
|
/*=========================================
|
||||||
|
* Target specific
|
||||||
|
=========================================*/
|
||||||
|
#ifndef ZSTD_NO_INTRINSICS
|
||||||
|
# if (defined(__BMI__) || defined(__BMI2__)) && defined(__GNUC__)
|
||||||
|
# include <immintrin.h> /* support for bextr (experimental)/bzhi */
|
||||||
|
# elif defined(__ICCARM__)
|
||||||
|
# include <intrinsics.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define STREAM_ACCUMULATOR_MIN_32 25
|
||||||
|
#define STREAM_ACCUMULATOR_MIN_64 57
|
||||||
|
#define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64))
|
||||||
|
|
||||||
|
|
||||||
|
/*-******************************************
|
||||||
|
* bitStream encoding API (write forward)
|
||||||
|
********************************************/
|
||||||
|
/* bitStream can mix input from multiple sources.
|
||||||
|
* A critical property of these streams is that they encode and decode in **reverse** direction.
|
||||||
|
* So the first bit sequence you add will be the last to be read, like a LIFO stack.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
size_t bitContainer;
|
||||||
|
unsigned bitPos;
|
||||||
|
char* startPtr;
|
||||||
|
char* ptr;
|
||||||
|
char* endPtr;
|
||||||
|
} BIT_CStream_t;
|
||||||
|
|
||||||
|
MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity);
|
||||||
|
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
|
||||||
|
MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC);
|
||||||
|
MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
|
||||||
|
|
||||||
|
/* Start with initCStream, providing the size of buffer to write into.
|
||||||
|
* bitStream will never write outside of this buffer.
|
||||||
|
* `dstCapacity` must be >= sizeof(bitD->bitContainer), otherwise @return will be an error code.
|
||||||
|
*
|
||||||
|
* bits are first added to a local register.
|
||||||
|
* Local register is size_t, hence 64-bits on 64-bits systems, or 32-bits on 32-bits systems.
|
||||||
|
* Writing data into memory is an explicit operation, performed by the flushBits function.
|
||||||
|
* Hence keep track how many bits are potentially stored into local register to avoid register overflow.
|
||||||
|
* After a flushBits, a maximum of 7 bits might still be stored into local register.
|
||||||
|
*
|
||||||
|
* Avoid storing elements of more than 24 bits if you want compatibility with 32-bits bitstream readers.
|
||||||
|
*
|
||||||
|
* Last operation is to close the bitStream.
|
||||||
|
* The function returns the final size of CStream in bytes.
|
||||||
|
* If data couldn't fit into `dstBuffer`, it will return a 0 ( == not storable)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*-********************************************
|
||||||
|
* bitStream decoding API (read backward)
|
||||||
|
**********************************************/
|
||||||
|
typedef struct {
|
||||||
|
size_t bitContainer;
|
||||||
|
unsigned bitsConsumed;
|
||||||
|
const char* ptr;
|
||||||
|
const char* start;
|
||||||
|
const char* limitPtr;
|
||||||
|
} BIT_DStream_t;
|
||||||
|
|
||||||
|
typedef enum { BIT_DStream_unfinished = 0,
|
||||||
|
BIT_DStream_endOfBuffer = 1,
|
||||||
|
BIT_DStream_completed = 2,
|
||||||
|
BIT_DStream_overflow = 3 } BIT_DStream_status; /* result of BIT_reloadDStream() */
|
||||||
|
/* 1,2,4,8 would be better for bitmap combinations, but slows down performance a bit ... :( */
|
||||||
|
|
||||||
|
MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize);
|
||||||
|
MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits);
|
||||||
|
MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD);
|
||||||
|
MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
|
||||||
|
|
||||||
|
|
||||||
|
/* Start by invoking BIT_initDStream().
|
||||||
|
* A chunk of the bitStream is then stored into a local register.
|
||||||
|
* Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t).
|
||||||
|
* You can then retrieve bitFields stored into the local register, **in reverse order**.
|
||||||
|
* Local register is explicitly reloaded from memory by the BIT_reloadDStream() method.
|
||||||
|
* A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BIT_DStream_unfinished.
|
||||||
|
* Otherwise, it can be less than that, so proceed accordingly.
|
||||||
|
* Checking if DStream has reached its end can be performed with BIT_endOfDStream().
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*-****************************************
|
||||||
|
* unsafe API
|
||||||
|
******************************************/
|
||||||
|
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
|
||||||
|
/* faster, but works only if value is "clean", meaning all high bits above nbBits are 0 */
|
||||||
|
|
||||||
|
MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC);
|
||||||
|
/* unsafe version; does not check buffer overflow */
|
||||||
|
|
||||||
|
MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits);
|
||||||
|
/* faster, but works only if nbBits >= 1 */
|
||||||
|
|
||||||
|
/*===== Local Constants =====*/
|
||||||
|
static const unsigned BIT_mask[] = {
|
||||||
|
0, 1, 3, 7, 0xF, 0x1F,
|
||||||
|
0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF,
|
||||||
|
0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF,
|
||||||
|
0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF,
|
||||||
|
0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF,
|
||||||
|
0x3FFFFFFF, 0x7FFFFFFF}; /* up to 31 bits */
|
||||||
|
#define BIT_MASK_SIZE (sizeof(BIT_mask) / sizeof(BIT_mask[0]))
|
||||||
|
|
||||||
|
/*-**************************************************************
|
||||||
|
* bitStream encoding
|
||||||
|
****************************************************************/
|
||||||
|
/*! BIT_initCStream() :
|
||||||
|
* `dstCapacity` must be > sizeof(size_t)
|
||||||
|
* @return : 0 if success,
|
||||||
|
* otherwise an error code (can be tested using ERR_isError()) */
|
||||||
|
MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC,
|
||||||
|
void* startPtr, size_t dstCapacity)
|
||||||
|
{
|
||||||
|
bitC->bitContainer = 0;
|
||||||
|
bitC->bitPos = 0;
|
||||||
|
bitC->startPtr = (char*)startPtr;
|
||||||
|
bitC->ptr = bitC->startPtr;
|
||||||
|
bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer);
|
||||||
|
if (dstCapacity <= sizeof(bitC->bitContainer)) return ERROR(dstSize_tooSmall);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
|
||||||
|
{
|
||||||
|
#if defined(STATIC_BMI2) && STATIC_BMI2 == 1 && !defined(ZSTD_NO_INTRINSICS)
|
||||||
|
return _bzhi_u64(bitContainer, nbBits);
|
||||||
|
#else
|
||||||
|
assert(nbBits < BIT_MASK_SIZE);
|
||||||
|
return bitContainer & BIT_mask[nbBits];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_addBits() :
|
||||||
|
* can add up to 31 bits into `bitC`.
|
||||||
|
* Note : does not check for register overflow ! */
|
||||||
|
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
|
||||||
|
size_t value, unsigned nbBits)
|
||||||
|
{
|
||||||
|
DEBUG_STATIC_ASSERT(BIT_MASK_SIZE == 32);
|
||||||
|
assert(nbBits < BIT_MASK_SIZE);
|
||||||
|
assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
||||||
|
bitC->bitContainer |= BIT_getLowerBits(value, nbBits) << bitC->bitPos;
|
||||||
|
bitC->bitPos += nbBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_addBitsFast() :
|
||||||
|
* works only if `value` is _clean_,
|
||||||
|
* meaning all high bits above nbBits are 0 */
|
||||||
|
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC,
|
||||||
|
size_t value, unsigned nbBits)
|
||||||
|
{
|
||||||
|
assert((value>>nbBits) == 0);
|
||||||
|
assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
||||||
|
bitC->bitContainer |= value << bitC->bitPos;
|
||||||
|
bitC->bitPos += nbBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_flushBitsFast() :
|
||||||
|
* assumption : bitContainer has not overflowed
|
||||||
|
* unsafe version; does not check buffer overflow */
|
||||||
|
MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC)
|
||||||
|
{
|
||||||
|
size_t const nbBytes = bitC->bitPos >> 3;
|
||||||
|
assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
||||||
|
assert(bitC->ptr <= bitC->endPtr);
|
||||||
|
MEM_writeLEST(bitC->ptr, bitC->bitContainer);
|
||||||
|
bitC->ptr += nbBytes;
|
||||||
|
bitC->bitPos &= 7;
|
||||||
|
bitC->bitContainer >>= nbBytes*8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_flushBits() :
|
||||||
|
* assumption : bitContainer has not overflowed
|
||||||
|
* safe version; check for buffer overflow, and prevents it.
|
||||||
|
* note : does not signal buffer overflow.
|
||||||
|
* overflow will be revealed later on using BIT_closeCStream() */
|
||||||
|
MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC)
|
||||||
|
{
|
||||||
|
size_t const nbBytes = bitC->bitPos >> 3;
|
||||||
|
assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
||||||
|
assert(bitC->ptr <= bitC->endPtr);
|
||||||
|
MEM_writeLEST(bitC->ptr, bitC->bitContainer);
|
||||||
|
bitC->ptr += nbBytes;
|
||||||
|
if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr;
|
||||||
|
bitC->bitPos &= 7;
|
||||||
|
bitC->bitContainer >>= nbBytes*8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_closeCStream() :
|
||||||
|
* @return : size of CStream, in bytes,
|
||||||
|
* or 0 if it could not fit into dstBuffer */
|
||||||
|
MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC)
|
||||||
|
{
|
||||||
|
BIT_addBitsFast(bitC, 1, 1); /* endMark */
|
||||||
|
BIT_flushBits(bitC);
|
||||||
|
if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */
|
||||||
|
return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-********************************************************
|
||||||
|
* bitStream decoding
|
||||||
|
**********************************************************/
|
||||||
|
/*! BIT_initDStream() :
|
||||||
|
* Initialize a BIT_DStream_t.
|
||||||
|
* `bitD` : a pointer to an already allocated BIT_DStream_t structure.
|
||||||
|
* `srcSize` must be the *exact* size of the bitStream, in bytes.
|
||||||
|
* @return : size of stream (== srcSize), or an errorCode if a problem is detected
|
||||||
|
*/
|
||||||
|
MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize)
|
||||||
|
{
|
||||||
|
if (srcSize < 1) { ZSTD_memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
|
||||||
|
|
||||||
|
bitD->start = (const char*)srcBuffer;
|
||||||
|
bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
|
||||||
|
|
||||||
|
if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */
|
||||||
|
bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
|
||||||
|
bitD->bitContainer = MEM_readLEST(bitD->ptr);
|
||||||
|
{ BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
|
||||||
|
bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0; /* ensures bitsConsumed is always set */
|
||||||
|
if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
|
||||||
|
} else {
|
||||||
|
bitD->ptr = bitD->start;
|
||||||
|
bitD->bitContainer = *(const BYTE*)(bitD->start);
|
||||||
|
switch(srcSize)
|
||||||
|
{
|
||||||
|
case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
|
||||||
|
ZSTD_FALLTHROUGH;
|
||||||
|
|
||||||
|
case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
|
||||||
|
ZSTD_FALLTHROUGH;
|
||||||
|
|
||||||
|
case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
|
||||||
|
ZSTD_FALLTHROUGH;
|
||||||
|
|
||||||
|
case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24;
|
||||||
|
ZSTD_FALLTHROUGH;
|
||||||
|
|
||||||
|
case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16;
|
||||||
|
ZSTD_FALLTHROUGH;
|
||||||
|
|
||||||
|
case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8;
|
||||||
|
ZSTD_FALLTHROUGH;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
{ BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
|
||||||
|
bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;
|
||||||
|
if (lastByte == 0) return ERROR(corruption_detected); /* endMark not present */
|
||||||
|
}
|
||||||
|
bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return srcSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getUpperBits(size_t bitContainer, U32 const start)
|
||||||
|
{
|
||||||
|
return bitContainer >> start;
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits)
|
||||||
|
{
|
||||||
|
U32 const regMask = sizeof(bitContainer)*8 - 1;
|
||||||
|
/* if start > regMask, bitstream is corrupted, and result is undefined */
|
||||||
|
assert(nbBits < BIT_MASK_SIZE);
|
||||||
|
/* x86 transform & ((1 << nbBits) - 1) to bzhi instruction, it is better
|
||||||
|
* than accessing memory. When bmi2 instruction is not present, we consider
|
||||||
|
* such cpus old (pre-Haswell, 2013) and their performance is not of that
|
||||||
|
* importance.
|
||||||
|
*/
|
||||||
|
#if defined(__x86_64__) || defined(_M_X86)
|
||||||
|
return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1);
|
||||||
|
#else
|
||||||
|
return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_lookBits() :
|
||||||
|
* Provides next n bits from local register.
|
||||||
|
* local register is not modified.
|
||||||
|
* On 32-bits, maxNbBits==24.
|
||||||
|
* On 64-bits, maxNbBits==56.
|
||||||
|
* @return : value extracted */
|
||||||
|
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
|
||||||
|
{
|
||||||
|
/* arbitrate between double-shift and shift+mask */
|
||||||
|
#if 1
|
||||||
|
/* if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8,
|
||||||
|
* bitstream is likely corrupted, and result is undefined */
|
||||||
|
return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits);
|
||||||
|
#else
|
||||||
|
/* this code path is slower on my os-x laptop */
|
||||||
|
U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
|
||||||
|
return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_lookBitsFast() :
|
||||||
|
* unsafe version; only works if nbBits >= 1 */
|
||||||
|
MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits)
|
||||||
|
{
|
||||||
|
U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
|
||||||
|
assert(nbBits >= 1);
|
||||||
|
return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC FORCE_INLINE_ATTR void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
|
||||||
|
{
|
||||||
|
bitD->bitsConsumed += nbBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_readBits() :
|
||||||
|
* Read (consume) next n bits from local register and update.
|
||||||
|
* Pay attention to not read more than nbBits contained into local register.
|
||||||
|
* @return : extracted value. */
|
||||||
|
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
|
||||||
|
{
|
||||||
|
size_t const value = BIT_lookBits(bitD, nbBits);
|
||||||
|
BIT_skipBits(bitD, nbBits);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_readBitsFast() :
|
||||||
|
* unsafe version; only works if nbBits >= 1 */
|
||||||
|
MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
|
||||||
|
{
|
||||||
|
size_t const value = BIT_lookBitsFast(bitD, nbBits);
|
||||||
|
assert(nbBits >= 1);
|
||||||
|
BIT_skipBits(bitD, nbBits);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_reloadDStreamFast() :
|
||||||
|
* Similar to BIT_reloadDStream(), but with two differences:
|
||||||
|
* 1. bitsConsumed <= sizeof(bitD->bitContainer)*8 must hold!
|
||||||
|
* 2. Returns BIT_DStream_overflow when bitD->ptr < bitD->limitPtr, at this
|
||||||
|
* point you must use BIT_reloadDStream() to reload.
|
||||||
|
*/
|
||||||
|
MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD)
|
||||||
|
{
|
||||||
|
if (UNLIKELY(bitD->ptr < bitD->limitPtr))
|
||||||
|
return BIT_DStream_overflow;
|
||||||
|
assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8);
|
||||||
|
bitD->ptr -= bitD->bitsConsumed >> 3;
|
||||||
|
bitD->bitsConsumed &= 7;
|
||||||
|
bitD->bitContainer = MEM_readLEST(bitD->ptr);
|
||||||
|
return BIT_DStream_unfinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_reloadDStream() :
|
||||||
|
* Refill `bitD` from buffer previously set in BIT_initDStream() .
|
||||||
|
* This function is safe, it guarantees it will not read beyond src buffer.
|
||||||
|
* @return : status of `BIT_DStream_t` internal register.
|
||||||
|
* when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
|
||||||
|
MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
|
||||||
|
{
|
||||||
|
if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */
|
||||||
|
return BIT_DStream_overflow;
|
||||||
|
|
||||||
|
if (bitD->ptr >= bitD->limitPtr) {
|
||||||
|
return BIT_reloadDStreamFast(bitD);
|
||||||
|
}
|
||||||
|
if (bitD->ptr == bitD->start) {
|
||||||
|
if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
|
||||||
|
return BIT_DStream_completed;
|
||||||
|
}
|
||||||
|
/* start < ptr < limitPtr */
|
||||||
|
{ U32 nbBytes = bitD->bitsConsumed >> 3;
|
||||||
|
BIT_DStream_status result = BIT_DStream_unfinished;
|
||||||
|
if (bitD->ptr - nbBytes < bitD->start) {
|
||||||
|
nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */
|
||||||
|
result = BIT_DStream_endOfBuffer;
|
||||||
|
}
|
||||||
|
bitD->ptr -= nbBytes;
|
||||||
|
bitD->bitsConsumed -= nbBytes*8;
|
||||||
|
bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! BIT_endOfDStream() :
|
||||||
|
* @return : 1 if DStream has _exactly_ reached its end (all bits consumed).
|
||||||
|
*/
|
||||||
|
MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
|
||||||
|
{
|
||||||
|
return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BITSTREAM_H_MODULE */
|
||||||
343
external/zstd/common/compiler.h
vendored
Normal file
343
external/zstd/common/compiler.h
vendored
Normal file
@@ -0,0 +1,343 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under both the BSD-style license (found in the
|
||||||
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
* in the COPYING file in the root directory of this source tree).
|
||||||
|
* You may select, at your option, one of the above-listed licenses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZSTD_COMPILER_H
|
||||||
|
#define ZSTD_COMPILER_H
|
||||||
|
|
||||||
|
#include "portability_macros.h"
|
||||||
|
|
||||||
|
/*-*******************************************************
|
||||||
|
* Compiler specifics
|
||||||
|
*********************************************************/
|
||||||
|
/* force inlining */
|
||||||
|
|
||||||
|
#if !defined(ZSTD_NO_INLINE)
|
||||||
|
#if (defined(__GNUC__) && !defined(__STRICT_ANSI__)) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
||||||
|
# define INLINE_KEYWORD inline
|
||||||
|
#else
|
||||||
|
# define INLINE_KEYWORD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||||
|
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# define FORCE_INLINE_ATTR __forceinline
|
||||||
|
#else
|
||||||
|
# define FORCE_INLINE_ATTR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define INLINE_KEYWORD
|
||||||
|
#define FORCE_INLINE_ATTR
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
On MSVC qsort requires that functions passed into it use the __cdecl calling conversion(CC).
|
||||||
|
This explicitly marks such functions as __cdecl so that the code will still compile
|
||||||
|
if a CC other than __cdecl has been made the default.
|
||||||
|
*/
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# define WIN_CDECL __cdecl
|
||||||
|
#else
|
||||||
|
# define WIN_CDECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
|
||||||
|
* parameters. They must be inlined for the compiler to eliminate the constant
|
||||||
|
* branches.
|
||||||
|
*/
|
||||||
|
#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
||||||
|
/**
|
||||||
|
* HINT_INLINE is used to help the compiler generate better code. It is *not*
|
||||||
|
* used for "templates", so it can be tweaked based on the compilers
|
||||||
|
* performance.
|
||||||
|
*
|
||||||
|
* gcc-4.8 and gcc-4.9 have been shown to benefit from leaving off the
|
||||||
|
* always_inline attribute.
|
||||||
|
*
|
||||||
|
* clang up to 5.0.0 (trunk) benefit tremendously from the always_inline
|
||||||
|
* attribute.
|
||||||
|
*/
|
||||||
|
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5
|
||||||
|
# define HINT_INLINE static INLINE_KEYWORD
|
||||||
|
#else
|
||||||
|
# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
# define UNUSED_ATTR __attribute__((unused))
|
||||||
|
#else
|
||||||
|
# define UNUSED_ATTR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* force no inlining */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# define FORCE_NOINLINE static __declspec(noinline)
|
||||||
|
#else
|
||||||
|
# if defined(__GNUC__) || defined(__ICCARM__)
|
||||||
|
# define FORCE_NOINLINE static __attribute__((__noinline__))
|
||||||
|
# else
|
||||||
|
# define FORCE_NOINLINE static
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* target attribute */
|
||||||
|
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||||
|
# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
|
||||||
|
#else
|
||||||
|
# define TARGET_ATTRIBUTE(target)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Target attribute for BMI2 dynamic dispatch.
|
||||||
|
* Enable lzcnt, bmi, and bmi2.
|
||||||
|
* We test for bmi1 & bmi2. lzcnt is included in bmi1.
|
||||||
|
*/
|
||||||
|
#define BMI2_TARGET_ATTRIBUTE TARGET_ATTRIBUTE("lzcnt,bmi,bmi2")
|
||||||
|
|
||||||
|
/* prefetch
|
||||||
|
* can be disabled, by declaring NO_PREFETCH build macro */
|
||||||
|
#if defined(NO_PREFETCH)
|
||||||
|
# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
|
||||||
|
# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
|
||||||
|
#else
|
||||||
|
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
|
||||||
|
# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
|
||||||
|
# define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
|
||||||
|
# define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
|
||||||
|
# elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
|
||||||
|
# define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
|
||||||
|
# define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
|
||||||
|
# elif defined(__aarch64__)
|
||||||
|
# define PREFETCH_L1(ptr) __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr)))
|
||||||
|
# define PREFETCH_L2(ptr) __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr)))
|
||||||
|
# else
|
||||||
|
# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
|
||||||
|
# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
|
||||||
|
# endif
|
||||||
|
#endif /* NO_PREFETCH */
|
||||||
|
|
||||||
|
#define CACHELINE_SIZE 64
|
||||||
|
|
||||||
|
#define PREFETCH_AREA(p, s) { \
|
||||||
|
const char* const _ptr = (const char*)(p); \
|
||||||
|
size_t const _size = (size_t)(s); \
|
||||||
|
size_t _pos; \
|
||||||
|
for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
|
||||||
|
PREFETCH_L2(_ptr + _pos); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vectorization
|
||||||
|
* older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax,
|
||||||
|
* and some compilers, like Intel ICC and MCST LCC, do not support it at all. */
|
||||||
|
#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && !defined(__LCC__)
|
||||||
|
# if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5)
|
||||||
|
# define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
|
||||||
|
# else
|
||||||
|
# define DONT_VECTORIZE _Pragma("GCC optimize(\"no-tree-vectorize\")")
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define DONT_VECTORIZE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Tell the compiler that a branch is likely or unlikely.
|
||||||
|
* Only use these macros if it causes the compiler to generate better code.
|
||||||
|
* If you can remove a LIKELY/UNLIKELY annotation without speed changes in gcc
|
||||||
|
* and clang, please do.
|
||||||
|
*/
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define LIKELY(x) (__builtin_expect((x), 1))
|
||||||
|
#define UNLIKELY(x) (__builtin_expect((x), 0))
|
||||||
|
#else
|
||||||
|
#define LIKELY(x) (x)
|
||||||
|
#define UNLIKELY(x) (x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_builtin(__builtin_unreachable) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
|
||||||
|
# define ZSTD_UNREACHABLE { assert(0), __builtin_unreachable(); }
|
||||||
|
#else
|
||||||
|
# define ZSTD_UNREACHABLE { assert(0); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* disable warnings */
|
||||||
|
#ifdef _MSC_VER /* Visual Studio */
|
||||||
|
# include <intrin.h> /* For Visual 2005 */
|
||||||
|
# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
|
||||||
|
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
||||||
|
# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
|
||||||
|
# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */
|
||||||
|
# pragma warning(disable : 4324) /* disable: C4324: padded structure */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Like DYNAMIC_BMI2 but for compile time determination of BMI2 support*/
|
||||||
|
#ifndef STATIC_BMI2
|
||||||
|
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))
|
||||||
|
# ifdef __AVX2__ //MSVC does not have a BMI2 specific flag, but every CPU that supports AVX2 also supports BMI2
|
||||||
|
# define STATIC_BMI2 1
|
||||||
|
# endif
|
||||||
|
# elif defined(__BMI2__) && defined(__x86_64__) && defined(__GNUC__)
|
||||||
|
# define STATIC_BMI2 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STATIC_BMI2
|
||||||
|
#define STATIC_BMI2 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* compile time determination of SIMD support */
|
||||||
|
#if !defined(ZSTD_NO_INTRINSICS)
|
||||||
|
# if defined(__SSE2__) || defined(_M_AMD64) || (defined (_M_IX86) && defined(_M_IX86_FP) && (_M_IX86_FP >= 2))
|
||||||
|
# define ZSTD_ARCH_X86_SSE2
|
||||||
|
# endif
|
||||||
|
# if defined(__ARM_NEON) || defined(_M_ARM64)
|
||||||
|
# define ZSTD_ARCH_ARM_NEON
|
||||||
|
# endif
|
||||||
|
#
|
||||||
|
# if defined(ZSTD_ARCH_X86_SSE2)
|
||||||
|
# include <emmintrin.h>
|
||||||
|
# elif defined(ZSTD_ARCH_ARM_NEON)
|
||||||
|
# include <arm_neon.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* C-language Attributes are added in C23. */
|
||||||
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201710L) && defined(__has_c_attribute)
|
||||||
|
# define ZSTD_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
|
||||||
|
#else
|
||||||
|
# define ZSTD_HAS_C_ATTRIBUTE(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Only use C++ attributes in C++. Some compilers report support for C++
|
||||||
|
* attributes when compiling with C.
|
||||||
|
*/
|
||||||
|
#if defined(__cplusplus) && defined(__has_cpp_attribute)
|
||||||
|
# define ZSTD_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
||||||
|
#else
|
||||||
|
# define ZSTD_HAS_CPP_ATTRIBUTE(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define ZSTD_FALLTHROUGH macro for annotating switch case with the 'fallthrough' attribute.
|
||||||
|
* - C23: https://en.cppreference.com/w/c/language/attributes/fallthrough
|
||||||
|
* - CPP17: https://en.cppreference.com/w/cpp/language/attributes/fallthrough
|
||||||
|
* - Else: __attribute__((__fallthrough__))
|
||||||
|
*/
|
||||||
|
#ifndef ZSTD_FALLTHROUGH
|
||||||
|
# if ZSTD_HAS_C_ATTRIBUTE(fallthrough)
|
||||||
|
# define ZSTD_FALLTHROUGH [[fallthrough]]
|
||||||
|
# elif ZSTD_HAS_CPP_ATTRIBUTE(fallthrough)
|
||||||
|
# define ZSTD_FALLTHROUGH [[fallthrough]]
|
||||||
|
# elif __has_attribute(__fallthrough__)
|
||||||
|
/* Leading semicolon is to satisfy gcc-11 with -pedantic. Without the semicolon
|
||||||
|
* gcc complains about: a label can only be part of a statement and a declaration is not a statement.
|
||||||
|
*/
|
||||||
|
# define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
|
||||||
|
# else
|
||||||
|
# define ZSTD_FALLTHROUGH
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-**************************************************************
|
||||||
|
* Alignment check
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
/* this test was initially positioned in mem.h,
|
||||||
|
* but this file is removed (or replaced) for linux kernel
|
||||||
|
* so it's now hosted in compiler.h,
|
||||||
|
* which remains valid for both user & kernel spaces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZSTD_ALIGNOF
|
||||||
|
# if defined(__GNUC__) || defined(_MSC_VER)
|
||||||
|
/* covers gcc, clang & MSVC */
|
||||||
|
/* note : this section must come first, before C11,
|
||||||
|
* due to a limitation in the kernel source generator */
|
||||||
|
# define ZSTD_ALIGNOF(T) __alignof(T)
|
||||||
|
|
||||||
|
# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||||
|
/* C11 support */
|
||||||
|
# include <stdalign.h>
|
||||||
|
# define ZSTD_ALIGNOF(T) alignof(T)
|
||||||
|
|
||||||
|
# else
|
||||||
|
/* No known support for alignof() - imperfect backup */
|
||||||
|
# define ZSTD_ALIGNOF(T) (sizeof(void*) < sizeof(T) ? sizeof(void*) : sizeof(T))
|
||||||
|
|
||||||
|
# endif
|
||||||
|
#endif /* ZSTD_ALIGNOF */
|
||||||
|
|
||||||
|
/*-**************************************************************
|
||||||
|
* Sanitizer
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
#if ZSTD_MEMORY_SANITIZER
|
||||||
|
/* Not all platforms that support msan provide sanitizers/msan_interface.h.
|
||||||
|
* We therefore declare the functions we need ourselves, rather than trying to
|
||||||
|
* include the header file... */
|
||||||
|
#include <stddef.h> /* size_t */
|
||||||
|
#define ZSTD_DEPS_NEED_STDINT
|
||||||
|
#include "zstd_deps.h" /* intptr_t */
|
||||||
|
|
||||||
|
/* Make memory region fully initialized (without changing its contents). */
|
||||||
|
void __msan_unpoison(const volatile void *a, size_t size);
|
||||||
|
|
||||||
|
/* Make memory region fully uninitialized (without changing its contents).
|
||||||
|
This is a legacy interface that does not update origin information. Use
|
||||||
|
__msan_allocated_memory() instead. */
|
||||||
|
void __msan_poison(const volatile void *a, size_t size);
|
||||||
|
|
||||||
|
/* Returns the offset of the first (at least partially) poisoned byte in the
|
||||||
|
memory range, or -1 if the whole range is good. */
|
||||||
|
intptr_t __msan_test_shadow(const volatile void *x, size_t size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ZSTD_ADDRESS_SANITIZER
|
||||||
|
/* Not all platforms that support asan provide sanitizers/asan_interface.h.
|
||||||
|
* We therefore declare the functions we need ourselves, rather than trying to
|
||||||
|
* include the header file... */
|
||||||
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a memory region (<c>[addr, addr+size)</c>) as unaddressable.
|
||||||
|
*
|
||||||
|
* This memory must be previously allocated by your program. Instrumented
|
||||||
|
* code is forbidden from accessing addresses in this region until it is
|
||||||
|
* unpoisoned. This function is not guaranteed to poison the entire region -
|
||||||
|
* it could poison only a subregion of <c>[addr, addr+size)</c> due to ASan
|
||||||
|
* alignment restrictions.
|
||||||
|
*
|
||||||
|
* \note This function is not thread-safe because no two threads can poison or
|
||||||
|
* unpoison memory in the same memory region simultaneously.
|
||||||
|
*
|
||||||
|
* \param addr Start of memory region.
|
||||||
|
* \param size Size of memory region. */
|
||||||
|
void __asan_poison_memory_region(void const volatile *addr, size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a memory region (<c>[addr, addr+size)</c>) as addressable.
|
||||||
|
*
|
||||||
|
* This memory must be previously allocated by your program. Accessing
|
||||||
|
* addresses in this region is allowed until this region is poisoned again.
|
||||||
|
* This function could unpoison a super-region of <c>[addr, addr+size)</c> due
|
||||||
|
* to ASan alignment restrictions.
|
||||||
|
*
|
||||||
|
* \note This function is not thread-safe because no two threads can
|
||||||
|
* poison or unpoison memory in the same memory region simultaneously.
|
||||||
|
*
|
||||||
|
* \param addr Start of memory region.
|
||||||
|
* \param size Size of memory region. */
|
||||||
|
void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZSTD_COMPILER_H */
|
||||||
213
external/zstd/common/cpu.h
vendored
Normal file
213
external/zstd/common/cpu.h
vendored
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under both the BSD-style license (found in the
|
||||||
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
* in the COPYING file in the root directory of this source tree).
|
||||||
|
* You may select, at your option, one of the above-listed licenses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZSTD_COMMON_CPU_H
|
||||||
|
#define ZSTD_COMMON_CPU_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation taken from folly/CpuId.h
|
||||||
|
* https://github.com/facebook/folly/blob/master/folly/CpuId.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
U32 f1c;
|
||||||
|
U32 f1d;
|
||||||
|
U32 f7b;
|
||||||
|
U32 f7c;
|
||||||
|
} ZSTD_cpuid_t;
|
||||||
|
|
||||||
|
MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
|
||||||
|
U32 f1c = 0;
|
||||||
|
U32 f1d = 0;
|
||||||
|
U32 f7b = 0;
|
||||||
|
U32 f7c = 0;
|
||||||
|
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
|
||||||
|
int reg[4];
|
||||||
|
__cpuid((int*)reg, 0);
|
||||||
|
{
|
||||||
|
int const n = reg[0];
|
||||||
|
if (n >= 1) {
|
||||||
|
__cpuid((int*)reg, 1);
|
||||||
|
f1c = (U32)reg[2];
|
||||||
|
f1d = (U32)reg[3];
|
||||||
|
}
|
||||||
|
if (n >= 7) {
|
||||||
|
__cpuidex((int*)reg, 7, 0);
|
||||||
|
f7b = (U32)reg[1];
|
||||||
|
f7c = (U32)reg[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && defined(__GNUC__)
|
||||||
|
/* The following block like the normal cpuid branch below, but gcc
|
||||||
|
* reserves ebx for use of its pic register so we must specially
|
||||||
|
* handle the save and restore to avoid clobbering the register
|
||||||
|
*/
|
||||||
|
U32 n;
|
||||||
|
__asm__(
|
||||||
|
"pushl %%ebx\n\t"
|
||||||
|
"cpuid\n\t"
|
||||||
|
"popl %%ebx\n\t"
|
||||||
|
: "=a"(n)
|
||||||
|
: "a"(0)
|
||||||
|
: "ecx", "edx");
|
||||||
|
if (n >= 1) {
|
||||||
|
U32 f1a;
|
||||||
|
__asm__(
|
||||||
|
"pushl %%ebx\n\t"
|
||||||
|
"cpuid\n\t"
|
||||||
|
"popl %%ebx\n\t"
|
||||||
|
: "=a"(f1a), "=c"(f1c), "=d"(f1d)
|
||||||
|
: "a"(1));
|
||||||
|
}
|
||||||
|
if (n >= 7) {
|
||||||
|
__asm__(
|
||||||
|
"pushl %%ebx\n\t"
|
||||||
|
"cpuid\n\t"
|
||||||
|
"movl %%ebx, %%eax\n\t"
|
||||||
|
"popl %%ebx"
|
||||||
|
: "=a"(f7b), "=c"(f7c)
|
||||||
|
: "a"(7), "c"(0)
|
||||||
|
: "edx");
|
||||||
|
}
|
||||||
|
#elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__)
|
||||||
|
U32 n;
|
||||||
|
__asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "ecx", "edx");
|
||||||
|
if (n >= 1) {
|
||||||
|
U32 f1a;
|
||||||
|
__asm__("cpuid" : "=a"(f1a), "=c"(f1c), "=d"(f1d) : "a"(1) : "ebx");
|
||||||
|
}
|
||||||
|
if (n >= 7) {
|
||||||
|
U32 f7a;
|
||||||
|
__asm__("cpuid"
|
||||||
|
: "=a"(f7a), "=b"(f7b), "=c"(f7c)
|
||||||
|
: "a"(7), "c"(0)
|
||||||
|
: "edx");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ZSTD_cpuid_t cpuid;
|
||||||
|
cpuid.f1c = f1c;
|
||||||
|
cpuid.f1d = f1d;
|
||||||
|
cpuid.f7b = f7b;
|
||||||
|
cpuid.f7c = f7c;
|
||||||
|
return cpuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define X(name, r, bit) \
|
||||||
|
MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) { \
|
||||||
|
return ((cpuid.r) & (1U << bit)) != 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cpuid(1): Processor Info and Feature Bits. */
|
||||||
|
#define C(name, bit) X(name, f1c, bit)
|
||||||
|
C(sse3, 0)
|
||||||
|
C(pclmuldq, 1)
|
||||||
|
C(dtes64, 2)
|
||||||
|
C(monitor, 3)
|
||||||
|
C(dscpl, 4)
|
||||||
|
C(vmx, 5)
|
||||||
|
C(smx, 6)
|
||||||
|
C(eist, 7)
|
||||||
|
C(tm2, 8)
|
||||||
|
C(ssse3, 9)
|
||||||
|
C(cnxtid, 10)
|
||||||
|
C(fma, 12)
|
||||||
|
C(cx16, 13)
|
||||||
|
C(xtpr, 14)
|
||||||
|
C(pdcm, 15)
|
||||||
|
C(pcid, 17)
|
||||||
|
C(dca, 18)
|
||||||
|
C(sse41, 19)
|
||||||
|
C(sse42, 20)
|
||||||
|
C(x2apic, 21)
|
||||||
|
C(movbe, 22)
|
||||||
|
C(popcnt, 23)
|
||||||
|
C(tscdeadline, 24)
|
||||||
|
C(aes, 25)
|
||||||
|
C(xsave, 26)
|
||||||
|
C(osxsave, 27)
|
||||||
|
C(avx, 28)
|
||||||
|
C(f16c, 29)
|
||||||
|
C(rdrand, 30)
|
||||||
|
#undef C
|
||||||
|
#define D(name, bit) X(name, f1d, bit)
|
||||||
|
D(fpu, 0)
|
||||||
|
D(vme, 1)
|
||||||
|
D(de, 2)
|
||||||
|
D(pse, 3)
|
||||||
|
D(tsc, 4)
|
||||||
|
D(msr, 5)
|
||||||
|
D(pae, 6)
|
||||||
|
D(mce, 7)
|
||||||
|
D(cx8, 8)
|
||||||
|
D(apic, 9)
|
||||||
|
D(sep, 11)
|
||||||
|
D(mtrr, 12)
|
||||||
|
D(pge, 13)
|
||||||
|
D(mca, 14)
|
||||||
|
D(cmov, 15)
|
||||||
|
D(pat, 16)
|
||||||
|
D(pse36, 17)
|
||||||
|
D(psn, 18)
|
||||||
|
D(clfsh, 19)
|
||||||
|
D(ds, 21)
|
||||||
|
D(acpi, 22)
|
||||||
|
D(mmx, 23)
|
||||||
|
D(fxsr, 24)
|
||||||
|
D(sse, 25)
|
||||||
|
D(sse2, 26)
|
||||||
|
D(ss, 27)
|
||||||
|
D(htt, 28)
|
||||||
|
D(tm, 29)
|
||||||
|
D(pbe, 31)
|
||||||
|
#undef D
|
||||||
|
|
||||||
|
/* cpuid(7): Extended Features. */
|
||||||
|
#define B(name, bit) X(name, f7b, bit)
|
||||||
|
B(bmi1, 3)
|
||||||
|
B(hle, 4)
|
||||||
|
B(avx2, 5)
|
||||||
|
B(smep, 7)
|
||||||
|
B(bmi2, 8)
|
||||||
|
B(erms, 9)
|
||||||
|
B(invpcid, 10)
|
||||||
|
B(rtm, 11)
|
||||||
|
B(mpx, 14)
|
||||||
|
B(avx512f, 16)
|
||||||
|
B(avx512dq, 17)
|
||||||
|
B(rdseed, 18)
|
||||||
|
B(adx, 19)
|
||||||
|
B(smap, 20)
|
||||||
|
B(avx512ifma, 21)
|
||||||
|
B(pcommit, 22)
|
||||||
|
B(clflushopt, 23)
|
||||||
|
B(clwb, 24)
|
||||||
|
B(avx512pf, 26)
|
||||||
|
B(avx512er, 27)
|
||||||
|
B(avx512cd, 28)
|
||||||
|
B(sha, 29)
|
||||||
|
B(avx512bw, 30)
|
||||||
|
B(avx512vl, 31)
|
||||||
|
#undef B
|
||||||
|
#define C(name, bit) X(name, f7c, bit)
|
||||||
|
C(prefetchwt1, 0)
|
||||||
|
C(avx512vbmi, 1)
|
||||||
|
#undef C
|
||||||
|
|
||||||
|
#undef X
|
||||||
|
|
||||||
|
#endif /* ZSTD_COMMON_CPU_H */
|
||||||
24
external/zstd/common/debug.c
vendored
Normal file
24
external/zstd/common/debug.c
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/* ******************************************************************
|
||||||
|
* debug
|
||||||
|
* Part of FSE library
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* You can contact the author at :
|
||||||
|
* - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
||||||
|
*
|
||||||
|
* This source code is licensed under both the BSD-style license (found in the
|
||||||
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
* in the COPYING file in the root directory of this source tree).
|
||||||
|
* You may select, at your option, one of the above-listed licenses.
|
||||||
|
****************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This module only hosts one global variable
|
||||||
|
* which can be used to dynamically influence the verbosity of traces,
|
||||||
|
* such as DEBUGLOG and RAWLOG
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
int g_debuglevel = DEBUGLEVEL;
|
||||||
107
external/zstd/common/debug.h
vendored
Normal file
107
external/zstd/common/debug.h
vendored
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/* ******************************************************************
|
||||||
|
* debug
|
||||||
|
* Part of FSE library
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* You can contact the author at :
|
||||||
|
* - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
||||||
|
*
|
||||||
|
* This source code is licensed under both the BSD-style license (found in the
|
||||||
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
* in the COPYING file in the root directory of this source tree).
|
||||||
|
* You may select, at your option, one of the above-listed licenses.
|
||||||
|
****************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The purpose of this header is to enable debug functions.
|
||||||
|
* They regroup assert(), DEBUGLOG() and RAWLOG() for run-time,
|
||||||
|
* and DEBUG_STATIC_ASSERT() for compile-time.
|
||||||
|
*
|
||||||
|
* By default, DEBUGLEVEL==0, which means run-time debug is disabled.
|
||||||
|
*
|
||||||
|
* Level 1 enables assert() only.
|
||||||
|
* Starting level 2, traces can be generated and pushed to stderr.
|
||||||
|
* The higher the level, the more verbose the traces.
|
||||||
|
*
|
||||||
|
* It's possible to dynamically adjust level using variable g_debug_level,
|
||||||
|
* which is only declared if DEBUGLEVEL>=2,
|
||||||
|
* and is a global variable, not multi-thread protected (use with care)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DEBUG_H_12987983217
|
||||||
|
#define DEBUG_H_12987983217
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* static assert is triggered at compile time, leaving no runtime artefact.
|
||||||
|
* static assert only works with compile-time constants.
|
||||||
|
* Also, this variant can only be used inside a function. */
|
||||||
|
#define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
|
||||||
|
|
||||||
|
|
||||||
|
/* DEBUGLEVEL is expected to be defined externally,
|
||||||
|
* typically through compiler command line.
|
||||||
|
* Value must be a number. */
|
||||||
|
#ifndef DEBUGLEVEL
|
||||||
|
# define DEBUGLEVEL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* recommended values for DEBUGLEVEL :
|
||||||
|
* 0 : release mode, no debug, all run-time checks disabled
|
||||||
|
* 1 : enables assert() only, no display
|
||||||
|
* 2 : reserved, for currently active debug path
|
||||||
|
* 3 : events once per object lifetime (CCtx, CDict, etc.)
|
||||||
|
* 4 : events once per frame
|
||||||
|
* 5 : events once per block
|
||||||
|
* 6 : events once per sequence (verbose)
|
||||||
|
* 7+: events at every position (*very* verbose)
|
||||||
|
*
|
||||||
|
* It's generally inconvenient to output traces > 5.
|
||||||
|
* In which case, it's possible to selectively trigger high verbosity levels
|
||||||
|
* by modifying g_debug_level.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (DEBUGLEVEL>=1)
|
||||||
|
# define ZSTD_DEPS_NEED_ASSERT
|
||||||
|
# include "zstd_deps.h"
|
||||||
|
#else
|
||||||
|
# ifndef assert /* assert may be already defined, due to prior #include <assert.h> */
|
||||||
|
# define assert(condition) ((void)0) /* disable assert (default) */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (DEBUGLEVEL>=2)
|
||||||
|
# define ZSTD_DEPS_NEED_IO
|
||||||
|
# include "zstd_deps.h"
|
||||||
|
extern int g_debuglevel; /* the variable is only declared,
|
||||||
|
it actually lives in debug.c,
|
||||||
|
and is shared by the whole process.
|
||||||
|
It's not thread-safe.
|
||||||
|
It's useful when enabling very verbose levels
|
||||||
|
on selective conditions (such as position in src) */
|
||||||
|
|
||||||
|
# define RAWLOG(l, ...) { \
|
||||||
|
if (l<=g_debuglevel) { \
|
||||||
|
ZSTD_DEBUG_PRINT(__VA_ARGS__); \
|
||||||
|
} }
|
||||||
|
# define DEBUGLOG(l, ...) { \
|
||||||
|
if (l<=g_debuglevel) { \
|
||||||
|
ZSTD_DEBUG_PRINT(__FILE__ ": " __VA_ARGS__); \
|
||||||
|
ZSTD_DEBUG_PRINT(" \n"); \
|
||||||
|
} }
|
||||||
|
#else
|
||||||
|
# define RAWLOG(l, ...) {} /* disabled */
|
||||||
|
# define DEBUGLOG(l, ...) {} /* disabled */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* DEBUG_H_12987983217 */
|
||||||
341
external/zstd/common/entropy_common.c
vendored
Normal file
341
external/zstd/common/entropy_common.c
vendored
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
/* ******************************************************************
|
||||||
|
* Common functions of New Generation Entropy library
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* You can contact the author at :
|
||||||
|
* - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
||||||
|
* - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||||
|
*
|
||||||
|
* This source code is licensed under both the BSD-style license (found in the
|
||||||
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
* in the COPYING file in the root directory of this source tree).
|
||||||
|
* You may select, at your option, one of the above-listed licenses.
|
||||||
|
****************************************************************** */
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Dependencies
|
||||||
|
***************************************/
|
||||||
|
#include "mem.h"
|
||||||
|
#include "error_private.h" /* ERR_*, ERROR */
|
||||||
|
#define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */
|
||||||
|
#include "fse.h"
|
||||||
|
#define HUF_STATIC_LINKING_ONLY /* HUF_TABLELOG_ABSOLUTEMAX */
|
||||||
|
#include "huf.h"
|
||||||
|
#include "bits.h" /* ZSDT_highbit32, ZSTD_countTrailingZeros32 */
|
||||||
|
|
||||||
|
|
||||||
|
/*=== Version ===*/
|
||||||
|
unsigned FSE_versionNumber(void) { return FSE_VERSION_NUMBER; }
|
||||||
|
|
||||||
|
|
||||||
|
/*=== Error Management ===*/
|
||||||
|
unsigned FSE_isError(size_t code) { return ERR_isError(code); }
|
||||||
|
const char* FSE_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
||||||
|
|
||||||
|
unsigned HUF_isError(size_t code) { return ERR_isError(code); }
|
||||||
|
const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
||||||
|
|
||||||
|
|
||||||
|
/*-**************************************************************
|
||||||
|
* FSE NCount encoding-decoding
|
||||||
|
****************************************************************/
|
||||||
|
FORCE_INLINE_TEMPLATE
|
||||||
|
size_t FSE_readNCount_body(short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
|
||||||
|
const void* headerBuffer, size_t hbSize)
|
||||||
|
{
|
||||||
|
const BYTE* const istart = (const BYTE*) headerBuffer;
|
||||||
|
const BYTE* const iend = istart + hbSize;
|
||||||
|
const BYTE* ip = istart;
|
||||||
|
int nbBits;
|
||||||
|
int remaining;
|
||||||
|
int threshold;
|
||||||
|
U32 bitStream;
|
||||||
|
int bitCount;
|
||||||
|
unsigned charnum = 0;
|
||||||
|
unsigned const maxSV1 = *maxSVPtr + 1;
|
||||||
|
int previous0 = 0;
|
||||||
|
|
||||||
|
if (hbSize < 8) {
|
||||||
|
/* This function only works when hbSize >= 8 */
|
||||||
|
char buffer[8] = {0};
|
||||||
|
ZSTD_memcpy(buffer, headerBuffer, hbSize);
|
||||||
|
{ size_t const countSize = FSE_readNCount(normalizedCounter, maxSVPtr, tableLogPtr,
|
||||||
|
buffer, sizeof(buffer));
|
||||||
|
if (FSE_isError(countSize)) return countSize;
|
||||||
|
if (countSize > hbSize) return ERROR(corruption_detected);
|
||||||
|
return countSize;
|
||||||
|
} }
|
||||||
|
assert(hbSize >= 8);
|
||||||
|
|
||||||
|
/* init */
|
||||||
|
ZSTD_memset(normalizedCounter, 0, (*maxSVPtr+1) * sizeof(normalizedCounter[0])); /* all symbols not present in NCount have a frequency of 0 */
|
||||||
|
bitStream = MEM_readLE32(ip);
|
||||||
|
nbBits = (bitStream & 0xF) + FSE_MIN_TABLELOG; /* extract tableLog */
|
||||||
|
if (nbBits > FSE_TABLELOG_ABSOLUTE_MAX) return ERROR(tableLog_tooLarge);
|
||||||
|
bitStream >>= 4;
|
||||||
|
bitCount = 4;
|
||||||
|
*tableLogPtr = nbBits;
|
||||||
|
remaining = (1<<nbBits)+1;
|
||||||
|
threshold = 1<<nbBits;
|
||||||
|
nbBits++;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (previous0) {
|
||||||
|
/* Count the number of repeats. Each time the
|
||||||
|
* 2-bit repeat code is 0b11 there is another
|
||||||
|
* repeat.
|
||||||
|
* Avoid UB by setting the high bit to 1.
|
||||||
|
*/
|
||||||
|
int repeats = ZSTD_countTrailingZeros32(~bitStream | 0x80000000) >> 1;
|
||||||
|
while (repeats >= 12) {
|
||||||
|
charnum += 3 * 12;
|
||||||
|
if (LIKELY(ip <= iend-7)) {
|
||||||
|
ip += 3;
|
||||||
|
} else {
|
||||||
|
bitCount -= (int)(8 * (iend - 7 - ip));
|
||||||
|
bitCount &= 31;
|
||||||
|
ip = iend - 4;
|
||||||
|
}
|
||||||
|
bitStream = MEM_readLE32(ip) >> bitCount;
|
||||||
|
repeats = ZSTD_countTrailingZeros32(~bitStream | 0x80000000) >> 1;
|
||||||
|
}
|
||||||
|
charnum += 3 * repeats;
|
||||||
|
bitStream >>= 2 * repeats;
|
||||||
|
bitCount += 2 * repeats;
|
||||||
|
|
||||||
|
/* Add the final repeat which isn't 0b11. */
|
||||||
|
assert((bitStream & 3) < 3);
|
||||||
|
charnum += bitStream & 3;
|
||||||
|
bitCount += 2;
|
||||||
|
|
||||||
|
/* This is an error, but break and return an error
|
||||||
|
* at the end, because returning out of a loop makes
|
||||||
|
* it harder for the compiler to optimize.
|
||||||
|
*/
|
||||||
|
if (charnum >= maxSV1) break;
|
||||||
|
|
||||||
|
/* We don't need to set the normalized count to 0
|
||||||
|
* because we already memset the whole buffer to 0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (LIKELY(ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) {
|
||||||
|
assert((bitCount >> 3) <= 3); /* For first condition to work */
|
||||||
|
ip += bitCount>>3;
|
||||||
|
bitCount &= 7;
|
||||||
|
} else {
|
||||||
|
bitCount -= (int)(8 * (iend - 4 - ip));
|
||||||
|
bitCount &= 31;
|
||||||
|
ip = iend - 4;
|
||||||
|
}
|
||||||
|
bitStream = MEM_readLE32(ip) >> bitCount;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int const max = (2*threshold-1) - remaining;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if ((bitStream & (threshold-1)) < (U32)max) {
|
||||||
|
count = bitStream & (threshold-1);
|
||||||
|
bitCount += nbBits-1;
|
||||||
|
} else {
|
||||||
|
count = bitStream & (2*threshold-1);
|
||||||
|
if (count >= threshold) count -= max;
|
||||||
|
bitCount += nbBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
count--; /* extra accuracy */
|
||||||
|
/* When it matters (small blocks), this is a
|
||||||
|
* predictable branch, because we don't use -1.
|
||||||
|
*/
|
||||||
|
if (count >= 0) {
|
||||||
|
remaining -= count;
|
||||||
|
} else {
|
||||||
|
assert(count == -1);
|
||||||
|
remaining += count;
|
||||||
|
}
|
||||||
|
normalizedCounter[charnum++] = (short)count;
|
||||||
|
previous0 = !count;
|
||||||
|
|
||||||
|
assert(threshold > 1);
|
||||||
|
if (remaining < threshold) {
|
||||||
|
/* This branch can be folded into the
|
||||||
|
* threshold update condition because we
|
||||||
|
* know that threshold > 1.
|
||||||
|
*/
|
||||||
|
if (remaining <= 1) break;
|
||||||
|
nbBits = ZSTD_highbit32(remaining) + 1;
|
||||||
|
threshold = 1 << (nbBits - 1);
|
||||||
|
}
|
||||||
|
if (charnum >= maxSV1) break;
|
||||||
|
|
||||||
|
if (LIKELY(ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) {
|
||||||
|
ip += bitCount>>3;
|
||||||
|
bitCount &= 7;
|
||||||
|
} else {
|
||||||
|
bitCount -= (int)(8 * (iend - 4 - ip));
|
||||||
|
bitCount &= 31;
|
||||||
|
ip = iend - 4;
|
||||||
|
}
|
||||||
|
bitStream = MEM_readLE32(ip) >> bitCount;
|
||||||
|
} }
|
||||||
|
if (remaining != 1) return ERROR(corruption_detected);
|
||||||
|
/* Only possible when there are too many zeros. */
|
||||||
|
if (charnum > maxSV1) return ERROR(maxSymbolValue_tooSmall);
|
||||||
|
if (bitCount > 32) return ERROR(corruption_detected);
|
||||||
|
*maxSVPtr = charnum-1;
|
||||||
|
|
||||||
|
ip += (bitCount+7)>>3;
|
||||||
|
return ip-istart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Avoids the FORCE_INLINE of the _body() function. */
|
||||||
|
static size_t FSE_readNCount_body_default(
|
||||||
|
short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
|
||||||
|
const void* headerBuffer, size_t hbSize)
|
||||||
|
{
|
||||||
|
return FSE_readNCount_body(normalizedCounter, maxSVPtr, tableLogPtr, headerBuffer, hbSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DYNAMIC_BMI2
|
||||||
|
BMI2_TARGET_ATTRIBUTE static size_t FSE_readNCount_body_bmi2(
|
||||||
|
short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
|
||||||
|
const void* headerBuffer, size_t hbSize)
|
||||||
|
{
|
||||||
|
return FSE_readNCount_body(normalizedCounter, maxSVPtr, tableLogPtr, headerBuffer, hbSize);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size_t FSE_readNCount_bmi2(
|
||||||
|
short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
|
||||||
|
const void* headerBuffer, size_t hbSize, int bmi2)
|
||||||
|
{
|
||||||
|
#if DYNAMIC_BMI2
|
||||||
|
if (bmi2) {
|
||||||
|
return FSE_readNCount_body_bmi2(normalizedCounter, maxSVPtr, tableLogPtr, headerBuffer, hbSize);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
(void)bmi2;
|
||||||
|
return FSE_readNCount_body_default(normalizedCounter, maxSVPtr, tableLogPtr, headerBuffer, hbSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t FSE_readNCount(
|
||||||
|
short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
|
||||||
|
const void* headerBuffer, size_t hbSize)
|
||||||
|
{
|
||||||
|
return FSE_readNCount_bmi2(normalizedCounter, maxSVPtr, tableLogPtr, headerBuffer, hbSize, /* bmi2 */ 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! HUF_readStats() :
|
||||||
|
Read compact Huffman tree, saved by HUF_writeCTable().
|
||||||
|
`huffWeight` is destination buffer.
|
||||||
|
`rankStats` is assumed to be a table of at least HUF_TABLELOG_MAX U32.
|
||||||
|
@return : size read from `src` , or an error Code .
|
||||||
|
Note : Needed by HUF_readCTable() and HUF_readDTableX?() .
|
||||||
|
*/
|
||||||
|
size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
||||||
|
U32* nbSymbolsPtr, U32* tableLogPtr,
|
||||||
|
const void* src, size_t srcSize)
|
||||||
|
{
|
||||||
|
U32 wksp[HUF_READ_STATS_WORKSPACE_SIZE_U32];
|
||||||
|
return HUF_readStats_wksp(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, wksp, sizeof(wksp), /* bmi2 */ 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE_TEMPLATE size_t
|
||||||
|
HUF_readStats_body(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
||||||
|
U32* nbSymbolsPtr, U32* tableLogPtr,
|
||||||
|
const void* src, size_t srcSize,
|
||||||
|
void* workSpace, size_t wkspSize,
|
||||||
|
int bmi2)
|
||||||
|
{
|
||||||
|
U32 weightTotal;
|
||||||
|
const BYTE* ip = (const BYTE*) src;
|
||||||
|
size_t iSize;
|
||||||
|
size_t oSize;
|
||||||
|
|
||||||
|
if (!srcSize) return ERROR(srcSize_wrong);
|
||||||
|
iSize = ip[0];
|
||||||
|
/* ZSTD_memset(huffWeight, 0, hwSize); *//* is not necessary, even though some analyzer complain ... */
|
||||||
|
|
||||||
|
if (iSize >= 128) { /* special header */
|
||||||
|
oSize = iSize - 127;
|
||||||
|
iSize = ((oSize+1)/2);
|
||||||
|
if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
|
||||||
|
if (oSize >= hwSize) return ERROR(corruption_detected);
|
||||||
|
ip += 1;
|
||||||
|
{ U32 n;
|
||||||
|
for (n=0; n<oSize; n+=2) {
|
||||||
|
huffWeight[n] = ip[n/2] >> 4;
|
||||||
|
huffWeight[n+1] = ip[n/2] & 15;
|
||||||
|
} } }
|
||||||
|
else { /* header compressed with FSE (normal case) */
|
||||||
|
if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
|
||||||
|
/* max (hwSize-1) values decoded, as last one is implied */
|
||||||
|
oSize = FSE_decompress_wksp_bmi2(huffWeight, hwSize-1, ip+1, iSize, 6, workSpace, wkspSize, bmi2);
|
||||||
|
if (FSE_isError(oSize)) return oSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* collect weight stats */
|
||||||
|
ZSTD_memset(rankStats, 0, (HUF_TABLELOG_MAX + 1) * sizeof(U32));
|
||||||
|
weightTotal = 0;
|
||||||
|
{ U32 n; for (n=0; n<oSize; n++) {
|
||||||
|
if (huffWeight[n] > HUF_TABLELOG_MAX) return ERROR(corruption_detected);
|
||||||
|
rankStats[huffWeight[n]]++;
|
||||||
|
weightTotal += (1 << huffWeight[n]) >> 1;
|
||||||
|
} }
|
||||||
|
if (weightTotal == 0) return ERROR(corruption_detected);
|
||||||
|
|
||||||
|
/* get last non-null symbol weight (implied, total must be 2^n) */
|
||||||
|
{ U32 const tableLog = ZSTD_highbit32(weightTotal) + 1;
|
||||||
|
if (tableLog > HUF_TABLELOG_MAX) return ERROR(corruption_detected);
|
||||||
|
*tableLogPtr = tableLog;
|
||||||
|
/* determine last weight */
|
||||||
|
{ U32 const total = 1 << tableLog;
|
||||||
|
U32 const rest = total - weightTotal;
|
||||||
|
U32 const verif = 1 << ZSTD_highbit32(rest);
|
||||||
|
U32 const lastWeight = ZSTD_highbit32(rest) + 1;
|
||||||
|
if (verif != rest) return ERROR(corruption_detected); /* last value must be a clean power of 2 */
|
||||||
|
huffWeight[oSize] = (BYTE)lastWeight;
|
||||||
|
rankStats[lastWeight]++;
|
||||||
|
} }
|
||||||
|
|
||||||
|
/* check tree construction validity */
|
||||||
|
if ((rankStats[1] < 2) || (rankStats[1] & 1)) return ERROR(corruption_detected); /* by construction : at least 2 elts of rank 1, must be even */
|
||||||
|
|
||||||
|
/* results */
|
||||||
|
*nbSymbolsPtr = (U32)(oSize+1);
|
||||||
|
return iSize+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Avoids the FORCE_INLINE of the _body() function. */
|
||||||
|
static size_t HUF_readStats_body_default(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
||||||
|
U32* nbSymbolsPtr, U32* tableLogPtr,
|
||||||
|
const void* src, size_t srcSize,
|
||||||
|
void* workSpace, size_t wkspSize)
|
||||||
|
{
|
||||||
|
return HUF_readStats_body(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, workSpace, wkspSize, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DYNAMIC_BMI2
|
||||||
|
static BMI2_TARGET_ATTRIBUTE size_t HUF_readStats_body_bmi2(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
||||||
|
U32* nbSymbolsPtr, U32* tableLogPtr,
|
||||||
|
const void* src, size_t srcSize,
|
||||||
|
void* workSpace, size_t wkspSize)
|
||||||
|
{
|
||||||
|
return HUF_readStats_body(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, workSpace, wkspSize, 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size_t HUF_readStats_wksp(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
||||||
|
U32* nbSymbolsPtr, U32* tableLogPtr,
|
||||||
|
const void* src, size_t srcSize,
|
||||||
|
void* workSpace, size_t wkspSize,
|
||||||
|
int bmi2)
|
||||||
|
{
|
||||||
|
#if DYNAMIC_BMI2
|
||||||
|
if (bmi2) {
|
||||||
|
return HUF_readStats_body_bmi2(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, workSpace, wkspSize);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
(void)bmi2;
|
||||||
|
return HUF_readStats_body_default(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, workSpace, wkspSize);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user