Compare commits
572 Commits
OpenHarmon
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c18b51182b | ||
|
|
d6dc0642c5 | ||
|
|
748e0d8ffb | ||
|
|
1cdd7307f3 | ||
|
|
9995d8e0e4 | ||
|
|
0ca4a128d2 | ||
|
|
de29140edf | ||
|
|
997e61ed53 | ||
|
|
6c2b163c7d | ||
|
|
979a8a8f27 | ||
|
|
b6f9dbbdba | ||
|
|
e567467b8a | ||
|
|
a776c04a3d | ||
|
|
f7932bd006 | ||
|
|
b0d31cb43f | ||
|
|
53addea304 | ||
|
|
954e7eb0cf | ||
|
|
0e48a0dd12 | ||
|
|
52c12f7c9d | ||
|
|
1e875d921b | ||
|
|
1db7aa7ada | ||
|
|
6a0c169780 | ||
|
|
bdb9864436 | ||
|
|
bc69ca104c | ||
|
|
0d325c56a1 | ||
|
|
5bed688ca6 | ||
|
|
63e71feca0 | ||
|
|
2ada41c826 | ||
|
|
9b397173fe | ||
|
|
2fa85a2c72 | ||
|
|
63a0fcaefb | ||
|
|
144214869f | ||
|
|
e1512566e3 | ||
|
|
6e886d4233 | ||
|
|
67e31f7b45 | ||
|
|
26c09d26fc | ||
|
|
1a8e22dcf1 | ||
|
|
8e614bb161 | ||
|
|
f88608e5a4 | ||
|
|
30d5badbce | ||
|
|
c8c07261ca | ||
|
|
2cd03c55b7 | ||
|
|
b3489d49d7 | ||
|
|
d955790a44 | ||
|
|
540b2017c5 | ||
|
|
212d1bd1e8 | ||
|
|
ba8438257a | ||
|
|
64e49aba7c | ||
|
|
3e7cfaa520 | ||
|
|
e748fdbe57 | ||
|
|
48f645db84 | ||
|
|
d73aff846b | ||
|
|
ce4323ff16 | ||
|
|
f6a7003c16 | ||
|
|
c12bef84b2 | ||
|
|
7a7c67cbdd | ||
|
|
d2a2f96adf | ||
|
|
5db6c62313 | ||
|
|
011a55ff21 | ||
|
|
68f9f49c2a | ||
|
|
fe4082ca9e | ||
|
|
ac08912230 | ||
|
|
a32a7c4fad | ||
|
|
bba832ea08 | ||
|
|
09fd11bc38 | ||
|
|
9ba725c3d4 | ||
|
|
2bddff54c8 | ||
|
|
bc32a1ec0f | ||
|
|
5d5df3a5d7 | ||
|
|
07cab40473 | ||
|
|
5ce70a50c3 | ||
|
|
0f878febb7 | ||
|
|
f63ce99399 | ||
|
|
e317f9b5b5 | ||
|
|
cc6e11281e | ||
|
|
9525ca2826 | ||
|
|
a412bfb275 | ||
|
|
3b8083815c | ||
|
|
a2fed9a56c | ||
|
|
2251b8a2d1 | ||
|
|
5077b1793f | ||
|
|
e99aba9d0f | ||
|
|
eedde91826 | ||
|
|
cdc0877f16 | ||
|
|
0f8ff8f545 | ||
|
|
f06e090a10 | ||
|
|
38163de8f3 | ||
|
|
fcb21ffc8a | ||
|
|
2e3bbf1e61 | ||
|
|
466996b2e1 | ||
|
|
52379242c1 | ||
|
|
e0a6e1f9f0 | ||
|
|
e54eb9e34d | ||
|
|
ef1d9f848d | ||
|
|
ebfac57d54 | ||
|
|
3074449c79 | ||
|
|
78a297fd4e | ||
|
|
5004ef4d87 | ||
|
|
79839a4325 | ||
|
|
b2274a009e | ||
|
|
a55f68f957 | ||
|
|
0f0e85b7a6 | ||
|
|
308750199f | ||
|
|
2f6cd46372 | ||
|
|
ea45982e1f | ||
|
|
f2f5c5fdc3 | ||
|
|
91c1737d1b | ||
|
|
557f4ccb66 | ||
|
|
1ed28b4c80 | ||
|
|
6827bd2a22 | ||
|
|
614cdccf91 | ||
|
|
23c4f2b81b | ||
|
|
d6f48477a4 | ||
|
|
7676cdb886 | ||
|
|
bd0c0835fc | ||
|
|
24ba16a01e | ||
|
|
f6ac03d3e3 | ||
|
|
f601c16b9e | ||
|
|
c121d0eea3 | ||
|
|
cf8446c941 | ||
|
|
e328c528b1 | ||
|
|
2be59680f2 | ||
|
|
805a67ae2f | ||
|
|
37bc11fa88 | ||
|
|
0507b9e8ea | ||
|
|
acd631c731 | ||
|
|
c1c2be2a87 | ||
|
|
bda00e6747 | ||
|
|
cb423f8454 | ||
|
|
d3b618887a | ||
|
|
e8f5a286aa | ||
|
|
b551270ef5 | ||
|
|
4ecc473843 | ||
|
|
8096d9f575 | ||
|
|
6d249618ae | ||
|
|
40338918d9 | ||
|
|
fd4b97e3f8 | ||
|
|
13e1e70358 | ||
|
|
c360a97bab | ||
|
|
665c152c27 | ||
|
|
3f71be7535 | ||
|
|
298ccea3fe | ||
|
|
56a92f9207 | ||
|
|
d21b05c0f6 | ||
|
|
29df5dc1f2 | ||
|
|
e4a06623ce | ||
|
|
e1b36bfe41 | ||
|
|
3dd952b0b7 | ||
|
|
06ea03715f | ||
|
|
48ca854bf0 | ||
|
|
c7da23695c | ||
|
|
2c33cfce86 | ||
|
|
9bf580b1f6 | ||
|
|
3be31d1cfb | ||
|
|
ee72b21aff | ||
|
|
6e0a3f10bb | ||
|
|
e1b85a4570 | ||
|
|
9726ba11a7 | ||
|
|
0fa1310a32 | ||
|
|
f7d010dfa4 | ||
|
|
bf030b6bb5 | ||
|
|
63fd8bc39b | ||
|
|
7d7cff4c51 | ||
|
|
9ab3e351d3 | ||
|
|
492264b8e6 | ||
|
|
d59aad1f3a | ||
|
|
9b07aece2d | ||
|
|
de8bd2866a | ||
|
|
1150f86d46 | ||
|
|
9fdb80f85f | ||
|
|
93e74c5f0b | ||
|
|
d23f2fc73f | ||
|
|
c0721f4f0b | ||
|
|
a375bf5668 | ||
|
|
52d1d8d8d0 | ||
|
|
c79bcd028e | ||
|
|
ecd9ca7781 | ||
|
|
38a6b804e9 | ||
|
|
92f33ab9c4 | ||
|
|
b3d96d166c | ||
|
|
0326cbf12e | ||
|
|
c3facd1b95 | ||
|
|
8713997548 | ||
|
|
a627cdba0c | ||
|
|
214f44e935 | ||
|
|
ba977dd5ab | ||
|
|
1ecacc15b1 | ||
|
|
33d0c1bd0b | ||
|
|
e095e87682 | ||
|
|
597ced7948 | ||
|
|
f67c4dae51 | ||
|
|
5e87d8c183 | ||
|
|
de8257bc82 | ||
|
|
19b39b1bff | ||
|
|
5e07663374 | ||
|
|
f9a907772f | ||
|
|
007f385396 | ||
|
|
463bc0546f | ||
|
|
0c93a9b4f8 | ||
|
|
d30a009ba5 | ||
|
|
4bee53a610 | ||
|
|
81b474813b | ||
|
|
dc9ec6856f | ||
|
|
658fafe83b | ||
|
|
f3562e490c | ||
|
|
9888185fcb | ||
|
|
055295b6d1 | ||
|
|
c26ca519f7 | ||
|
|
df35eb513d | ||
|
|
7cb2ad67bf | ||
|
|
98ca8441fe | ||
|
|
3393479c52 | ||
|
|
aa5b2c7641 | ||
|
|
7661aedcc9 | ||
|
|
c97178f2f6 | ||
|
|
8839fdd399 | ||
|
|
a3b480b18e | ||
|
|
defedb6fdf | ||
|
|
7019fdfcbb | ||
|
|
5a80d4e1a3 | ||
|
|
1ec8d5a454 | ||
|
|
7c577d8963 | ||
|
|
6e2a4be155 | ||
|
|
682ae82158 | ||
|
|
e828cbdeac | ||
|
|
45a128a4f0 | ||
|
|
83bff88f7f | ||
|
|
181322a3c1 | ||
|
|
5369b6aa23 | ||
|
|
0e260949c9 | ||
|
|
8b267dc690 | ||
|
|
d16bfd005a | ||
|
|
40297a6dbc | ||
|
|
752aa49018 | ||
|
|
5569b1d1ec | ||
|
|
9549f5ebd0 | ||
|
|
aa1cd245a5 | ||
|
|
36cfc68a54 | ||
|
|
4dc059f207 | ||
|
|
f4409babd4 | ||
|
|
e1b9a6b185 | ||
|
|
b5528e1d17 | ||
|
|
2db80ecb38 | ||
|
|
ec366df863 | ||
|
|
e1472b494f | ||
|
|
67ac8c4c58 | ||
|
|
555e0681be | ||
|
|
fb5df47b6c | ||
|
|
339e937a6a | ||
|
|
5910c9ab8d | ||
|
|
9fa8d27c6c | ||
|
|
7bc68f454f | ||
|
|
dc3cc094a7 | ||
|
|
1aa9f98858 | ||
|
|
42a3a6c51b | ||
|
|
bbdb977b5e | ||
|
|
87c2d4f7e4 | ||
|
|
0f4d5a4b0c | ||
|
|
dd91c5c772 | ||
|
|
da43449939 | ||
|
|
d6e0d3ee7d | ||
|
|
27dca4d857 | ||
|
|
70a8901c72 | ||
|
|
2f214bf4de | ||
|
|
76507c05a8 | ||
|
|
9b24cc4915 | ||
|
|
e64ee0f4e6 | ||
|
|
e13cb3bcc4 | ||
|
|
51da89a3fb | ||
|
|
42f374dd7a | ||
|
|
689c2e90cf | ||
|
|
cdf96fef0c | ||
|
|
26ee8b836e | ||
|
|
6917e08431 | ||
|
|
4c57aa26ad | ||
|
|
007c75eb18 | ||
|
|
8118408123 | ||
|
|
8df3e8c965 | ||
|
|
5edd78e756 | ||
|
|
ba16cd34d4 | ||
|
|
77dcef4bc0 | ||
|
|
024a8f2771 | ||
|
|
3bfa995a9d | ||
|
|
6549fd8be6 | ||
|
|
9ec208a273 | ||
|
|
53ced1a85e | ||
|
|
2b9c55fd90 | ||
|
|
7a98cad11a | ||
|
|
827e060606 | ||
|
|
78e8d86611 | ||
|
|
30b7d34eb4 | ||
|
|
a23b491f8c | ||
|
|
72734a335c | ||
|
|
626b6600c0 | ||
|
|
e8037dc56a | ||
|
|
4c8a86ece7 | ||
|
|
3cc09763f2 | ||
|
|
3bb3173604 | ||
|
|
d2fe0e788b | ||
|
|
6a5a0326d2 | ||
|
|
c3245b3ce3 | ||
|
|
e425187d17 | ||
|
|
a6c02e29c1 | ||
|
|
d169cad6b4 | ||
|
|
4875707b37 | ||
|
|
9b4fd13c3c | ||
|
|
343b92661d | ||
|
|
79982895ec | ||
|
|
7f7eb8374f | ||
|
|
1c8f3b98c9 | ||
|
|
8de96bba65 | ||
|
|
c66681a1f9 | ||
|
|
8696e1c6cb | ||
|
|
4dc421e3de | ||
|
|
ce66a234fc | ||
|
|
f85c27de59 | ||
|
|
9c291a4361 | ||
|
|
1722aaa80d | ||
|
|
88358ab302 | ||
|
|
1e5d01360b | ||
|
|
a7a25bb0a3 | ||
|
|
1394b3be26 | ||
|
|
590c7b4e22 | ||
|
|
698756d1e6 | ||
|
|
7819d15b36 | ||
|
|
11a9b00d43 | ||
|
|
2ad176e587 | ||
|
|
c54bfa16e3 | ||
|
|
187884937c | ||
|
|
2d8e59ccf3 | ||
|
|
85b4cb7a67 | ||
|
|
66764e48fb | ||
|
|
def22d3fd1 | ||
|
|
08878bd99f | ||
|
|
468c47b6b1 | ||
|
|
f3beb4b273 | ||
|
|
c71ec9d7e8 | ||
|
|
787fae2eec | ||
|
|
875c46290b | ||
|
|
09d5bcc22d | ||
|
|
abf4d8fb25 | ||
|
|
0dc79479ff | ||
|
|
0dfa58ca5a | ||
|
|
4427142d73 | ||
|
|
a531bcf389 | ||
|
|
9458de9ac6 | ||
|
|
76f45b3fb2 | ||
|
|
aaa9018acf | ||
|
|
3b5268f02a | ||
|
|
fa056ce246 | ||
|
|
0ad91713f6 | ||
|
|
9e9c7b28d4 | ||
|
|
8f6a1dd33c | ||
|
|
77270dd783 | ||
|
|
8755dc9d35 | ||
|
|
a8805a65aa | ||
|
|
4adc15e630 | ||
|
|
d9774e016e | ||
|
|
c610578d73 | ||
|
|
3b9e3f8471 | ||
|
|
58d4366e1d | ||
|
|
650d2b91cd | ||
|
|
35a2f3af33 | ||
|
|
2ff44c4938 | ||
|
|
7b7d64cc87 | ||
|
|
70c18b4a75 | ||
|
|
14bd753aa8 | ||
|
|
8729f6ee57 | ||
|
|
51a50c95b4 | ||
|
|
9d3e872454 | ||
|
|
80473f0975 | ||
|
|
7a6e4c8155 | ||
|
|
c40e1464b9 | ||
|
|
700c3415c4 | ||
|
|
0973004870 | ||
|
|
c9d69e2d1b | ||
|
|
d79fd50693 | ||
|
|
9547133e64 | ||
|
|
2d31aed27b | ||
|
|
d9ed4b4bf6 | ||
|
|
60bf2fc517 | ||
|
|
cb17fa50ed | ||
|
|
09c491ca1f | ||
|
|
a531da901d | ||
|
|
a195aac9fb | ||
|
|
1157c4a289 | ||
|
|
0056b4ade5 | ||
|
|
78a50aff99 | ||
|
|
7240fe3bd4 | ||
|
|
e7c4b1963a | ||
|
|
fd6f91bc9f | ||
|
|
33f5c70e6c | ||
|
|
ec977a1c7e | ||
|
|
92d7672b19 | ||
|
|
390159f58a | ||
|
|
d8be8aad65 | ||
|
|
6d948a42bb | ||
|
|
72d9aa1bcb | ||
|
|
8390738de5 | ||
|
|
40f239a7d4 | ||
|
|
cacb4f0103 | ||
|
|
ee54cd8b7e | ||
|
|
f523d7a98c | ||
|
|
d7387508e3 | ||
|
|
e4ff04586f | ||
|
|
8784694686 | ||
|
|
b29d9d88ab | ||
|
|
d8263b1e91 | ||
|
|
9304a683ad | ||
|
|
78906f4a6c | ||
|
|
ee7eb89354 | ||
|
|
55e5e29005 | ||
|
|
ac8c2c6d5b | ||
|
|
feae60c8fe | ||
|
|
425975e481 | ||
|
|
cc731d1e69 | ||
|
|
56a95b9ec9 | ||
|
|
3e7622ca78 | ||
|
|
b1b4ddcc7d | ||
|
|
e567a10d02 | ||
|
|
23fd4e55a3 | ||
|
|
e57dc7762b | ||
|
|
003810284c | ||
|
|
379d602ab6 | ||
|
|
bf7b2c0a3e | ||
|
|
4e4f2d6d7e | ||
|
|
d7672d47f2 | ||
|
|
abbeca1cb2 | ||
|
|
50c8abc521 | ||
|
|
0469e5b849 | ||
|
|
dfea902a08 | ||
|
|
339c467e71 | ||
|
|
455e42e5b9 | ||
|
|
6f6dc4f24c | ||
|
|
9e45086d19 | ||
|
|
9515d53dcc | ||
|
|
e0a27badde | ||
|
|
49856dc1e0 | ||
|
|
43bdf2f1d3 | ||
|
|
eb1900d4db | ||
|
|
7de43bb004 | ||
|
|
1d952a254a | ||
|
|
9db3407589 | ||
|
|
bb6abd8c6b | ||
|
|
3cddcb9f66 | ||
|
|
bfd27e78b2 | ||
|
|
a8384b5db2 | ||
|
|
5db839acef | ||
|
|
f4626985fd | ||
|
|
68da7aefc5 | ||
|
|
f1b4c87bc4 | ||
|
|
1348809807 | ||
|
|
eb72f78cf1 | ||
|
|
12577eade5 | ||
|
|
de6db86df3 | ||
|
|
56b8ecaf17 | ||
|
|
1e345f18b3 | ||
|
|
f793dc1097 | ||
|
|
112cdebe41 | ||
|
|
a28dcc38c9 | ||
|
|
3d1cf683f3 | ||
|
|
a9fc1e0e5d | ||
|
|
2e2b14205f | ||
|
|
b8e18ffdf1 | ||
|
|
21d8ac8752 | ||
|
|
008fa8660d | ||
|
|
6860246cfa | ||
|
|
8a3d188240 | ||
|
|
8f0d25225e | ||
|
|
8fe0cc7770 | ||
|
|
ee4cf83121 | ||
|
|
702d8d9dde | ||
|
|
290a3c6f92 | ||
|
|
600dded31e | ||
|
|
67806596a3 | ||
|
|
88fe4eb3e1 | ||
|
|
ca40c79761 | ||
|
|
231cb6be27 | ||
|
|
7f484dfa09 | ||
|
|
1fa6ba3389 | ||
|
|
b7f2df0350 | ||
|
|
8bb4538de1 | ||
|
|
99d7072332 | ||
|
|
30f5ab89b7 | ||
|
|
fd3f4072b5 | ||
|
|
143efc0fab | ||
|
|
2f3d7efc24 | ||
|
|
e76c0046f7 | ||
|
|
b3120b5498 | ||
|
|
53c6d96c6f | ||
|
|
3f84ed5075 | ||
|
|
e9ad6b71c3 | ||
|
|
e5a3ee6f33 | ||
|
|
fbfd71dfe3 | ||
|
|
36e5124c0a | ||
|
|
73a777777e | ||
|
|
e4b6ba56b9 | ||
|
|
5f970888ef | ||
|
|
6e95771303 | ||
|
|
f8cf6e6439 | ||
|
|
ed0041ac65 | ||
|
|
acda419a2d | ||
|
|
dca42b9ef6 | ||
|
|
fa6993381a | ||
|
|
37d80146db | ||
|
|
7e2aef2480 | ||
|
|
9169637084 | ||
|
|
acb24924be | ||
|
|
bfb74b2027 | ||
|
|
f0b419099d | ||
|
|
81f3d59717 | ||
|
|
eca711bb64 | ||
|
|
900269bd46 | ||
|
|
e50cf0be6f | ||
|
|
a760c268f4 | ||
|
|
5c78236428 | ||
|
|
7ffc996b0a | ||
|
|
23937a239f | ||
|
|
b91fabb76c | ||
|
|
e36b0fd4d5 | ||
|
|
4e269d7071 | ||
|
|
6eddc869d3 | ||
|
|
561831928b | ||
|
|
6dee4ae603 | ||
|
|
413e02304d | ||
|
|
8c5b358bb1 | ||
|
|
3bf8cbc728 | ||
|
|
36462bcd7e | ||
|
|
1f8e5424f3 | ||
|
|
ebb1305ba4 | ||
|
|
565b2e85cd | ||
|
|
44ce696904 | ||
|
|
3fa315ab0b | ||
|
|
e5ba92b4b9 | ||
|
|
6352d6e1da | ||
|
|
1a3f3f54e7 | ||
|
|
7d10057103 | ||
|
|
a94c6b09bd | ||
|
|
647f3defcd | ||
|
|
101a55d119 | ||
|
|
09756fe55b | ||
|
|
3457c0b11d | ||
|
|
0676578aae | ||
|
|
b5370af822 | ||
|
|
744b2021b2 | ||
|
|
c39c10c978 | ||
|
|
efbab200aa | ||
|
|
a580754751 | ||
|
|
e5bfe19b28 | ||
|
|
4f514a16af | ||
|
|
c4595d2504 | ||
|
|
eb7d977b3e | ||
|
|
f10dd7c135 | ||
|
|
e5f6bf0556 | ||
|
|
c54879b548 | ||
|
|
e93c52c091 | ||
|
|
042f06e2b1 | ||
|
|
0db43f24f5 | ||
|
|
2067b2f648 | ||
|
|
e59693e7fa | ||
|
|
4d07d2e954 | ||
|
|
db38464778 | ||
|
|
071cd6268a | ||
|
|
2e82c361f7 | ||
|
|
a00cce8128 | ||
|
|
25f1051d7a | ||
|
|
4c024159a9 | ||
|
|
9bdf716407 | ||
|
|
cf89f016e9 | ||
|
|
471de3663e | ||
|
|
73223ae7e6 | ||
|
|
d25560f8ac |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -16,10 +16,9 @@ cscope*
|
||||
tags
|
||||
|
||||
# Menuconfig temp files
|
||||
/include/config
|
||||
/include/generated
|
||||
.config*
|
||||
/config.h
|
||||
/.config
|
||||
/.config.old
|
||||
|
||||
# Build temp files
|
||||
/platform/board.ld
|
||||
/out
|
||||
|
||||
383
BUILD.gn
383
BUILD.gn
@@ -28,56 +28,369 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//build/lite/config/subsystem/lite_subsystem.gni")
|
||||
|
||||
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||
|
||||
declare_args() {
|
||||
tee_enable = false
|
||||
liteos_name = "OHOS_Image"
|
||||
liteos_skip_make = false
|
||||
}
|
||||
|
||||
tee = ""
|
||||
if (tee_enable) {
|
||||
tee = "_tee"
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
liteos_config_file = "${ohos_build_type}${tee}.config"
|
||||
}
|
||||
|
||||
liteos_config_file =
|
||||
rebase_path(liteos_config_file, "", "$product_path/kernel_configs")
|
||||
print("liteos_config_file:", liteos_config_file)
|
||||
|
||||
exec_script("//build/lite/run_shell_cmd.py",
|
||||
[ "env" + " CONFIG_=LOSCFG_" + " KCONFIG_CONFIG_HEADER='y=true'" +
|
||||
" KCONFIG_CONFIG=$liteos_config_file" +
|
||||
" DEVICE_PATH=$device_path" + " srctree=" + rebase_path(".") +
|
||||
" genconfig" + " --header-path $LITEOS_MENUCONFIG_H" +
|
||||
" --file-list kconfig_files.txt" +
|
||||
" --env-list kconfig_env.txt" + " --config-out config.gni" ],
|
||||
"",
|
||||
[ liteos_config_file ])
|
||||
|
||||
import("liteos.gni")
|
||||
|
||||
assert(ARCH != "", "ARCH not set!")
|
||||
assert(ARCH == arch, "ARCH not match! details: $ARCH != $arch")
|
||||
assert(tee_enable == defined(LOSCFG_TEE_ENABLE), "TEE switch not match!")
|
||||
assert(ohos_build_compiler == "clang" == defined(LOSCFG_COMPILER_CLANG_LLVM),
|
||||
"compiler not match!")
|
||||
|
||||
generate_notice_file("kernel_notice_file") {
|
||||
module_name = "kernel"
|
||||
module_source_dir_list = [
|
||||
"//third_party/FreeBSD",
|
||||
"//third_party/musl",
|
||||
"//third_party/zlib",
|
||||
"//third_party/FatFs",
|
||||
"//third_party/Linux_Kernel",
|
||||
"//third_party/lwip",
|
||||
"//third_party/NuttX",
|
||||
"//third_party/mtd-utils",
|
||||
"$LITEOSTHIRDPARTY/FreeBSD",
|
||||
"$LITEOSTHIRDPARTY/musl",
|
||||
"$LITEOSTHIRDPARTY/zlib",
|
||||
"$LITEOSTHIRDPARTY/FatFs",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel",
|
||||
"$LITEOSTHIRDPARTY/lwip",
|
||||
"$LITEOSTHIRDPARTY/NuttX",
|
||||
"$LITEOSTHIRDPARTY/mtd-utils",
|
||||
]
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
enable_ohos_kernel_liteos_a_ext_build = true
|
||||
LOSCFG_TEST_APPS = false
|
||||
tee_enable = ""
|
||||
liteos_arch_cflags = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
mcpu = LOSCFG_ARCH_CPU
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH64) && defined(LOSCFG_ARCH_FPU_DISABLE)) {
|
||||
mcpu += "+nofp"
|
||||
}
|
||||
liteos_arch_cflags += [ "-mcpu=$mcpu" ]
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
liteos_arch_cflags += [
|
||||
"-mfloat-abi=softfp",
|
||||
"-mfpu=$LOSCFG_ARCH_FPU",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
lite_subsystem("kernel") {
|
||||
subsystem_components = []
|
||||
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
cc += " --target=$target_triple"
|
||||
}
|
||||
|
||||
if (enable_ohos_kernel_liteos_a_ext_build == false) {
|
||||
subsystem_components += [
|
||||
"//kernel/liteos_a/kernel",
|
||||
"//kernel/liteos_a/net",
|
||||
"//kernel/liteos_a/lib",
|
||||
"//kernel/liteos_a/compat",
|
||||
"//kernel/liteos_a/fs",
|
||||
"//kernel/liteos_a/arch:platform_cpu",
|
||||
]
|
||||
if (LOSCFG_SHELL) {
|
||||
subsystem_components += [ "//kernel/liteos_a/shell" ]
|
||||
config("arch_config") {
|
||||
cflags = liteos_arch_cflags
|
||||
asmflags = cflags
|
||||
ldflags = cflags
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-mthumb-interwork" ]
|
||||
}
|
||||
} else {
|
||||
deps = [ ":make" ]
|
||||
deps += [ "//kernel/liteos_a/testsuites/unittest:unittest" ]
|
||||
}
|
||||
if (defined(LOSCFG_THUMB)) {
|
||||
cflags += [ "-mthumb" ]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-mimplicit-it=thumb" ]
|
||||
} else {
|
||||
cflags += [ "-Wa,-mimplicit-it=thumb" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config("stdinc_config") {
|
||||
std_include = exec_script("//build/lite/run_shell_cmd.py",
|
||||
[ "$cc -print-file-name=include" ],
|
||||
"trim string")
|
||||
cflags = [
|
||||
"-isystem",
|
||||
std_include,
|
||||
]
|
||||
cflags += [ "-nostdinc" ]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("ssp_config") {
|
||||
cflags = []
|
||||
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
|
||||
cflags += [ "-fstack-protector-all" ]
|
||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
|
||||
cflags += [ "-fstack-protector-strong" ]
|
||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
|
||||
cflags += [
|
||||
"-fstack-protector",
|
||||
"--param",
|
||||
"ssp-buffer-size=4",
|
||||
]
|
||||
} else {
|
||||
cflags += [ "-fno-stack-protector" ]
|
||||
}
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("optimize_config") {
|
||||
cflags = []
|
||||
if (defined(LOSCFG_COMPILE_DEBUG)) {
|
||||
cflags += [
|
||||
"-g",
|
||||
"-gdwarf-2",
|
||||
]
|
||||
optimization_cflag = "-O0"
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
|
||||
optimization_cflag = "-O2"
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_OPTIMIZE_SIZE)) {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
optimization_cflag = "-Oz"
|
||||
} else {
|
||||
optimization_cflag = "-Os"
|
||||
}
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_LTO)) {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-flto=thin" ]
|
||||
} else {
|
||||
#cflags += [ "-flto" ]
|
||||
}
|
||||
}
|
||||
cflags += [ optimization_cflag ]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("kconfig_config") {
|
||||
cflags = [
|
||||
"-imacros",
|
||||
"$LITEOS_MENUCONFIG_H",
|
||||
]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("warn_config") {
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wpointer-arith",
|
||||
"-Wstrict-prototypes",
|
||||
"-Winvalid-pch",
|
||||
]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-Wno-address-of-packed-member" ]
|
||||
}
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("dialect_config") {
|
||||
cflags_c = [ "-std=c99" ]
|
||||
cflags_cc = [ "-std=c++11" ]
|
||||
}
|
||||
|
||||
config("misc_config") {
|
||||
defines = [ "__LITEOS__" ]
|
||||
defines += [ "__LITEOS_A__" ]
|
||||
if (!defined(LOSCFG_DEBUG_VERSION)) {
|
||||
defines += [ "NDEBUG" ]
|
||||
}
|
||||
|
||||
cflags = [
|
||||
"-fno-pic",
|
||||
"-fno-builtin",
|
||||
"-fms-extensions",
|
||||
"-fno-strict-aliasing",
|
||||
"-fno-common",
|
||||
"-fsigned-char",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
"-fno-exceptions",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fno-short-enums",
|
||||
"-mno-unaligned-access",
|
||||
]
|
||||
|
||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-fno-aggressive-loop-optimizations" ]
|
||||
}
|
||||
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("los_config") {
|
||||
configs = [
|
||||
":arch_config",
|
||||
":kconfig_config",
|
||||
":stdinc_config",
|
||||
":dialect_config",
|
||||
":optimize_config",
|
||||
":ssp_config",
|
||||
":warn_config",
|
||||
":misc_config",
|
||||
]
|
||||
}
|
||||
|
||||
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
|
||||
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
|
||||
|
||||
config("public") {
|
||||
configs = [
|
||||
"arch:public",
|
||||
"kernel:public",
|
||||
"compat:public",
|
||||
"bsd:public",
|
||||
"fs:public",
|
||||
"drivers:public",
|
||||
"security:public",
|
||||
"net:public",
|
||||
"shell:public",
|
||||
"lib:public",
|
||||
]
|
||||
|
||||
configs += [
|
||||
"$HDFTOPDIR:public",
|
||||
"//drivers/liteos:public",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
configs += [ "$device_path:public" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("modules") {
|
||||
deps = [
|
||||
"arch",
|
||||
"bsd",
|
||||
"compat",
|
||||
"drivers",
|
||||
"fs",
|
||||
"kernel",
|
||||
"lib",
|
||||
"net",
|
||||
"security",
|
||||
"shell",
|
||||
"syscall",
|
||||
]
|
||||
|
||||
deps += [
|
||||
"//drivers/liteos",
|
||||
HDFTOPDIR,
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
deps += [ device_path ]
|
||||
}
|
||||
}
|
||||
|
||||
group("apps") {
|
||||
deps = [ "apps" ]
|
||||
}
|
||||
|
||||
group("tests") {
|
||||
deps = [ "testsuites" ]
|
||||
}
|
||||
|
||||
group("kernel") {
|
||||
deps = [ ":build_kernel_image" ]
|
||||
}
|
||||
|
||||
group("liteos_a") {
|
||||
deps = [
|
||||
":apps",
|
||||
":kernel",
|
||||
":make",
|
||||
":tests",
|
||||
"//prebuilts/lite/sysroot/build:strip",
|
||||
]
|
||||
}
|
||||
|
||||
executable("liteos") {
|
||||
configs = [] # clear default configs
|
||||
configs += [ ":arch_config" ]
|
||||
configs += [ ":public" ]
|
||||
|
||||
ldflags = [
|
||||
"-static",
|
||||
"-nostdlib",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,-Map=$liteos_name.map",
|
||||
"-Wl,--no-eh-frame-hdr",
|
||||
]
|
||||
|
||||
libgcc = exec_script("//build/lite/run_shell_cmd.py",
|
||||
[ "$cc -print-libgcc-file-name" ],
|
||||
"trim string")
|
||||
libs = [ libgcc ]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
ldflags +=
|
||||
[ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
|
||||
inputs = [ "tools/build/liteos_llvm.ld" ]
|
||||
} else {
|
||||
ldflags +=
|
||||
[ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
|
||||
ldflags += [ "-Wl,-nostartfiles" ]
|
||||
inputs = [ "tools/build/liteos.ld" ]
|
||||
}
|
||||
|
||||
inputs += [ "$root_out_dir/board.ld" ]
|
||||
|
||||
output_dir = target_out_dir
|
||||
|
||||
deps = [
|
||||
":modules",
|
||||
"platform:copy_board.ld",
|
||||
]
|
||||
}
|
||||
|
||||
copy("copy_liteos") {
|
||||
deps = [ ":liteos" ]
|
||||
sources = [ "$target_out_dir/unstripped/bin/liteos" ]
|
||||
outputs = [ "$root_out_dir/$liteos_name" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_kernel_image") {
|
||||
deps = [ ":copy_liteos" ]
|
||||
exec_path = rebase_path(root_out_dir)
|
||||
|
||||
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
||||
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
||||
|
||||
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
|
||||
command +=
|
||||
" && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
||||
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
|
||||
}
|
||||
|
||||
build_ext_component("make") {
|
||||
exec_path = rebase_path(".", root_build_dir)
|
||||
tee_enable = "false"
|
||||
if (board_name == "hi3516dv300" && enable_tee_ree) {
|
||||
tee_enable = "tee"
|
||||
outdir = rebase_path("$target_out_dir/${target_name}_out")
|
||||
sysroot_path = rebase_path(ohos_current_sysroot)
|
||||
arch_cflags = string_join(" ", target_arch_cflags)
|
||||
command = "./build.sh \"$board_name\" \"$ohos_build_compiler\" \"$root_build_dir\" \"$ohos_build_type\" \"$tee_enable\""
|
||||
command += " \"$device_company\" \"$product_path\" \"$outdir\" \"$ohos_version\" \"$sysroot_path\" \"$arch_cflags\""
|
||||
command += " \"$device_path\" \"$compile_prefix\" \"$liteos_config_file\""
|
||||
if (liteos_skip_make) {
|
||||
print("build_ext_component \"$target_name\" skipped:", command)
|
||||
command = "true"
|
||||
}
|
||||
prebuilts = "sh build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} ${tee_enable} \"${device_company}\" \"${product_path}\""
|
||||
outdir = rebase_path(get_path_info(".", "out_dir"))
|
||||
command = "make clean OUTDIR=$outdir && make rootfs VERSION=\"${ohos_version}\" -j 16 OUTDIR=$outdir"
|
||||
}
|
||||
|
||||
154
Kconfig
154
Kconfig
@@ -26,43 +26,73 @@
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see extra/config/Kconfig-language.txt
|
||||
#
|
||||
|
||||
mainmenu "Huawei LiteOS Configuration"
|
||||
|
||||
menu "Compiler"
|
||||
choice
|
||||
prompt "LiteOS_Compiler_Type"
|
||||
prompt "Compiler type"
|
||||
default COMPILER_CLANG_LLVM
|
||||
help
|
||||
Enable arm-himix100 or aarch64-himix100 or compiler.
|
||||
Choose compiler type.
|
||||
|
||||
config COMPILER_HIMIX_32
|
||||
bool "arm-linux-ohoseabi"
|
||||
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7
|
||||
config COMPILER_GCC
|
||||
bool "GCC"
|
||||
|
||||
config CROSS_COMPILE
|
||||
string "GCC cross-compile toolchain prefix"
|
||||
depends on COMPILER_GCC
|
||||
default "arm-linux-ohoseabi-" if ARCH_ARM_AARCH32
|
||||
|
||||
config COMPILER_CLANG_LLVM
|
||||
bool "clang-llvm"
|
||||
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7
|
||||
bool "Clang"
|
||||
|
||||
config LLVM_TARGET
|
||||
string "Clang LLVM target"
|
||||
depends on COMPILER_CLANG_LLVM
|
||||
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
|
||||
|
||||
endchoice
|
||||
|
||||
config COMPILE_DEBUG
|
||||
bool "Enable debug options"
|
||||
default n
|
||||
help
|
||||
Answer Y to add -g option in compile command.
|
||||
|
||||
config COMPILE_OPTIMIZE
|
||||
bool "Enable code optimization options"
|
||||
default y
|
||||
help
|
||||
Answer Y to add optimization options for efficient code.
|
||||
The final binary size will be smaller and execute faster.
|
||||
But the debugging experience may be worst somehow.
|
||||
|
||||
config COMPILE_OPTIMIZE_SIZE
|
||||
bool "Enable code size optimization options" if COMPILE_OPTIMIZE
|
||||
default y
|
||||
help
|
||||
Answer Y to add optimization options for small code size.
|
||||
The final binary size will be smaller.
|
||||
But the compile time may be a bit longer.
|
||||
|
||||
config COMPILE_LTO
|
||||
bool "Enable link time optimization (LTO)" if COMPILE_OPTIMIZE_SIZE
|
||||
default y
|
||||
help
|
||||
Answer Y to add lto options for more smaller code size.
|
||||
The final binary size will be smaller.
|
||||
But the compile time may be much longer.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Platform"
|
||||
|
||||
######################### config options of bsp #####################
|
||||
source "../../kernel/liteos_a/platform/Kconfig"
|
||||
source "platform/Kconfig"
|
||||
|
||||
######################### config options of cpu arch ################
|
||||
source "../../kernel/liteos_a/arch/Kconfig"
|
||||
|
||||
######################### config options of rootfs #####################
|
||||
source "../../kernel/liteos_a/kernel/common/Kconfig"
|
||||
######################### config options of patchfs #####################
|
||||
source "../../kernel/liteos_a/kernel/common/patchfs/Kconfig"
|
||||
source "arch/Kconfig"
|
||||
|
||||
config QUICK_START
|
||||
bool "Enable QUICK_START"
|
||||
@@ -73,60 +103,30 @@ config QUICK_START
|
||||
endmenu
|
||||
|
||||
######################### config options of kernel #####################
|
||||
source "../../kernel/liteos_a/kernel/Kconfig"
|
||||
source "kernel/Kconfig"
|
||||
######################### config options of lib ########################
|
||||
source "../../kernel/liteos_a/lib/Kconfig"
|
||||
source "lib/Kconfig"
|
||||
######################### config options of compatibility ##############
|
||||
menu "Compat"
|
||||
source "../../kernel/liteos_a/compat/posix/Kconfig"
|
||||
source "../../kernel/liteos_a/bsd/Kconfig"
|
||||
source "compat/posix/Kconfig"
|
||||
source "bsd/Kconfig"
|
||||
endmenu
|
||||
|
||||
######################### config options of framework ##################
|
||||
#source "../../frameworks/m2mcomm/Kconfig"
|
||||
|
||||
######################## config options of filesystem ##################
|
||||
menu "FileSystem"
|
||||
source "../../kernel/liteos_a/fs/vfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/fat/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/ramfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/nfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/proc/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/jffs2/Kconfig"
|
||||
config ENABLE_READ_BUFFER
|
||||
bool "Enable read buffer Option"
|
||||
default n
|
||||
depends on FS_VFS
|
||||
help
|
||||
Answer Y to add enable read buffer Option.
|
||||
|
||||
config MAX_VNODE_SIZE
|
||||
int "Vnode max number"
|
||||
range 0 512
|
||||
default 512
|
||||
depends on FS_VFS
|
||||
help
|
||||
vnode number, range from 0 to 512.
|
||||
|
||||
config MAX_PATH_CACHE_SIZE
|
||||
int "PathCache max number"
|
||||
range 0 1024
|
||||
default 512
|
||||
depends on FS_VFS
|
||||
help
|
||||
pathCache number, range from 0 to 1024.
|
||||
source "fs/Kconfig"
|
||||
endmenu
|
||||
|
||||
######################## config options of net ############################
|
||||
source "../../kernel/liteos_a/net/Kconfig"
|
||||
source "net/Kconfig"
|
||||
|
||||
######################## config options of debug ########################
|
||||
menu "Debug"
|
||||
config COMPILE_DEBUG
|
||||
bool "Enable GCC -g Option"
|
||||
config GDB
|
||||
bool "Enable gdb functions"
|
||||
default n
|
||||
help
|
||||
Answer Y to add -g option in gcc command. But the LiteOS size will be much larger.
|
||||
Answer Y to enable gdb functions.
|
||||
|
||||
config PLATFORM_ADAPT
|
||||
bool "Enable Os_adapt"
|
||||
@@ -163,6 +163,7 @@ config ENABLE_MAGICKEY
|
||||
config THUMB
|
||||
bool "Enable Thumb"
|
||||
default n
|
||||
depends on ARCH_ARM
|
||||
help
|
||||
Answer Y to build thumb version. This will make LiteOS smaller.
|
||||
|
||||
@@ -185,8 +186,8 @@ config DEBUG_VERSION
|
||||
default n
|
||||
help
|
||||
If you do not select this option that means you enable a release version for LiteOS.
|
||||
It also means you do not want to use debug modules, like shell,telnet,tftp,
|
||||
,nfs,ramfs proc and memory check.
|
||||
It also means you do not want to use debug modules, like shell,telnet,tftp,nfs and
|
||||
memory check, etc.
|
||||
If you select this option that means you enable a debug version for LiteOS.
|
||||
That means you want a opposite behaviour compared to release version.
|
||||
|
||||
@@ -220,14 +221,14 @@ config DEBUG_SEMAPHORE
|
||||
help
|
||||
Answer Y to enable debug semaphore.
|
||||
|
||||
source "../../kernel/liteos_a/shell/Kconfig"
|
||||
source "shell/Kconfig"
|
||||
config NET_LWIP_SACK_TFTP
|
||||
bool "Enable Tftp"
|
||||
default y
|
||||
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
|
||||
help
|
||||
Answer Y to enable LiteOS support tftp cmd and tftp tool.
|
||||
source "../../kernel/liteos_a/net/telnet/Kconfig"
|
||||
source "net/telnet/Kconfig"
|
||||
config SCHED_DEBUG
|
||||
bool "Enable sched debug Feature"
|
||||
default n
|
||||
@@ -266,7 +267,7 @@ config MEM_LEAKCHECK
|
||||
help
|
||||
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node.
|
||||
config BASE_MEM_NODE_INTEGRITY_CHECK
|
||||
bool "Enable integrity check or not "
|
||||
bool "Enable integrity check or not"
|
||||
default n
|
||||
depends on DEBUG_VERSION && MEM_DEBUG
|
||||
config MEM_WATERLINE
|
||||
@@ -281,37 +282,16 @@ config VM_OVERLAP_CHECK
|
||||
help
|
||||
Answer Y to enable vm overlap check.
|
||||
|
||||
config NULL_ADDRESS_PROTECT
|
||||
bool "Enable NULL Address protect"
|
||||
default n
|
||||
depends on (PLATFORM_HI3518EV200 || PLATFORM_HI3516CV300 || PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7) && DEBUG_VERSION
|
||||
help
|
||||
Answer Y to set mem address 0~1M prohibit to access, read or write will trigger exception.
|
||||
|
||||
endmenu
|
||||
|
||||
######################## config options os drivers ########################
|
||||
menu "Driver"
|
||||
config DRIVERS
|
||||
bool "Enable Driver"
|
||||
default y
|
||||
help
|
||||
Answer Y to enable LiteOS support driver.
|
||||
|
||||
source "../../kernel/liteos_a/bsd/dev/usb/Kconfig"
|
||||
source "../../drivers/adapter/khdf/liteos/Kconfig"
|
||||
|
||||
source "drivers/char/mem/Kconfig"
|
||||
source "drivers/char/quickstart/Kconfig"
|
||||
source "drivers/char/random/Kconfig"
|
||||
source "../../drivers/liteos/tzdriver/Kconfig"
|
||||
source "drivers/char/video/Kconfig"
|
||||
source "../../drivers/liteos/hievent/Kconfig"
|
||||
|
||||
source "drivers/Kconfig"
|
||||
endmenu
|
||||
|
||||
######################## config options os security #######################
|
||||
menu "Security"
|
||||
source "../../kernel/liteos_a/security/Kconfig"
|
||||
source "security/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "Test"
|
||||
|
||||
262
Makefile
262
Makefile
@@ -27,44 +27,51 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
LITEOSTOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
|
||||
export OS=$(shell uname -s)
|
||||
ifneq ($(OS), Linux)
|
||||
LITEOSTOPDIR := $(shell dirname $(subst \,/,$(LITEOSTOPDIR))/./)
|
||||
endif
|
||||
|
||||
LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
|
||||
|
||||
LITEOSTOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
export LITEOSTOPDIR
|
||||
export LITEOSTHIRDPARTY
|
||||
|
||||
RM = -rm -rf
|
||||
MAKE = make
|
||||
__LIBS = libs
|
||||
APPS = apps
|
||||
ROOTFSDIR = rootfsdir
|
||||
ROOTFS = rootfs
|
||||
|
||||
LITEOS_TARGET = liteos
|
||||
LITEOS_LIBS_TARGET = libs_target
|
||||
LITEOS_MENUCONFIG_H = $(LITEOSTOPDIR)/include/generated/autoconf.h
|
||||
LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform
|
||||
LITEOS_LIBS_TARGET = libs
|
||||
KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config))
|
||||
|
||||
export CONFIG_=LOSCFG_
|
||||
MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig
|
||||
KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
|
||||
|
||||
ifeq ($(OS), Linux)
|
||||
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/mconf
|
||||
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/conf
|
||||
else
|
||||
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/kconfig-mconf.exe
|
||||
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/kconfig-conf.exe
|
||||
ohos_kernel ?= liteos_a
|
||||
$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line)))
|
||||
ifneq ($(ohos_kernel),liteos_a)
|
||||
$(error The selected product ($(ohos_product)) is not a liteos_a kernel type product)
|
||||
endif
|
||||
|
||||
$(shell env CONFIG_=$(CONFIG_) $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH))
|
||||
ifeq ($(PRODUCT_PATH),)
|
||||
PRODUCT_PATH:=$(ohos_product_path)
|
||||
endif
|
||||
|
||||
-include $(LITEOSTOPDIR)/tools/build/config.mk
|
||||
ifeq ($(DEVICE_PATH),)
|
||||
DEVICE_PATH:=$(ohos_device_path)
|
||||
endif
|
||||
|
||||
ifeq ($(TEE:1=y),y)
|
||||
tee = _tee
|
||||
endif
|
||||
ifeq ($(RELEASE:1=y),y)
|
||||
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/release$(tee).config
|
||||
else
|
||||
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config
|
||||
endif
|
||||
|
||||
KCONFIG_CONFIG ?= $(CONFIG)
|
||||
SYSROOT_PATH ?= $(OUT)/sysroot
|
||||
|
||||
# export subdir Makefile related environment variables
|
||||
export SYSROOT_PATH
|
||||
export PRODUCT_PATH
|
||||
export DEVICE_PATH
|
||||
|
||||
# export kconfig related environment variables
|
||||
export CONFIG_=LOSCFG_
|
||||
export srctree=$(LITEOSTOPDIR)
|
||||
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(LOSCFG_STORAGE_SPINOR), y)
|
||||
FSTYPE = jffs2
|
||||
@@ -80,142 +87,115 @@ FSTYPE = jffs2
|
||||
endif
|
||||
ROOTFS_DIR = $(OUT)/rootfs
|
||||
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
||||
VERSION =
|
||||
|
||||
all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)
|
||||
lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
|
||||
define HELP =
|
||||
Usage: make [TARGET]... [PARAMETER=VALUE]...
|
||||
|
||||
Targets:
|
||||
help: display this help and exit
|
||||
clean: clean compiled objects
|
||||
cleanall: clean all build outputs
|
||||
all: make liteos kernel image and rootfs image (Default target)
|
||||
$(APPS): build all apps
|
||||
$(ROOTFS): make a original rootfs image
|
||||
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
|
||||
$(LITEOS_TARGET): make liteos kernel image
|
||||
update_config: update product kernel config (use menuconfig)
|
||||
xxconfig: invoke xxconfig command of kconfiglib (xxconfig is one of $(KCONFIG_CMDS))
|
||||
|
||||
Parameters:
|
||||
FSTYPE: value should be one of (jffs2 vfat yaffs2)
|
||||
TEE: boolean value(1 or y for true), enable tee
|
||||
RELEASE: boolean value(1 or y for true), build release version
|
||||
CONFIG: kernel config file to be use
|
||||
args: arguments for xxconfig command
|
||||
endef
|
||||
export HELP
|
||||
|
||||
all: $(LITEOS_TARGET) $(ROOTFS)
|
||||
|
||||
help:
|
||||
$(HIDE)echo "-------------------------------------------------------"
|
||||
$(HIDE)echo "1.====make help: get help infomation of make"
|
||||
$(HIDE)echo "2.====make: make a debug version based the .config"
|
||||
$(HIDE)echo "3.====make debug: make a debug version based the .config"
|
||||
$(HIDE)echo "4.====make release: make a release version for all platform"
|
||||
$(HIDE)echo "5.====make release PLATFORM=xxx: make a release version only for platform xxx"
|
||||
$(HIDE)echo "6.====make rootfsdir: make a original rootfs dir"
|
||||
$(HIDE)echo "7.====make rootfs FSTYPE=***: make a original rootfs img"
|
||||
$(HIDE)echo "8.====make test: make the testsuits_app and put it into the rootfs dir"
|
||||
$(HIDE)echo "9.====make test_apps FSTYPE=***: make a rootfs img with the testsuits_app in it"
|
||||
$(HIDE)echo "xxx should be one of (hi3516cv300 hi3516ev200 hi3556av100/cortex-a53_aarch32 hi3559av100/cortex-a53_aarch64)"
|
||||
$(HIDE)echo "*** should be one of (jffs2)"
|
||||
$(HIDE)echo "-------------------------------------------------------"
|
||||
$(HIDE)echo "$$HELP"
|
||||
|
||||
debug:
|
||||
$(HIDE)echo "=============== make a debug version ==============="
|
||||
$(HIDE) $(MAKE) all
|
||||
|
||||
release:
|
||||
ifneq ($(PLATFORM),)
|
||||
$(HIDE)echo "=============== make a release version for platform $(PLATFORM) ==============="
|
||||
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh $(PLATFORM)
|
||||
else
|
||||
$(HIDE)echo "================make a release version for all platform ==============="
|
||||
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh
|
||||
sysroot:
|
||||
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
|
||||
ifeq ($(origin SYSROOT_PATH),file)
|
||||
$(HIDE)mkdir -p $(SYSROOT_PATH)/build && cd $(SYSROOT_PATH)/build && \
|
||||
ln -snf $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/build/Makefile && \
|
||||
$(MAKE) TARGETS=liteos_a_user \
|
||||
ARCH=$(ARCH) \
|
||||
TARGET=$(LOSCFG_LLVM_TARGET) \
|
||||
ARCH_CFLAGS="$(LITEOS_CORE_COPTS) -w" \
|
||||
TOPDIR="$(LITEOSTOPDIR)/../.." \
|
||||
SYSROOTDIR="$(SYSROOT_PATH)" \
|
||||
$(if $(LOSCFG_COMPILER_CLANG_LLVM),CLANG="$(LITEOS_COMPILER_PATH)clang",GCC="$(CC)") \
|
||||
BUILD_DEBUG=$(if $(patsubst y,,$(or $(RELEASE:1=y),n)),true,false)
|
||||
endif
|
||||
|
||||
##### make dynload #####
|
||||
-include $(LITEOS_MK_PATH)/dynload.mk
|
||||
$(filter-out menuconfig,$(KCONFIG_CMDS)):
|
||||
$(HIDE)$@ $(args)
|
||||
|
||||
#-----need move when make version-----#
|
||||
##### make lib #####
|
||||
$(__LIBS): $(OUT) $(CXX_INCLUDE)
|
||||
$(LITEOS_CONFIG_FILE): $(KCONFIG_CONFIG)
|
||||
$(HIDE)env KCONFIG_CONFIG=$< genconfig --config-out $@ --header-path $(LITEOS_MENUCONFIG_H)
|
||||
|
||||
$(OUT): $(LITEOS_MENUCONFIG_H)
|
||||
$(HIDE)mkdir -p $(OUT)/lib
|
||||
$(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \
|
||||
-I$(LITEOS_PLATFORM_BASE)/include -imacros $< -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
|
||||
-o $(LITEOS_PLATFORM_BASE)/board.ld -P
|
||||
update_config menuconfig:
|
||||
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig $(args) && savedefconfig --out "$(CONFIG)"
|
||||
|
||||
$(BUILD):
|
||||
$(HIDE)mkdir -p $(BUILD)
|
||||
$(LITEOS_LIBS_TARGET): sysroot
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
|
||||
|
||||
$(LITEOS_LIBS_TARGET): $(__LIBS)
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS); \
|
||||
do $(MAKE) -C $$dir all || exit 1; \
|
||||
done
|
||||
$(HIDE)echo "=============== make lib done ==============="
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET)
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).map
|
||||
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).objsize
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).bin
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).sym.sorted
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).asm
|
||||
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).size
|
||||
|
||||
##### make menuconfig #####
|
||||
menuconfig:$(MENUCONFIG_MCONF)
|
||||
$< $(KCONFIG_FILE_PATH)
|
||||
$(OUT)/$(LITEOS_TARGET): $(LITEOS_LIBS_TARGET)
|
||||
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) -Map=$@.map -o $@ --start-group $(LITEOS_LIBDEP) --end-group
|
||||
$(OUT)/$(LITEOS_TARGET).map: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OUT)/$(LITEOS_TARGET).objsize: $(LITEOS_LIBS_TARGET)
|
||||
$(SIZE) -t --common $(OUT)/lib/*.a >$@
|
||||
$(OUT)/$(LITEOS_TARGET).bin: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(OUT)/$(LITEOS_TARGET).sym.sorted: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJDUMP) -t $< |sort >$@
|
||||
$(OUT)/$(LITEOS_TARGET).asm: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJDUMP) -d $< >$@
|
||||
$(OUT)/$(LITEOS_TARGET).size: $(OUT)/$(LITEOS_TARGET)
|
||||
$(NM) -S --size-sort $< >$@
|
||||
|
||||
genconfig:$(MENUCONFIG_CONF)
|
||||
$(HIDE)mkdir -p include/config include/generated
|
||||
$< --olddefconfig $(KCONFIG_FILE_PATH)
|
||||
$< --silentoldconfig $(KCONFIG_FILE_PATH)
|
||||
##### menuconfig end #######
|
||||
|
||||
$(LITEOS_MENUCONFIG_H):
|
||||
ifneq ($(LITEOS_MENUCONFIG_H), $(wildcard $(LITEOS_MENUCONFIG_H)))
|
||||
$(HIDE)$(MAKE) genconfig
|
||||
endif
|
||||
$(LITEOS_TARGET): $(__LIBS)
|
||||
$(HIDE)touch $(LOSCFG_ENTRY_SRC)
|
||||
|
||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
|
||||
do $(MAKE) -C $$dir all || exit 1; \
|
||||
done
|
||||
|
||||
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@ --start-group $(LITEOS_LIBDEP) --end-group
|
||||
# $(SIZE) -t --common $(OUT)/lib/*.a >$(OUT)/$@.objsize
|
||||
$(OBJCOPY) -O binary $(OUT)/$@ $(LITEOS_TARGET_DIR)/$@.bin
|
||||
$(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted
|
||||
$(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm
|
||||
# $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size
|
||||
|
||||
$(APPS): $(LITEOS_TARGET)
|
||||
$(APPS): sysroot
|
||||
$(HIDE)$(MAKE) -C apps all
|
||||
|
||||
prepare:
|
||||
$(ROOTFS): $(APPS)
|
||||
$(HIDE)mkdir -p $(OUT)/musl
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
$(HIDE)cp -f $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/usr/lib/$(LLVM_TARGET)/a7_softfp_neon-vfpv4/libc.so $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/a7_softfp_neon-vfpv4/libc++.so $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libc++.so) $(OUT)/musl
|
||||
else
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libgcc_s.so.1 $(OUT)/musl
|
||||
$(STRIP) $(OUT)/musl/*
|
||||
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libgcc_s.so.1) $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl
|
||||
endif
|
||||
|
||||
$(ROOTFSDIR): prepare $(APPS)
|
||||
$(HIDE)$(MAKE) clean -C apps
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR)
|
||||
$(HIDE)shopt -s nullglob && $(STRIP) $(ROOTFS_DIR)/bin/* $(ROOTFS_DIR)/lib/*
|
||||
ifneq ($(VERSION),)
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)
|
||||
endif
|
||||
|
||||
$(ROOTFS): $(ROOTFSDIR)
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
|
||||
$(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
|
||||
|
||||
clean:
|
||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
|
||||
do $(MAKE) -C $$dir clean|| exit 1; \
|
||||
done
|
||||
$(HIDE)$(MAKE) -C apps clean
|
||||
$(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~
|
||||
$(HIDE)$(RM) include/config include/generated
|
||||
$(HIDE)$(MAKE) cleanrootfs
|
||||
$(HIDE)echo "clean $(LITEOS_PLATFORM) finish"
|
||||
$(HIDE)if [ -d $(SYSROOT_PATH)/build ]; then $(MAKE) -C $(SYSROOT_PATH)/build clean; fi
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS) apps; do $(MAKE) -C $$dir clean || exit 1; done
|
||||
$(HIDE)$(RM) $(LITEOS_MENUCONFIG_H)
|
||||
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"
|
||||
|
||||
cleanall: clean
|
||||
$(HIDE)$(RM) $(LITEOSTOPDIR)/out $(LITEOS_PLATFORM_BASE)/board.ld
|
||||
$(HIDE)$(RM) $(LITEOSTOPDIR)/out $(LITEOS_CONFIG_FILE)
|
||||
$(HIDE)echo "clean all done"
|
||||
|
||||
cleanrootfs:
|
||||
$(HIDE)$(RM) $(OUT)/rootfs
|
||||
$(HIDE)$(RM) $(OUT)/rootfs.zip
|
||||
$(HIDE)$(RM) $(OUT)/rootfs.img
|
||||
|
||||
update_all_config:
|
||||
$(HIDE)shopt -s globstar && for f in tools/build/config/**/*.config ; \
|
||||
do \
|
||||
echo updating $$f; \
|
||||
test -f $$f && cp $$f .config && $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig $$f $(KCONFIG_FILE_PATH); \
|
||||
done
|
||||
|
||||
%.config:
|
||||
$(HIDE)test -f tools/build/config/$@ && cp tools/build/config/$@ .config && $(MENUCONFIG_MCONF) $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig tools/build/config/$@ $(KCONFIG_FILE_PATH)
|
||||
|
||||
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config
|
||||
.PHONY: all clean cleanall sysroot help update_config
|
||||
.PHONY: $(LITEOS_TARGET) $(ROOTFS) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET) $(KCONFIG_CONFIG)
|
||||
|
||||
83
OAT.xml
Normal file
83
OAT.xml
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
|
||||
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="文件属于FreeBSD仓库软连接,本仓库屏蔽告警,在FreeBSD仓库进行处理">
|
||||
<filteritem type="filepath" name="bsd/.*" desc="文件属于FreeBSD仓库软连接,本仓库屏蔽告警,在FreeBSD仓库进行处理"/>
|
||||
<filteritem type="filepath" name="kernel/extended" desc="文件属于Nuttx仓库软连接,本仓库屏蔽告警,在Nuttx仓库进行处理"/>
|
||||
<filteritem type="filepath" name="fs/include/fs" desc="文件属于Nuttx仓库软连接,本仓库屏蔽告警,在Nuttx仓库进行处理"/>
|
||||
</filefilter>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
|
||||
</filefilterlist>
|
||||
<licensematcherlist>
|
||||
<!--licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped.">
|
||||
<licensetext name="
|
||||
uvwxyz license textA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
" desc=""/>
|
||||
<licensetext name="
|
||||
uvwxyz license textB xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
" desc=""/>
|
||||
</licensematcher-->
|
||||
</licensematcherlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
||||
13
README.md
13
README.md
@@ -67,26 +67,27 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
|
||||
|
||||
## Usage<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/introduction-to-the-hi3518-development-board.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/introduction-to-the-hi3516-development-board.md). You can develop and run your applications based on both development boards.
|
||||
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on both development boards.
|
||||
|
||||
### Preparations<a name="section1579912573329"></a>
|
||||
|
||||
You need to set up the compilation environment on Linux.
|
||||
|
||||
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/setting-up-the-hi3518-development-environment.md).
|
||||
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/setting-up-the-hi3516-development-environment.md).
|
||||
- [Compilation environment on Linux](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup-lin.md)
|
||||
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-setting.md).
|
||||
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-setting.md).
|
||||
|
||||
### Source Code Acquisition<a name="section11443189655"></a>
|
||||
|
||||
Download and decompress a set of source code on a Linux server to acquire the [source code](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz). For more acquisition methods, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/source-code-acquisition.md).
|
||||
Download and decompress a set of source code on a Linux server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
|
||||
|
||||
### Compilation and Building<a name="section2081013992812"></a>
|
||||
|
||||
For details about how to develop the first application, see:
|
||||
|
||||
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/developing-the-first-example-program-running-on-hi3518.md)
|
||||
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-running.md)
|
||||
|
||||
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/developing-the-first-example-program-running-on-hi3516.md)
|
||||
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-running.md)
|
||||
|
||||
## Repositories Involved<a name="section1371113476307"></a>
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代內核,Huawei LiteOS是面向IoT領域構建的輕量級物聯網操作系統。在IoT產業高速發展的潮流中,OpenHarmony LiteOS-A內核能夠帶給用戶小體積、低功耗、高性能的體驗以及統一開放的生態系統能力,新增了豐富的內核機制、更加全面的POSIX標準接口以及統一驅動框架**HDF**(OpenHarmony Driver Foundation)等,為設備廠商提供了更統一的接入方式,為OpenHarmony的應用開發者提供了更友好的開發體驗。圖1為OpenHarmony LiteOS-A內核架構圖:
|
||||
|
||||
**圖 1** OpenHarmony LiteOS-A內核架構圖<a name="fig27311582210"></a>
|
||||

|
||||
|
||||

|
||||
|
||||
## 目錄<a name="section161941989596"></a>
|
||||
|
||||
@@ -67,31 +68,32 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
|
||||
|
||||
## 使用說明<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS-A內核支持Hi3518EV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5% 8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))、Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh- cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
|
||||
OpenHarmony LiteOS-A內核支持Hi3518EV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md))、Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
|
||||
|
||||
### 準備<a name="section1579912573329"></a>
|
||||
|
||||
開發者需要在Linux上搭建編譯環境:
|
||||
|
||||
- Hi3518EV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E6%90%AD%E5%BB% BA%E7%8E%AF%E5%A2%83.md);
|
||||
- Hi3516DV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E6%90%AD%E5%BB %BA%E7%8E%AF%E5%A2%83.md)。
|
||||
- [Ubuntu編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
|
||||
- Hi3518EV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md);
|
||||
- Hi3516DV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||
|
||||
### 獲取源碼<a name="section11443189655"></a>
|
||||
|
||||
在Linux服務器上下載並解壓一套源代碼,獲取源碼([下載鏈結](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz))。更多源碼獲取方式,參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/%E6%BA%90%E7%A0 %81%E8%8E%B7%E5%8F%96.md)。
|
||||
在Linux服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
||||
|
||||
### 編譯構建<a name="section2081013992812"></a>
|
||||
|
||||
開發者開發第一個應用程序可參考:
|
||||
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3518%E7% AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F.md);
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md);
|
||||
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3516%E7% AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%A4%BA%E4%BE% 8B.md)。
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||
|
||||
## 相關倉<a name="section1371113476307"></a>
|
||||
|
||||
[內核子系統](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3 %BB%E7%BB%9F.md)
|
||||
[內核子系統](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
|
||||
|
||||
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
|
||||
|
||||
**kernel\_liteos\_a**
|
||||
**kernel\_liteos\_a**
|
||||
|
||||
13
README_zh.md
13
README_zh.md
@@ -67,26 +67,27 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
|
||||
|
||||
## 使用说明<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))单板,开发者可基于两种单板开发运行自己的应用程序。
|
||||
OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))单板,开发者可基于两种单板开发运行自己的应用程序。
|
||||
|
||||
### 准备<a name="section1579912573329"></a>
|
||||
|
||||
开发者需要在Linux上搭建编译环境:
|
||||
|
||||
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83.md);
|
||||
- Hi3516DV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83.md)。
|
||||
- [Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
|
||||
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md);
|
||||
- Hi3516DV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||
|
||||
### 获取源码<a name="section11443189655"></a>
|
||||
|
||||
在Linux服务器上下载并解压一套源代码,获取源码([下载链接](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz))。更多源码获取方式,参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md)。
|
||||
在Linux服务器上下载并解压一套源代码,源码获取方式参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
||||
|
||||
### 编译构建<a name="section2081013992812"></a>
|
||||
|
||||
开发者开发第一个应用程序可参考:
|
||||
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3518%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F.md);
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md);
|
||||
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3516%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%A4%BA%E4%BE%8B.md)。
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||
|
||||
## 相关仓<a name="section1371113476307"></a>
|
||||
|
||||
|
||||
61
TODOList.md
61
TODOList.md
@@ -1,61 +0,0 @@
|
||||
- liteos_m易用性
|
||||
- [ ] liteos_m开发者手册
|
||||
- [ ] 低功耗框架及实现(含投票机制)
|
||||
- [ ] dump增强(配套解析工具)
|
||||
- [ ] 全内存dump(配套解析工具)
|
||||
- [ ] 实现完整L0 OHOS的qemu仿真
|
||||
- [ ] Shell + AT
|
||||
|
||||
- liteos_m能力增强
|
||||
- [ ] liteos_m支持elf动态加载
|
||||
- [ ] 基于MPU/PMP的多任务简化隔离
|
||||
- [ ] 基于MPU/PMP的多BIN隔离及灌段隔离
|
||||
- [ ] 扩展支持中断嵌套
|
||||
- [ ] 支持arm9架构
|
||||
- [ ] 支持xtensa架构
|
||||
|
||||
- 文件系统增强
|
||||
- [ ] 提供一种好用且开源的NandFlash文件系统
|
||||
- [ ] 面向fat32、jffs2持续性能优化,做到极致
|
||||
- [ ] fat32支持fast seek(现有fast seek限制文件扩展,需要改造)
|
||||
- [ ] 支持软链接
|
||||
- [ ] 头文件引用关系整理
|
||||
- [ ] 接口层去nuttx
|
||||
- [ ] 文件系统去大锁
|
||||
|
||||
- liteos_a支持三方芯片易移植性
|
||||
- [ ] 启动框架重构
|
||||
- [ ] musl库归一化
|
||||
- [ ] 去C库预编译
|
||||
- [ ] 宏配置依赖关系整理
|
||||
- [ ] 典型商用配置场景整理并导入门禁(1V1映射,去缺页,去隔离,单进程等等)
|
||||
- [ ] 编译框架整合到gn
|
||||
- [ ] 实现基于python的kconfig可视化配置
|
||||
|
||||
- liteos_a易用性
|
||||
- [ ] 实现L1 LiteOS-A及上层鸿蒙组件的qemu仿真
|
||||
- [ ] liteos_a开发者手册
|
||||
- [ ] mksh移植
|
||||
- [ ] toybox命令集
|
||||
- [ ] trace、backtrace、dump解析工具等
|
||||
- procfs适配
|
||||
- [ ] ifconfig、fd、free等
|
||||
|
||||
- liteos_a能力增强
|
||||
- [ ] 单链表整改(SMP多核性能)
|
||||
- [ ] 快启
|
||||
- [ ] 典型高频函数C库性能优化
|
||||
- [ ] rwlock
|
||||
|
||||
- liteos_a三方库移植
|
||||
- [ ] libuv、dlna、benchmark、iperf、perf、tcpdump 等等
|
||||
- C库能力补全
|
||||
- [ ] epoll实现
|
||||
|
||||
- 测试验证
|
||||
- [ ] syzkaller、difuze等
|
||||
|
||||
- 探索性课题
|
||||
- [ ] 基于rust重写liteos_m基础内核
|
||||
- [ ] 用户态驱动(对比业界并增强)
|
||||
- [ ] 用户态文件系统
|
||||
62
apps/BUILD.gn
Normal file
62
apps/BUILD.gn
Normal file
@@ -0,0 +1,62 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("apps") {
|
||||
deps = []
|
||||
|
||||
if (defined(LOSCFG_SHELL)) {
|
||||
deps += [
|
||||
"mksh",
|
||||
"shell",
|
||||
"toybox",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_USER_INIT_DEBUG)) {
|
||||
deps += [ "init" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_NET_LWIP_SACK_TFTP)) {
|
||||
deps += [ "tftp" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_TRACE)) {
|
||||
deps += [ "trace" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_PERF)) {
|
||||
deps += [ "perf" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_KERNEL_LMS)) {
|
||||
deps += [ "lms:sample_usr_lms" ]
|
||||
}
|
||||
}
|
||||
@@ -27,26 +27,14 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
LITEOSTOPDIR = $(shell pwd)/../
|
||||
APPSTOPDIR := $(shell pwd)
|
||||
LITEOSTOPDIR ?= $(APPSTOPDIR)/..
|
||||
export LITEOSTOPDIR
|
||||
export APPSTOPDIR
|
||||
|
||||
include $(LITEOSTOPDIR)/.config
|
||||
include ./config.mk
|
||||
include ./module.mk
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
HIDE := @
|
||||
APPS := app
|
||||
all clean:
|
||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir $@ || exit 1; done
|
||||
|
||||
all: $(APPS)
|
||||
|
||||
# Make
|
||||
$(APPS):
|
||||
ifneq ($(APP_SUBDIRS), )
|
||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir || exit 1; done
|
||||
endif
|
||||
|
||||
clean:
|
||||
ifneq ($(APP_SUBDIRS), )
|
||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean; done
|
||||
endif
|
||||
|
||||
.PHONY: all $(APPS) clean
|
||||
.PHONY: all clean
|
||||
|
||||
6
tools/fsimage/MakeVersion.sh → apps/app.mk
Executable file → Normal file
6
tools/fsimage/MakeVersion.sh → apps/app.mk
Executable file → Normal file
@@ -1,5 +1,3 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
@@ -29,4 +27,6 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
./mkfs.jffs2 -s 0x1000 -e 0x10000 -p 0x100000 -d rootfs/ -o rootfs_64k.jffs2
|
||||
override TARGET = $(OUT)/bin/$(APP_NAME)
|
||||
|
||||
include $(MODULE)
|
||||
@@ -27,30 +27,18 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# common dir config
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
# output dir config
|
||||
OBJOUT := $(APPSTOPDIR)/out
|
||||
APPSOUT := $(OBJOUT)/apps
|
||||
LIBSOUT := $(OBJOUT)/libs
|
||||
IMGOUT := $(OUT)
|
||||
|
||||
# common flags config
|
||||
BASE_OPTS := -ffunction-sections -fdata-sections -fno-omit-frame-pointer -D_GNU_SOURCE \
|
||||
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LLVM_EXTRA_OPTS) $(LITEOS_GCOV_OPTS)
|
||||
BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700
|
||||
|
||||
CFLAGS := -std=c99 -fno-exceptions $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||
CXXFLAGS := -std=c++11 -fexceptions -fpermissive -frtti $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||
LDCFLAGS := -lc
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LLVM_SYSROOT := --sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
||||
LDCXXFLGS := -lc++ -lc++abi -lc
|
||||
else
|
||||
BASE_OPTS += -Wl,-z,relro,-z,now
|
||||
LDCXXFLGS := -lstdc++ -lsupc++ -lc
|
||||
endif
|
||||
COMMON_INCLUDE := -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
||||
ASFLAGS :=
|
||||
CFLAGS := $(LITEOS_COPTS) $(BASE_OPTS) -fPIE
|
||||
CXXFLAGS := $(LITEOS_CXXOPTS) $(BASE_OPTS) -fPIE
|
||||
LDFLAGS := $(LITEOS_CORE_COPTS) -pie -Wl,-z,relro,-z,now -O2
|
||||
|
||||
CFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib,$(CFLAGS))
|
||||
CXXFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib -nostdinc++,$(CXXFLAGS))
|
||||
|
||||
# alias variable config
|
||||
HIDE := @
|
||||
@@ -58,3 +46,30 @@ MAKE := make
|
||||
RM := rm -rf
|
||||
CP := cp -rf
|
||||
MV := mv -f
|
||||
|
||||
APP := $(APPSTOPDIR)/app.mk
|
||||
|
||||
##build modules config##
|
||||
APP_SUBDIRS :=
|
||||
|
||||
ifeq ($(LOSCFG_SHELL), y)
|
||||
APP_SUBDIRS += shell
|
||||
APP_SUBDIRS += mksh
|
||||
APP_SUBDIRS += toybox
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
||||
APP_SUBDIRS += init
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
|
||||
APP_SUBDIRS += tftp
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_DRIVERS_TRACE), y)
|
||||
APP_SUBDIRS += trace
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_DRIVERS_PERF), y)
|
||||
APP_SUBDIRS += perf
|
||||
endif
|
||||
|
||||
20
tools/scripts/make_rootfs/rootfs.sh → apps/init/BUILD.gn
Executable file → Normal file
20
tools/scripts/make_rootfs/rootfs.sh → apps/init/BUILD.gn
Executable file → Normal file
@@ -1,5 +1,3 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
@@ -28,12 +26,14 @@
|
||||
# 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.
|
||||
set -e
|
||||
|
||||
BIN_DIR=$1
|
||||
LIB_DIR=$2
|
||||
ROOTFS_DIR=$3
|
||||
FSTYPE=$4
|
||||
CUR_DIR=$(dirname $(readlink -f "$0"))
|
||||
. ${CUR_DIR}/rootfsdir.sh ${BIN_DIR} ${LIB_DIR} ${ROOTFS_DIR}
|
||||
. ${CUR_DIR}/rootfsimg.sh ${ROOTFS_DIR} ${FSTYPE}
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("init") {
|
||||
sources = [ "src/init.c" ]
|
||||
|
||||
if (defined(LOSCFG_QUICK_START)) {
|
||||
ldflags = [ "--static" ]
|
||||
defines = [ "LOSCFG_QUICK_START" ]
|
||||
}
|
||||
}
|
||||
@@ -27,43 +27,15 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
INIT_DIR := $(dir $(shell pwd))/init/
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(INIT_DIR)/../config.mk
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
LOCAL_SRCS := src/init.c
|
||||
LOCAL_OBJ := src/init.o
|
||||
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses -Wnonnull $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_QUICK_START), y)
|
||||
LDCFLAGS += --static
|
||||
LDFLAGS += --static
|
||||
CFLAGS += -DLOSCFG_QUICK_START
|
||||
endif
|
||||
|
||||
INITNAME := init
|
||||
|
||||
all: $(INITNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(CFLAGS) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(INITNAME):$(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(INITNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(INITNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(INITNAME)
|
||||
|
||||
.PHONY: all $(INITNAME) clean
|
||||
include $(APP)
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
int main(int argc, char * const *argv)
|
||||
{
|
||||
int ret;
|
||||
pid_t gid;
|
||||
const char *shellPath = "/bin/mksh";
|
||||
|
||||
#ifdef LOSCFG_QUICK_START
|
||||
@@ -74,9 +75,14 @@ int main(int argc, char * const *argv)
|
||||
if (ret < 0) {
|
||||
printf("Failed to fork for shell\n");
|
||||
} else if (ret == 0) {
|
||||
ret = tcsetpgrp(STDIN_FILENO, getpgrp());
|
||||
gid = getpgrp();
|
||||
if (gid < 0) {
|
||||
printf("get group id failed, pgrpid %d, errno %d\n", gid, errno);
|
||||
exit(0);
|
||||
}
|
||||
ret = tcsetpgrp(STDIN_FILENO, gid);
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, pgrpid %d, errno %d\n", getpgrp(), errno);
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
exit(0);
|
||||
}
|
||||
(void)execve(shellPath, NULL, NULL);
|
||||
|
||||
76
tools/build/mk/get_compiler_path.sh → apps/lms/BUILD.gn
Executable file → Normal file
76
tools/build/mk/get_compiler_path.sh → apps/lms/BUILD.gn
Executable file → Normal file
@@ -1,5 +1,3 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
@@ -29,31 +27,51 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
set -e
|
||||
declare CROSS_COMPILER="$1"
|
||||
declare HMOS_TOP_DIR="$2"
|
||||
declare gcc_path=${HMOS_TOP_DIR}/../../prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc
|
||||
declare windows_gcc_path=${HMOS_TOP_DIR}/../../prebuilts/gcc/win-x86/arm/arm-linux-ohoseabi-gcc
|
||||
function get_compiler_path()
|
||||
{
|
||||
local system=$(uname -s)
|
||||
local user_gcc="${CROSS_COMPILER}"gcc
|
||||
local gcc_install_path=$(which "${user_gcc}")
|
||||
|
||||
if [ "$system" != "Linux" ] ; then
|
||||
if [ -e "${windows_gcc_path}" ] ; then
|
||||
gcc_install_path=$windows_gcc_path
|
||||
else
|
||||
gcc_install_path=$(dirname $gcc_install_path)/../
|
||||
fi
|
||||
else
|
||||
if [ -e "${gcc_path}" ] ; then
|
||||
gcc_install_path=$gcc_path
|
||||
else
|
||||
gcc_install_path=$(dirname $gcc_install_path)/../
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$gcc_install_path"
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
lite_component("LMS-Sample") {
|
||||
features = [ ":sample_usr_lms" ]
|
||||
}
|
||||
executable("sample_usr_lms") {
|
||||
output_name = "sample_usr_lms"
|
||||
sources = [ "src/sample_usr_lms.c" ]
|
||||
include_dirs = []
|
||||
defines = []
|
||||
if (ohos_build_compiler == "gcc") {
|
||||
cflags_c = [
|
||||
"-O0",
|
||||
"-fsanitize=kernel-address",
|
||||
"-funwind-tables",
|
||||
"-fasynchronous-unwind-tables",
|
||||
]
|
||||
} else {
|
||||
cflags_c = [
|
||||
"-O0",
|
||||
"-fsanitize=kernel-address",
|
||||
"-mllvm",
|
||||
"-asan-instrumentation-with-call-threshold=0",
|
||||
"-mllvm",
|
||||
"-asan-stack=0",
|
||||
"-mllvm",
|
||||
"-asan-globals=0",
|
||||
"-funwind-tables",
|
||||
"-fasynchronous-unwind-tables",
|
||||
]
|
||||
}
|
||||
ldflags = [
|
||||
"-rdynamic",
|
||||
"-lunwind",
|
||||
"-lusrlms",
|
||||
"-Wl,--wrap=realloc",
|
||||
"-Wl,--wrap=calloc",
|
||||
"-Wl,--wrap=malloc",
|
||||
"-Wl,--wrap=free",
|
||||
"-Wl,--wrap=valloc",
|
||||
"-Wl,--wrap=aligned_alloc",
|
||||
"-Wl,--wrap=memset",
|
||||
"-Wl,--wrap=memcpy",
|
||||
"-Wl,--wrap=memmove",
|
||||
"-Wl,--wrap=strcpy",
|
||||
"-Wl,--wrap=strcat",
|
||||
]
|
||||
deps = [ "//kernel/liteos_a/kernel/extended/lms/usr:usrlmslib" ]
|
||||
}
|
||||
get_compiler_path
|
||||
208
apps/lms/src/sample_usr_lms.c
Executable file
208
apps/lms/src/sample_usr_lms.c
Executable file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static void BufWriteTest(void *buf, int start, int end)
|
||||
{
|
||||
for (int i = start; i <= end; i++) {
|
||||
((char *)buf)[i] = 'a';
|
||||
}
|
||||
}
|
||||
|
||||
static void BufReadTest(void *buf, int start, int end)
|
||||
{
|
||||
char tmp;
|
||||
for (int i = start; i <= end; i++) {
|
||||
tmp = ((char *)buf)[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void LmsMallocTest(void)
|
||||
{
|
||||
printf("\n-------- LmsMallocTest Start --------\n");
|
||||
char *buf = (char *)malloc(16);
|
||||
printf("[LmsMallocTest] malloc addr:%p size:%d\n", buf, 16);
|
||||
|
||||
printf("[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1,16]\n");
|
||||
BufReadTest(buf, -1, 16);
|
||||
printf("[LmsMallocTest] write overflow error should be triggered, write range[0,16]\n");
|
||||
BufWriteTest(buf, 0, 16);
|
||||
|
||||
free(buf);
|
||||
printf("\n-------- LmsMallocTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsReallocTest(void)
|
||||
{
|
||||
printf("\n-------- LmsReallocTest Start --------\n");
|
||||
char *buf = (char *)malloc(64);
|
||||
printf("[LmsReallocTest] malloc addr:%p size:%d\n", buf, 64);
|
||||
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1,64]\n");
|
||||
BufReadTest(buf, -1, 64);
|
||||
buf = (char *)realloc(buf, 32);
|
||||
printf("[LmsReallocTest] realloc addr:%p size:%d\n", buf, 32);
|
||||
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1,32]\n");
|
||||
BufReadTest(buf, -1, 32);
|
||||
free(buf);
|
||||
printf("\n-------- LmsReallocTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsCallocTest(void)
|
||||
{
|
||||
printf("\n-------- LmsCallocTest Start --------\n");
|
||||
char *buf = (char *)calloc(4, 4);
|
||||
printf("[LmsCallocTest] calloc addr:%p size:%d\n", buf, 16);
|
||||
printf("[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1,16]\n");
|
||||
BufReadTest(buf, -1, 16);
|
||||
free(buf);
|
||||
printf("\n-------- LmsCallocTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsVallocTest(void)
|
||||
{
|
||||
printf("\n-------- LmsVallocTest Start --------\n");
|
||||
char *buf = (char *)valloc(4096);
|
||||
printf("[LmsVallocTest] valloc addr:%p size:%d\n", buf, 4096);
|
||||
printf("[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1,4096]\n");
|
||||
BufReadTest(buf, -1, 4096);
|
||||
free(buf);
|
||||
printf("\n-------- LmsVallocTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsAlignedAllocTest(void)
|
||||
{
|
||||
printf("\n-------- LmsAlignedAllocTest Start --------\n");
|
||||
char *buf = (char *)aligned_alloc(64, 128);
|
||||
printf("[LmsAlignedAllocTest] aligned_alloc boundsize:%d addr:%p size:%d\n", 64, buf, 128);
|
||||
printf("[LmsAlignedAllocTest] read overflow & underflow error should be triggered, read range[-1,128]\n");
|
||||
BufReadTest(buf, -1, 128);
|
||||
free(buf);
|
||||
printf("\n-------- LmsAlignedAllocTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsMemsetTest(void)
|
||||
{
|
||||
printf("\n-------- LmsMemsetTest Start --------\n");
|
||||
char *buf = (char *)malloc(32);
|
||||
printf("[LmsMemsetTest] malloc addr:%p size:%d\n", buf, 32);
|
||||
printf("[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d\n", 33);
|
||||
memset(buf, 0, 33);
|
||||
free(buf);
|
||||
printf("\n-------- LmsMemsetTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsMemcpyTest(void)
|
||||
{
|
||||
printf("\n-------- LmsMemcpyTest Start --------\n");
|
||||
char *buf = (char *)malloc(20);
|
||||
printf("[LmsMemcpyTest] malloc addr:%p size:%d\n", buf, 20);
|
||||
char localBuf[32] = {0};
|
||||
printf("[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d\n", 21);
|
||||
memcpy(buf, localBuf, 21);
|
||||
free(buf);
|
||||
printf("\n-------- LmsMemcpyTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsMemmoveTest(void)
|
||||
{
|
||||
printf("\n-------- LmsMemmoveTest Start --------\n");
|
||||
char *buf = (char *)malloc(20);
|
||||
printf("[LmsMemmoveTest] malloc addr:%p size:%d\n", buf, 20);
|
||||
printf("[LmsMemmoveTest] memmove overflow error should be triggered, dest addr:%p src addr:%p size:%d\n", buf + 12,
|
||||
buf, 10);
|
||||
memmove(buf + 12, buf, 10);
|
||||
free(buf);
|
||||
printf("\n-------- LmsMemmoveTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsStrcpyTest(void)
|
||||
{
|
||||
printf("\n-------- LmsStrcpyTest Start --------\n");
|
||||
char *buf = (char *)malloc(16);
|
||||
printf("[LmsStrcpyTest] malloc addr:%p size:%d\n", buf, 16);
|
||||
char *testStr = "bbbbbbbbbbbbbbbbb";
|
||||
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1);
|
||||
strcpy(buf, testStr);
|
||||
free(buf);
|
||||
printf("\n-------- LmsStrcpyTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsStrcatTest(void)
|
||||
{
|
||||
printf("\n-------- LmsStrcatTest Start --------\n");
|
||||
char *buf = (char *)malloc(16);
|
||||
printf("[LmsStrcatTest] malloc addr:%p size:%d\n", buf, 16);
|
||||
buf[0] = 'a';
|
||||
buf[1] = 'b';
|
||||
buf[2] = 0;
|
||||
char *testStr = "cccccccccccccc";
|
||||
printf("[LmsStrcatTest] strcat overflow error should be triggered, src string:%s dest string:%s"
|
||||
"total buf size:%d\n",
|
||||
testStr, buf, strlen(testStr) + strlen(buf) + 1);
|
||||
strcat(buf, testStr);
|
||||
free(buf);
|
||||
printf("\n-------- LmsStrcatTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsFreeTest(void)
|
||||
{
|
||||
printf("\n-------- LmsFreeTest Start --------\n");
|
||||
char *buf = (char *)malloc(16);
|
||||
printf("[LmsFreeTest] malloc addr:%p size:%d\n", buf, 16);
|
||||
printf("[LmsFreeTest] free addr:%p\n", buf, 16);
|
||||
free(buf);
|
||||
printf("[LmsFreeTest] Use after free error should be triggered, read addr:%p range[1,1]\n", buf);
|
||||
BufReadTest(buf, 1, 1);
|
||||
printf("[LmsFreeTest] double free error should be triggered, free addr:%p\n", buf);
|
||||
free(buf);
|
||||
printf("\n-------- LmsFreeTest End --------\n");
|
||||
}
|
||||
|
||||
int main(int argc, char * const * argv)
|
||||
{
|
||||
printf("\n############### Lms Test start ###############\n");
|
||||
char *tmp = (char *)malloc(5000);
|
||||
LmsMallocTest();
|
||||
LmsReallocTest();
|
||||
LmsCallocTest();
|
||||
LmsVallocTest();
|
||||
LmsAlignedAllocTest();
|
||||
LmsMemsetTest();
|
||||
LmsMemcpyTest();
|
||||
LmsMemmoveTest();
|
||||
LmsStrcpyTest();
|
||||
LmsStrcatTest();
|
||||
LmsFreeTest();
|
||||
printf("\n############### Lms Test End ###############\n");
|
||||
}
|
||||
99
apps/mksh/BUILD.gn
Normal file
99
apps/mksh/BUILD.gn
Normal file
@@ -0,0 +1,99 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("mksh") {
|
||||
deps = [ ":build_mksh" ]
|
||||
}
|
||||
|
||||
copy("copy_mksh_src") {
|
||||
sources = [ "$LITEOSTHIRDPARTY/mksh" ]
|
||||
outputs = [ "$target_out_dir/mksh_build" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_mksh") {
|
||||
deps = [ ":copy_mksh_src" ]
|
||||
deps += [ "//prebuilts/lite/sysroot" ]
|
||||
exec_path = rebase_path("$target_out_dir/mksh_build")
|
||||
|
||||
cflags = [
|
||||
"-flto",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fstack-protector-strong",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
"-DMKSH_DISABLE_TTY_WARNING",
|
||||
"-DMKSH_SMALL=1",
|
||||
"-DMKSH_ASSUME_UTF8=1",
|
||||
"-DMKSH_SMALL_BUT_FAST=0",
|
||||
"-DMKSH_S_NOVI=1",
|
||||
"-DHAVE_CAN_FSTACKPROTECTORSTRONG=1",
|
||||
"-DMKSH_LESS_CMDLINE_EDITING",
|
||||
"-DMKSH_LESS_BUILDINS",
|
||||
"-DMKSH_NO_INITCOMS",
|
||||
"-DADAPT_FOR_LITEOS_A",
|
||||
]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-Oz" ]
|
||||
} else {
|
||||
cflags += [ "-O2" ]
|
||||
}
|
||||
cflags = string_join(" ", cflags)
|
||||
|
||||
extra_flags = string_join(" ", target_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
extra_flags += " --target=$target_triple"
|
||||
extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot)
|
||||
}
|
||||
|
||||
command = "rm -rf .git && env"
|
||||
command += " CC=\"$ohos_current_cc_command\""
|
||||
command += " TARGET_OS=OpenHarmony"
|
||||
command += " CFLAGS=\"$cflags $extra_flags\""
|
||||
command += " LDFLAGS=\"-Wl,--gc-sections -flto -O2\""
|
||||
command += " sh ./Build.sh -r"
|
||||
|
||||
# copy mksh and .mkshrc to out dir
|
||||
command += " && mkdir -p "
|
||||
command += rebase_path("$root_out_dir/bin", exec_path)
|
||||
command += " && install -D mksh "
|
||||
command += rebase_path("$root_out_dir/unstripped/bin/mksh", exec_path)
|
||||
command += " && $ohos_current_strip_command mksh -o "
|
||||
command += rebase_path("$root_out_dir/bin/mksh", exec_path)
|
||||
command += " && install -D .mkshrc "
|
||||
command += rebase_path("$root_out_dir/etc/.mkshrc", exec_path)
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/unstripped/bin/mksh",
|
||||
"$root_out_dir/bin/mksh",
|
||||
"$root_out_dir/etc/.mkshrc",
|
||||
]
|
||||
}
|
||||
@@ -27,41 +27,30 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
MKSH := mksh
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
MKSH_DIR := $(shell pwd)/
|
||||
LITEOSTOPDIR = $(MKSH_DIR)/../../
|
||||
include $(MKSH_DIR)/../config.mk
|
||||
BUILD_DIR := $(OUT)/mksh_build
|
||||
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
BUILD_DIR := $(MKSH_DIR)/build
|
||||
BUILD_LOG := $(MKSH_DIR)/build.log
|
||||
TARGET_OS := OpenHarmony
|
||||
CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
|
||||
CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||
CFLAGS += -Wno-error
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -O2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4
|
||||
LOCAL_CFLAGS += --target=arm-liteos --sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
||||
LOCAL_CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
|
||||
LOCAL_CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||
|
||||
all:$(MKSH)
|
||||
|
||||
$(MKSH):
|
||||
all:
|
||||
ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),)
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
$(HIDE)chmod +x $(BUILD_DIR)/Rebuild.sh
|
||||
$(HIDE)cd $(BUILD_DIR) && ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||
$(HIDE)cd $(BUILD_DIR) && sh ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||
else
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(MKSH)/. $(BUILD_DIR)
|
||||
$(HIDE)chmod +x $(BUILD_DIR)/Build.sh
|
||||
$(HIDE)cd $(BUILD_DIR) && CC=$(CC) TARGET_OS=$(TARGET_OS) CFLAGS="$(LOCAL_CFLAGS)" LDFLAGS="$(LDFLAGS)" ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/mksh/. $(BUILD_DIR)
|
||||
$(HIDE)cd $(BUILD_DIR) && CC="$(CC)" TARGET_OS=OpenHarmony CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" sh ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||
endif
|
||||
$(HIDE)$(CP) -rf $(BUILD_DIR)/$(MKSH) .
|
||||
$(HIDE)$(STRIP) $(MKSH)
|
||||
$(HIDE)mkdir -p $(APPS_OUT)
|
||||
$(HIDE)$(CP) $(MKSH) $(APPS_OUT)
|
||||
$(HIDE)mkdir -p $(OUT)/bin/ $(OUT)/etc/
|
||||
$(HIDE)$(STRIP) $(BUILD_DIR)/mksh -o $(OUT)/bin/mksh
|
||||
$(HIDE)$(CP) $(BUILD_DIR)/.mkshrc $(OUT)/etc/
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG)
|
||||
$(HIDE)$(RM) $(BUILD_DIR)
|
||||
|
||||
.PHONY: all $(MKSH) clean
|
||||
.PHONY: all clean
|
||||
|
||||
63
apps/perf/BUILD.gn
Normal file
63
apps/perf/BUILD.gn
Normal file
@@ -0,0 +1,63 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("perf") {
|
||||
sources = [
|
||||
"src/main.c",
|
||||
"src/option.c",
|
||||
"src/perf.c",
|
||||
"src/perf_list.c",
|
||||
"src/perf_record.c",
|
||||
"src/perf_stat.c",
|
||||
]
|
||||
include_dirs = [ "include" ]
|
||||
defines = []
|
||||
|
||||
if (defined(LOSCFG_PERF_HW_PMU)) {
|
||||
defines += [ "LOSCFG_PERF_HW_PMU" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_PERF_TIMED_PMU)) {
|
||||
defines += [ "LOSCFG_PERF_TIMED_PMU" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_PERF_SW_PMU)) {
|
||||
defines += [ "LOSCFG_PERF_SW_PMU" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_FS_VFS)) {
|
||||
defines += [ "LOSCFG_FS_VFS" ]
|
||||
}
|
||||
|
||||
defines += [ "LOSCFG_PERF_BUFFER_SIZE=$LOSCFG_PERF_BUFFER_SIZE" ]
|
||||
|
||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
}
|
||||
62
apps/perf/Makefile
Normal file
62
apps/perf/Makefile
Normal file
@@ -0,0 +1,62 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||
|
||||
LOCAL_SRCS = $(wildcard src/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I include \
|
||||
-I $(SECUREC_DIR)/include
|
||||
|
||||
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||
|
||||
ifeq ($(LOSCFG_PERF_HW_PMU), y)
|
||||
CFLAGS += -DLOSCFG_PERF_HW_PMU
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_PERF_TIMED_PMU), y)
|
||||
CFLAGS += -DLOSCFG_PERF_TIMED_PMU
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_PERF_SW_PMU), y)
|
||||
CFLAGS += -DLOSCFG_PERF_SW_PMU
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_FS_VFS), y)
|
||||
CFLAGS += -DLOSCFG_FS_VFS
|
||||
endif
|
||||
|
||||
CFLAGS += -DLOSCFG_PERF_BUFFER_SIZE=$(LOSCFG_PERF_BUFFER_SIZE)
|
||||
include $(APP)
|
||||
81
apps/perf/include/option.h
Normal file
81
apps/perf/include/option.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _OPTION_H
|
||||
#define _OPTION_H
|
||||
|
||||
#include "perf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define CMD_MAX_PARAMS 10
|
||||
typedef int (*CALL_BACK)(const char *argv);
|
||||
|
||||
enum OptionType {
|
||||
OPTION_TYPE_UINT,
|
||||
OPTION_TYPE_STRING,
|
||||
OPTION_TYPE_CALLBACK,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
const char *name;
|
||||
const char **str;
|
||||
unsigned int *value;
|
||||
CALL_BACK cb;
|
||||
} PerfOption;
|
||||
|
||||
typedef struct {
|
||||
const char *path;
|
||||
char *params[CMD_MAX_PARAMS];
|
||||
} SubCmd;
|
||||
|
||||
#define OPTION_END() {.name = ""}
|
||||
#define OPTION_UINT(n, v) {.type = OPTION_TYPE_UINT, .name = (n), .value = (v)}
|
||||
#define OPTION_STRING(n, s) {.type = OPTION_TYPE_STRING, .name = (n), .str = (s)}
|
||||
#define OPTION_CALLBACK(n, c) {.type = OPTION_TYPE_CALLBACK, .name = (n), .cb = (c)}
|
||||
|
||||
int ParseOptions(int argc, char **argv, PerfOption *opt, SubCmd *cmd);
|
||||
int ParseEvents(const char *argv, PerfEventConfig *eventsCfg, unsigned int *len);
|
||||
int ParseIds(const char *argv, int *arr, unsigned int *len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _OPTION_H */
|
||||
163
apps/perf/include/perf.h
Normal file
163
apps/perf/include/perf.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _PERF_H
|
||||
#define _PERF_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define PERF_MAX_EVENT 7
|
||||
#define PERF_MAX_FILTER_TSKS 32
|
||||
|
||||
#ifdef PERF_DEBUG
|
||||
#define printf_debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define printf_debug(fmt, ...)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Perf types
|
||||
*/
|
||||
enum PerfEventType {
|
||||
PERF_EVENT_TYPE_HW, /* boards common hw events */
|
||||
PERF_EVENT_TYPE_TIMED, /* hrtimer timed events */
|
||||
PERF_EVENT_TYPE_SW, /* software trace events */
|
||||
PERF_EVENT_TYPE_RAW, /* boards special hw events, see enum PmuEventType in corresponding arch headfile */
|
||||
|
||||
PERF_EVENT_TYPE_MAX
|
||||
};
|
||||
|
||||
/*
|
||||
* Common hardware pmu events
|
||||
*/
|
||||
enum PmuHwId {
|
||||
PERF_COUNT_HW_CPU_CYCLES = 0, /* cpu cycle event */
|
||||
PERF_COUNT_HW_INSTRUCTIONS, /* instruction event */
|
||||
PERF_COUNT_HW_DCACHE_REFERENCES, /* dcache access event */
|
||||
PERF_COUNT_HW_DCACHE_MISSES, /* dcache miss event */
|
||||
PERF_COUNT_HW_ICACHE_REFERENCES, /* icache access event */
|
||||
PERF_COUNT_HW_ICACHE_MISSES, /* icache miss event */
|
||||
PERF_COUNT_HW_BRANCH_INSTRUCTIONS, /* software change of pc event */
|
||||
PERF_COUNT_HW_BRANCH_MISSES, /* branch miss event */
|
||||
|
||||
PERF_COUNT_HW_MAX,
|
||||
};
|
||||
|
||||
/*
|
||||
* Common hrtimer timed events
|
||||
*/
|
||||
enum PmuTimedId {
|
||||
PERF_COUNT_CPU_CLOCK = 0, /* hrtimer timed event */
|
||||
};
|
||||
|
||||
/*
|
||||
* Common software pmu events
|
||||
*/
|
||||
enum PmuSwId {
|
||||
PERF_COUNT_SW_TASK_SWITCH = 1, /* task switch event */
|
||||
PERF_COUNT_SW_IRQ_RESPONSE, /* irq response event */
|
||||
PERF_COUNT_SW_MEM_ALLOC, /* memory alloc event */
|
||||
PERF_COUNT_SW_MUX_PEND, /* mutex pend event */
|
||||
|
||||
PERF_COUNT_SW_MAX,
|
||||
};
|
||||
|
||||
/*
|
||||
* perf sample data types
|
||||
* Config it through PerfConfigAttr->sampleType.
|
||||
*/
|
||||
enum PerfSampleType {
|
||||
PERF_RECORD_CPU = 1U << 0, /* record current cpuid */
|
||||
PERF_RECORD_TID = 1U << 1, /* record current task id */
|
||||
PERF_RECORD_TYPE = 1U << 2, /* record event type */
|
||||
PERF_RECORD_PERIOD = 1U << 3, /* record event period */
|
||||
PERF_RECORD_TIMESTAMP = 1U << 4, /* record timestamp */
|
||||
PERF_RECORD_IP = 1U << 5, /* record instruction pointer */
|
||||
PERF_RECORD_CALLCHAIN = 1U << 6, /* record backtrace */
|
||||
PERF_RECORD_PID = 1U << 7, /* record current process id */
|
||||
};
|
||||
|
||||
/*
|
||||
* perf configuration sub event information
|
||||
*
|
||||
* This structure is used to config specific events attributes.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int type; /* enum PerfEventType */
|
||||
struct {
|
||||
unsigned int eventId; /* the specific event corresponds to the PerfEventType */
|
||||
unsigned int period; /* event period, for every "period"th occurrence of the event a
|
||||
sample will be recorded */
|
||||
} events[PERF_MAX_EVENT]; /* perf event list */
|
||||
unsigned int eventsNr; /* total perf event number */
|
||||
size_t predivided; /* whether to prescaler (once every 64 counts),
|
||||
which only take effect on cpu cycle hardware event */
|
||||
} PerfEventConfig;
|
||||
|
||||
/*
|
||||
* perf configuration main information
|
||||
*
|
||||
* This structure is used to set perf sampling attributes, including events, tasks and other information.
|
||||
*/
|
||||
typedef struct {
|
||||
PerfEventConfig eventsCfg; /* perf event config */
|
||||
unsigned int taskIds[PERF_MAX_FILTER_TSKS]; /* perf task filter list (allowlist) */
|
||||
unsigned int taskIdsNr; /* task numbers of task filter allowlist,
|
||||
if set 0 perf will sample all tasks */
|
||||
unsigned int processIds[PERF_MAX_FILTER_TSKS]; /* perf process filter list (allowlist) */
|
||||
unsigned int processIdsNr; /* process numbers of process filter allowlist,
|
||||
if set 0 perf will sample all processes */
|
||||
unsigned int sampleType; /* type of data to sample defined in PerfSampleType */
|
||||
size_t needSample; /* whether to sample data */
|
||||
} PerfConfigAttr;
|
||||
|
||||
void PerfUsage(void);
|
||||
void PerfDumpAttr(PerfConfigAttr *attr);
|
||||
int PerfConfig(int fd, PerfConfigAttr *attr);
|
||||
void PerfStart(int fd, size_t sectionId);
|
||||
void PerfStop(int fd);
|
||||
ssize_t PerfRead(int fd, char *buf, size_t size);
|
||||
void PerfPrintBuffer(const char *buf, ssize_t num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _PERF_H */
|
||||
57
apps/perf/include/perf_list.h
Normal file
57
apps/perf/include/perf_list.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _PERF_LIST_H
|
||||
#define _PERF_LIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
int event;
|
||||
int type;
|
||||
} PerfEvent;
|
||||
|
||||
extern const PerfEvent g_events[];
|
||||
void PerfList(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _PERF_LIST_H */
|
||||
49
apps/perf/include/perf_record.h
Normal file
49
apps/perf/include/perf_record.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#ifndef _PERF_RECORD_H
|
||||
#define _PERF_RECORD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void PerfRecord(int fd, int argc, char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _PERF_RECORD_H */
|
||||
49
apps/perf/include/perf_stat.h
Normal file
49
apps/perf/include/perf_stat.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#ifndef _PERF_STAT_H
|
||||
#define _PERF_STAT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void PerfStat(int fd, int argc, char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _PERF_STAT_H */
|
||||
82
apps/perf/src/main.c
Normal file
82
apps/perf/src/main.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "perf.h"
|
||||
#include "perf_list.h"
|
||||
#include "perf_stat.h"
|
||||
#include "perf_record.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#define TWO_ARGS 2
|
||||
#define THREE_ARGS 3
|
||||
int fd = open("/dev/perf", O_RDWR);
|
||||
if (fd == -1) {
|
||||
printf("Perf open failed.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
PerfUsage();
|
||||
} else if ((argc == TWO_ARGS) && strcmp(argv[1], "start") == 0) {
|
||||
PerfStart(fd, 0);
|
||||
} else if ((argc == THREE_ARGS) && strcmp(argv[1], "start") == 0) {
|
||||
size_t id = strtoul(argv[THREE_ARGS - 1], NULL, 0);
|
||||
PerfStart(fd, id);
|
||||
} else if ((argc == TWO_ARGS) && strcmp(argv[1], "stop") == 0) {
|
||||
PerfStop(fd);
|
||||
} else if ((argc == THREE_ARGS) && strcmp(argv[1], "read") == 0) {
|
||||
size_t size = strtoul(argv[THREE_ARGS - 1], NULL, 0);
|
||||
char *buf = (char *)malloc(size);
|
||||
int len = PerfRead(fd, buf, size);
|
||||
PerfPrintBuffer(buf, len);
|
||||
free(buf);
|
||||
} else if ((argc == TWO_ARGS) && strcmp(argv[1], "list") == 0) {
|
||||
PerfList();
|
||||
} else if ((argc >= THREE_ARGS) && strcmp(argv[1], "stat") == 0) {
|
||||
PerfStat(fd, argc, argv);
|
||||
} else if ((argc >= THREE_ARGS) && strcmp(argv[1], "record") == 0) {
|
||||
PerfRecord(fd, argc, argv);
|
||||
} else {
|
||||
printf("Unsupported perf command.\n");
|
||||
PerfUsage();
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
182
apps/perf/src/option.c
Normal file
182
apps/perf/src/option.c
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "option.h"
|
||||
#include "perf_list.h"
|
||||
|
||||
static int ParseOption(char **argv, int *index, PerfOption *opts)
|
||||
{
|
||||
int ret = 0;
|
||||
const char *str = NULL;
|
||||
|
||||
while ((opts->name != NULL) && (*opts->name != 0)) {
|
||||
if (strcmp(argv[*index], opts->name) == 0) {
|
||||
switch (opts->type) {
|
||||
case OPTION_TYPE_UINT:
|
||||
*opts->value = strtoul(argv[++(*index)], NULL, 0);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
*opts->str = argv[++(*index)];
|
||||
break;
|
||||
case OPTION_TYPE_CALLBACK:
|
||||
str = argv[++(*index)];
|
||||
if ((*opts->cb)(str) != 0) {
|
||||
printf("parse error\n");
|
||||
ret = -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("invalid option\n");
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
opts++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ParseOptions(int argc, char **argv, PerfOption *opts, SubCmd *cmd)
|
||||
{
|
||||
int i;
|
||||
int index = 0;
|
||||
|
||||
while ((index < argc) && (argv[index] != NULL) && (*argv[index] == '-')) {
|
||||
if (ParseOption(argv, &index, opts) != 0) {
|
||||
return -1;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if ((index < argc) && (argv[index] != NULL)) {
|
||||
cmd->path = argv[index];
|
||||
cmd->params[0] = argv[index];
|
||||
index++;
|
||||
} else {
|
||||
printf("no subcmd to execute\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 1; (index < argc) && (i < CMD_MAX_PARAMS); index++, i++) {
|
||||
cmd->params[i] = argv[index];
|
||||
}
|
||||
printf_debug("subcmd = %s\n", cmd->path);
|
||||
for (int j = 0; j < i; j++) {
|
||||
printf_debug("paras[%d]:%s\n", j, cmd->params[j]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ParseIds(const char *argv, int *arr, unsigned int *len)
|
||||
{
|
||||
int res, ret;
|
||||
unsigned int index = 0;
|
||||
char *sp = NULL;
|
||||
char *this = NULL;
|
||||
char *list = strdup(argv);
|
||||
|
||||
if (list == NULL) {
|
||||
printf("no memory for ParseIds\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sp = strtok_r(list, ",", &this);
|
||||
while (sp) {
|
||||
res = strtoul(sp, NULL, 0);
|
||||
if (res < 0) {
|
||||
ret = -1;
|
||||
goto EXIT;
|
||||
}
|
||||
arr[index++] = res;
|
||||
sp = strtok_r(NULL, ",", &this);
|
||||
}
|
||||
*len = index;
|
||||
ret = 0;
|
||||
EXIT:
|
||||
free(list);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline const PerfEvent *StrToEvent(const char *str)
|
||||
{
|
||||
const PerfEvent *evt = &g_events[0];
|
||||
|
||||
for (; evt->event != -1; evt++) {
|
||||
if (strcmp(str, evt->name) == 0) {
|
||||
return evt;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ParseEvents(const char *argv, PerfEventConfig *eventsCfg, unsigned int *len)
|
||||
{
|
||||
int ret;
|
||||
unsigned int index = 0;
|
||||
const PerfEvent *event = NULL;
|
||||
char *sp = NULL;
|
||||
char *this = NULL;
|
||||
char *list = strdup(argv);
|
||||
|
||||
if (list == NULL) {
|
||||
printf("no memory for ParseEvents\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sp = strtok_r(list, ",", &this);
|
||||
while (sp) {
|
||||
event = StrToEvent(sp);
|
||||
if (event == NULL) {
|
||||
ret = -1;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
eventsCfg->type = event->type;
|
||||
} else if (eventsCfg->type != event->type) {
|
||||
printf("events type must be same\n");
|
||||
ret = -1;
|
||||
goto EXIT;
|
||||
}
|
||||
eventsCfg->events[index].eventId = event->event;
|
||||
sp = strtok_r(NULL, ",", &this);
|
||||
index++;
|
||||
}
|
||||
*len = index;
|
||||
ret = 0;
|
||||
EXIT:
|
||||
free(list);
|
||||
return ret;
|
||||
}
|
||||
136
apps/perf/src/perf.c
Normal file
136
apps/perf/src/perf.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "perf.h"
|
||||
|
||||
#define PERF_IOC_MAGIC 'T'
|
||||
#define PERF_START _IO(PERF_IOC_MAGIC, 1)
|
||||
#define PERF_STOP _IO(PERF_IOC_MAGIC, 2)
|
||||
|
||||
void PerfUsage(void)
|
||||
{
|
||||
printf("\nUsage: ./perf start [id]. Start perf.\n");
|
||||
printf("\nUsage: ./perf stop. Stop perf.\n");
|
||||
printf("\nUsage: ./perf read <nBytes>. Read nBytes raw data from perf buffer and print out.\n");
|
||||
printf("\nUsage: ./perf list. List events to be used in -e.\n");
|
||||
printf("\nUsage: ./perf stat/record [option] <command>. \n"
|
||||
"-e, event selector. use './perf list' to list available events.\n"
|
||||
"-p, event period.\n"
|
||||
"-o, perf data output filename.\n"
|
||||
"-t, taskId filter(allowlist), if not set perf will sample all tasks.\n"
|
||||
"-s, type of data to sample defined in PerfSampleType los_perf.h.\n"
|
||||
"-P, processId filter(allowlist), if not set perf will sample all processes.\n"
|
||||
"-d, whether to prescaler (once every 64 counts),"
|
||||
"which only take effect on cpu cycle hardware event.\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void PerfSetPeriod(PerfConfigAttr *attr)
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < attr->eventsCfg.eventsNr; i++) {
|
||||
attr->eventsCfg.events[i].period = attr->eventsCfg.events[0].period;
|
||||
}
|
||||
}
|
||||
|
||||
void PerfPrintBuffer(const char *buf, ssize_t num)
|
||||
{
|
||||
#define BYTES_PER_LINE 4
|
||||
ssize_t i;
|
||||
for (i = 0; i < num; i++) {
|
||||
printf(" %02x", (unsigned char)buf[i]);
|
||||
if (((i + 1) % BYTES_PER_LINE) == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void PerfDumpAttr(PerfConfigAttr *attr)
|
||||
{
|
||||
int i;
|
||||
printf_debug("attr->type: %d\n", attr->eventsCfg.type);
|
||||
for (i = 0; i < attr->eventsCfg.eventsNr; i++) {
|
||||
printf_debug("attr->events[%d]: %d, 0x%x\n", i, attr->eventsCfg.events[i].eventId,
|
||||
attr->eventsCfg.events[i].period);
|
||||
}
|
||||
printf_debug("attr->predivided: %d\n", attr->eventsCfg.predivided);
|
||||
printf_debug("attr->sampleType: 0x%x\n", attr->sampleType);
|
||||
|
||||
for (i = 0; i < attr->taskIdsNr; i++) {
|
||||
printf_debug("attr->taskIds[%d]: %d\n", i, attr->taskIds[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < attr->processIdsNr; i++) {
|
||||
printf_debug("attr->processIds[%d]: %d\n", i, attr->processIds[i]);
|
||||
}
|
||||
|
||||
printf_debug("attr->needSample: %d\n", attr->needSample);
|
||||
}
|
||||
|
||||
|
||||
void PerfStart(int fd, size_t sectionId)
|
||||
{
|
||||
(void)ioctl(fd, PERF_START, sectionId);
|
||||
}
|
||||
|
||||
void PerfStop(int fd)
|
||||
{
|
||||
(void)ioctl(fd, PERF_STOP, NULL);
|
||||
}
|
||||
|
||||
int PerfConfig(int fd, PerfConfigAttr *attr)
|
||||
{
|
||||
if (attr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
PerfSetPeriod(attr);
|
||||
PerfDumpAttr(attr);
|
||||
return write(fd, attr, sizeof(PerfConfigAttr));
|
||||
}
|
||||
|
||||
ssize_t PerfRead(int fd, char *buf, size_t size)
|
||||
{
|
||||
ssize_t len;
|
||||
if (buf == NULL) {
|
||||
printf("Read buffer is null.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = read(fd, buf, size);
|
||||
return len;
|
||||
}
|
||||
129
apps/perf/src/perf_list.c
Normal file
129
apps/perf/src/perf_list.c
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "perf.h"
|
||||
#include "perf_list.h"
|
||||
|
||||
static const char *g_eventTypeStr[] = {
|
||||
"[Hardware event]",
|
||||
"[Timed event]",
|
||||
"[Software event]",
|
||||
};
|
||||
|
||||
const PerfEvent g_events[] = {
|
||||
#ifdef LOSCFG_PERF_HW_PMU
|
||||
{
|
||||
.name = "cycles",
|
||||
.event = PERF_COUNT_HW_CPU_CYCLES,
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
},
|
||||
{
|
||||
.name = "instruction",
|
||||
.event = PERF_COUNT_HW_INSTRUCTIONS,
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
},
|
||||
{
|
||||
.name = "dcache",
|
||||
.event = PERF_COUNT_HW_DCACHE_REFERENCES,
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
},
|
||||
{
|
||||
.name = "dcache-miss",
|
||||
.event = PERF_COUNT_HW_DCACHE_MISSES,
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
},
|
||||
{
|
||||
.name = "icache",
|
||||
.event = PERF_COUNT_HW_ICACHE_REFERENCES,
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
},
|
||||
{
|
||||
.name = "icache-miss",
|
||||
.event = PERF_COUNT_HW_ICACHE_MISSES,
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
},
|
||||
{
|
||||
.name = "branch",
|
||||
.event = PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
},
|
||||
{
|
||||
.name = "branch-miss",
|
||||
.event = PERF_COUNT_HW_BRANCH_MISSES,
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_PERF_TIMED_PMU
|
||||
{
|
||||
.name = "clock",
|
||||
.event = PERF_COUNT_CPU_CLOCK,
|
||||
.type = PERF_EVENT_TYPE_TIMED,
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_PERF_SW_PMU
|
||||
{
|
||||
.name = "task-switch",
|
||||
.event = PERF_COUNT_SW_TASK_SWITCH,
|
||||
.type = PERF_EVENT_TYPE_SW,
|
||||
},
|
||||
{
|
||||
.name = "irq-in",
|
||||
.event = PERF_COUNT_SW_IRQ_RESPONSE,
|
||||
.type = PERF_EVENT_TYPE_SW,
|
||||
},
|
||||
{
|
||||
.name = "mem-alloc",
|
||||
.event = PERF_COUNT_SW_MEM_ALLOC,
|
||||
.type = PERF_EVENT_TYPE_SW,
|
||||
},
|
||||
{
|
||||
.name = "mux-pend",
|
||||
.event = PERF_COUNT_SW_MUX_PEND,
|
||||
.type = PERF_EVENT_TYPE_SW,
|
||||
},
|
||||
#endif
|
||||
{
|
||||
.name = "",
|
||||
.event = -1,
|
||||
.type = PERF_EVENT_TYPE_MAX,
|
||||
}
|
||||
};
|
||||
|
||||
void PerfList(void)
|
||||
{
|
||||
const PerfEvent *evt = &g_events[0];
|
||||
printf("\n");
|
||||
for (; evt->event != -1; evt++) {
|
||||
printf("\t %-25s%30s\n", evt->name, g_eventTypeStr[evt->type]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
204
apps/perf/src/perf_record.c
Normal file
204
apps/perf/src/perf_record.c
Normal file
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <securec.h>
|
||||
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include "perf.h"
|
||||
#include "option.h"
|
||||
#include "perf_record.h"
|
||||
|
||||
#define PERF_FILE_MODE 0644
|
||||
static PerfConfigAttr g_recordAttr;
|
||||
static const char *g_savePath = "/storage/data/perf.data";
|
||||
|
||||
static inline int GetEvents(const char *argv)
|
||||
{
|
||||
return ParseEvents(argv, &g_recordAttr.eventsCfg, &g_recordAttr.eventsCfg.eventsNr);
|
||||
}
|
||||
|
||||
static inline int GetTids(const char *argv)
|
||||
{
|
||||
return ParseIds(argv, (int *)g_recordAttr.taskIds, &g_recordAttr.taskIdsNr);
|
||||
}
|
||||
|
||||
static inline int GetPids(const char *argv)
|
||||
{
|
||||
return ParseIds(argv, (int *)g_recordAttr.processIds, &g_recordAttr.processIdsNr);
|
||||
}
|
||||
|
||||
static PerfOption g_recordOpts[] = {
|
||||
OPTION_CALLBACK("-e", GetEvents),
|
||||
OPTION_CALLBACK("-t", GetTids),
|
||||
OPTION_CALLBACK("-P", GetPids),
|
||||
OPTION_STRING("-o", &g_savePath),
|
||||
OPTION_UINT("-p", &g_recordAttr.eventsCfg.events[0].period),
|
||||
OPTION_UINT("-s", &g_recordAttr.sampleType),
|
||||
OPTION_UINT("-d", &g_recordAttr.eventsCfg.predivided),
|
||||
};
|
||||
|
||||
static int PerfRecordAttrInit(void)
|
||||
{
|
||||
PerfConfigAttr attr = {
|
||||
.eventsCfg = {
|
||||
#ifdef LOSCFG_PERF_HW_PMU
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
.events = {
|
||||
[0] = {PERF_COUNT_HW_CPU_CYCLES, 0xFFFF},
|
||||
},
|
||||
#elif defined LOSCFG_PERF_TIMED_PMU
|
||||
.type = PERF_EVENT_TYPE_TIMED,
|
||||
.events = {
|
||||
[0] = {PERF_COUNT_CPU_CLOCK, 100},
|
||||
},
|
||||
#elif defined LOSCFG_PERF_SW_PMU
|
||||
.type = PERF_EVENT_TYPE_SW,
|
||||
.events = {
|
||||
[0] = {PERF_COUNT_SW_TASK_SWITCH, 1},
|
||||
},
|
||||
#endif
|
||||
.eventsNr = 1, /* 1 event */
|
||||
.predivided = 0,
|
||||
},
|
||||
.taskIds = {0},
|
||||
.taskIdsNr = 0,
|
||||
.processIds = {0},
|
||||
.processIdsNr = 0,
|
||||
.needSample = 1,
|
||||
.sampleType = PERF_RECORD_IP | PERF_RECORD_CALLCHAIN,
|
||||
};
|
||||
|
||||
return memcpy_s(&g_recordAttr, sizeof(PerfConfigAttr), &attr, sizeof(PerfConfigAttr)) != EOK ? -1 : 0;
|
||||
}
|
||||
|
||||
ssize_t PerfWriteFile(const char *filePath, const char *buf, ssize_t bufSize)
|
||||
{
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
int fd = -1;
|
||||
ssize_t totalToWrite = bufSize;
|
||||
ssize_t totalWrite = 0;
|
||||
|
||||
if (filePath == NULL || buf == NULL || bufSize == 0) {
|
||||
printf("filePath: %p, buf: %p, bufSize: %u!\n", filePath, buf, bufSize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = open(filePath, O_CREAT | O_RDWR | O_TRUNC, PERF_FILE_MODE);
|
||||
if (fd < 0) {
|
||||
printf("create file [%s] failed, fd: %d, %s!\n", filePath, fd, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
while (totalToWrite > 0) {
|
||||
ssize_t writeThisTime = write(fd, buf, totalToWrite);
|
||||
if (writeThisTime < 0) {
|
||||
printf("failed to write file [%s], %s!\n", filePath, strerror(errno));
|
||||
(void)close(fd);
|
||||
return -1;
|
||||
}
|
||||
buf += writeThisTime;
|
||||
totalToWrite -= writeThisTime;
|
||||
totalWrite += writeThisTime;
|
||||
}
|
||||
(void)fsync(fd);
|
||||
(void)close(fd);
|
||||
|
||||
return (totalWrite == bufSize) ? 0 : -1;
|
||||
#else
|
||||
(void)filePath;
|
||||
PerfPrintBuffer(buf, bufSize);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void PerfRecord(int fd, int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
int child;
|
||||
char *buf;
|
||||
ssize_t len;
|
||||
SubCmd cmd = {0};
|
||||
|
||||
if (argc < 3) { /* perf record argc is at least 3 */
|
||||
return;
|
||||
}
|
||||
|
||||
ret = PerfRecordAttrInit();
|
||||
if (ret != 0) {
|
||||
printf("perf record attr init failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ParseOptions(argc - 2, &argv[2], g_recordOpts, &cmd); /* parse option and cmd begin at index 2 */
|
||||
if (ret != 0) {
|
||||
printf("parse error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = PerfConfig(fd, &g_recordAttr);
|
||||
if (ret != 0) {
|
||||
printf("perf config failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
PerfStart(fd, 0);
|
||||
child = fork();
|
||||
if (child < 0) {
|
||||
printf("fork error\n");
|
||||
PerfStop(fd);
|
||||
return;
|
||||
} else if (child == 0) {
|
||||
(void)execve(cmd.path, cmd.params, NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
waitpid(child, 0, 0);
|
||||
PerfStop(fd);
|
||||
|
||||
buf = (char *)malloc(LOSCFG_PERF_BUFFER_SIZE);
|
||||
if (buf == NULL) {
|
||||
printf("no memory for read perf 0x%x\n", LOSCFG_PERF_BUFFER_SIZE);
|
||||
return;
|
||||
}
|
||||
len = PerfRead(fd, buf, LOSCFG_PERF_BUFFER_SIZE);
|
||||
ret = PerfWriteFile(g_savePath, buf, len);
|
||||
if (ret == 0) {
|
||||
printf("save perf data success at %s\n", g_savePath);
|
||||
} else {
|
||||
printf("save perf data failed at %s\n", g_savePath);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
149
apps/perf/src/perf_stat.c
Normal file
149
apps/perf/src/perf_stat.c
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <securec.h>
|
||||
#include <sys/wait.h>
|
||||
#include "perf.h"
|
||||
#include "option.h"
|
||||
#include "perf_stat.h"
|
||||
|
||||
static PerfConfigAttr g_statAttr;
|
||||
|
||||
static inline int GetEvents(const char *argv)
|
||||
{
|
||||
return ParseEvents(argv, &g_statAttr.eventsCfg, &g_statAttr.eventsCfg.eventsNr);
|
||||
}
|
||||
|
||||
static inline int GetTids(const char *argv)
|
||||
{
|
||||
return ParseIds(argv, (int *)g_statAttr.taskIds, &g_statAttr.taskIdsNr);
|
||||
}
|
||||
|
||||
static inline int GetPids(const char *argv)
|
||||
{
|
||||
return ParseIds(argv, (int *)g_statAttr.processIds, &g_statAttr.processIdsNr);
|
||||
}
|
||||
|
||||
static PerfOption g_statOpts[] = {
|
||||
OPTION_CALLBACK("-e", GetEvents),
|
||||
OPTION_CALLBACK("-t", GetTids),
|
||||
OPTION_CALLBACK("-P", GetPids),
|
||||
OPTION_UINT("-p", &g_statAttr.eventsCfg.events[0].period),
|
||||
OPTION_UINT("-s", &g_statAttr.sampleType),
|
||||
OPTION_UINT("-d", &g_statAttr.eventsCfg.predivided),
|
||||
};
|
||||
|
||||
static int PerfStatAttrInit(void)
|
||||
{
|
||||
PerfConfigAttr attr = {
|
||||
.eventsCfg = {
|
||||
#ifdef LOSCFG_PERF_HW_PMU
|
||||
.type = PERF_EVENT_TYPE_HW,
|
||||
.events = {
|
||||
[0] = {PERF_COUNT_HW_CPU_CYCLES, 0xFFFF},
|
||||
[1] = {PERF_COUNT_HW_INSTRUCTIONS, 0xFFFFFF00},
|
||||
[2] = {PERF_COUNT_HW_ICACHE_REFERENCES, 0xFFFF},
|
||||
[3] = {PERF_COUNT_HW_DCACHE_REFERENCES, 0xFFFF},
|
||||
},
|
||||
.eventsNr = 4, /* 4 events */
|
||||
#elif defined LOSCFG_PERF_TIMED_PMU
|
||||
.type = PERF_EVENT_TYPE_TIMED,
|
||||
.events = {
|
||||
[0] = {PERF_COUNT_CPU_CLOCK, 100},
|
||||
},
|
||||
.eventsNr = 1, /* 1 event */
|
||||
#elif defined LOSCFG_PERF_SW_PMU
|
||||
.type = PERF_EVENT_TYPE_SW,
|
||||
.events = {
|
||||
[0] = {PERF_COUNT_SW_TASK_SWITCH, 1},
|
||||
[1] = {PERF_COUNT_SW_IRQ_RESPONSE, 1},
|
||||
[2] = {PERF_COUNT_SW_MEM_ALLOC, 1},
|
||||
[3] = {PERF_COUNT_SW_MUX_PEND, 1},
|
||||
},
|
||||
.eventsNr = 4, /* 4 events */
|
||||
#endif
|
||||
.predivided = 0,
|
||||
},
|
||||
.taskIds = {0},
|
||||
.taskIdsNr = 0,
|
||||
.processIds = {0},
|
||||
.processIdsNr = 0,
|
||||
.needSample = 0,
|
||||
.sampleType = 0,
|
||||
};
|
||||
|
||||
return memcpy_s(&g_statAttr, sizeof(PerfConfigAttr), &attr, sizeof(PerfConfigAttr)) != EOK ? -1 : 0;
|
||||
}
|
||||
|
||||
void PerfStat(int fd, int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
int child;
|
||||
SubCmd cmd = {0};
|
||||
|
||||
if (argc < 3) { /* perf stat argc is at least 3 */
|
||||
return;
|
||||
}
|
||||
|
||||
ret = PerfStatAttrInit();
|
||||
if (ret != 0) {
|
||||
printf("perf stat attr init failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ParseOptions(argc - 2, &argv[2], g_statOpts, &cmd); /* parse option and cmd begin at index 2 */
|
||||
if (ret != 0) {
|
||||
printf("parse error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = PerfConfig(fd, &g_statAttr);
|
||||
if (ret != 0) {
|
||||
printf("perf config failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
PerfStart(fd, 0);
|
||||
child = fork();
|
||||
if (child < 0) {
|
||||
printf("fork error\n");
|
||||
goto EXIT;
|
||||
} else if (child == 0) {
|
||||
(void)execve(cmd.path, cmd.params, NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
(void)waitpid(child, 0, 0);
|
||||
EXIT:
|
||||
PerfStop(fd);
|
||||
}
|
||||
|
||||
44
apps/shell/BUILD.gn
Normal file
44
apps/shell/BUILD.gn
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("shell") {
|
||||
sources = [
|
||||
"builtin/cd.c",
|
||||
"src/main.c",
|
||||
"src/shcmd.c",
|
||||
"src/shcmdparse.c",
|
||||
"src/shmsg.c",
|
||||
]
|
||||
|
||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -27,52 +27,19 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SHELL_DIR := $(dir $(shell pwd))/shell/
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(SHELL_DIR)/../config.mk
|
||||
APPS_OUT := $(OUT)/bin
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
SECUREC_INCLUDE := $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
||||
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||
|
||||
LOCAL_SRCS = $(wildcard src/main.c)\
|
||||
$(wildcard src/shcmd.c)\
|
||||
$(wildcard src/shmsg.c)\
|
||||
$(wildcard src/shcmdparse.c)\
|
||||
$(wildcard builtin/cd.c)
|
||||
LOCAL_SRCS += $(wildcard $(LITEOSTHIRDPARTY)/bounds_checking_function/src/*.c)
|
||||
LOCAL_OBJ := $(LOCAL_SRCS:.c=.o)
|
||||
LOCAL_SRCS = $(wildcard src/*.c builtin/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(SHELL_DIR)/include/ \
|
||||
-I $(SECUREC_INCLUDE)\
|
||||
-I include \
|
||||
-I $(SECUREC_DIR)/include
|
||||
|
||||
LOCAL_FLAGS += $(CFLAGS)
|
||||
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||
|
||||
LDPATH := -L$(SHELL_DIR)/
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
SHELLNAME := shell
|
||||
|
||||
all: $(SHELLNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(SHELLNAME): $(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(SHELLNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(SHELLNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(SHELLNAME)
|
||||
|
||||
.PHONY: all $(SHELLNAME) clean
|
||||
include $(APP)
|
||||
|
||||
@@ -29,9 +29,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include "unistd.h"
|
||||
#include "shcmd.h"
|
||||
@@ -48,7 +46,7 @@ int Chdir(const char *tgtDir)
|
||||
|
||||
ret = chdir(tgtDir);
|
||||
if (ret == 0) {
|
||||
ret = OsShellSetWorkingDirtectory(tgtDir, strlen(tgtDir) + 1); /* 1: the length of '\0' */
|
||||
ret = OsShellSetWorkingDirectory(tgtDir, strlen(tgtDir) + 1); /* 1: the length of '\0' */
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -53,7 +53,7 @@ typedef struct {
|
||||
} CmdKeyLink;
|
||||
|
||||
#define NEED_NEW_LINE(timesPrint, lineCap) ((timesPrint) % (lineCap) == 0)
|
||||
#define SCREEN_IS_FULL(timesPrint, lineCap) ((timesPrint) >= ((lineCap) * DEFAULT_SCREEN_HEIGNT))
|
||||
#define SCREEN_IS_FULL(timesPrint, lineCap) ((timesPrint) >= ((lineCap) * DEFAULT_SCREEN_HEIGHT))
|
||||
|
||||
extern unsigned int OsCmdExec(CmdParsed *cmdParsed, char *cmdStr);
|
||||
extern unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size);
|
||||
@@ -62,7 +62,7 @@ extern void OsShellCmdPush(const char *string, CmdKeyLink *cmdKeyLink);
|
||||
extern void OsShellHistoryShow(unsigned int value, ShellCB *shellCB);
|
||||
extern unsigned int OsShellKeyInit(ShellCB *shellCB);
|
||||
extern void OsShellKeyDeInit(CmdKeyLink *cmdKeyLink);
|
||||
extern int OsShellSetWorkingDirtectory(const char *dir, size_t len);
|
||||
extern int OsShellSetWorkingDirectory(const char *dir, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -54,7 +54,7 @@ extern "C" {
|
||||
#define CMD_HISTORY_LEN 10
|
||||
#define CMD_MAX_PATH 256
|
||||
#define DEFAULT_SCREEN_WIDTH 80
|
||||
#define DEFAULT_SCREEN_HEIGNT 24
|
||||
#define DEFAULT_SCREEN_HEIGHT 24
|
||||
|
||||
#define SWITCH_QUOTES_STATUS(qu) do { \
|
||||
if ((qu) == TRUE) { \
|
||||
|
||||
@@ -32,10 +32,6 @@
|
||||
#ifndef _SHELL_PRI_H
|
||||
#define _SHELL_PRI_H
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "bits/alltypes.h"
|
||||
#include "shcmd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -32,9 +32,6 @@
|
||||
#ifndef _SHERR_H
|
||||
#define _SHERR_H
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "bits/alltypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -43,8 +43,13 @@ extern "C" {
|
||||
#define SHELL_ENTRY_STACKSIZE 0x1000
|
||||
#define SHELL_TASK_STACKSIZE 0x3000
|
||||
|
||||
#define SHELL_EXEC_COMMAND "exec "
|
||||
#define SHELL_EXEC_COMMAND_BYTES 5
|
||||
#define SHELL_EXEC_COMMAND "exec"
|
||||
#define SHELL_EXEC_COMMAND_BYTES 4
|
||||
#define CMD_EXEC_COMMAND SHELL_EXEC_COMMAND" "
|
||||
#define CMD_EXEC_COMMAND_BYTES (SHELL_EXEC_COMMAND_BYTES + 1)
|
||||
#define CMD_EXIT_COMMAND "exit"
|
||||
#define CMD_EXIT_COMMAND_BYTES 4
|
||||
#define CMD_EXIT_CODE_BASE_DEC 10
|
||||
|
||||
#define CONSOLE_IOC_MAGIC 'c'
|
||||
#define CONSOLE_CONTROL_REG_USERTASK _IO(CONSOLE_IOC_MAGIC, 7)
|
||||
@@ -54,9 +59,10 @@ extern "C" {
|
||||
#define COLOR_L_RED "\e[1;31m"
|
||||
#define SHELL_PROMPT COLOR_L_RED"OHOS # "COLOR_NONE
|
||||
|
||||
typedef void (*OutputFunc)(const char *fmt, ...);
|
||||
typedef void (* OutputFunc)(const char *fmt, ...);
|
||||
extern int ShellTaskInit(ShellCB *shellCB);
|
||||
extern int ShellEntryInit(ShellCB *shellCB);
|
||||
extern void ChildExec(const char *cmdName, char *const paramArray[]);
|
||||
extern void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB);
|
||||
extern int ShellNotify(ShellCB *shellCB);
|
||||
|
||||
|
||||
@@ -42,10 +42,10 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern char *OsShellGetWorkingDirtectory();
|
||||
extern unsigned int OsShellInit();
|
||||
extern char *OsShellGetWorkingDirectory(void);
|
||||
extern unsigned int OsShellInit(void);
|
||||
extern int OsShellDeinit(ShellCB *shellCB);
|
||||
extern ShellCB *OsGetShellCb();
|
||||
extern ShellCB *OsGetShellCb(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -29,13 +29,15 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "show.h"
|
||||
#include "shmsg.h"
|
||||
#include "shcmd.h"
|
||||
#include "semaphore.h"
|
||||
#include "securec.h"
|
||||
#include "unistd.h"
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
ShellCB *g_shellCB = NULL;
|
||||
|
||||
@@ -88,11 +90,47 @@ OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main()
|
||||
static int DoShellExec(char **argv)
|
||||
{
|
||||
int i, j;
|
||||
int len = 0;
|
||||
int ret = SH_NOK;
|
||||
char *cmdLine = NULL;
|
||||
|
||||
if (strncmp(argv[0], SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
|
||||
ChildExec(argv[1], argv + 1);
|
||||
}
|
||||
for (i = 0; argv[i]; i++) {
|
||||
len += strlen(argv[i]);
|
||||
}
|
||||
len += i + 1;
|
||||
cmdLine = (char *)malloc(len);
|
||||
if (!cmdLine) {
|
||||
return ret;
|
||||
}
|
||||
memset_s(cmdLine, len, 0, len);
|
||||
|
||||
for (j = 0; j < i; j++) {
|
||||
strcat_s(cmdLine, len, argv[j]);
|
||||
strcat_s(cmdLine, len, " ");
|
||||
}
|
||||
|
||||
cmdLine[len - 2] = '\0'; /* 2, (len - 2) is the end of cmdline buf */
|
||||
ret = syscall(__NR_shellexec, argv[0], cmdLine);
|
||||
free(cmdLine);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = SH_NOK;
|
||||
ShellCB *shellCB = NULL;
|
||||
|
||||
if (argc > 1) {
|
||||
ret = DoShellExec(argv + 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
|
||||
|
||||
@@ -91,12 +91,12 @@ static int OsStrSeparateTabStrGet(const char **tabStr, CmdParsed *parsed, unsign
|
||||
return SH_OK;
|
||||
}
|
||||
|
||||
char *OsShellGetWorkingDirtectory()
|
||||
char *OsShellGetWorkingDirectory(void)
|
||||
{
|
||||
return OsGetShellCb()->shellWorkingDirectory;
|
||||
}
|
||||
|
||||
int OsShellSetWorkingDirtectory(const char *dir, size_t len)
|
||||
int OsShellSetWorkingDirectory(const char *dir, size_t len)
|
||||
{
|
||||
if (dir == NULL) {
|
||||
return SH_NOK;
|
||||
@@ -115,7 +115,7 @@ static int OsStrSeparate(const char *tabStr, char *strPath, char *nameLooking, u
|
||||
char *strEnd = NULL;
|
||||
char *cutPos = NULL;
|
||||
CmdParsed parsed = {0};
|
||||
char *shellWorkingDirectory = OsShellGetWorkingDirtectory();
|
||||
char *shellWorkingDirectory = OsShellGetWorkingDirectory();
|
||||
int ret;
|
||||
|
||||
ret = OsStrSeparateTabStrGet(&tabStr, &parsed, tabStrLen);
|
||||
@@ -223,7 +223,7 @@ static int OsPrintMatchList(unsigned int count, const char *strPath, const char
|
||||
return (int)SH_ERROR;
|
||||
}
|
||||
|
||||
if (count > (lineCap * DEFAULT_SCREEN_HEIGNT)) {
|
||||
if (count > (lineCap * DEFAULT_SCREEN_HEIGHT)) {
|
||||
ret = OsSurePrintAll(count);
|
||||
if (ret != 1) {
|
||||
return ret;
|
||||
@@ -375,10 +375,10 @@ static int OsTabMatchFile(char *cmdKey, unsigned int *len)
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: Pass in the string and clear useless space ,which inlcude:
|
||||
* Description: Pass in the string and clear useless space ,which include:
|
||||
* 1) The overmatch space which is not be marked by Quote's area
|
||||
* Squeeze the overmatch space into one space
|
||||
* 2) Clear all space before first vaild charatctor
|
||||
* 2) Clear all space before first valid charatctor
|
||||
* Input: cmdKey : Pass in the buff string, which is ready to be operated
|
||||
* cmdOut : Pass out the buffer string ,which has already been operated
|
||||
* size : cmdKey length
|
||||
@@ -407,7 +407,7 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
|
||||
|
||||
/* Backup the 'output' start address */
|
||||
outputBak = output;
|
||||
/* Scan each charactor in 'cmdKey',and squeeze the overmuch space and ignore invaild charactor */
|
||||
/* Scan each charactor in 'cmdKey',and squeeze the overmuch space and ignore invalid charactor */
|
||||
for (; *cmdKey != '\0'; cmdKey++) {
|
||||
/* Detected a Double Quotes, switch the matching status */
|
||||
if (*(cmdKey) == '\"') {
|
||||
@@ -417,7 +417,7 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
|
||||
/* 1) Quotes matching status is FALSE (which said that the space is not been marked by double quotes) */
|
||||
/* 2) Current charactor is a space */
|
||||
/* 3) Next charactor is a space too, or the string is been seeked to the end already(\0) */
|
||||
/* 4) Invaild charactor, such as single quotes */
|
||||
/* 4) Invalid charactor, such as single quotes */
|
||||
if ((*cmdKey == ' ') && ((*(cmdKey + 1) == ' ') || (*(cmdKey + 1) == '\0')) && QUOTES_STATUS_CLOSE(quotes)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "unistd.h"
|
||||
@@ -42,7 +44,10 @@
|
||||
#include "shell_pri.h"
|
||||
#include "shcmd.h"
|
||||
|
||||
#define CHAR_CTRL_C '\x03'
|
||||
#define CHAR_CTRL_DEL '\x7F'
|
||||
|
||||
#define VISIABLE_CHAR(ch) ((ch) > 0x1F && (ch) < 0x7F)
|
||||
|
||||
char *GetCmdline(ShellCB *shellCB)
|
||||
{
|
||||
@@ -128,7 +133,7 @@ int ShellNotify(ShellCB *shellCB)
|
||||
}
|
||||
|
||||
enum {
|
||||
STAT_NOMAL_KEY,
|
||||
STAT_NORMAL_KEY,
|
||||
STAT_ESC_KEY,
|
||||
STAT_MULTI_KEY
|
||||
};
|
||||
@@ -147,23 +152,23 @@ static int ShellCmdLineCheckUDRL(const char ch, ShellCB *shellCB)
|
||||
} else if (ch == 0x41) { /* up */
|
||||
if (shellCB->shellKeyType == STAT_MULTI_KEY) {
|
||||
OsShellHistoryShow(CMD_KEY_UP, shellCB);
|
||||
shellCB->shellKeyType = STAT_NOMAL_KEY;
|
||||
shellCB->shellKeyType = STAT_NORMAL_KEY;
|
||||
return ret;
|
||||
}
|
||||
} else if (ch == 0x42) { /* down */
|
||||
if (shellCB->shellKeyType == STAT_MULTI_KEY) {
|
||||
shellCB->shellKeyType = STAT_NOMAL_KEY;
|
||||
shellCB->shellKeyType = STAT_NORMAL_KEY;
|
||||
OsShellHistoryShow(CMD_KEY_DOWN, shellCB);
|
||||
return ret;
|
||||
}
|
||||
} else if (ch == 0x43) { /* right */
|
||||
if (shellCB->shellKeyType == STAT_MULTI_KEY) {
|
||||
shellCB->shellKeyType = STAT_NOMAL_KEY;
|
||||
shellCB->shellKeyType = STAT_NORMAL_KEY;
|
||||
return ret;
|
||||
}
|
||||
} else if (ch == 0x44) { /* left */
|
||||
if (shellCB->shellKeyType == STAT_MULTI_KEY) {
|
||||
shellCB->shellKeyType = STAT_NOMAL_KEY;
|
||||
shellCB->shellKeyType = STAT_NORMAL_KEY;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -200,7 +205,21 @@ void ParseEnterKey(OutputFunc outputFunc, ShellCB *shellCB)
|
||||
shellCB->shellBuf[shellCB->shellBufOffset] = '\0';
|
||||
}
|
||||
NOTIFY:
|
||||
outputFunc("\n");
|
||||
shellCB->shellBufOffset = 0;
|
||||
ShellTaskNotify(shellCB);
|
||||
}
|
||||
|
||||
void ParseCancelKey(OutputFunc outputFunc, ShellCB *shellCB)
|
||||
{
|
||||
if ((shellCB == NULL) || (outputFunc == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shellCB->shellBufOffset <= (SHOW_MAX_LEN - 1)) {
|
||||
shellCB->shellBuf[0] = CHAR_CTRL_C;
|
||||
shellCB->shellBuf[1] = '\0';
|
||||
}
|
||||
|
||||
shellCB->shellBufOffset = 0;
|
||||
ShellTaskNotify(shellCB);
|
||||
}
|
||||
@@ -236,7 +255,7 @@ void ParseTabKey(OutputFunc outputFunc, ShellCB *shellCB)
|
||||
|
||||
void ParseNormalChar(char ch, OutputFunc outputFunc, ShellCB *shellCB)
|
||||
{
|
||||
if ((shellCB == NULL) || (outputFunc == NULL)) {
|
||||
if ((shellCB == NULL) || (outputFunc == NULL) || !VISIABLE_CHAR(ch)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -246,7 +265,7 @@ void ParseNormalChar(char ch, OutputFunc outputFunc, ShellCB *shellCB)
|
||||
outputFunc("%c", ch);
|
||||
}
|
||||
|
||||
shellCB->shellKeyType = STAT_NOMAL_KEY;
|
||||
shellCB->shellKeyType = STAT_NORMAL_KEY;
|
||||
}
|
||||
|
||||
void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB)
|
||||
@@ -254,7 +273,7 @@ void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB)
|
||||
const char ch = c;
|
||||
int ret;
|
||||
|
||||
if ((shellCB->shellBufOffset == 0) && (ch != '\n') && (ch != '\0')) {
|
||||
if ((shellCB->shellBufOffset == 0) && (ch != '\n') && (ch != CHAR_CTRL_C) && (ch != '\0')) {
|
||||
(void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN);
|
||||
}
|
||||
|
||||
@@ -263,8 +282,11 @@ void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB)
|
||||
case '\n': /* enter */
|
||||
ParseEnterKey(outputFunc, shellCB);
|
||||
break;
|
||||
case CHAR_CTRL_C: /* ctrl + c */
|
||||
ParseCancelKey(outputFunc, shellCB);
|
||||
break;
|
||||
case '\b': /* backspace */
|
||||
case 0x7F: /* delete(0x7F) */
|
||||
case CHAR_CTRL_DEL: /* delete(0x7F) */
|
||||
ParseDeleteKey(outputFunc, shellCB);
|
||||
break;
|
||||
case '\t': /* tab */
|
||||
@@ -329,34 +351,82 @@ char *GetCmdName(const char *cmdline, unsigned int len)
|
||||
return cmdName;
|
||||
}
|
||||
|
||||
void ChildExec(const char *cmdName, char *const paramArray[])
|
||||
{
|
||||
int ret;
|
||||
pid_t gid;
|
||||
|
||||
ret = setpgrp();
|
||||
if (ret == -1) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
gid = getpgrp();
|
||||
if (gid < 0) {
|
||||
printf("get group id failed, pgrpid %d, errno %d\n", gid, errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = tcsetpgrp(STDIN_FILENO, gid);
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = execve(cmdName, paramArray, NULL);
|
||||
if (ret == -1) {
|
||||
perror("execve");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int CheckExit(const char *cmdName, const CmdParsed *cmdParsed)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (strlen(cmdName) != CMD_EXIT_COMMAND_BYTES || strncmp(cmdName, CMD_EXIT_COMMAND, CMD_EXIT_COMMAND_BYTES) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cmdParsed->paramCnt > 1) {
|
||||
printf("exit: too many arguments\n");
|
||||
return -1;
|
||||
}
|
||||
if (cmdParsed->paramCnt == 1) {
|
||||
char *p = NULL;
|
||||
ret = strtol(cmdParsed->paramArray[0], &p, CMD_EXIT_CODE_BASE_DEC);
|
||||
if (*p != '\0') {
|
||||
printf("exit: bad number: %s\n", cmdParsed->paramArray[0]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, const CmdParsed *cmdParsed)
|
||||
{
|
||||
int ret;
|
||||
pid_t forkPid;
|
||||
|
||||
if (strncmp(cmdline, SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
|
||||
if (strncmp(cmdline, CMD_EXEC_COMMAND, CMD_EXEC_COMMAND_BYTES) == 0) {
|
||||
forkPid = fork();
|
||||
if (forkPid < 0) {
|
||||
printf("Faild to fork from shell\n");
|
||||
return;
|
||||
} else if (forkPid == 0) {
|
||||
ret = setpgrp();
|
||||
if (ret == -1) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = tcsetpgrp(STDIN_FILENO, getpgrp());
|
||||
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray);
|
||||
} else {
|
||||
waitpid(forkPid, 0, 0);
|
||||
ret = tcsetpgrp(STDIN_FILENO, getpid());
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, pgrpid %d, errno %d\n", getpgrp(), errno);
|
||||
}
|
||||
|
||||
ret = execve((const char *)cmdParsed->paramArray[0], (char * const *)cmdParsed->paramArray, NULL);
|
||||
if (ret == -1) {
|
||||
perror("execve");
|
||||
exit(-1);
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (CheckExit(cmdName, cmdParsed) < 0) {
|
||||
return;
|
||||
}
|
||||
(void)syscall(__NR_shellexec, cmdName, cmdline);
|
||||
}
|
||||
}
|
||||
@@ -391,7 +461,7 @@ static void ParseAndExecCmdline(CmdParsed *cmdParsed, const char *cmdline, unsig
|
||||
DoCmdExec(cmdName, cmdlineOrigin, len, cmdParsed);
|
||||
|
||||
if (getcwd(shellWorkingDirectory, PATH_MAX) != NULL) {
|
||||
(void)OsShellSetWorkingDirtectory(shellWorkingDirectory, (PATH_MAX + 1));
|
||||
(void)OsShellSetWorkingDirectory(shellWorkingDirectory, (PATH_MAX + 1));
|
||||
}
|
||||
|
||||
OUT:
|
||||
@@ -411,7 +481,7 @@ unsigned int PreHandleCmdline(const char *input, char **output, unsigned int *ou
|
||||
unsigned int removeLen = strlen("./"); /* "./" needs to be removed if it exists */
|
||||
unsigned int ret;
|
||||
char *newCmd = NULL;
|
||||
char *execCmd = SHELL_EXEC_COMMAND;
|
||||
char *execCmd = CMD_EXEC_COMMAND;
|
||||
const char *cmdBuf = input;
|
||||
unsigned int cmdBufLen = strlen(cmdBuf);
|
||||
char *shiftStr = (char *)malloc(cmdBufLen + 1);
|
||||
@@ -514,7 +584,11 @@ static void ShellCmdProcess(ShellCB *shellCB)
|
||||
if (buf == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (buf[0] == CHAR_CTRL_C) {
|
||||
printf("^C");
|
||||
buf[0] = '\n';
|
||||
}
|
||||
printf("\n");
|
||||
ExecCmdline(buf);
|
||||
ShellSaveHistoryCmd(buf, shellCB);
|
||||
shellCB->cmdMaskKeyLink = shellCB->cmdHistoryKeyLink;
|
||||
|
||||
41
apps/tftp/BUILD.gn
Normal file
41
apps/tftp/BUILD.gn
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("tftp") {
|
||||
sources = [
|
||||
"src/main.c",
|
||||
"src/tftpc.c",
|
||||
]
|
||||
|
||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -27,51 +27,19 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ROOT_DIR := $(dir $(shell pwd))/tftp/
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(ROOT_DIR)/../config.mk
|
||||
APPS_OUT := $(OUT)/bin
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||
|
||||
LOCAL_SRCS = $(wildcard src/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncpy_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memcpy_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memset_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncat_s.c)
|
||||
LOCAL_OBJ := $(LOCAL_SRCS:.c=.o)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(ROOT_DIR)/include/ \
|
||||
-I $(SECUREC_DIR)/include/\
|
||||
-I include \
|
||||
-I $(SECUREC_DIR)/include
|
||||
|
||||
LOCAL_FLAGS += $(CFLAGS)
|
||||
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||
|
||||
LDPATH := -L$(ROOT_DIR)/
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
TARGETNAME := tftp
|
||||
|
||||
all: $(TARGETNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(TARGETNAME): $(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(TARGETNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(TARGETNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(TARGETNAME)
|
||||
|
||||
.PHONY: all $(TARGETNAME) clean
|
||||
include $(APP)
|
||||
|
||||
83
apps/toybox/BUILD.gn
Normal file
83
apps/toybox/BUILD.gn
Normal file
@@ -0,0 +1,83 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("toybox") {
|
||||
deps = [ ":build_toybox" ]
|
||||
}
|
||||
|
||||
copy("copy_toybox_src") {
|
||||
sources = [ "$LITEOSTHIRDPARTY/toybox" ]
|
||||
outputs = [ "$target_out_dir/toybox_build" ]
|
||||
}
|
||||
|
||||
copy("copy_toybox_config") {
|
||||
deps = [ ":copy_toybox_src" ]
|
||||
sources = [ "liteos_a_custom.config" ]
|
||||
outputs = [ "$target_out_dir/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_toybox") {
|
||||
deps = [
|
||||
":copy_toybox_config",
|
||||
":copy_toybox_src",
|
||||
]
|
||||
deps += [ "//prebuilts/lite/sysroot" ]
|
||||
exec_path = rebase_path("$target_out_dir/toybox_build")
|
||||
|
||||
cflags = [
|
||||
"-fstack-protector-strong",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
]
|
||||
cflags = string_join(" ", cflags)
|
||||
|
||||
extra_flags = string_join(" ", target_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
extra_flags += " --target=$target_triple"
|
||||
extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot)
|
||||
}
|
||||
|
||||
command = "rm -rf .git && cp -rfp porting/liteos_a/. . && env"
|
||||
command += " CC=\"$ohos_current_cc_command\""
|
||||
command += " STRIP=\"$ohos_current_strip_command\""
|
||||
command += " OUTNAME=toybox"
|
||||
command += " CFLAGS=\"$cflags $extra_flags\""
|
||||
command += " make toybox"
|
||||
command += " && install -D toybox "
|
||||
command += rebase_path("$root_out_dir/bin/toybox", exec_path)
|
||||
command += " && install -D generated/unstripped/toybox "
|
||||
command += rebase_path("$root_out_dir/unstripped/bin/toybox", exec_path)
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/unstripped/bin/toybox",
|
||||
"$root_out_dir/bin/toybox",
|
||||
]
|
||||
}
|
||||
@@ -27,33 +27,27 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
TOYBOX:= toybox
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
TOYBOX_DIR := $(shell pwd)
|
||||
LITEOSTOPDIR = $(TOYBOX_DIR)/../../
|
||||
include $(TOYBOX_DIR)/../config.mk
|
||||
BUILD_DIR := $(OUT)/toybox_build
|
||||
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
BUILD_DIR := $(TOYBOX_DIR)/build
|
||||
BUILD_LOG := $(TOYBOX_DIR)/build.log
|
||||
OUTNAME := $(TOYBOX)
|
||||
CFLAGS += -Wno-error
|
||||
|
||||
$(TOYBOX):
|
||||
all:
|
||||
ifneq ($(wildcard $(BUILD_DIR)),)
|
||||
$(HIDE)echo "not clean, rebuilding now";
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
else
|
||||
$(HIDE)mkdir $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/porting/liteos_a/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) liteos_a_custom.config $(BUILD_DIR)/../
|
||||
endif
|
||||
$(HIDE)CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong --target=arm-liteos \
|
||||
--sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/" CC="$(CC)" OUTNAME=$(OUTNAME) \
|
||||
$(HIDE)unset KCONFIG_CONFIG CROSS_COMPILE && \
|
||||
env CC="$(CC)" OUTNAME="$(OUT)/bin/toybox" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
|
||||
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
|
||||
$(HIDE)$(CP) $(BUILD_DIR)/$(TOYBOX) .
|
||||
$(HIDE)$(STRIP) $(TOYBOX)
|
||||
$(HIDE)mkdir -p $(APPS_OUT)
|
||||
$(HIDE)$(CP) $(TOYBOX) $(APPS_OUT)
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(TOYBOX) $(BUILD_DIR) $(BUILD_LOG)
|
||||
$(HIDE)$(RM) $(BUILD_DIR)
|
||||
|
||||
.PHONY: all $(TOYBOX) clean
|
||||
.PHONY: all clean
|
||||
|
||||
186
apps/toybox/liteos_a_custom.config
Normal file
186
apps/toybox/liteos_a_custom.config
Normal file
@@ -0,0 +1,186 @@
|
||||
# CONFIG_BASENAME is not set
|
||||
# CONFIG_CAL is not set
|
||||
# CONFIG_CAT is not set
|
||||
# CONFIG_CATV is not set
|
||||
# CONFIG_CKSUM is not set
|
||||
# CONFIG_CRC32 is not set
|
||||
# CONFIG_CMP is not set
|
||||
# CONFIG_COMM is not set
|
||||
# CONFIG_CP_PRESERVE is not set
|
||||
# CONFIG_INSTALL is not set
|
||||
# CONFIG_CPIO is not set
|
||||
# CONFIG_CUT is not set
|
||||
# CONFIG_DF is not set
|
||||
# CONFIG_DIRNAME is not set
|
||||
# CONFIG_ECHO is not set
|
||||
# CONFIG_ENV is not set
|
||||
# CONFIG_EXPAND is not set
|
||||
# CONFIG_FALSE is not set
|
||||
# CONFIG_FILE is not set
|
||||
# CONFIG_FIND is not set
|
||||
# CONFIG_GETCONF is not set
|
||||
# CONFIG_GREP is not set
|
||||
# CONFIG_EGREP is not set
|
||||
# CONFIG_FGREP is not set
|
||||
# CONFIG_HEAD is not set
|
||||
# CONFIG_ICONV is not set
|
||||
# CONFIG_ID is not set
|
||||
# CONFIG_GROUPS is not set
|
||||
# CONFIG_LOGNAME is not set
|
||||
# CONFIG_WHOAMI is not set
|
||||
# CONFIG_LINK is not set
|
||||
# CONFIG_LN is not set
|
||||
# CONFIG_LOGGER is not set
|
||||
# CONFIG_MKFIFO is not set
|
||||
# CONFIG_NICE is not set
|
||||
# CONFIG_NL is not set
|
||||
# CONFIG_NOHUP is not set
|
||||
# CONFIG_OD is not set
|
||||
# CONFIG_PASTE is not set
|
||||
# CONFIG_PATCH is not set
|
||||
# CONFIG_PRINTF is not set
|
||||
# CONFIG_IOTOP is not set
|
||||
# CONFIG_PGREP is not set
|
||||
# CONFIG_PKILL is not set
|
||||
# CONFIG_PWD is not set
|
||||
# CONFIG_RENICE is not set
|
||||
# CONFIG_SED is not set
|
||||
# CONFIG_SLEEP is not set
|
||||
# CONFIG_SORT is not set
|
||||
# CONFIG_SORT_FLOAT is not set
|
||||
# CONFIG_SPLIT is not set
|
||||
# CONFIG_STRINGS is not set
|
||||
# CONFIG_TAIL is not set
|
||||
# CONFIG_TAR is not set
|
||||
# CONFIG_TEE is not set
|
||||
# CONFIG_TEST is not set
|
||||
# CONFIG_TIME is not set
|
||||
# CONFIG_TRUE is not set
|
||||
# CONFIG_TTY is not set
|
||||
# CONFIG_ULIMIT is not set
|
||||
# CONFIG_ARCH is not set
|
||||
# CONFIG_UNIQ is not set
|
||||
# CONFIG_UNLINK is not set
|
||||
# CONFIG_UUDECODE is not set
|
||||
# CONFIG_UUENCODE is not set
|
||||
# CONFIG_WC is not set
|
||||
# CONFIG_WHO is not set
|
||||
# CONFIG_XARGS is not set
|
||||
# CONFIG_ACPI is not set
|
||||
# CONFIG_ASCII is not set
|
||||
# CONFIG_BASE64 is not set
|
||||
# CONFIG_BLKID is not set
|
||||
# CONFIG_FSTYPE is not set
|
||||
# CONFIG_BLOCKDEV is not set
|
||||
# CONFIG_BUNZIP2 is not set
|
||||
# CONFIG_BZCAT is not set
|
||||
# CONFIG_CHROOT is not set
|
||||
# CONFIG_CHRT is not set
|
||||
# CONFIG_CHVT is not set
|
||||
# CONFIG_CLEAR is not set
|
||||
# CONFIG_COUNT is not set
|
||||
# CONFIG_DEVMEM is not set
|
||||
# CONFIG_DOS2UNIX is not set
|
||||
# CONFIG_UNIX2DOS is not set
|
||||
# CONFIG_EJECT is not set
|
||||
# CONFIG_FACTOR is not set
|
||||
# CONFIG_FALLOCATE is not set
|
||||
# CONFIG_FLOCK is not set
|
||||
# CONFIG_FMT is not set
|
||||
# CONFIG_FREERAMDISK is not set
|
||||
# CONFIG_FSFREEZE is not set
|
||||
# CONFIG_FSYNC is not set
|
||||
# CONFIG_HELP_EXTRAS is not set
|
||||
# CONFIG_HEXEDIT is not set
|
||||
# CONFIG_HWCLOCK is not set
|
||||
# CONFIG_I2CDETECT is not set
|
||||
# CONFIG_I2CDUMP is not set
|
||||
# CONFIG_I2CGET is not set
|
||||
# CONFIG_I2CSET is not set
|
||||
# CONFIG_INOTIFYD is not set
|
||||
# CONFIG_INSMOD is not set
|
||||
# CONFIG_IONICE is not set
|
||||
# CONFIG_IORENICE is not set
|
||||
# CONFIG_LOGIN is not set
|
||||
# CONFIG_LOSETUP is not set
|
||||
# CONFIG_LSATTR is not set
|
||||
# CONFIG_CHATTR is not set
|
||||
# CONFIG_LSMOD is not set
|
||||
# CONFIG_LSPCI is not set
|
||||
# CONFIG_LSPCI_TEXT is not set
|
||||
# CONFIG_LSUSB is not set
|
||||
# CONFIG_MAKEDEVS is not set
|
||||
# CONFIG_MCOOKIE is not set
|
||||
# CONFIG_MIX is not set
|
||||
# CONFIG_MKPASSWD is not set
|
||||
# CONFIG_MKSWAP is not set
|
||||
# CONFIG_MODINFO is not set
|
||||
# CONFIG_MOUNTPOINT is not set
|
||||
# CONFIG_NBD_CLIENT is not set
|
||||
# CONFIG_UNSHARE is not set
|
||||
# CONFIG_NSENTER is not set
|
||||
# CONFIG_ONEIT is not set
|
||||
# CONFIG_PARTPROBE is not set
|
||||
# CONFIG_PIVOT_ROOT is not set
|
||||
# CONFIG_PMAP is not set
|
||||
# CONFIG_PRINTENV is not set
|
||||
# CONFIG_PWDX is not set
|
||||
# CONFIG_READAHEAD is not set
|
||||
# CONFIG_READLINK is not set
|
||||
# CONFIG_REALPATH is not set
|
||||
# CONFIG_RESET is not set
|
||||
# CONFIG_REV is not set
|
||||
# CONFIG_RMMOD is not set
|
||||
# CONFIG_SETFATTR is not set
|
||||
# CONFIG_SETSID is not set
|
||||
# CONFIG_SHRED is not set
|
||||
# CONFIG_STAT is not set
|
||||
# CONFIG_SWAPOFF is not set
|
||||
# CONFIG_SWAPON is not set
|
||||
# CONFIG_SWITCH_ROOT is not set
|
||||
# CONFIG_SYSCTL is not set
|
||||
# CONFIG_TAC is not set
|
||||
# CONFIG_NPROC is not set
|
||||
# CONFIG_TASKSET is not set
|
||||
# CONFIG_TIMEOUT is not set
|
||||
# CONFIG_TRUNCATE is not set
|
||||
# CONFIG_UPTIME is not set
|
||||
# CONFIG_USLEEP is not set
|
||||
# CONFIG_UUIDGEN is not set
|
||||
# CONFIG_VCONFIG is not set
|
||||
# CONFIG_VMSTAT is not set
|
||||
# CONFIG_W is not set
|
||||
# CONFIG_WATCH is not set
|
||||
# CONFIG_WHICH is not set
|
||||
# CONFIG_XXD is not set
|
||||
# CONFIG_YES is not set
|
||||
# CONFIG_FTPGET is not set
|
||||
# CONFIG_FTPPUT is not set
|
||||
# CONFIG_MICROCOM is not set
|
||||
# CONFIG_NETCAT is not set
|
||||
# CONFIG_NETCAT_LISTEN is not set
|
||||
# CONFIG_NETSTAT is not set
|
||||
# CONFIG_RFKILL is not set
|
||||
# CONFIG_SNTP is not set
|
||||
# CONFIG_TUNCTL is not set
|
||||
# CONFIG_DMESG is not set
|
||||
# CONFIG_GUNZIP is not set
|
||||
# CONFIG_ZCAT is not set
|
||||
# CONFIG_HOSTNAME is not set
|
||||
# CONFIG_DNSDOMAINNAME is not set
|
||||
# CONFIG_KILLALL is not set
|
||||
# CONFIG_MD5SUM is not set
|
||||
# CONFIG_SHA1SUM is not set
|
||||
# CONFIG_MKNOD is not set
|
||||
# CONFIG_MKTEMP is not set
|
||||
# CONFIG_PASSWD is not set
|
||||
# CONFIG_PIDOF is not set
|
||||
# CONFIG_SEQ is not set
|
||||
# CONFIG_SU is not set
|
||||
# CONFIG_SYNC is not set
|
||||
#
|
||||
# pending (see toys/pending/README)
|
||||
#
|
||||
# CONFIG_GETTY is not set
|
||||
# CONFIG_MDEV is not set
|
||||
# CONFIG_MDEV_CONF is not set
|
||||
@@ -27,8 +27,8 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
DYNLOADTESTDIR := $(LITEOSTOPDIR)/test/kernel/sample/kernel_extend/dynload
|
||||
export DYNLOADTESTDIR
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
##### command to test dynload #####
|
||||
-include $(DYNLOADTESTDIR)/test_dynload.mk
|
||||
executable("trace") {
|
||||
sources = [ "src/trace.c" ]
|
||||
}
|
||||
36
apps/trace/Makefile
Normal file
36
apps/trace/Makefile
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := src/trace.c
|
||||
|
||||
include $(APP)
|
||||
137
apps/trace/src/trace.c
Normal file
137
apps/trace/src/trace.c
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define TRACE_IOC_MAGIC 'T'
|
||||
#define TRACE_START _IO(TRACE_IOC_MAGIC, 1)
|
||||
#define TRACE_STOP _IO(TRACE_IOC_MAGIC, 2)
|
||||
#define TRACE_RESET _IO(TRACE_IOC_MAGIC, 3)
|
||||
#define TRACE_DUMP _IO(TRACE_IOC_MAGIC, 4)
|
||||
#define TRACE_SET_MASK _IO(TRACE_IOC_MAGIC, 5)
|
||||
|
||||
#define TRACE_USR_MAX_PARAMS 3
|
||||
typedef struct {
|
||||
unsigned int eventType;
|
||||
uintptr_t identity;
|
||||
uintptr_t params[TRACE_USR_MAX_PARAMS];
|
||||
} UsrEventInfo;
|
||||
|
||||
static void TraceUsage(void)
|
||||
{
|
||||
printf("\nUsage: ./trace [start] Start to trace events.\n");
|
||||
printf("\nUsage: ./trace [stop] Stop trace.\n");
|
||||
printf("\nUsage: ./trace [reset] Clear the trace record buffer.\n");
|
||||
printf("\nUsage: ./trace [dump 0/1] Format printf trace data,"
|
||||
"0/1 stands for whether to send data to studio for analysis.\n");
|
||||
printf("\nUsage: ./trace [mask num] Set trace filter event mask.\n");
|
||||
printf("\nUsage: ./trace [read nBytes] Read nBytes raw data from trace buffer.\n");
|
||||
printf("\nUsage: ./trace [write type id params..] Write a user event, no more than 3 parameters.\n");
|
||||
}
|
||||
|
||||
static void TraceRead(int fd, size_t size)
|
||||
{
|
||||
ssize_t i;
|
||||
ssize_t len;
|
||||
char *buffer = (char *)malloc(size);
|
||||
if (buffer == NULL) {
|
||||
printf("Read buffer malloc failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
len = read(fd, buffer, size);
|
||||
for (i = 0; i < len; i++) {
|
||||
printf("%02x ", buffer[i] & 0xFF);
|
||||
}
|
||||
printf("\n");
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static void TraceWrite(int fd, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
UsrEventInfo info = {0};
|
||||
info.eventType = strtoul(argv[2], NULL, 0); /* 2, argv number */
|
||||
info.identity = strtoul(argv[3], NULL, 0); /* 3, argv number */
|
||||
/* 4, argc -4 means user argv that does not contain argv[0]~argv[3] */
|
||||
int paramNum = (argc - 4) > TRACE_USR_MAX_PARAMS ? TRACE_USR_MAX_PARAMS : (argc - 4);
|
||||
|
||||
for (i = 0; i < paramNum; i++) {
|
||||
/* 4, argc -4 means user argv that does not contain argv[0]~argv[3] */
|
||||
info.params[i] = strtoul(argv[4 + i], NULL, 0);
|
||||
}
|
||||
(void)write(fd, &info, sizeof(UsrEventInfo));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd = open("/dev/trace", O_RDWR);
|
||||
if (fd == -1) {
|
||||
printf("Trace open failed.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
TraceUsage();
|
||||
} else if (argc == 2 && strcmp(argv[1], "start") == 0) { /* 2, argv num, no special meaning */
|
||||
ioctl(fd, TRACE_START, NULL);
|
||||
} else if (argc == 2 && strcmp(argv[1], "stop") == 0) { /* 2, argv num, no special meaning */
|
||||
ioctl(fd, TRACE_STOP, NULL);
|
||||
} else if (argc == 2 && strcmp(argv[1], "reset") == 0) { /* 2, argv num, no special meaning */
|
||||
ioctl(fd, TRACE_RESET, NULL);
|
||||
} else if (argc == 3 && strcmp(argv[1], "mask") == 0) { /* 3, argv num, no special meaning */
|
||||
size_t mask = strtoul(argv[2], NULL, 0);
|
||||
ioctl(fd, TRACE_SET_MASK, mask);
|
||||
} else if (argc == 3 && strcmp(argv[1], "dump") == 0) { /* 3, argv num, no special meaning */
|
||||
size_t flag = strtoul(argv[2], NULL, 0);
|
||||
ioctl(fd, TRACE_DUMP, flag);
|
||||
} else if (argc == 3 && strcmp(argv[1], "read") == 0) { /* 3, argv num, no special meaning */
|
||||
size_t size = strtoul(argv[2], NULL, 0);
|
||||
TraceRead(fd, size);
|
||||
} else if (argc >= 4 && strcmp(argv[1], "write") == 0) { /* 4, argv num, no special meaning */
|
||||
TraceWrite(fd, argc, argv);
|
||||
} else {
|
||||
printf("Unsupported trace command.\n");
|
||||
TraceUsage();
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
44
arch/BUILD.gn
Normal file
44
arch/BUILD.gn
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("arch") {
|
||||
deps = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
deps += [ "arm" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("public") {
|
||||
configs = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
configs += [ "arm:public" ]
|
||||
}
|
||||
}
|
||||
40
arch/arm/BUILD.gn
Normal file
40
arch/arm/BUILD.gn
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("arm") {
|
||||
deps = [ "gic" ]
|
||||
deps += [ ARCH ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
configs = [ "$ARCH:public" ]
|
||||
}
|
||||
@@ -36,15 +36,15 @@ LOSCFG_ARCH_FPU_STRIP := $(subst $\",,$(LOSCFG_ARCH_FPU))
|
||||
LOSCFG_ARCH_FPU = $(LOSCFG_ARCH_FPU_STRIP)
|
||||
|
||||
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
|
||||
LITEOS_ARCH_ARM := arm
|
||||
ARCH := arm
|
||||
else ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y)
|
||||
LITEOS_ARCH_ARM :=
|
||||
ARCH := aarch64
|
||||
endif
|
||||
|
||||
LITEOS_BASELIB += -l$(LOSCFG_ARCH_CPU)
|
||||
LITEOS_BASELIB += -lgic
|
||||
|
||||
LIB_SUBDIRS += arch/arm/$(LITEOS_ARCH_ARM)
|
||||
LIB_SUBDIRS += arch/arm/$(ARCH)
|
||||
LIB_SUBDIRS += arch/arm/gic
|
||||
|
||||
# CPU compile options
|
||||
@@ -65,38 +65,12 @@ LITEOS_FPU_OPTS := -mfpu=$(LOSCFG_ARCH_FPU)
|
||||
LITEOS_GCCLIB := $(subst cortex-,,$(LOSCFG_ARCH_CPU))_softfp_$(LOSCFG_ARCH_FPU)
|
||||
endif
|
||||
|
||||
LITEOS_CORE_COPTS = $(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS)
|
||||
LITEOS_INTERWORK += $(LITEOS_CORE_COPTS)
|
||||
LITEOS_NODEBUG += $(LITEOS_CORE_COPTS)
|
||||
LITEOS_CORE_COPTS = $(or $(ARCH_CFLAGS),$(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS))
|
||||
LITEOS_ASOPTS += $(LITEOS_CPU_OPTS)
|
||||
LITEOS_CXXOPTS_BASE += $(LITEOS_CORE_COPTS)
|
||||
|
||||
ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/src/include
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include
|
||||
|
||||
LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE)
|
||||
LITEOS_CXXINCLUDE += $(ARCH_INCLUDE)
|
||||
|
||||
# expose FPU info to assembly code
|
||||
ifeq ($(LOSCFG_ARCH_FPU_DISABLE), y)
|
||||
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_DISABLE
|
||||
else ifeq ($(LOSCFG_ARCH_FPU_VFP_D16), y)
|
||||
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D16
|
||||
else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y)
|
||||
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D32
|
||||
endif
|
||||
|
||||
# extra definition for other module
|
||||
LITEOS_CPU_TYPE = $(LOSCFG_ARCH_CPU)
|
||||
LITEOS_ARM_ARCH := -march=$(subst $\",,$(LOSCFG_ARCH_ARM_VER))
|
||||
|
||||
# linux style macros
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7A) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7R) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7M) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8A) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8R) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8M) = -D__LINUX_ARM_ARCH__=8
|
||||
|
||||
AS_OBJS_LIBC_FLAGS += $(LINUX_ARCH_y)
|
||||
|
||||
@@ -27,34 +27,70 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
############### this is a makefile that you can config it ###############
|
||||
-include $(LITEOSTOPDIR)/tools/build/mk/los_config.mk
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
TOP_LD_PATH = $(LITEOSTOPDIR)
|
||||
SCRIPTS_PATH = $(LITEOS_SCRIPTPATH)
|
||||
LITEOS_MK_PATH = $(MK_PATH)
|
||||
LITEOS_SUBDIRS = $(LIB_SUBDIRS)
|
||||
LIB_BIGODIR = $(LITEOS_LIB_BIGODIR)
|
||||
module_name = LOSCFG_ARCH_CPU
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/arm_generic_timer.c",
|
||||
"src/clear_user.S",
|
||||
"src/hw_user_get.S",
|
||||
"src/hw_user_put.S",
|
||||
"src/jmp.S",
|
||||
"src/los_arch_mmu.c",
|
||||
"src/los_asid.c",
|
||||
"src/los_dispatch.S",
|
||||
"src/los_exc.c",
|
||||
"src/los_hw.c",
|
||||
"src/los_hw_exc.S",
|
||||
"src/los_hw_runstop.S",
|
||||
"src/los_hw_tick.c",
|
||||
"src/los_hwi.c",
|
||||
"src/smp.c",
|
||||
"src/strncpy_from_user.c",
|
||||
"src/strnlen_user.c",
|
||||
"src/user_copy.c",
|
||||
]
|
||||
|
||||
##### liteos tables -u ldflags #####
|
||||
-include $(LITEOS_MK_PATH)/liteos_tables_ldflags.mk
|
||||
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
|
||||
sources += [ "src/armv7a/cache.S" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_KERNEL_SMP)) {
|
||||
sources += [ "src/startup/reset_vector_mp.S" ]
|
||||
} else {
|
||||
sources += [ "src/startup/reset_vector_up.S" ]
|
||||
}
|
||||
|
||||
LITEOS_COPTS := $(LITEOS_COPTS_DEBUG) $(LITEOS_COPTS_BASE) \
|
||||
$(LITEOS_COPTS_EXTRA) $(LITEOS_CORE_COPTS)
|
||||
LITEOS_CXXOPTS := $(LITEOS_CXXOPTS_BASE)
|
||||
LITEOS_INCLUDE := $(LITEOS_KERNEL_INCLUDE) $(LITEOS_EXTKERNEL_INCLUDE) \
|
||||
$(LITEOS_COMPAT_INCLUDE) $(LITEOS_FS_INCLUDE) \
|
||||
$(LITEOS_NET_INCLUDE) $(LITEOS_LIB_INCLUDE) \
|
||||
$(LITEOS_DRIVERS_INCLUDE) $(LOSCFG_TOOLS_DEBUG_INCLUDE) \
|
||||
$(LITEOS_PLATFORM_INCLUDE)
|
||||
LITEOS_LIBDEP := $(LITEOS_BASELIB)
|
||||
LITEOS_ASFLAGS := $(LITEOS_ASOPTS) $(LITEOS_INCLUDE)
|
||||
LITEOS_CFLAGS := $(LITEOS_COPTS) $(LITEOS_CMACRO) \
|
||||
$(LITEOS_CMACRO_TEST) $(LITEOS_IMAGE_MACRO) \
|
||||
$(LITEOS_INCLUDE)
|
||||
LITEOS_CXXFLAGS := $(LITEOS_CXXOPTS) $(LITEOS_CXXMACRO) \
|
||||
$(LITEOS_CMACRO) $(LITEOS_CXXINCLUDE)
|
||||
LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \
|
||||
$(LITEOS_LD_SCRIPT)
|
||||
include_dirs = [ "src/include" ]
|
||||
|
||||
if (defined(LOSCFG_PERF_HW_PMU)) {
|
||||
sources += [ "src/pmu/armv7_pmu.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_GDB)) {
|
||||
configs += [ ":as_objs_libc_flags" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"src/include",
|
||||
]
|
||||
}
|
||||
|
||||
config("as_objs_libc_flags") {
|
||||
defines = [ "__ASSEMBLY__" ]
|
||||
|
||||
# linux style macros
|
||||
if (defined(LOSCFG_ARCH_ARM_V7A) || defined(LOSCFG_ARCH_ARM_V7R) ||
|
||||
defined(LOSCFG_ARCH_ARM_V7M)) {
|
||||
defines += [ "__LINUX_ARM_ARCH__=7" ]
|
||||
} else if (defined(LOSCFG_ARCH_ARM_V8A) || defined(LOSCFG_ARCH_ARM_V8R) ||
|
||||
defined(LOSCFG_ARCH_ARM_V8M)) {
|
||||
defines += [ "__LINUX_ARM_ARCH__=8" ]
|
||||
}
|
||||
}
|
||||
@@ -32,13 +32,8 @@ include $(LITEOSTOPDIR)/config.mk
|
||||
MODULE_NAME := $(LOSCFG_ARCH_CPU)
|
||||
|
||||
LOCAL_SRCS := $(wildcard src/*.c) $(wildcard src/*.S)
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/base/include \
|
||||
-I $(LITEOSTOPDIR)/kernel/extended/include \
|
||||
-I $(LITEOSTOPDIR)/kernel/extended/dynload/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/arm/include \
|
||||
|
||||
ifeq ($(LITEOS_ARM_ARCH), -march=armv7-a)
|
||||
ifeq ($(LOSCFG_ARCH_ARM_VER), "armv7-a")
|
||||
LOCAL_SRCS += $(wildcard src/armv7a/*.S)
|
||||
endif
|
||||
|
||||
@@ -48,7 +43,21 @@ else
|
||||
LOCAL_SRCS += src/startup/reset_vector_up.S
|
||||
endif
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
ifeq ($(LOSCFG_PERF_HW_PMU), y)
|
||||
LOCAL_SRCS += src/pmu/armv7_pmu.c
|
||||
endif
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
||||
|
||||
AS_OBJS_LIBC_FLAGS = -D__ASSEMBLY__
|
||||
# linux style macros
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7A) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7R) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7M) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8A) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8R) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8M) = -D__LINUX_ARM_ARCH__=8
|
||||
AS_OBJS_LIBC_FLAGS += $(LINUX_ARCH_y)
|
||||
|
||||
ifeq ($(LOSCFG_GDB), y)
|
||||
LOCAL_FLAGS += $(AS_OBJS_LIBC_FLAGS)
|
||||
|
||||
50
arch/arm/arm/include/arm_user_clear.h
Normal file
50
arch/arm/arm/include/arm_user_clear.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#ifndef _ARM_USER_CLEAR_H
|
||||
#define _ARM_USER_CLEAR_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
size_t _arm_clear_user(void *addr, size_t bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _ARM_USER_CLEAR_H */
|
||||
@@ -38,7 +38,10 @@
|
||||
#define __LOS_ARCH_MMU_H__
|
||||
|
||||
#include "los_typedef.h"
|
||||
#include "los_mux.h"
|
||||
#include "los_vm_phys.h"
|
||||
#ifndef LOSCFG_PAGE_TABLE_FINE_LOCK
|
||||
#include "los_spinlock.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -47,7 +50,9 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct ArchMmu {
|
||||
LosMux mtx; /**< arch mmu page table entry modification mutex lock */
|
||||
#ifndef LOSCFG_PAGE_TABLE_FINE_LOCK
|
||||
SPIN_LOCK_S lock; /**< arch mmu page table entry modification spin lock */
|
||||
#endif
|
||||
VADDR_T *virtTtb; /**< translation table base virtual addr */
|
||||
PADDR_T physTtb; /**< translation table base phys addr */
|
||||
UINT32 asid; /**< TLB asid */
|
||||
@@ -71,5 +76,5 @@ VADDR_T *OsGFirstTableGet(VOID);
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __LOS_VM_PAGE_H__ */
|
||||
#endif /* __LOS_ARCH_MMU_H__ */
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ extern "C" {
|
||||
#define ISB __asm__ volatile("isb" ::: "memory")
|
||||
#define WFI __asm__ volatile("wfi" ::: "memory")
|
||||
#define BARRIER __asm__ volatile("":::"memory")
|
||||
#define WFE __asm__ volatile("wfe" ::: "memory")
|
||||
#define SEV __asm__ volatile("sev" ::: "memory")
|
||||
|
||||
#define ARM_SYSREG_READ(REG) \
|
||||
({ \
|
||||
@@ -145,7 +147,7 @@ STATIC INLINE VOID ArchCurrUserTaskSet(UINTPTR val)
|
||||
|
||||
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
return ARM_SYSREG_READ(MPIDR) & MPIDR_CPUID_MASK;
|
||||
#else
|
||||
return 0;
|
||||
|
||||
@@ -69,6 +69,11 @@ STATIC INLINE VOID OsClearPte1(PTE_T *pte1Ptr)
|
||||
OsSavePte1(pte1Ptr, 0);
|
||||
}
|
||||
|
||||
STATIC INLINE PADDR_T OsGetPte1Paddr(PADDR_T PhysTtb, vaddr_t va)
|
||||
{
|
||||
return (PhysTtb + (OsGetPte1Index(va) * sizeof(PADDR_T)));
|
||||
}
|
||||
|
||||
STATIC INLINE PTE_T *OsGetPte1Ptr(PTE_T *pte1BasePtr, vaddr_t va)
|
||||
{
|
||||
return (pte1BasePtr + OsGetPte1Index(va));
|
||||
|
||||
@@ -29,12 +29,10 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LOS_TRACE_PRI_H
|
||||
#define LOS_TRACE_PRI_H
|
||||
#ifndef _ARCH_SMP_H
|
||||
#define _ARCH_SMP_H
|
||||
|
||||
#include "los_trace.h"
|
||||
#include "los_spinlock.h"
|
||||
#include "los_seq_buf.h"
|
||||
#include "los_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -42,25 +40,13 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct {
|
||||
TraceSwitch onOff;
|
||||
WriteHook inputHook;
|
||||
const CHAR *typeStr;
|
||||
} TraceHook;
|
||||
struct SmpOps {
|
||||
INT32 (*SmpCpuOn)(UINT32 cpuNum, UINTPTR startEntry); /* The startEntry is physical addr. */
|
||||
};
|
||||
|
||||
/*
|
||||
* |1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0|
|
||||
* | |
|
||||
* readIndex writeIndex
|
||||
*/
|
||||
typedef VOID (*ArchCpuStartFunc)(VOID *arg);
|
||||
|
||||
typedef struct {
|
||||
UINT8 *dataBuf;
|
||||
UINT32 bufLen;
|
||||
TraceSwitch onOff;
|
||||
UINT32 writeIndex;
|
||||
UINT32 readIndex;
|
||||
} TraceBufferCtl;
|
||||
VOID HalArchCpuOn(UINT32 cpuNum, ArchCpuStartFunc func, struct SmpOps *ops, VOID *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -68,4 +54,5 @@ typedef struct {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LOS_TRACE_PRI_H */
|
||||
#endif /* _ARCH_SMP_H */
|
||||
|
||||
100
arch/arm/arm/src/clear_user.S
Normal file
100
arch/arm/arm/src/clear_user.S
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
.syntax unified
|
||||
.arm
|
||||
|
||||
// size_t _arm_clear_user(void *addr, size_t bytes)
|
||||
FUNCTION(_arm_clear_user)
|
||||
push {r0-r6, lr}
|
||||
cmp r1, #0
|
||||
beq .Lclear_user_return
|
||||
tst r0, #7
|
||||
beq .Lclear_user_aligned
|
||||
|
||||
.Lclear_user_byte:
|
||||
mov r2, #0
|
||||
0: strb r2, [r0], #1
|
||||
subs r1, r1, #1
|
||||
beq .Lclear_user_return
|
||||
tst r0, #7
|
||||
bne 0b
|
||||
|
||||
.Lclear_user_aligned:
|
||||
eor r3, r3
|
||||
eor r4, r4
|
||||
bics r2, r1, #15
|
||||
bne .Lclear_user_16bytes
|
||||
bics r2, r1, #7
|
||||
bne .Lclear_user_8bytes
|
||||
b .Lclear_user_remaining
|
||||
|
||||
.Lclear_user_16bytes:
|
||||
eor r5, r5
|
||||
eor r6, r6
|
||||
1: stmia r0!, {r3, r4, r5, r6}
|
||||
subs r2, r2, #16
|
||||
bne 1b
|
||||
ands r1, r1, #15
|
||||
beq .Lclear_user_return
|
||||
bics r2, r1, #7
|
||||
beq .Lclear_user_remaining
|
||||
|
||||
.Lclear_user_8bytes:
|
||||
2: stmia r0!, {r3, r4}
|
||||
ands r1, r1, #7
|
||||
beq .Lclear_user_return
|
||||
|
||||
.Lclear_user_remaining:
|
||||
mov r2, #0
|
||||
3: strb r2, [r0], #1
|
||||
subs r1, r1, #1
|
||||
bne 3b
|
||||
|
||||
.Lclear_user_return:
|
||||
pop {r0-r6, lr}
|
||||
mov r0, #0
|
||||
bx lr
|
||||
|
||||
.Lclear_user_err:
|
||||
pop {r0, r1}
|
||||
sub r0, r2, r0
|
||||
sub r0, r1, r0
|
||||
pop {r2-r6, lr}
|
||||
bx lr
|
||||
|
||||
.pushsection __exc_table, "a"
|
||||
.long 0b, .Lclear_user_err
|
||||
.long 1b, .Lclear_user_err
|
||||
.long 2b, .Lclear_user_err
|
||||
.long 3b, .Lclear_user_err
|
||||
.popsection
|
||||
108
arch/arm/arm/src/include/armv7_pmu_pri.h
Normal file
108
arch/arm/arm/src/include/armv7_pmu_pri.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#ifndef _ARMV7_PMU_PRI_H
|
||||
#define _ARMV7_PMU_PRI_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* counters overflow flag status reg */
|
||||
#define ARMV7_FLAG_MASK 0xffffffff /* Mask for writable bits */
|
||||
#define ARMV7_OVERFLOWED_MASK ARMV7_FLAG_MASK /* Mask for pmu overflowed */
|
||||
|
||||
/* pmnc config reg */
|
||||
#define ARMV7_PMNC_E (1U << 0) /* Enable all counters */
|
||||
#define ARMV7_PMNC_P (1U << 1) /* Reset all counters */
|
||||
#define ARMV7_PMNC_C (1U << 2) /* Cycle counter reset */
|
||||
#define ARMV7_PMNC_D (1U << 3) /* CCNT counts every 64th cpu cycle */
|
||||
#define ARMV7_PMNC_X (1U << 4) /* Export to ETM */
|
||||
#define ARMV7_PMNC_DP (1U << 5) /* Disable CCNT if non-invasive debug */
|
||||
#define ARMV7_PMNC_MASK 0x3f /* Mask for writable bits */
|
||||
|
||||
/* pmxevtyper event selection reg */
|
||||
#define ARMV7_EVTYPE_MASK 0xc80000ff /* Mask for writable bits */
|
||||
|
||||
/* armv7 counters index */
|
||||
#define ARMV7_IDX_COUNTER0 1
|
||||
#define ARMV7_IDX_CYCLE_COUNTER 0
|
||||
#define ARMV7_IDX_MAX_COUNTER 9
|
||||
|
||||
#define ARMV7_MAX_COUNTERS 32
|
||||
#define ARMV7_IDX_COUNTER_LAST (ARMV7_IDX_CYCLE_COUNTER + ARMV7_MAX_COUNTERS - 1)
|
||||
#define ARMV7_COUNTER_MASK (ARMV7_MAX_COUNTERS - 1)
|
||||
|
||||
/* armv7 event counter index mapping */
|
||||
#define ARMV7_CNT2BIT(x) (1UL << (x))
|
||||
#define ARMV7_IDX2CNT(x) (((x) - ARMV7_IDX_COUNTER0) & ARMV7_COUNTER_MASK)
|
||||
|
||||
enum PmuEventType {
|
||||
ARMV7_PERF_HW_CYCLES = 0xFF, /* cycles */
|
||||
ARMV7_PERF_HW_INSTRUCTIONS = 0x08, /* instructions */
|
||||
ARMV7_PERF_HW_DCACHES = 0x04, /* dcache */
|
||||
ARMV7_PERF_HW_DCACHE_MISSES = 0x03, /* dcache-misses */
|
||||
ARMV7_PERF_HW_ICACHES = 0x14, /* icache */
|
||||
ARMV7_PERF_HW_ICACHE_MISSES = 0x01, /* icache-misses */
|
||||
ARMV7_PERF_HW_BRANCHES = 0x0C, /* software change of pc */
|
||||
ARMV7_PERF_HW_BRANCE_MISSES = 0x10, /* branch-misses */
|
||||
ARMV7_PERF_HW_PRED_BRANCH = 0x12, /* predictable branches */
|
||||
ARMV7_PERF_HW_NUM_CYC_IRQ = 0x50, /* number of cycles Irqs are interrupted */
|
||||
ARMV7_PERF_HW_EXC_TAKEN = 0x09, /* exception_taken */
|
||||
ARMV7_PERF_HW_DATA_READ = 0x06, /* data read */
|
||||
ARMV7_PERF_HW_DATA_WRITE = 0x07, /* data write */
|
||||
ARMV7_PERF_HW_STREX_PASSED = 0x80, /* strex passed */
|
||||
ARMV7_PERF_HW_STREX_FAILED = 0x81, /* strex failed */
|
||||
ARMV7_PERF_HW_LP_IN_TCM = 0x82, /* literal pool in TCM region */
|
||||
ARMV7_PERF_HW_DMB_STALL = 0x90, /* DMB stall */
|
||||
ARMV7_PERF_HW_ITCM_ACCESS = 0x91, /* ITCM access */
|
||||
ARMV7_PERF_HW_DTCM_ACCESS = 0x92, /* DTCM access */
|
||||
ARMV7_PERF_HW_DATA_EVICTION = 0x93, /* data eviction */
|
||||
ARMV7_PERF_HW_SCU = 0x94, /* SCU coherency operation */
|
||||
ARMV7_PERF_HW_INSCACHE_DEP_DW = 0x95, /* instruction cache dependent stall */
|
||||
ARMV7_PERF_HW_DATA_CACHE_DEP_STALL = 0x96, /* data cache dependent stall */
|
||||
ARMV7_PERF_HW_NOCACHE_NO_PER_DEP_STALL = 0x97, /* non-cacheable no peripheral dependent stall */
|
||||
ARMV7_PERF_HW_NOCACHE_PER_DEP_STALL = 0x98, /* non-Cacheable peripheral dependent stall */
|
||||
ARMV7_PERF_HW_DATA_CACHE_HP_DEP_STALL = 0x99, /* data cache high priority dependent stall */
|
||||
ARMV7_PERF_HW_AXI_FAST_PERIPHERAL = 0x9A, /* Accesses_to_AXI_fast_peripheral_port(reads_and_writes) */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _ARMV7_PMU_PRI_H */
|
||||
@@ -44,10 +44,24 @@ extern "C" {
|
||||
#define OS_SYSTEM_EXC_CURR_CPU 1
|
||||
#define OS_SYSTEM_EXC_OTHER_CPU 2
|
||||
|
||||
#define REGION_PATH_MAX 32
|
||||
|
||||
typedef struct {
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINTPTR ip;
|
||||
UINT32 len; /* f_path length */
|
||||
CHAR f_path[REGION_PATH_MAX];
|
||||
#else
|
||||
UINTPTR ip;
|
||||
#endif
|
||||
} IpInfo;
|
||||
|
||||
extern UINT32 OsGetSystemStatus(VOID);
|
||||
extern VOID BackTraceSub(UINTPTR regFP);
|
||||
extern VOID OsExcInit(VOID);
|
||||
extern BOOL OsSystemExcIsReset(VOID);
|
||||
extern UINT32 BackTraceGet(UINTPTR regFP, IpInfo *callChain, UINT32 maxDepth);
|
||||
extern BOOL OsGetUsrIpInfo(UINTPTR ip, IpInfo *info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -104,7 +104,7 @@ typedef struct {
|
||||
extern VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag);
|
||||
extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStask, UINT32 parentStackSize);
|
||||
extern VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
|
||||
extern VOID OsInitSignalContext(VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
|
||||
extern VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
|
||||
extern void arm_clean_cache_range(UINTPTR start, UINTPTR end);
|
||||
extern void arm_inv_cache_range(UINTPTR start, UINTPTR end);
|
||||
|
||||
|
||||
@@ -39,19 +39,26 @@
|
||||
#include "los_pte_ops.h"
|
||||
#include "los_tlb_v6.h"
|
||||
#include "los_printf.h"
|
||||
#include "los_vm_phys.h"
|
||||
#include "los_vm_common.h"
|
||||
#include "los_vm_map.h"
|
||||
#include "los_vm_boot.h"
|
||||
#include "los_mmu_descriptor_v6.h"
|
||||
|
||||
#include "los_process_pri.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
typedef struct {
|
||||
LosArchMmu *archMmu;
|
||||
VADDR_T *vaddr;
|
||||
PADDR_T *paddr;
|
||||
UINT32 *flags;
|
||||
} MmuMapInfo;
|
||||
|
||||
#define TRY_MAX_TIMES 10
|
||||
|
||||
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
|
||||
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
|
||||
g_firstPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
|
||||
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
|
||||
g_tempPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
|
||||
@@ -61,6 +68,75 @@ extern CHAR __mmu_ttlb_begin; /* defined in .ld script */
|
||||
UINT8 *g_mmuJumpPageTable = (UINT8 *)&__mmu_ttlb_begin; /* temp page table, this is only used when system power up */
|
||||
#endif
|
||||
|
||||
STATIC SPIN_LOCK_S *OsGetPteLock(LosArchMmu *archMmu, PADDR_T paddr, UINT32 *intSave)
|
||||
{
|
||||
SPIN_LOCK_S *lock = NULL;
|
||||
#ifdef LOSCFG_PAGE_TABLE_FINE_LOCK
|
||||
LosVmPage *vmPage = NULL;
|
||||
|
||||
vmPage = OsVmPaddrToPage(paddr);
|
||||
if (vmPage == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
lock = &vmPage->lock;
|
||||
#else
|
||||
lock = &archMmu->lock;
|
||||
#endif
|
||||
|
||||
LOS_SpinLockSave(lock, intSave);
|
||||
return lock;
|
||||
}
|
||||
|
||||
STATIC SPIN_LOCK_S *OsGetPte1Lock(LosArchMmu *archMmu, PADDR_T paddr, UINT32 *intSave)
|
||||
{
|
||||
return OsGetPteLock(archMmu, paddr, intSave);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsUnlockPte1(SPIN_LOCK_S *lock, UINT32 intSave)
|
||||
{
|
||||
if (lock == NULL) {
|
||||
return;
|
||||
}
|
||||
LOS_SpinUnlockRestore(lock, intSave);
|
||||
}
|
||||
|
||||
STATIC SPIN_LOCK_S *OsGetPte1LockTmp(LosArchMmu *archMmu, PADDR_T paddr, UINT32 *intSave)
|
||||
{
|
||||
SPIN_LOCK_S *spinLock = NULL;
|
||||
#ifdef LOSCFG_PAGE_TABLE_FINE_LOCK
|
||||
spinLock = OsGetPteLock(archMmu, paddr, intSave);
|
||||
#else
|
||||
(VOID)archMmu;
|
||||
(VOID)paddr;
|
||||
(VOID)intSave;
|
||||
#endif
|
||||
return spinLock;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsUnlockPte1Tmp(SPIN_LOCK_S *lock, UINT32 intSave)
|
||||
{
|
||||
#ifdef LOSCFG_PAGE_TABLE_FINE_LOCK
|
||||
if (lock == NULL) {
|
||||
return;
|
||||
}
|
||||
LOS_SpinUnlockRestore(lock, intSave);
|
||||
#else
|
||||
(VOID)lock;
|
||||
(VOID)intSave;
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE SPIN_LOCK_S *OsGetPte2Lock(LosArchMmu *archMmu, PTE_T pte1, UINT32 *intSave)
|
||||
{
|
||||
PADDR_T pa = MMU_DESCRIPTOR_L1_PAGE_TABLE_ADDR(pte1);
|
||||
return OsGetPteLock(archMmu, pa, intSave);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsUnlockPte2(SPIN_LOCK_S *lock, UINT32 intSave)
|
||||
{
|
||||
return OsUnlockPte1(lock, intSave);
|
||||
}
|
||||
|
||||
STATIC INLINE PTE_T *OsGetPte2BasePtr(PTE_T pte1)
|
||||
{
|
||||
PADDR_T pa = MMU_DESCRIPTOR_L1_PAGE_TABLE_ADDR(pte1);
|
||||
@@ -172,20 +248,30 @@ STATIC VOID OsPutL2Table(const LosArchMmu *archMmu, UINT32 l1Index, paddr_t l2Pa
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC VOID OsTryUnmapL1PTE(const LosArchMmu *archMmu, vaddr_t vaddr, UINT32 scanIndex, UINT32 scanCount)
|
||||
STATIC VOID OsTryUnmapL1PTE(LosArchMmu *archMmu, PTE_T *l1Entry, vaddr_t vaddr, UINT32 scanIndex, UINT32 scanCount)
|
||||
{
|
||||
/*
|
||||
* Check if all pages related to this l1 entry are deallocated.
|
||||
* We only need to check pages that we did not clear above starting
|
||||
* from page_idx and wrapped around SECTION.
|
||||
* from scanIndex and wrapped around SECTION.
|
||||
*/
|
||||
UINT32 l1Index;
|
||||
PTE_T l1Entry;
|
||||
PTE_T *pte2BasePtr = NULL;
|
||||
SPIN_LOCK_S *pte1Lock = NULL;
|
||||
SPIN_LOCK_S *pte2Lock = NULL;
|
||||
UINT32 pte1IntSave;
|
||||
UINT32 pte2IntSave;
|
||||
PTE_T pte1Val;
|
||||
PADDR_T pte1Paddr;
|
||||
|
||||
pte2BasePtr = OsGetPte2BasePtr(OsGetPte1(archMmu->virtTtb, vaddr));
|
||||
pte1Paddr = OsGetPte1Paddr(archMmu->physTtb, vaddr);
|
||||
pte2Lock = OsGetPte2Lock(archMmu, *l1Entry, &pte2IntSave);
|
||||
if (pte2Lock == NULL) {
|
||||
return;
|
||||
}
|
||||
pte2BasePtr = OsGetPte2BasePtr(*l1Entry);
|
||||
if (pte2BasePtr == NULL) {
|
||||
VM_ERR("pte2 base ptr is NULL");
|
||||
OsUnlockPte2(pte2Lock, pte2IntSave);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -200,15 +286,27 @@ STATIC VOID OsTryUnmapL1PTE(const LosArchMmu *archMmu, vaddr_t vaddr, UINT32 sca
|
||||
}
|
||||
|
||||
if (!scanCount) {
|
||||
l1Index = OsGetPte1Index(vaddr);
|
||||
l1Entry = archMmu->virtTtb[l1Index];
|
||||
/*
|
||||
* The pte1 of kprocess is placed in kernel image when compiled. So the pte1Lock will be null.
|
||||
* There is no situation to simultaneous access the pte1 of kprocess.
|
||||
*/
|
||||
pte1Lock = OsGetPte1LockTmp(archMmu, pte1Paddr, &pte1IntSave);
|
||||
if (!OsIsPte1PageTable(*l1Entry)) {
|
||||
OsUnlockPte1Tmp(pte1Lock, pte1IntSave);
|
||||
OsUnlockPte2(pte2Lock, pte2IntSave);
|
||||
return;
|
||||
}
|
||||
pte1Val = *l1Entry;
|
||||
/* we can kill l1 entry */
|
||||
OsClearPte1(&archMmu->virtTtb[l1Index]);
|
||||
OsClearPte1(l1Entry);
|
||||
l1Index = OsGetPte1Index(vaddr);
|
||||
OsArmInvalidateTlbMvaNoBarrier(l1Index << MMU_DESCRIPTOR_L1_SMALL_SHIFT);
|
||||
|
||||
/* try to free l2 page itself */
|
||||
OsPutL2Table(archMmu, l1Index, MMU_DESCRIPTOR_L1_PAGE_TABLE_ADDR(l1Entry));
|
||||
OsPutL2Table(archMmu, l1Index, MMU_DESCRIPTOR_L1_PAGE_TABLE_ADDR(pte1Val));
|
||||
OsUnlockPte1Tmp(pte1Lock, pte1IntSave);
|
||||
}
|
||||
OsUnlockPte2(pte2Lock, pte2IntSave);
|
||||
}
|
||||
|
||||
STATIC UINT32 OsCvtSecCacheFlagsToMMUFlags(UINT32 flags)
|
||||
@@ -218,7 +316,7 @@ STATIC UINT32 OsCvtSecCacheFlagsToMMUFlags(UINT32 flags)
|
||||
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
|
||||
case VM_MAP_REGION_FLAG_CACHED:
|
||||
mmuFlags |= MMU_DESCRIPTOR_L1_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
mmuFlags |= MMU_DESCRIPTOR_L1_SECTION_SHAREABLE;
|
||||
#endif
|
||||
break;
|
||||
@@ -340,34 +438,54 @@ STATIC VOID OsCvtSecAttsToFlags(PTE_T l1Entry, UINT32 *flags)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC UINT32 OsUnmapL2PTE(const LosArchMmu *archMmu, vaddr_t vaddr, UINT32 *count)
|
||||
STATIC UINT32 OsUnmapL2PTE(LosArchMmu *archMmu, PTE_T *pte1, vaddr_t vaddr, UINT32 *count)
|
||||
{
|
||||
UINT32 unmapCount;
|
||||
UINT32 pte2Index;
|
||||
UINT32 intSave;
|
||||
PTE_T *pte2BasePtr = NULL;
|
||||
|
||||
pte2BasePtr = OsGetPte2BasePtr(OsGetPte1((PTE_T *)archMmu->virtTtb, vaddr));
|
||||
if (pte2BasePtr == NULL) {
|
||||
LOS_Panic("%s %d, pte2 base ptr is NULL\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
SPIN_LOCK_S *lock = NULL;
|
||||
|
||||
pte2Index = OsGetPte2Index(vaddr);
|
||||
unmapCount = MIN2(MMU_DESCRIPTOR_L2_NUMBERS_PER_L1 - pte2Index, *count);
|
||||
|
||||
lock = OsGetPte2Lock(archMmu, *pte1, &intSave);
|
||||
if (lock == NULL) {
|
||||
return unmapCount;
|
||||
}
|
||||
|
||||
pte2BasePtr = OsGetPte2BasePtr(*pte1);
|
||||
if (pte2BasePtr == NULL) {
|
||||
OsUnlockPte2(lock, intSave);
|
||||
return unmapCount;
|
||||
}
|
||||
|
||||
/* unmap page run */
|
||||
OsClearPte2Continuous(&pte2BasePtr[pte2Index], unmapCount);
|
||||
|
||||
/* invalidate tlb */
|
||||
OsArmInvalidateTlbMvaRangeNoBarrier(vaddr, unmapCount);
|
||||
OsUnlockPte2(lock, intSave);
|
||||
|
||||
*count -= unmapCount;
|
||||
return unmapCount;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsUnmapSection(LosArchMmu *archMmu, vaddr_t *vaddr, UINT32 *count)
|
||||
STATIC UINT32 OsUnmapSection(LosArchMmu *archMmu, PTE_T *l1Entry, vaddr_t *vaddr, UINT32 *count)
|
||||
{
|
||||
UINT32 intSave;
|
||||
PADDR_T pte1Paddr;
|
||||
SPIN_LOCK_S *lock = NULL;
|
||||
|
||||
pte1Paddr = OsGetPte1Paddr(archMmu->physTtb, *vaddr);
|
||||
lock = OsGetPte1Lock(archMmu, pte1Paddr, &intSave);
|
||||
if (!OsIsPte1Section(*l1Entry)) {
|
||||
OsUnlockPte1(lock, intSave);
|
||||
return 0;
|
||||
}
|
||||
OsClearPte1(OsGetPte1Ptr((PTE_T *)archMmu->virtTtb, *vaddr));
|
||||
OsArmInvalidateTlbMvaNoBarrier(*vaddr);
|
||||
OsUnlockPte1(lock, intSave);
|
||||
|
||||
*vaddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
|
||||
*count -= MMU_DESCRIPTOR_L2_NUMBERS_PER_L1;
|
||||
@@ -384,12 +502,9 @@ BOOL OsArchMmuInit(LosArchMmu *archMmu, VADDR_T *virtTtb)
|
||||
}
|
||||
#endif
|
||||
|
||||
status_t retval = LOS_MuxInit(&archMmu->mtx, NULL);
|
||||
if (retval != LOS_OK) {
|
||||
VM_ERR("Create mutex for arch mmu failed, status: %d", retval);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef LOSCFG_PAGE_TABLE_FINE_LOCK
|
||||
LOS_SpinInit(&archMmu->lock);
|
||||
#endif
|
||||
LOS_ListInit(&archMmu->ptList);
|
||||
archMmu->virtTtb = virtTtb;
|
||||
archMmu->physTtb = (VADDR_T)(UINTPTR)virtTtb - KERNEL_ASPACE_BASE + SYS_MEM_BASE;
|
||||
@@ -438,45 +553,55 @@ STATUS_T LOS_ArchMmuQuery(const LosArchMmu *archMmu, VADDR_T vaddr, PADDR_T *pad
|
||||
|
||||
STATUS_T LOS_ArchMmuUnmap(LosArchMmu *archMmu, VADDR_T vaddr, size_t count)
|
||||
{
|
||||
PTE_T l1Entry;
|
||||
PTE_T *l1Entry = NULL;
|
||||
INT32 unmapped = 0;
|
||||
UINT32 unmapCount = 0;
|
||||
INT32 tryTime = TRY_MAX_TIMES;
|
||||
|
||||
while (count > 0) {
|
||||
l1Entry = OsGetPte1(archMmu->virtTtb, vaddr);
|
||||
if (OsIsPte1Invalid(l1Entry)) {
|
||||
l1Entry = OsGetPte1Ptr(archMmu->virtTtb, vaddr);
|
||||
if (OsIsPte1Invalid(*l1Entry)) {
|
||||
unmapCount = OsUnmapL1Invalid(&vaddr, &count);
|
||||
} else if (OsIsPte1Section(l1Entry)) {
|
||||
} else if (OsIsPte1Section(*l1Entry)) {
|
||||
if (MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(vaddr) && count >= MMU_DESCRIPTOR_L2_NUMBERS_PER_L1) {
|
||||
unmapCount = OsUnmapSection(archMmu, &vaddr, &count);
|
||||
unmapCount = OsUnmapSection(archMmu, l1Entry, &vaddr, &count);
|
||||
} else {
|
||||
LOS_Panic("%s %d, unimplemented\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
} else if (OsIsPte1PageTable(l1Entry)) {
|
||||
unmapCount = OsUnmapL2PTE(archMmu, vaddr, &count);
|
||||
OsTryUnmapL1PTE(archMmu, vaddr, OsGetPte2Index(vaddr) + unmapCount,
|
||||
MMU_DESCRIPTOR_L2_NUMBERS_PER_L1 - unmapCount);
|
||||
} else if (OsIsPte1PageTable(*l1Entry)) {
|
||||
unmapCount = OsUnmapL2PTE(archMmu, l1Entry, vaddr, &count);
|
||||
OsTryUnmapL1PTE(archMmu, l1Entry, vaddr, OsGetPte2Index(vaddr) + unmapCount,
|
||||
MMU_DESCRIPTOR_L2_NUMBERS_PER_L1);
|
||||
vaddr += unmapCount << MMU_DESCRIPTOR_L2_SMALL_SHIFT;
|
||||
} else {
|
||||
LOS_Panic("%s %d, unimplemented\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
tryTime = (unmapCount == 0) ? (tryTime - 1) : tryTime;
|
||||
if (tryTime == 0) {
|
||||
return LOS_ERRNO_VM_FAULT;
|
||||
}
|
||||
unmapped += unmapCount;
|
||||
}
|
||||
OsArmInvalidateTlbBarrier();
|
||||
return unmapped;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsMapSection(const LosArchMmu *archMmu, UINT32 flags, VADDR_T *vaddr,
|
||||
PADDR_T *paddr, UINT32 *count)
|
||||
STATIC UINT32 OsMapSection(MmuMapInfo *mmuMapInfo, UINT32 *count)
|
||||
{
|
||||
UINT32 mmuFlags = 0;
|
||||
UINT32 intSave;
|
||||
PADDR_T pte1Paddr;
|
||||
SPIN_LOCK_S *lock = NULL;
|
||||
|
||||
mmuFlags |= OsCvtSecFlagsToAttrs(flags);
|
||||
OsSavePte1(OsGetPte1Ptr(archMmu->virtTtb, *vaddr),
|
||||
OsTruncPte1(*paddr) | mmuFlags | MMU_DESCRIPTOR_L1_TYPE_SECTION);
|
||||
mmuFlags |= OsCvtSecFlagsToAttrs(*mmuMapInfo->flags);
|
||||
pte1Paddr = OsGetPte1Paddr(mmuMapInfo->archMmu->physTtb, *mmuMapInfo->vaddr);
|
||||
lock = OsGetPte1Lock(mmuMapInfo->archMmu, pte1Paddr, &intSave);
|
||||
OsSavePte1(OsGetPte1Ptr(mmuMapInfo->archMmu->virtTtb, *mmuMapInfo->vaddr),
|
||||
OsTruncPte1(*mmuMapInfo->paddr) | mmuFlags | MMU_DESCRIPTOR_L1_TYPE_SECTION);
|
||||
OsUnlockPte1(lock, intSave);
|
||||
*count -= MMU_DESCRIPTOR_L2_NUMBERS_PER_L1;
|
||||
*vaddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
|
||||
*paddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
|
||||
*mmuMapInfo->vaddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
|
||||
*mmuMapInfo->paddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
|
||||
|
||||
return MMU_DESCRIPTOR_L2_NUMBERS_PER_L1;
|
||||
}
|
||||
@@ -517,34 +642,17 @@ STATIC STATUS_T OsGetL2Table(LosArchMmu *archMmu, UINT32 l1Index, paddr_t *ppa)
|
||||
(VOID)memset_s(kvaddr, MMU_DESCRIPTOR_L2_SMALL_SIZE, 0, MMU_DESCRIPTOR_L2_SMALL_SIZE);
|
||||
|
||||
/* get physical address */
|
||||
*ppa = LOS_PaddrQuery(kvaddr) + l2Offset;
|
||||
*ppa = OsKVaddrToPaddr((VADDR_T)kvaddr) + l2Offset;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID OsMapL1PTE(LosArchMmu *archMmu, PTE_T *pte1Ptr, vaddr_t vaddr, UINT32 flags)
|
||||
{
|
||||
paddr_t pte2Base = 0;
|
||||
|
||||
if (OsGetL2Table(archMmu, OsGetPte1Index(vaddr), &pte2Base) != LOS_OK) {
|
||||
LOS_Panic("%s %d, failed to allocate pagetable\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
*pte1Ptr = pte2Base | MMU_DESCRIPTOR_L1_TYPE_PAGE_TABLE;
|
||||
if (flags & VM_MAP_REGION_FLAG_NS) {
|
||||
*pte1Ptr |= MMU_DESCRIPTOR_L1_PAGETABLE_NON_SECURE;
|
||||
}
|
||||
*pte1Ptr &= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_MASK;
|
||||
*pte1Ptr |= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_CLIENT; // use client AP
|
||||
OsSavePte1(OsGetPte1Ptr(archMmu->virtTtb, vaddr), *pte1Ptr);
|
||||
}
|
||||
|
||||
STATIC UINT32 OsCvtPte2CacheFlagsToMMUFlags(UINT32 flags)
|
||||
{
|
||||
UINT32 mmuFlags = 0;
|
||||
|
||||
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
|
||||
case VM_MAP_REGION_FLAG_CACHED:
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
mmuFlags |= MMU_DESCRIPTOR_L2_SHAREABLE;
|
||||
#endif
|
||||
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
|
||||
@@ -618,32 +726,93 @@ STATIC UINT32 OsCvtPte2FlagsToAttrs(UINT32 flags)
|
||||
return mmuFlags;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsMapL2PageContinous(PTE_T pte1, UINT32 flags, VADDR_T *vaddr, PADDR_T *paddr, UINT32 *count)
|
||||
STATIC UINT32 OsMapL1PTE(MmuMapInfo *mmuMapInfo, PTE_T *l1Entry, UINT32 *count)
|
||||
{
|
||||
PADDR_T pte2Base = 0;
|
||||
PADDR_T pte1Paddr;
|
||||
SPIN_LOCK_S *pte1Lock = NULL;
|
||||
SPIN_LOCK_S *pte2Lock = NULL;
|
||||
PTE_T *pte2BasePtr = NULL;
|
||||
UINT32 saveCounts, archFlags, pte1IntSave, pte2IntSave;
|
||||
|
||||
pte1Paddr = OsGetPte1Paddr(mmuMapInfo->archMmu->physTtb, *mmuMapInfo->vaddr);
|
||||
pte1Lock = OsGetPte1Lock(mmuMapInfo->archMmu, pte1Paddr, &pte1IntSave);
|
||||
if (!OsIsPte1Invalid(*l1Entry)) {
|
||||
OsUnlockPte1(pte1Lock, pte1IntSave);
|
||||
return 0;
|
||||
}
|
||||
if (OsGetL2Table(mmuMapInfo->archMmu, OsGetPte1Index(*mmuMapInfo->vaddr), &pte2Base) != LOS_OK) {
|
||||
LOS_Panic("%s %d, failed to allocate pagetable\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
*l1Entry = pte2Base | MMU_DESCRIPTOR_L1_TYPE_PAGE_TABLE;
|
||||
if (*mmuMapInfo->flags & VM_MAP_REGION_FLAG_NS) {
|
||||
*l1Entry |= MMU_DESCRIPTOR_L1_PAGETABLE_NON_SECURE;
|
||||
}
|
||||
*l1Entry &= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_MASK;
|
||||
*l1Entry |= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_CLIENT; // use client AP
|
||||
OsSavePte1(OsGetPte1Ptr(mmuMapInfo->archMmu->virtTtb, *mmuMapInfo->vaddr), *l1Entry);
|
||||
OsUnlockPte1(pte1Lock, pte1IntSave);
|
||||
|
||||
pte2Lock = OsGetPte2Lock(mmuMapInfo->archMmu, *l1Entry, &pte2IntSave);
|
||||
if (pte2Lock == NULL) {
|
||||
LOS_Panic("pte2 should not be null!\n");
|
||||
}
|
||||
pte2BasePtr = (PTE_T *)LOS_PaddrToKVaddr(pte2Base);
|
||||
|
||||
/* compute the arch flags for L2 4K pages */
|
||||
archFlags = OsCvtPte2FlagsToAttrs(*mmuMapInfo->flags);
|
||||
saveCounts = OsSavePte2Continuous(pte2BasePtr, OsGetPte2Index(*mmuMapInfo->vaddr), *mmuMapInfo->paddr | archFlags,
|
||||
*count);
|
||||
OsUnlockPte2(pte2Lock, pte2IntSave);
|
||||
*mmuMapInfo->paddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
*mmuMapInfo->vaddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
*count -= saveCounts;
|
||||
return saveCounts;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsMapL2PageContinous(MmuMapInfo *mmuMapInfo, PTE_T *pte1, UINT32 *count)
|
||||
{
|
||||
PTE_T *pte2BasePtr = NULL;
|
||||
UINT32 archFlags;
|
||||
UINT32 saveCounts;
|
||||
UINT32 intSave;
|
||||
SPIN_LOCK_S *lock = NULL;
|
||||
|
||||
pte2BasePtr = OsGetPte2BasePtr(pte1);
|
||||
lock = OsGetPte2Lock(mmuMapInfo->archMmu, *pte1, &intSave);
|
||||
if (lock == NULL) {
|
||||
return 0;
|
||||
}
|
||||
pte2BasePtr = OsGetPte2BasePtr(*pte1);
|
||||
if (pte2BasePtr == NULL) {
|
||||
LOS_Panic("%s %d, pte1 %#x error\n", __FUNCTION__, __LINE__, pte1);
|
||||
OsUnlockPte2(lock, intSave);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* compute the arch flags for L2 4K pages */
|
||||
archFlags = OsCvtPte2FlagsToAttrs(flags);
|
||||
saveCounts = OsSavePte2Continuous(pte2BasePtr, OsGetPte2Index(*vaddr), *paddr | archFlags, *count);
|
||||
*paddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
*vaddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
archFlags = OsCvtPte2FlagsToAttrs(*mmuMapInfo->flags);
|
||||
saveCounts = OsSavePte2Continuous(pte2BasePtr, OsGetPte2Index(*mmuMapInfo->vaddr), *mmuMapInfo->paddr | archFlags,
|
||||
*count);
|
||||
OsUnlockPte2(lock, intSave);
|
||||
*mmuMapInfo->paddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
*mmuMapInfo->vaddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
*count -= saveCounts;
|
||||
return saveCounts;
|
||||
}
|
||||
|
||||
status_t LOS_ArchMmuMap(LosArchMmu *archMmu, VADDR_T vaddr, PADDR_T paddr, size_t count, UINT32 flags)
|
||||
{
|
||||
PTE_T l1Entry;
|
||||
PTE_T *l1Entry = NULL;
|
||||
UINT32 saveCounts = 0;
|
||||
INT32 mapped = 0;
|
||||
INT32 tryTime = TRY_MAX_TIMES;
|
||||
INT32 checkRst;
|
||||
MmuMapInfo mmuMapInfo = {
|
||||
.archMmu = archMmu,
|
||||
.vaddr = &vaddr,
|
||||
.paddr = &paddr,
|
||||
.flags = &flags,
|
||||
};
|
||||
|
||||
checkRst = OsMapParamCheck(flags, vaddr, paddr);
|
||||
if (checkRst < 0) {
|
||||
@@ -652,24 +821,27 @@ status_t LOS_ArchMmuMap(LosArchMmu *archMmu, VADDR_T vaddr, PADDR_T paddr, size_
|
||||
|
||||
/* see what kind of mapping we can use */
|
||||
while (count > 0) {
|
||||
if (MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(vaddr) &&
|
||||
MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(paddr) &&
|
||||
if (MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(*mmuMapInfo.vaddr) &&
|
||||
MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(*mmuMapInfo.paddr) &&
|
||||
count >= MMU_DESCRIPTOR_L2_NUMBERS_PER_L1) {
|
||||
/* compute the arch flags for L1 sections cache, r ,w ,x, domain and type */
|
||||
saveCounts = OsMapSection(archMmu, flags, &vaddr, &paddr, &count);
|
||||
saveCounts = OsMapSection(&mmuMapInfo, &count);
|
||||
} else {
|
||||
/* have to use a L2 mapping, we only allocate 4KB for L1, support 0 ~ 1GB */
|
||||
l1Entry = OsGetPte1(archMmu->virtTtb, vaddr);
|
||||
if (OsIsPte1Invalid(l1Entry)) {
|
||||
OsMapL1PTE(archMmu, &l1Entry, vaddr, flags);
|
||||
saveCounts = OsMapL2PageContinous(l1Entry, flags, &vaddr, &paddr, &count);
|
||||
} else if (OsIsPte1PageTable(l1Entry)) {
|
||||
saveCounts = OsMapL2PageContinous(l1Entry, flags, &vaddr, &paddr, &count);
|
||||
l1Entry = OsGetPte1Ptr(archMmu->virtTtb, *mmuMapInfo.vaddr);
|
||||
if (OsIsPte1Invalid(*l1Entry)) {
|
||||
saveCounts = OsMapL1PTE(&mmuMapInfo, l1Entry, &count);
|
||||
} else if (OsIsPte1PageTable(*l1Entry)) {
|
||||
saveCounts = OsMapL2PageContinous(&mmuMapInfo, l1Entry, &count);
|
||||
} else {
|
||||
LOS_Panic("%s %d, unimplemented tt_entry %x\n", __FUNCTION__, __LINE__, l1Entry);
|
||||
}
|
||||
}
|
||||
mapped += saveCounts;
|
||||
tryTime = (saveCounts == 0) ? (tryTime - 1) : tryTime;
|
||||
if (tryTime == 0) {
|
||||
return LOS_ERRNO_VM_TIMED_OUT;
|
||||
}
|
||||
}
|
||||
|
||||
return mapped;
|
||||
@@ -716,7 +888,7 @@ STATUS_T LOS_ArchMmuMove(LosArchMmu *archMmu, VADDR_T oldVaddr, VADDR_T newVaddr
|
||||
PADDR_T paddr = 0;
|
||||
|
||||
if ((archMmu == NULL) || (oldVaddr == 0) || (newVaddr == 0) || (count == 0)) {
|
||||
VM_ERR("invalid args: archMmu %p, oldVaddr %p, newVddr %p, count %d",
|
||||
VM_ERR("invalid args: archMmu %p, oldVaddr %p, newVaddr %p, count %d",
|
||||
archMmu, oldVaddr, newVaddr, count);
|
||||
return LOS_NOK;
|
||||
}
|
||||
@@ -790,10 +962,9 @@ STATUS_T LOS_ArchMmuDestroy(LosArchMmu *archMmu)
|
||||
LOS_PhysPageFree(page);
|
||||
}
|
||||
|
||||
OsArmWriteTlbiasid(archMmu->asid);
|
||||
OsArmWriteTlbiasidis(archMmu->asid);
|
||||
OsFreeAsid(archMmu->asid);
|
||||
#endif
|
||||
(VOID)LOS_MuxDestroy(&archMmu->mtx);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
@@ -862,7 +1033,7 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
LosVmSpace *kSpace = LOS_GetKVmSpace();
|
||||
status_t status;
|
||||
UINT32 length;
|
||||
int i;
|
||||
INT32 i;
|
||||
LosArchMmuInitMapping *kernelMap = NULL;
|
||||
UINT32 kmallocLength;
|
||||
UINT32 flags;
|
||||
@@ -871,7 +1042,7 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
kSpace->archMmu.virtTtb = (PTE_T *)g_firstPageTable;
|
||||
kSpace->archMmu.physTtb = LOS_PaddrQuery(kSpace->archMmu.virtTtb);
|
||||
status = LOS_ArchMmuUnmap(&kSpace->archMmu, virtAddr,
|
||||
(bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
(bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
if (status != ((bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("unmap failed, status: %d", status);
|
||||
return;
|
||||
@@ -882,8 +1053,8 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
flags |= VM_MAP_REGION_FLAG_UNCACHED;
|
||||
}
|
||||
status = LOS_ArchMmuMap(&kSpace->archMmu, virtAddr, SYS_MEM_BASE,
|
||||
(textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
(textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
if (status != ((textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("mmap failed, status: %d", status);
|
||||
return;
|
||||
@@ -910,9 +1081,9 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
flags |= VM_MAP_REGION_FLAG_UNCACHED;
|
||||
}
|
||||
status = LOS_ArchMmuMap(&kSpace->archMmu, bssEndBoundary,
|
||||
SYS_MEM_BASE + bssEndBoundary - virtAddr,
|
||||
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
SYS_MEM_BASE + bssEndBoundary - virtAddr,
|
||||
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
if (status != (kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("mmap failed, status: %d", status);
|
||||
return;
|
||||
@@ -966,4 +1137,3 @@ VOID OsInitMappingStartUp(VOID)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -147,6 +147,14 @@ OsIrqHandler:
|
||||
/* disable irq, switch to svc mode */
|
||||
CPSID i, #0x13
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PERF
|
||||
PUSH {R0-R3, R12, LR}
|
||||
MOV R0, LR
|
||||
MOV R1, FP
|
||||
BL OsPerfSetIrqRegs
|
||||
POP {R0-R3, R12, LR}
|
||||
#endif
|
||||
|
||||
STMFD SP!, {R0-R3, R12, LR}
|
||||
STMFD SP, {R13, R14}^
|
||||
SUB SP, SP, #(4 * 4)
|
||||
@@ -173,6 +181,7 @@ OsIrqHandler:
|
||||
POP_FPU_REGS R0
|
||||
LDR R4, [SP, #0]
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* Obtain the CPSR to determine the mode the system is in when the interrupt is triggered */
|
||||
LDR R3, [SP, #(11 * 4)]
|
||||
AND R1, R3, #CPSR_MASK_MODE
|
||||
@@ -187,6 +196,7 @@ OsIrqHandler:
|
||||
BLX OsSaveSignalContext
|
||||
MOV SP, R0
|
||||
1:
|
||||
#endif
|
||||
ADD SP, SP, #(2 * 4)
|
||||
/* load user sp and lr, and jump cpsr */
|
||||
LDMFD SP, {R13, R14}^
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "los_excinfo_pri.h"
|
||||
#endif
|
||||
#include "los_sys_stack_pri.h"
|
||||
#include "los_stackinfo_pri.h"
|
||||
#ifdef LOSCFG_COREDUMP
|
||||
#include "los_coredump.h"
|
||||
#endif
|
||||
@@ -62,6 +61,9 @@
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "console.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
#include "los_blackbox.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define INVALID_CPUID 0xFFFF
|
||||
@@ -75,7 +77,7 @@ VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr);
|
||||
UINT32 g_curNestCount[LOSCFG_KERNEL_CORE_NUM] = { 0 };
|
||||
BOOL g_excFromUserMode[LOSCFG_KERNEL_CORE_NUM];
|
||||
STATIC EXC_PROC_FUNC g_excHook = (EXC_PROC_FUNC)OsExcHook;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
STATIC SPIN_LOCK_INIT(g_excSerializerSpin);
|
||||
STATIC UINT32 g_currHandleExcPID = OS_INVALID_VALUE;
|
||||
STATIC UINT32 g_nextExcWaitCpu = INVALID_CPUID;
|
||||
@@ -220,11 +222,14 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
|
||||
pfFlags |= user ? VM_MAP_PF_FLAG_USER : 0;
|
||||
pfFlags |= instructionFault ? VM_MAP_PF_FLAG_INSTRUCTION : 0;
|
||||
pfFlags |= VM_MAP_PF_FLAG_NOT_PRESENT;
|
||||
OsSigIntLock();
|
||||
ret = OsVmPageFaultHandler(far, pfFlags, frame);
|
||||
OsSigIntUnlock();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = LOS_ERRNO_VM_NOT_FOUND;
|
||||
OsArmWriteTlbimvaais(ROUNDDOWN(far, PAGE_SIZE));
|
||||
ret = LOS_OK;
|
||||
break;
|
||||
}
|
||||
#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
|
||||
@@ -240,7 +245,7 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
|
||||
|
||||
STATIC VOID OsExcType(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr)
|
||||
{
|
||||
/* undefinited exception handling or software interrupt */
|
||||
/* undefined exception handling or software interrupt */
|
||||
if ((excType == OS_EXCEPT_UNDEF_INSTR) || (excType == OS_EXCEPT_SWI)) {
|
||||
if ((excBufAddr->regCPSR & INSTR_SET_MASK) == 0) { /* work status: ARM */
|
||||
excBufAddr->PC = excBufAddr->PC - ARM_INSTR_LEN;
|
||||
@@ -272,8 +277,8 @@ STATIC const CHAR *g_excTypeString[] = {
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProcess)
|
||||
{
|
||||
struct file *curFilep = NULL;
|
||||
struct file *lastFilep = NULL;
|
||||
struct Vnode *curVnode = NULL;
|
||||
struct Vnode *lastVnode = NULL;
|
||||
LosVmMapRegion *curRegion = NULL;
|
||||
LosVmMapRegion *lastRegion = NULL;
|
||||
|
||||
@@ -292,9 +297,9 @@ STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProc
|
||||
if ((lastRegion == NULL) || !LOS_IsRegionFileValid(lastRegion)) {
|
||||
goto DONE;
|
||||
}
|
||||
curFilep = curRegion->unTypeData.rf.file;
|
||||
lastFilep = lastRegion->unTypeData.rf.file;
|
||||
} while (!strcmp(curFilep->f_path, lastFilep->f_path));
|
||||
curVnode = curRegion->unTypeData.rf.vnode;
|
||||
lastVnode = lastRegion->unTypeData.rf.vnode;
|
||||
} while (curVnode == lastVnode);
|
||||
|
||||
DONE:
|
||||
#ifdef LOSCFG_KERNEL_DYNLOAD
|
||||
@@ -475,7 +480,7 @@ STATIC VOID OsDumpProcessUsedMemRegion(LosProcessCB *runProcess, LosVmSpace *run
|
||||
RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNodeTemp, pstRbNodeNext)
|
||||
}
|
||||
|
||||
STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFalgs)
|
||||
STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFlags)
|
||||
{
|
||||
LosProcessCB *runProcess = NULL;
|
||||
LosVmSpace *runspace = NULL;
|
||||
@@ -496,7 +501,7 @@ STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFalgs)
|
||||
return;
|
||||
}
|
||||
|
||||
OsDumpProcessUsedMemRegion(runProcess, runspace, vmmFalgs);
|
||||
OsDumpProcessUsedMemRegion(runProcess, runspace, vmmFlags);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -529,7 +534,7 @@ STATIC VOID OsExcRestore(VOID)
|
||||
g_excFromUserMode[currCpuID] = FALSE;
|
||||
g_intCount[currCpuID] = 0;
|
||||
g_curNestCount[currCpuID] = 0;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsPercpuGet()->excFlag = CPU_RUNNING;
|
||||
#endif
|
||||
OsPercpuGet()->taskLockCnt = 0;
|
||||
@@ -537,14 +542,16 @@ STATIC VOID OsExcRestore(VOID)
|
||||
|
||||
STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 currCpu = ArchCurrCpuid();
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
if (g_nextExcWaitCpu != INVALID_CPUID) {
|
||||
g_currHandleExcCpuID = g_nextExcWaitCpu;
|
||||
@@ -557,24 +564,38 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
#else
|
||||
g_currHandleExcCpuID = INVALID_CPUID;
|
||||
#endif
|
||||
runProcess->processStatus &= ~OS_PROCESS_FLAG_EXIT;
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
OsWakeConsoleSendTask();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
BBoxNotifyError("USER_CRASH", MODULE_SYSTEM, "Crash in user", 0);
|
||||
#endif
|
||||
SCHEDULER_LOCK(intSave);
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
OsProcessExitCodeCoreDumpSet(runProcess);
|
||||
#endif
|
||||
OsProcessExitCodeSignalSet(runProcess, SIGUSR2);
|
||||
|
||||
/* Exception handling All operations should be kept prior to that operation */
|
||||
OsExcRestore();
|
||||
/* An exception was raised by a task during the exit process of
|
||||
* the current process.
|
||||
*/
|
||||
if (runProcess->processStatus & OS_PROCESS_FLAG_EXIT) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
/* Exception handling All operations should be kept prior to that operation */
|
||||
OsExcRestore();
|
||||
OsTaskToExit(runTask, OS_PRO_EXIT_OK);
|
||||
} else {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
/* kill user exc process */
|
||||
LOS_Exit(OS_PRO_EXIT_OK);
|
||||
/* Exception handling All operations should be kept prior to that operation */
|
||||
OsExcRestore();
|
||||
/* kill user exc process */
|
||||
LOS_Exit(OS_PRO_EXIT_OK);
|
||||
}
|
||||
|
||||
/* User mode exception handling failed , which normally does not exist */
|
||||
g_curNestCount[currCpu]++;
|
||||
@@ -669,18 +690,66 @@ FOUND:
|
||||
return found;
|
||||
}
|
||||
|
||||
VOID BackTraceSub(UINTPTR regFP)
|
||||
BOOL OsGetUsrIpInfo(UINTPTR ip, IpInfo *info)
|
||||
{
|
||||
if (info == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
BOOL ret = FALSE;
|
||||
const CHAR *name = NULL;
|
||||
LosVmMapRegion *region = NULL;
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
|
||||
if (LOS_IsUserAddress((VADDR_T)ip) == FALSE) {
|
||||
info->ip = ip;
|
||||
name = "kernel";
|
||||
ret = FALSE;
|
||||
goto END;
|
||||
}
|
||||
|
||||
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)ip);
|
||||
if (region == NULL) {
|
||||
info->ip = ip;
|
||||
name = "invalid";
|
||||
ret = FALSE;
|
||||
goto END;
|
||||
}
|
||||
|
||||
info->ip = ip - OsGetTextRegionBase(region, runProcess);
|
||||
name = OsGetRegionNameOrFilePath(region);
|
||||
ret = TRUE;
|
||||
if (strcmp(name, "/lib/libc.so") != 0) {
|
||||
PRINT_ERR("ip = 0x%x, %s\n", info->ip, name);
|
||||
}
|
||||
END:
|
||||
info->len = strlen(name);
|
||||
if (strncpy_s(info->f_path, REGION_PATH_MAX, name, REGION_PATH_MAX - 1) != EOK) {
|
||||
info->f_path[0] = '\0';
|
||||
info->len = 0;
|
||||
PRINT_ERR("copy f_path failed, %s\n", name);
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
info->ip = ip;
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT32 BackTraceGet(UINTPTR regFP, IpInfo *callChain, UINT32 maxDepth)
|
||||
{
|
||||
UINTPTR tmpFP, backLR;
|
||||
UINTPTR stackStart, stackEnd;
|
||||
UINTPTR backFP = regFP;
|
||||
UINT32 count = 0;
|
||||
BOOL ret;
|
||||
VADDR_T kvaddr;
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
|
||||
if (FindSuitableStack(regFP, &stackStart, &stackEnd, &kvaddr) == FALSE) {
|
||||
PrintExcInfo("traceback error fp = 0x%x\n", regFP);
|
||||
return;
|
||||
if (callChain == NULL) {
|
||||
PrintExcInfo("traceback error fp = 0x%x\n", regFP);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -692,46 +761,59 @@ VOID BackTraceSub(UINTPTR regFP)
|
||||
tmpFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
if (IsValidFP(tmpFP, stackStart, stackEnd, NULL) == TRUE) {
|
||||
backFP = tmpFP;
|
||||
PrintExcInfo("traceback fp fixed, trace using fp = 0x%x\n", backFP);
|
||||
if (callChain == NULL) {
|
||||
PrintExcInfo("traceback fp fixed, trace using fp = 0x%x\n", backFP);
|
||||
}
|
||||
}
|
||||
|
||||
while (IsValidFP(backFP, stackStart, stackEnd, &kvaddr) == TRUE) {
|
||||
tmpFP = backFP;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
if (IsValidFP(tmpFP + POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
|
||||
PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE);
|
||||
return;
|
||||
if (callChain == NULL) {
|
||||
PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
#else
|
||||
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
if (IsValidFP(tmpFP - POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
|
||||
PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE);
|
||||
return;
|
||||
if (callChain == NULL) {
|
||||
PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
#endif
|
||||
IpInfo info = {0};
|
||||
ret = OsGetUsrIpInfo((VADDR_T)backLR, &info);
|
||||
if (callChain == NULL) {
|
||||
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x ", count, backLR, backFP);
|
||||
if (ret) {
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmMapRegion *region = NULL;
|
||||
if (LOS_IsUserAddress((VADDR_T)backLR) == TRUE) {
|
||||
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)backLR);
|
||||
}
|
||||
if (region != NULL) {
|
||||
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x lr in %s --> 0x%x\n", count, backLR, backFP,
|
||||
OsGetRegionNameOrFilePath(region),
|
||||
backLR - OsGetTextRegionBase(region, runProcess));
|
||||
region = NULL;
|
||||
} else
|
||||
PrintExcInfo("lr in %s --> 0x%x\n", info.f_path, info.ip);
|
||||
#else
|
||||
PrintExcInfo("\n");
|
||||
#endif
|
||||
{
|
||||
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x\n", count, backLR, backFP);
|
||||
} else {
|
||||
PrintExcInfo("\n");
|
||||
}
|
||||
} else {
|
||||
(VOID)memcpy_s(&callChain[count], sizeof(IpInfo), &info, sizeof(IpInfo));
|
||||
}
|
||||
count++;
|
||||
if ((count == OS_MAX_BACKTRACE) || (backFP == tmpFP)) {
|
||||
if ((count == maxDepth) || (backFP == tmpFP)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
VOID BackTraceSub(UINTPTR regFP)
|
||||
{
|
||||
(VOID)BackTraceGet(regFP, NULL, OS_MAX_BACKTRACE);
|
||||
}
|
||||
|
||||
VOID BackTrace(UINT32 regFP)
|
||||
@@ -891,7 +973,7 @@ VOID OsDataAbortExcHandleEntry(ExcContext *excBufAddr)
|
||||
#endif /* __LINUX_ARM_ARCH__ */
|
||||
#endif /* LOSCFG_GDB */
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#define EXC_WAIT_INTER 50U
|
||||
#define EXC_WAIT_TIME 2000U
|
||||
|
||||
@@ -940,7 +1022,6 @@ STATIC VOID WaitAllCpuStop(UINT32 cpuID)
|
||||
|
||||
STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
|
||||
{
|
||||
OsProcessSuspendAllTask();
|
||||
while (1) {
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
if ((g_currHandleExcCpuID == INVALID_CPUID) || (g_currHandleExcCpuID == currCpuID)) {
|
||||
@@ -967,28 +1048,32 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
LOCKDEP_CLEAR_LOCKS();
|
||||
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
/* Only the current CPU anomaly */
|
||||
if (g_currHandleExcCpuID == INVALID_CPUID) {
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
g_currHandleExcPID = OsCurrProcessGet()->processID;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
#ifndef LOSCFG_SAVE_EXCINFO
|
||||
if (g_excFromUserMode[currCpuID] == FALSE) {
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
|
||||
}
|
||||
#endif
|
||||
} else if (g_excFromUserMode[currCpuID] == TRUE) {
|
||||
/* Both cores raise exceptions, and the current core is a user-mode exception.
|
||||
* Both cores are abnormal and come from the same process
|
||||
*/
|
||||
if (OsCurrProcessGet()->processID == g_currHandleExcPID) {
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
OsExcRestore();
|
||||
while (1) {
|
||||
ret = LOS_TaskSuspend(OsCurrTaskGet()->taskID);
|
||||
PrintExcInfo("%s supend task :%u failed: 0x%x\n", __FUNCTION__, OsCurrTaskGet()->taskID, ret);
|
||||
}
|
||||
ret = LOS_TaskDelete(OsCurrTaskGet()->taskID);
|
||||
LOS_Panic("%s supend task :%u failed: 0x%x\n", __FUNCTION__, OsCurrTaskGet()->taskID, ret);
|
||||
}
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
|
||||
OsWaitOtherCoresHandleExcEnd(currCpuID);
|
||||
} else {
|
||||
if (g_excFromUserMode[g_currHandleExcCpuID] == TRUE) {
|
||||
if ((g_currHandleExcCpuID < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuID] == TRUE)) {
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||
@@ -998,17 +1083,18 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
while (1) {}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef LOSCFG_SAVE_EXCINFO
|
||||
/* use halt ipi to stop other active cores */
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
|
||||
WaitAllCpuStop(currCpuID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID OsCheckCpuStatus(VOID)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsCheckAllCpuStatus();
|
||||
#else
|
||||
g_currHandleExcCpuID = ArchCurrCpuid();
|
||||
@@ -1017,10 +1103,6 @@ STATIC VOID OsCheckCpuStatus(VOID)
|
||||
|
||||
LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
UINT16 runCount;
|
||||
#endif
|
||||
|
||||
if ((excBufAddr->regCPSR & CPSR_MASK_MODE) == CPSR_USER_MODE) {
|
||||
g_minAddr = USER_ASPACE_BASE;
|
||||
g_maxAddr = USER_ASPACE_BASE + USER_ASPACE_SIZE;
|
||||
@@ -1033,23 +1115,7 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||
|
||||
OsCheckCpuStatus();
|
||||
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
while (1) {
|
||||
OsProcessSuspendAllTask();
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
LOS_SpinLock(&g_taskSpin);
|
||||
runCount = OS_PROCESS_GET_RUNTASK_COUNT(OsCurrProcessGet()->processStatus);
|
||||
LOS_SpinUnlock(&g_taskSpin);
|
||||
if (runCount == 1) {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
/* Wait for the end of the Console task to avoid multicore printing code */
|
||||
OsWaitConsoleSendTaskPend(OsCurrTaskGet()->taskID);
|
||||
@@ -1059,6 +1125,11 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
|
||||
{
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
SetExcInfoIndex(0);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* You are not allowed to add any other print information before this exception information */
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
@@ -1114,7 +1185,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
|
||||
OsPrintExcHead(far);
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsAllCpuStatusOutput();
|
||||
#endif
|
||||
|
||||
@@ -1126,7 +1197,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
if (g_curNestCount[ArchCurrCpuid()] == 1) {
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
if (func != NULL) {
|
||||
#ifndef LOSCFG_BLACKBOX
|
||||
SetExcInfoIndex(0);
|
||||
#endif
|
||||
OsSysStateSave(&intCount, &lockCount);
|
||||
OsRecordExcInfoTime();
|
||||
OsSysStateRestore(intCount, lockCount);
|
||||
@@ -1155,6 +1228,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
BBoxNotifyError(EVENT_PANIC, MODULE_SYSTEM, "Crash in kernel", 1);
|
||||
#endif
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
@@ -1162,14 +1238,14 @@ __attribute__((noinline)) VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
UartVprintf(fmt, ap);
|
||||
OsVprintf(fmt, ap, EXC_OUTPUT);
|
||||
va_end(ap);
|
||||
__asm__ __volatile__("swi 0");
|
||||
while (1);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
/* stack protector */
|
||||
UINT32 __stack_chk_guard = 0xd00a0dff;
|
||||
USED UINT32 __stack_chk_guard = 0xd00a0dff;
|
||||
|
||||
VOID __stack_chk_fail(VOID)
|
||||
{
|
||||
@@ -1201,7 +1277,11 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
|
||||
framePtr = Get_Fp();
|
||||
while ((framePtr > stackStart) && (framePtr < stackEnd) && IS_ALIGNED(framePtr, sizeof(CHAR *))) {
|
||||
tmpFramePtr = framePtr;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
linkReg = *(UINTPTR *)(tmpFramePtr + sizeof(UINTPTR));
|
||||
#else
|
||||
linkReg = *(UINTPTR *)framePtr;
|
||||
#endif
|
||||
if (index >= jumpCount) {
|
||||
LR[count++] = linkReg;
|
||||
if (count == recordCount) {
|
||||
@@ -1209,7 +1289,11 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
|
||||
}
|
||||
}
|
||||
index++;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
framePtr = *(UINTPTR *)framePtr;
|
||||
#else
|
||||
framePtr = *(UINTPTR *)(tmpFramePtr - sizeof(UINTPTR));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* if linkReg is not enough,clean up the last of the effective LR as the end. */
|
||||
|
||||
@@ -85,7 +85,7 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
|
||||
taskContext->LR = (UINTPTR)OsTaskExit; /* LR should be kept, to distinguish it's THUMB or ARM instruction */
|
||||
taskContext->R0 = taskID; /* R0 */
|
||||
|
||||
#ifdef LOSCFG_INTERWORK_THUMB
|
||||
#ifdef LOSCFG_THUMB
|
||||
taskContext->regCPSR = PSR_MODE_SVC_THUMB; /* CPSR (Enable IRQ and FIQ interrupts, THUMNB-mode) */
|
||||
#else
|
||||
taskContext->regCPSR = PSR_MODE_SVC_ARM; /* CPSR (Enable IRQ and FIQ interrupts, ARM-mode) */
|
||||
@@ -105,7 +105,15 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStack, UINT32 parentStackSize)
|
||||
{
|
||||
VOID *cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
|
||||
LosTaskCB *task = OsCurrTaskGet();
|
||||
sig_cb *sigcb = &task->sig;
|
||||
VOID *cloneStack = NULL;
|
||||
|
||||
if (sigcb->sigContext != NULL) {
|
||||
cloneStack = (VOID *)((UINTPTR)sigcb->sigContext - sizeof(TaskContext));
|
||||
} else {
|
||||
cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
|
||||
}
|
||||
|
||||
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
|
||||
((TaskContext *)childStack)->R0 = 0;
|
||||
@@ -115,7 +123,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR tas
|
||||
{
|
||||
LOS_ASSERT(context != NULL);
|
||||
|
||||
#ifdef LOSCFG_INTERWORK_THUMB
|
||||
#ifdef LOSCFG_THUMB
|
||||
context->regCPSR = PSR_MODE_USR_THUMB;
|
||||
#else
|
||||
context->regCPSR = PSR_MODE_USR_ARM;
|
||||
@@ -126,7 +134,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR tas
|
||||
context->PC = (UINTPTR)taskEntry;
|
||||
}
|
||||
|
||||
VOID OsInitSignalContext(VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param)
|
||||
VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param)
|
||||
{
|
||||
IrqContext *newSp = (IrqContext *)signalContext;
|
||||
(VOID)memcpy_s(signalContext, sizeof(IrqContext), sp, sizeof(IrqContext));
|
||||
|
||||
@@ -325,6 +325,14 @@ _osExceptDataAbortHdl:
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
_osExcPageFaultReturn:
|
||||
LDMFD SP!, {R4-R11}
|
||||
|
||||
MOV R0, SP
|
||||
STR R7, [SP, #0]
|
||||
SUB SP, SP, #(12 * 4) @ sp - sizeof(IrqContext), reserved for signal
|
||||
MOV R1, SP
|
||||
BLX OsSaveSignalContext
|
||||
MOV SP, R0
|
||||
|
||||
ADD SP, SP, #(2 * 4)
|
||||
LDMFD SP, {R13, R14}^
|
||||
ADD SP, SP, #(2 * 4) @ Jump reserved fileds
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_cpup_pri.h"
|
||||
#endif
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#include "los_hook.h"
|
||||
|
||||
/* spinlock for hwi module, only available on SMP mode */
|
||||
LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin);
|
||||
@@ -84,7 +84,7 @@ VOID OsInterrupt(UINT32 intNum)
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqStart();
|
||||
#endif
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, intNum);
|
||||
hwiForm = (&g_hwiForm[intNum]);
|
||||
#ifndef LOSCFG_NO_SHARED_IRQ
|
||||
while (hwiForm->pstNext != NULL) {
|
||||
@@ -107,6 +107,7 @@ VOID OsInterrupt(UINT32 intNum)
|
||||
#endif
|
||||
++g_hwiFormCnt[intNum];
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, intNum);
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqEnd(intNum);
|
||||
#endif
|
||||
|
||||
373
arch/arm/arm/src/pmu/armv7_pmu.c
Normal file
373
arch/arm/arm/src/pmu/armv7_pmu.c
Normal file
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#include "armv7_pmu_pri.h"
|
||||
#include "perf_pmu_pri.h"
|
||||
#include "los_hw_cpu.h"
|
||||
#include "asm/platform.h"
|
||||
|
||||
OS_PMU_INTS(LOSCFG_KERNEL_CORE_NUM, g_pmuIrqNr);
|
||||
STATIC HwPmu g_armv7Pmu;
|
||||
|
||||
STATIC INLINE UINT32 Armv7PmncRead(VOID)
|
||||
{
|
||||
UINT32 value = 0;
|
||||
__asm__ volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID Armv7PmncWrite(UINT32 value)
|
||||
{
|
||||
value &= ARMV7_PMNC_MASK;
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c12, 0" : : "r"(value));
|
||||
ISB;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 Armv7PmuOverflowed(UINT32 pmnc)
|
||||
{
|
||||
return pmnc & ARMV7_OVERFLOWED_MASK;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 Armv7PmuCntOverflowed(UINT32 pmnc, UINT32 index)
|
||||
{
|
||||
return pmnc & ARMV7_CNT2BIT(ARMV7_IDX2CNT(index));
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 Armv7CntValid(UINT32 index)
|
||||
{
|
||||
return index <= ARMV7_IDX_COUNTER_LAST;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID Armv7PmuSelCnt(UINT32 index)
|
||||
{
|
||||
UINT32 counter = ARMV7_IDX2CNT(index);
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c12, 5" : : "r" (counter));
|
||||
ISB;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID Armv7PmuSetCntPeriod(UINT32 index, UINT32 period)
|
||||
{
|
||||
if (!Armv7CntValid(index)) {
|
||||
PRINT_ERR("CPU writing wrong counter %u\n", index);
|
||||
} else if (index == ARMV7_IDX_CYCLE_COUNTER) {
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (period));
|
||||
} else {
|
||||
Armv7PmuSelCnt(index);
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (period));
|
||||
}
|
||||
}
|
||||
|
||||
STATIC INLINE VOID Armv7BindEvt2Cnt(UINT32 index, UINT32 value)
|
||||
{
|
||||
PRINT_DEBUG("bind event: %u to counter: %u\n", value, index);
|
||||
Armv7PmuSelCnt(index);
|
||||
value &= ARMV7_EVTYPE_MASK;
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (value));
|
||||
}
|
||||
|
||||
STATIC INLINE VOID Armv7EnableCnt(UINT32 index)
|
||||
{
|
||||
UINT32 counter = ARMV7_IDX2CNT(index);
|
||||
PRINT_DEBUG("index : %u, counter: %u\n", index, counter);
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c12, 1" : : "r" (ARMV7_CNT2BIT(counter)));
|
||||
}
|
||||
|
||||
STATIC INLINE VOID Armv7DisableCnt(UINT32 index)
|
||||
{
|
||||
UINT32 counter = ARMV7_IDX2CNT(index);
|
||||
PRINT_DEBUG("index : %u, counter: %u\n", index, counter);
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c12, 2" : : "r" (ARMV7_CNT2BIT(counter)));
|
||||
}
|
||||
|
||||
STATIC INLINE VOID Armv7EnableCntInterrupt(UINT32 index)
|
||||
{
|
||||
UINT32 counter = ARMV7_IDX2CNT(index);
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c14, 1" : : "r" (ARMV7_CNT2BIT(counter)));
|
||||
ISB;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID Armv7DisableCntInterrupt(UINT32 index)
|
||||
{
|
||||
UINT32 counter = ARMV7_IDX2CNT(index);
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c14, 2" : : "r" (ARMV7_CNT2BIT(counter)));
|
||||
/* Clear the overflow flag in case an interrupt is pending. */
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (ARMV7_CNT2BIT(counter)));
|
||||
ISB;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 Armv7PmuGetOverflowStatus(VOID)
|
||||
{
|
||||
UINT32 value;
|
||||
|
||||
__asm__ volatile("mrc p15, 0, %0, c9, c12, 3" : "=r" (value));
|
||||
value &= ARMV7_FLAG_MASK;
|
||||
__asm__ volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (value));
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
STATIC VOID Armv7EnableEvent(Event *event)
|
||||
{
|
||||
UINT32 cnt = event->counter;
|
||||
|
||||
if (!Armv7CntValid(cnt)) {
|
||||
PRINT_ERR("CPU enabling wrong PMNC counter IRQ enable %u\n", cnt);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->period == 0) {
|
||||
PRINT_INFO("event period value not valid, counter: %u\n", cnt);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Enable counter and interrupt, and set the counter to count
|
||||
* the event that we're interested in.
|
||||
*/
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
|
||||
Armv7DisableCnt(cnt);
|
||||
|
||||
/*
|
||||
* Set event (if destined for PMNx counters)
|
||||
* We only need to set the event for the cycle counter if we
|
||||
* have the ability to perform event filtering.
|
||||
*/
|
||||
if (cnt != ARMV7_IDX_CYCLE_COUNTER) {
|
||||
Armv7BindEvt2Cnt(cnt, event->eventId);
|
||||
}
|
||||
|
||||
/* Enable interrupt for this counter */
|
||||
Armv7EnableCntInterrupt(cnt);
|
||||
Armv7EnableCnt(cnt);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
PRINT_DEBUG("enabled event: %u cnt: %u\n", event->eventId, cnt);
|
||||
}
|
||||
|
||||
STATIC VOID Armv7DisableEvent(Event *event)
|
||||
{
|
||||
UINT32 cnt = event->counter;
|
||||
|
||||
if (!Armv7CntValid(cnt)) {
|
||||
PRINT_ERR("CPU enabling wrong PMNC counter IRQ enable %u\n", cnt);
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
Armv7DisableCnt(cnt);
|
||||
Armv7DisableCntInterrupt(cnt);
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
|
||||
STATIC VOID Armv7StartAllCnt(VOID)
|
||||
{
|
||||
PRINT_DEBUG("starting pmu...\n");
|
||||
|
||||
/* Enable all counters */
|
||||
UINT32 reg = Armv7PmncRead() | ARMV7_PMNC_E;
|
||||
if (g_armv7Pmu.cntDivided) {
|
||||
reg |= ARMV7_PMNC_D;
|
||||
} else {
|
||||
reg &= ~ARMV7_PMNC_D;
|
||||
}
|
||||
|
||||
Armv7PmncWrite(reg);
|
||||
HalIrqUnmask(g_pmuIrqNr[ArchCurrCpuid()]);
|
||||
}
|
||||
|
||||
STATIC VOID Armv7StopAllCnt(VOID)
|
||||
{
|
||||
PRINT_DEBUG("stopping pmu...\n");
|
||||
/* Disable all counters */
|
||||
Armv7PmncWrite(Armv7PmncRead() & ~ARMV7_PMNC_E);
|
||||
|
||||
HalIrqMask(g_pmuIrqNr[ArchCurrCpuid()]);
|
||||
}
|
||||
|
||||
STATIC VOID Armv7ResetAllCnt(VOID)
|
||||
{
|
||||
UINT32 index;
|
||||
|
||||
/* The counter and interrupt enable registers are unknown at reset. */
|
||||
for (index = ARMV7_IDX_CYCLE_COUNTER; index < ARMV7_IDX_MAX_COUNTER; index++) {
|
||||
Armv7DisableCnt(index);
|
||||
Armv7DisableCntInterrupt(index);
|
||||
}
|
||||
|
||||
/* Initialize & Reset PMNC: C and P bits and D bits */
|
||||
UINT32 reg = ARMV7_PMNC_P | ARMV7_PMNC_C | (g_armv7Pmu.cntDivided ? ARMV7_PMNC_D : 0);
|
||||
Armv7PmncWrite(reg);
|
||||
}
|
||||
|
||||
STATIC VOID Armv7SetEventPeriod(Event *event)
|
||||
{
|
||||
if (event->period != 0) {
|
||||
PRINT_INFO("counter: %u, period: 0x%x\n", event->counter, event->period);
|
||||
Armv7PmuSetCntPeriod(event->counter, PERIOD_CALC(event->period));
|
||||
}
|
||||
}
|
||||
|
||||
STATIC UINTPTR Armv7ReadEventCnt(Event *event)
|
||||
{
|
||||
UINT32 value = 0;
|
||||
UINT32 index = event->counter;
|
||||
|
||||
if (!Armv7CntValid(index)) {
|
||||
PRINT_ERR("CPU reading wrong counter %u\n", index);
|
||||
} else if (index == ARMV7_IDX_CYCLE_COUNTER) {
|
||||
__asm__ volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (value));
|
||||
} else {
|
||||
Armv7PmuSelCnt(index);
|
||||
__asm__ volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (value));
|
||||
}
|
||||
|
||||
if (value < PERIOD_CALC(event->period)) {
|
||||
if (Armv7PmuCntOverflowed(Armv7PmuGetOverflowStatus(), event->counter)) {
|
||||
value += event->period;
|
||||
}
|
||||
} else {
|
||||
value -= PERIOD_CALC(event->period);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
STATIC const UINT32 g_armv7Map[] = {
|
||||
[PERF_COUNT_HW_CPU_CYCLES] = ARMV7_PERF_HW_CYCLES,
|
||||
[PERF_COUNT_HW_INSTRUCTIONS] = ARMV7_PERF_HW_INSTRUCTIONS,
|
||||
[PERF_COUNT_HW_DCACHE_REFERENCES] = ARMV7_PERF_HW_DCACHES,
|
||||
[PERF_COUNT_HW_DCACHE_MISSES] = ARMV7_PERF_HW_DCACHE_MISSES,
|
||||
[PERF_COUNT_HW_ICACHE_REFERENCES] = ARMV7_PERF_HW_ICACHES,
|
||||
[PERF_COUNT_HW_ICACHE_MISSES] = ARMV7_PERF_HW_ICACHE_MISSES,
|
||||
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = ARMV7_PERF_HW_BRANCHES,
|
||||
[PERF_COUNT_HW_BRANCH_MISSES] = ARMV7_PERF_HW_BRANCE_MISSES,
|
||||
};
|
||||
|
||||
UINT32 Armv7PmuMapEvent(UINT32 eventType, BOOL reverse)
|
||||
{
|
||||
if (!reverse) { /* Common event to armv7 real event */
|
||||
if (eventType < ARRAY_SIZE(g_armv7Map)) {
|
||||
return g_armv7Map[eventType];
|
||||
}
|
||||
return eventType;
|
||||
} else { /* Armv7 real event to common event */
|
||||
UINT32 i;
|
||||
for (i = 0; i < ARRAY_SIZE(g_armv7Map); i++) {
|
||||
if (g_armv7Map[i] == eventType) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return PERF_HW_INVALID_EVENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID Armv7PmuIrqHandler(VOID)
|
||||
{
|
||||
UINT32 index;
|
||||
PerfRegs regs;
|
||||
|
||||
PerfEvent *events = &(g_armv7Pmu.pmu.events);
|
||||
UINT32 eventNum = events->nr;
|
||||
|
||||
/* Get and reset the IRQ flags */
|
||||
UINT32 pmnc = Armv7PmuGetOverflowStatus();
|
||||
if (!Armv7PmuOverflowed(pmnc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
(VOID)memset_s(®s, sizeof(PerfRegs), 0, sizeof(PerfRegs));
|
||||
OsPerfFetchIrqRegs(®s);
|
||||
|
||||
Armv7StopAllCnt();
|
||||
|
||||
for (index = 0; index < eventNum; index++) {
|
||||
Event *event = &(events->per[index]);
|
||||
/*
|
||||
* We have a single interrupt for all counters. Check that
|
||||
* each counter has overflowed before we process it.
|
||||
*/
|
||||
if (!Armv7PmuCntOverflowed(pmnc, event->counter) || (event->period == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Armv7PmuSetCntPeriod(event->counter, PERIOD_CALC(event->period));
|
||||
|
||||
OsPerfUpdateEventCount(event, event->period);
|
||||
OsPerfHandleOverFlow(event, ®s);
|
||||
}
|
||||
Armv7StartAllCnt();
|
||||
}
|
||||
|
||||
UINT32 OsGetPmuMaxCounter(VOID)
|
||||
{
|
||||
return ARMV7_IDX_MAX_COUNTER;
|
||||
}
|
||||
|
||||
UINT32 OsGetPmuCycleCounter(VOID)
|
||||
{
|
||||
return ARMV7_IDX_CYCLE_COUNTER;
|
||||
}
|
||||
|
||||
UINT32 OsGetPmuCounter0(VOID)
|
||||
{
|
||||
return ARMV7_IDX_COUNTER0;
|
||||
}
|
||||
|
||||
STATIC HwPmu g_armv7Pmu = {
|
||||
.canDivided = TRUE,
|
||||
.enable = Armv7EnableEvent,
|
||||
.disable = Armv7DisableEvent,
|
||||
.start = Armv7StartAllCnt,
|
||||
.stop = Armv7StopAllCnt,
|
||||
.clear = Armv7ResetAllCnt,
|
||||
.setPeriod = Armv7SetEventPeriod,
|
||||
.readCnt = Armv7ReadEventCnt,
|
||||
.mapEvent = Armv7PmuMapEvent,
|
||||
};
|
||||
|
||||
UINT32 OsHwPmuInit(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 index;
|
||||
|
||||
for (index = 0; index < LOSCFG_KERNEL_CORE_NUM; index++) {
|
||||
ret = LOS_HwiCreate(g_pmuIrqNr[index], 0, 0, Armv7PmuIrqHandler, 0);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("pmu %u irq handler register failed\n", g_pmuIrqNr[index]);
|
||||
return ret;
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
HalIrqSetAffinity(g_pmuIrqNr[index], CPUID_TO_AFFI_MASK(index));
|
||||
#endif
|
||||
}
|
||||
ret = OsPerfHwInit(&g_armv7Pmu);
|
||||
return ret;
|
||||
}
|
||||
@@ -29,47 +29,76 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ZPFS_VFS_ZPFS_H
|
||||
#define ZPFS_VFS_ZPFS_H
|
||||
|
||||
#include <fs/fs.h>
|
||||
|
||||
#include "compiler.h"
|
||||
#include "smp.h"
|
||||
#include "arch_config.h"
|
||||
#include "los_base.h"
|
||||
#include "los_typedef.h"
|
||||
#include "los_hw.h"
|
||||
#include "los_atomic.h"
|
||||
#include "los_arch_mmu.h"
|
||||
#include "gic_common.h"
|
||||
#include "los_task_pri.h"
|
||||
|
||||
#ifdef LOSCFG_FS_ZPFS
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
|
||||
#define ZPFS_NAME "zpfs"
|
||||
#define ZPFS_LEVELS 3
|
||||
extern VOID reset_vector(VOID);
|
||||
|
||||
typedef struct ZpfsDir {
|
||||
char *relPath;
|
||||
int index;
|
||||
int openEntry;
|
||||
} ZpfsDir;
|
||||
struct OsCpuInit {
|
||||
ArchCpuStartFunc cpuStart;
|
||||
VOID *arg;
|
||||
Atomic initFlag;
|
||||
};
|
||||
|
||||
typedef struct ZpfsEntry {
|
||||
struct inode *mountedInode;
|
||||
char *mountedPath;
|
||||
char *mountedRelpath;
|
||||
} ZpfsEntry;
|
||||
STATIC struct OsCpuInit g_cpuInit[CORE_NUM - 1] = {0};
|
||||
|
||||
typedef struct ZpfsConfig {
|
||||
char *patchTarget;
|
||||
struct inode *patchTargetInode;
|
||||
struct inode *patchInode;
|
||||
VOID HalArchCpuOn(UINT32 cpuNum, ArchCpuStartFunc func, struct SmpOps *ops, VOID *arg)
|
||||
{
|
||||
struct OsCpuInit *cpuInit = &g_cpuInit[cpuNum - 1];
|
||||
UINTPTR startEntry = (UINTPTR)&reset_vector - KERNEL_VMM_BASE + SYS_MEM_BASE;
|
||||
INT32 ret;
|
||||
|
||||
int entryCount;
|
||||
ZpfsEntry orgEntry[ZPFS_LEVELS];
|
||||
} ZpfsConfig;
|
||||
cpuInit->cpuStart = func;
|
||||
cpuInit->arg = arg;
|
||||
cpuInit->initFlag = 0;
|
||||
|
||||
ZpfsConfig *GetZpfsConfig(const struct inode *inode);
|
||||
int ZpfsPrepare(const char *source, const char *target, struct inode **inodePtr, bool force);
|
||||
void ZpfsFreeConfig(ZpfsConfig *zpfsCfg);
|
||||
void ZpfsCleanUp(const void *node, const char *target);
|
||||
bool IsZpfsFileSystem(struct inode *inode);
|
||||
DCacheFlushRange((UINTPTR)cpuInit, (UINTPTR)cpuInit + sizeof(struct OsCpuInit));
|
||||
|
||||
#endif /* LOSCFG_FS_ZPFS */
|
||||
LOS_ASSERT(ops != NULL);
|
||||
|
||||
|
||||
ret = ops->SmpCpuOn(cpuNum, startEntry);
|
||||
if (ret < 0) {
|
||||
PRINT_ERR("cpu start failed, cpu num: %u, ret: %d\n", cpuNum, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
while (!LOS_AtomicRead(&cpuInit->initFlag)) {
|
||||
WFE;
|
||||
}
|
||||
}
|
||||
|
||||
VOID HalSecondaryCpuStart(VOID)
|
||||
{
|
||||
UINT32 cpuid = ArchCurrCpuid();
|
||||
struct OsCpuInit *cpuInit = &g_cpuInit[cpuid - 1];
|
||||
|
||||
OsCurrTaskSet(OsGetMainTask());
|
||||
|
||||
LOS_AtomicSet(&cpuInit->initFlag, 1);
|
||||
SEV;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
OsArchMmuInitPerCPU();
|
||||
#endif
|
||||
|
||||
/* store each core's hwid */
|
||||
CPU_MAP_SET(cpuid, OsHwIDGet());
|
||||
HalIrqInitPercpu();
|
||||
|
||||
cpuInit->cpuStart(cpuInit->arg);
|
||||
|
||||
while (1) {
|
||||
WFI;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZPFS_VFS_ZPFS_H */
|
||||
@@ -28,6 +28,7 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define ASSEMBLY
|
||||
#include "arch_config.h"
|
||||
#include "los_vm_boot.h"
|
||||
@@ -54,6 +55,8 @@
|
||||
.extern __stack_chk_guard_setup
|
||||
.extern g_firstPageTable
|
||||
.extern g_mmuJumpPageTable
|
||||
.extern g_archMmuInitMapping
|
||||
.extern HalSecondaryCpuStart
|
||||
|
||||
.equ MPIDR_CPUID_MASK, 0xffU
|
||||
|
||||
@@ -77,14 +80,6 @@
|
||||
bl excstack_magic
|
||||
.endm
|
||||
|
||||
/* param0 is physical address, param1 virtual address, param2 is sizes, param3 is flag */
|
||||
.macro PAGE_TABLE_SET param0, param1, param2, param3
|
||||
ldr r6, =\param0
|
||||
ldr r7, =\param1
|
||||
ldr r8, =\param2
|
||||
ldr r10, =\param3
|
||||
bl page_table_build
|
||||
.endm
|
||||
.code 32
|
||||
.section ".vectors","ax"
|
||||
|
||||
@@ -184,12 +179,15 @@ reloc_img_to_bottom_done:
|
||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
|
||||
|
||||
ldr r5, =g_archMmuInitMapping
|
||||
add r5, r5, r11
|
||||
init_mmu_loop:
|
||||
ldmia r5!, {r6-r10} /* r6 = phys, r7 = virt, r8 = size, r9 = mmu_flags, r10 = name */
|
||||
cmp r8, 0 /* if size = 0, the mmu init done */
|
||||
beq init_mmu_done
|
||||
bl page_table_build
|
||||
b init_mmu_loop
|
||||
init_mmu_done:
|
||||
orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
|
||||
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
||||
add r4, r4, r11
|
||||
@@ -205,9 +203,7 @@ reloc_img_to_bottom_done:
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[paIndex] = pt entry */
|
||||
rsb r7, r11, r6, lsl #20 /* r7: va */
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
||||
#endif
|
||||
bl _bootaddr_setup
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
|
||||
bl mmu_setup /* set up the mmu */
|
||||
#endif
|
||||
/* clear out the interrupt and exception stack and set magic num to check the overflow */
|
||||
@@ -317,6 +313,7 @@ reset_platform:
|
||||
mov r0, #0
|
||||
mov pc, r0 // Jump to reset vector
|
||||
#endif
|
||||
|
||||
cpu_start:
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
ldr r4, =g_firstPageTable /* r4 = physical address of translation table and clear it */
|
||||
@@ -330,7 +327,8 @@ cpu_start:
|
||||
|
||||
bl mmu_setup
|
||||
#endif
|
||||
bl secondary_cpu_start
|
||||
|
||||
bl HalSecondaryCpuStart
|
||||
b .
|
||||
|
||||
secondary_cpu_init:
|
||||
@@ -370,9 +368,9 @@ sp_set:
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r9
|
||||
mov r10, r6
|
||||
bfc r10, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r10
|
||||
add r8, r8, #(1 << 20)
|
||||
sub r8, r8, #1
|
||||
lsr r6, #20 /* r6 = physical address / MB */
|
||||
@@ -380,7 +378,7 @@ page_table_build:
|
||||
lsr r8, #20 /* r8 = roundup(size, MB) */
|
||||
|
||||
page_table_build_loop:
|
||||
orr r12, r10, r6, lsl #20 /* r12: flags | physAddr */
|
||||
orr r12, r9, r6, lsl #20 /* r12: flags | physAddr */
|
||||
str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
|
||||
add r6, #1 /* physAddr+ */
|
||||
add r7, #1 /* l1Index++ */
|
||||
@@ -422,24 +420,6 @@ excstack_magic_loop:
|
||||
blt excstack_magic_loop
|
||||
bx lr
|
||||
|
||||
/*
|
||||
* 0xe51ff004 = "ldr pc, [pc, #-4]"
|
||||
* next addr value will be the real booting addr
|
||||
*/
|
||||
_bootaddr_setup:
|
||||
mov r0, #0
|
||||
ldr r1, =0xe51ff004
|
||||
str r1, [r0]
|
||||
|
||||
add r0, r0, #4
|
||||
ldr r1, =SYS_MEM_BASE
|
||||
str r1, [r0]
|
||||
|
||||
dsb
|
||||
isb
|
||||
|
||||
bx lr
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
.extern __stack_chk_guard_setup
|
||||
.extern g_firstPageTable
|
||||
.extern g_mmuJumpPageTable
|
||||
.extern g_archMmuInitMapping
|
||||
|
||||
.equ MPIDR_CPUID_MASK, 0xffU
|
||||
|
||||
@@ -77,14 +78,6 @@
|
||||
bl excstack_magic
|
||||
.endm
|
||||
|
||||
/* param0 is physical address, param1 virtual address, param2 is sizes, param3 is flag */
|
||||
.macro PAGE_TABLE_SET param0, param1, param2, param3
|
||||
ldr r6, =\param0
|
||||
ldr r7, =\param1
|
||||
ldr r8, =\param2
|
||||
ldr r10, =\param3
|
||||
bl page_table_build
|
||||
.endm
|
||||
.code 32
|
||||
.section ".vectors","ax"
|
||||
|
||||
@@ -161,12 +154,15 @@ reloc_img_to_bottom_done:
|
||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
|
||||
|
||||
ldr r5, =g_archMmuInitMapping
|
||||
add r5, r5, r11
|
||||
init_mmu_loop:
|
||||
ldmia r5!, {r6-r10} /* r6 = phys, r7 = virt, r8 = size, r9 = mmu_flags, r10 = name */
|
||||
cmp r8, 0 /* if size = 0, the mmu init done */
|
||||
beq init_mmu_done
|
||||
bl page_table_build
|
||||
b init_mmu_loop
|
||||
init_mmu_done:
|
||||
orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
|
||||
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
||||
add r4, r4, r11
|
||||
@@ -231,9 +227,6 @@ warm_reset:
|
||||
LDR r0, =__exception_handlers
|
||||
MCR p15, 0, r0, c12, c0, 0
|
||||
|
||||
cmp r11, #0
|
||||
bne cpu_start
|
||||
|
||||
clear_bss:
|
||||
ldr r0, =__bss_start
|
||||
ldr r2, =__bss_end
|
||||
@@ -310,11 +303,6 @@ reset_platform:
|
||||
mov r0, #0
|
||||
mov pc, r0 // Jump to reset vector
|
||||
#endif
|
||||
cpu_start:
|
||||
bl secondary_cpu_start
|
||||
b .
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* set sp for current cpu
|
||||
@@ -336,9 +324,9 @@ sp_set:
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r9
|
||||
mov r10, r6
|
||||
bfc r10, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r10
|
||||
add r8, r8, #(1 << 20)
|
||||
sub r8, r8, #1
|
||||
lsr r6, #20 /* r6 = physical address / MB */
|
||||
@@ -346,7 +334,7 @@ page_table_build:
|
||||
lsr r8, #20 /* r8 = roundup(size, MB) */
|
||||
|
||||
page_table_build_loop:
|
||||
orr r12, r10, r6, lsl #20 /* r12: flags | physAddr */
|
||||
orr r12, r9, r6, lsl #20 /* r12: flags | physAddr */
|
||||
str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
|
||||
add r6, #1 /* physAddr+ */
|
||||
add r7, #1 /* l1Index++ */
|
||||
@@ -388,24 +376,6 @@ excstack_magic_loop:
|
||||
blt excstack_magic_loop
|
||||
bx lr
|
||||
|
||||
/*
|
||||
* 0xe51ff004 = "ldr pc, [pc, #-4]"
|
||||
* next addr value will be the real booting addr
|
||||
*/
|
||||
_bootaddr_setup:
|
||||
mov r0, #0
|
||||
ldr r1, =0xe51ff004
|
||||
str r1, [r0]
|
||||
|
||||
add r0, r0, #4
|
||||
ldr r1, =SYS_MEM_BASE
|
||||
str r1, [r0]
|
||||
|
||||
dsb
|
||||
isb
|
||||
|
||||
bx lr
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "user_copy.h"
|
||||
#include "arm_user_copy.h"
|
||||
#include "arm_user_clear.h"
|
||||
#include "securec.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_vm_map.h"
|
||||
@@ -96,15 +97,9 @@ INT32 LOS_UserMemClear(unsigned char *buf, UINT32 len)
|
||||
if (!LOS_IsUserAddressRange((vaddr_t)(UINTPTR)buf, len)) {
|
||||
(VOID)memset_s(buf, len, 0, len);
|
||||
} else {
|
||||
unsigned char *tmp = (unsigned char *)LOS_MemAlloc(OS_SYS_MEM_ADDR, len);
|
||||
if (tmp == NULL) {
|
||||
return -ENOMEM;
|
||||
if (_arm_clear_user(buf, len)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
(VOID)memset_s(tmp, len, 0, len);
|
||||
if (_arm_user_copy(buf, tmp, len) != 0) {
|
||||
ret = -EFAULT;
|
||||
}
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, tmp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
41
arch/arm/gic/BUILD.gn
Normal file
41
arch/arm/gic/BUILD.gn
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = []
|
||||
|
||||
if (defined(LOSCFG_ARCH_GIC_V2)) {
|
||||
sources += [ "gic_v2.c" ]
|
||||
} else if (defined(LOSCFG_ARCH_GIC_V3)) {
|
||||
sources += [ "gic_v3.c" ]
|
||||
}
|
||||
}
|
||||
@@ -31,18 +31,10 @@ include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
# LOCAL_SRCS := $(wildcard *.c)
|
||||
|
||||
ifeq ($(LOSCFG_ARCH_GIC_V2), y)
|
||||
LOCAL_SRCS := gic_v2.c
|
||||
else ifeq ($(LOSCFG_ARCH_GIC_V3), y)
|
||||
LOCAL_SRCS := gic_v3.c
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/base/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/arm/src/include \
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
||||
include $(MODULE)
|
||||
|
||||
@@ -40,7 +40,7 @@ STATIC_ASSERT(OS_USER_HWI_MAX <= 1020, "hwi max is too large!");
|
||||
|
||||
STATIC UINT32 g_curIrqNum = 0;
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/*
|
||||
* filter description
|
||||
* 0b00: forward to the cpu interfaces specified in cpu_mask
|
||||
@@ -144,11 +144,14 @@ VOID HalIrqInit(VOID)
|
||||
/* enable gic distributor control */
|
||||
GIC_REG_32(GICD_CTLR) = 1;
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/* register inter-processor interrupt */
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_HALT, 0xa0, 0, OsMpHaltHandler, 0);
|
||||
#ifdef LOSCFG_KERNEL_SMP_CALL
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_FUNC_CALL, 0xa0, 0, OsMpFuncCallHandler, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -169,7 +172,7 @@ VOID HalIrqHandler(VOID)
|
||||
|
||||
OsInterrupt(vector);
|
||||
|
||||
/* use orignal iar to do the EOI */
|
||||
/* use original iar to do the EOI */
|
||||
GIC_REG_32(GICC_EOIR) = iar;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ STATIC INLINE UINT64 MpidrToAffinity(UINT64 mpidr)
|
||||
(MPIDR_AFF_LEVEL(mpidr, 0)));
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
|
||||
STATIC UINT32 NextCpu(UINT32 cpu, UINT32 cpuMask)
|
||||
{
|
||||
@@ -399,11 +399,14 @@ VOID HalIrqInit(VOID)
|
||||
|
||||
HalIrqInitPercpu();
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/* register inter-processor interrupt */
|
||||
LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
|
||||
LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);
|
||||
LOS_HwiCreate(LOS_MP_IPI_HALT, 0xa0, 0, OsMpScheduleHandler, 0);
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_HALT, 0xa0, 0, OsMpScheduleHandler, 0);
|
||||
#ifdef LOSCFG_KERNEL_SMP_CALL
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_FUNC_CALL, 0xa0, 0, OsMpFuncCallHandler, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ extern VOID HalIrqClear(UINT32 vector);
|
||||
extern CHAR *HalIrqVersion(VOID);
|
||||
extern UINT32 HalCurIrqGet(VOID);
|
||||
extern UINT32 HalIrqSetPrio(UINT32 vector, UINT8 priority);
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
extern VOID HalIrqSendIpi(UINT32 target, UINT32 ipi);
|
||||
extern VOID HalIrqSetAffinity(UINT32 vector, UINT32 cpuMask);
|
||||
#endif
|
||||
|
||||
61
arch/arm/include/perf.h
Normal file
61
arch/arm/include/perf.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder 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.
|
||||
*/
|
||||
|
||||
#ifndef _PERF_H
|
||||
#define _PERF_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define OsPerfArchFetchCallerRegs(regs) \
|
||||
do { \
|
||||
(regs)->pc = (UINTPTR)__builtin_return_address(0); \
|
||||
(regs)->fp = (UINTPTR)__builtin_frame_address(0); \
|
||||
} while (0)
|
||||
|
||||
#define OsPerfArchFetchIrqRegs(regs, tcb) \
|
||||
do { \
|
||||
(regs)->pc = (tcb)->pc; \
|
||||
(regs)->fp = (tcb)->fp; \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _PERF_H */
|
||||
86
bsd/BUILD.gn
Normal file
86
bsd/BUILD.gn
Normal file
@@ -0,0 +1,86 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_COMPAT_BSD)
|
||||
module_name = "libbsd"
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"kern/bus_if.c",
|
||||
"kern/device_if.c",
|
||||
"kern/kern_condvar.c",
|
||||
"kern/kern_timeout.c",
|
||||
"kern/subr_bus.c",
|
||||
"kern/subr_kobj.c",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
sources += [
|
||||
"arm/autoconf.c",
|
||||
"arm/hw_user_copy.S",
|
||||
"arm/in_cksum.c",
|
||||
"arm/in_cksum_arm.S",
|
||||
"arm/nexus.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_RANDOM)) {
|
||||
sources += [
|
||||
"crypto/rijndael/rijndael-alg-fst.c",
|
||||
"crypto/rijndael/rijndael-api-fst.c",
|
||||
"crypto/sha2/sha256c.c",
|
||||
"dev/random/hash.c",
|
||||
"dev/random/yarrow.c",
|
||||
"libkern/explicit_bzero.c",
|
||||
]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
group("bsd") {
|
||||
public_deps = [ ":$module_name" ]
|
||||
|
||||
deps = [
|
||||
"compat/linuxkpi",
|
||||
"dev/usb",
|
||||
]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
".",
|
||||
"kern",
|
||||
]
|
||||
configs = [
|
||||
"compat/linuxkpi:public",
|
||||
"dev/usb:public",
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,14 @@
|
||||
config COMPAT_BSD
|
||||
bool "Enable FreeBSD"
|
||||
default y
|
||||
select COMPAT_LINUXKPI
|
||||
|
||||
help
|
||||
Answer Y to enable LiteOS support FreeBSD.
|
||||
|
||||
config COMPAT_LINUXKPI
|
||||
bool "Enable linuxkpi" if COMPAT_BSD
|
||||
default y
|
||||
|
||||
help
|
||||
Answer Y to enable LiteOS support compatible layer for linuxkpi.
|
||||
|
||||
12
bsd/Makefile
12
bsd/Makefile
@@ -33,22 +33,14 @@ MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := $(wildcard kern/*.c)
|
||||
|
||||
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.S)
|
||||
LOCAL_SRCS += $(wildcard $(ARCH)/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(ARCH)/*.S)
|
||||
|
||||
ifeq ($(LOSCFG_DRIVERS_RANDOM), y)
|
||||
LOCAL_SRCS += $(wildcard crypto/rijndael/*.c) \
|
||||
$(wildcard crypto/sha2/*.c) \
|
||||
$(wildcard dev/random/*.c) \
|
||||
$(wildcard libkern/*.c)
|
||||
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/base/include \
|
||||
-I $(LITEOSTOPDIR)/bsd \
|
||||
-I $(LITEOSTOPDIR)/bsd/kern \
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
include $(MODULE)
|
||||
|
||||
57
bsd/compat/linuxkpi/BUILD.gn
Normal file
57
bsd/compat/linuxkpi/BUILD.gn
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_COMPAT_BSD)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/adp.c",
|
||||
"src/linux_completion.c",
|
||||
"src/linux_interrupt.c",
|
||||
"src/linux_sched.c",
|
||||
"src/linux_semaphore.c",
|
||||
"src/linux_timer.c",
|
||||
"src/linux_wakelock.c",
|
||||
"src/linux_workqueue.c",
|
||||
"src/prctl.c",
|
||||
"src/tzdst.c",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_HRTIMER_ENABLE)) {
|
||||
sources += [ "src/linux_hrtimer.c" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -37,10 +37,4 @@ ifneq ($(LOSCFG_HRTIMER_ENABLE), y)
|
||||
LOCAL_SRCS := $(filter-out src/linux_hrtimer.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/base/include \
|
||||
-I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
include $(MODULE)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../../../../third_party/Linux_Kernel/fs/jffs2/mtd.h
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../../../../third_party/Linux_Kernel/fs/jffs2/mtd_list.h
|
||||
149
bsd/dev/usb/BUILD.gn
Normal file
149
bsd/dev/usb/BUILD.gn
Normal file
@@ -0,0 +1,149 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_USB)
|
||||
module_name = "usb_base"
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"implementation/bsd_busspace.c",
|
||||
"implementation/bsd_kernel.c",
|
||||
"implementation/usb_btree.c",
|
||||
"implementation/usb_busdma_loader.c",
|
||||
"implementation/usb_init.c",
|
||||
"implementation/usb_version.c",
|
||||
"usb_debug.c",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB)) {
|
||||
sources += [
|
||||
"controller/usb_controller.c",
|
||||
"quirk/usb_quirk.c",
|
||||
"usb_dev.c",
|
||||
"usb_device.c",
|
||||
"usb_dynamic.c",
|
||||
"usb_error.c",
|
||||
"usb_generic.c",
|
||||
"usb_handle_request.c",
|
||||
"usb_hub.c",
|
||||
"usb_if.c",
|
||||
"usb_lookup.c",
|
||||
"usb_mbuf.c",
|
||||
"usb_parse.c",
|
||||
"usb_process.c",
|
||||
"usb_request.c",
|
||||
"usb_transfer.c",
|
||||
"usb_util.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM)) {
|
||||
sources += [ "net/if_cdce.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_ETHERNET)) {
|
||||
sources += [
|
||||
"net/if_axe.c",
|
||||
"net/if_axge.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_RNDIS_HOST)) {
|
||||
sources += [ "net/if_urndis.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM) ||
|
||||
defined(LOSCFG_DRIVERS_USB_ETHERNET) ||
|
||||
defined(LOSCFG_DRIVERS_USB_RNDIS_HOST)) {
|
||||
sources += [
|
||||
"net/usb_eth_drv.c",
|
||||
"net/usb_ethernet.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM) ||
|
||||
defined(LOSCFG_DRIVERS_USB_SERIAL)) {
|
||||
sources += [
|
||||
"serial/u3g.c",
|
||||
"serial/usb_serial.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HOST_EHCI)) {
|
||||
sources += [
|
||||
"controller/ehci.c",
|
||||
"controller/ehci_pci.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HOST_XHCI) ||
|
||||
defined(LOSCFG_DRIVERS_USB_HOST_XHCI_FOR_PORT2)) {
|
||||
sources += [
|
||||
"controller/xhci.c",
|
||||
"controller/xhci_pci.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_WIRELESS)) {
|
||||
sources += [ "linux_usb.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_MASS_STORAGE)) {
|
||||
sources += [ "storage/umass.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HID_CLASS) &&
|
||||
defined(LOSCFG_DRIVERS_HDF_INPUT)) {
|
||||
sources += [
|
||||
"input/uhid.c",
|
||||
"usb_hid.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"//drivers/framework/model/input/driver",
|
||||
"//drivers/framework/include/core",
|
||||
"//drivers/framework/core/common/include/host",
|
||||
"//drivers/framework/utils",
|
||||
"//drivers/framework/osal",
|
||||
"//drivers/framework/ability/sbuf/include",
|
||||
"//drivers/framework/include/osal",
|
||||
]
|
||||
}
|
||||
|
||||
configs += [ "$HDFTOPDIR:hdf_config" ]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
defines = [ "USB_DEBUG_VAR=5" ]
|
||||
include_dirs = [ "." ]
|
||||
include_dirs += [ "$LITEOSTHIRDPARTY/FreeBSD/sys/dev/evdev" ]
|
||||
}
|
||||
@@ -15,7 +15,7 @@ config DRIVERS_USB_HOST_DRIVER
|
||||
choice
|
||||
depends on DRIVERS_USB_HOST_DRIVER
|
||||
prompt "USB HCD"
|
||||
default y
|
||||
default DRIVERS_USB_HOST_EHCI
|
||||
help
|
||||
Enable EHCI for USB 2.0.
|
||||
Enable XHCI for USB 3.0
|
||||
|
||||
@@ -135,6 +135,4 @@ LOCAL_SRCS += $(INPUT_SRC)/uhid.c \
|
||||
$(CORE_SRC)/usb_hid.c
|
||||
endif
|
||||
|
||||
LOCAL_FLAGS += $(LITEOS_GCOV_OPTS)
|
||||
|
||||
include $(HDF_DRIVER)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../../third_party/NuttX/include/nuttx/usb/storage.h
|
||||
74
build.sh
74
build.sh
@@ -30,44 +30,40 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
set -e
|
||||
|
||||
echo "sh param:$1,$2,$3,$4,$5,$6,$7"
|
||||
destination=".config"
|
||||
config_file=""
|
||||
tee=""
|
||||
outdir="../..$3/test_info/gen/kernel/test"
|
||||
if [ "$5" = "tee" ]; then
|
||||
tee="_tee"
|
||||
fi
|
||||
productName="$(basename $7)"
|
||||
source="tools/build/config/${productName}_release.config"
|
||||
if [ "$2" = "clang" ]; then
|
||||
if [ "$4" = "debug" ]; then
|
||||
config_file="${productName}_$2$tee.config"
|
||||
source="tools/build/config/debug/$config_file"
|
||||
else
|
||||
config_file="${productName}_$2_release$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
fi
|
||||
elif [ "$2" = "gcc" ]; then
|
||||
if [ "$4" = "debug" ]; then
|
||||
config_file="${productName}_debug_shell$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
else
|
||||
config_file="${productName}_release$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
fi
|
||||
fi
|
||||
if [ -d "./out" ]; then
|
||||
rm -rf ./out
|
||||
fi
|
||||
if [ -f "$destination" ]; then
|
||||
rm -rf $destination
|
||||
fi
|
||||
if [ ! -f "$source" ]; then
|
||||
source="$7/config/sys/$config_file"
|
||||
fi
|
||||
cp $source $destination
|
||||
board_name=${1}
|
||||
ohos_build_compiler=${2}
|
||||
root_build_dir=${3}
|
||||
ohos_build_type=${4}
|
||||
tee_enable=${5}
|
||||
device_company=${6}
|
||||
product_path=${7}
|
||||
outdir=${8}
|
||||
ohos_version=${9}
|
||||
sysroot_path=${10}
|
||||
arch_cflags=${11}
|
||||
device_path=${12}
|
||||
compile_prefix=${13}
|
||||
liteos_config_file=${14}
|
||||
|
||||
mkdir -p $outdir
|
||||
cp kernel_test.sources $outdir
|
||||
echo "sh param:" "$@"
|
||||
|
||||
if [ "x" != "x${sysroot_path}" ]; then
|
||||
export SYSROOT_PATH=${sysroot_path}
|
||||
fi
|
||||
|
||||
if [ "x" != "x${arch_cflags}" ]; then
|
||||
export ARCH_CFLAGS="${arch_cflags}"
|
||||
fi
|
||||
|
||||
export PRODUCT_PATH="${product_path}"
|
||||
export DEVICE_PATH="${device_path}"
|
||||
|
||||
export OUTDIR="${outdir}"
|
||||
export KCONFIG_CONFIG="${liteos_config_file}"
|
||||
export LITEOS_MENUCONFIG_H="${outdir}/config.h"
|
||||
export LITEOS_CONFIG_FILE="${outdir}/.config"
|
||||
export LITEOS_COMPILER_PATH="${compile_prefix%/*}/"
|
||||
export CROSS_COMPILE="${compile_prefix##*/}"
|
||||
|
||||
mkdir -p "${outdir}"
|
||||
make -j all VERSION="${ohos_version}"
|
||||
|
||||
38
compat/BUILD.gn
Normal file
38
compat/BUILD.gn
Normal file
@@ -0,0 +1,38 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("compat") {
|
||||
deps = [ "posix" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
configs = [ "posix:public" ]
|
||||
}
|
||||
59
compat/posix/BUILD.gn
Normal file
59
compat/posix/BUILD.gn
Normal file
@@ -0,0 +1,59 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder 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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_COMPAT_POSIX)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/errno.c",
|
||||
"src/malloc.c",
|
||||
"src/map_error.c",
|
||||
"src/misc.c",
|
||||
"src/mqueue.c",
|
||||
"src/posix_memalign.c",
|
||||
"src/pthread.c",
|
||||
"src/pthread_attr.c",
|
||||
"src/pthread_cond.c",
|
||||
"src/pthread_mutex.c",
|
||||
"src/sched.c",
|
||||
"src/semaphore.c",
|
||||
"src/socket.c",
|
||||
"src/stdio.c",
|
||||
"src/stdlib.c",
|
||||
"src/time.c",
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -33,10 +33,8 @@ MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := $(wildcard src/*.c)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/compat/posix/src \
|
||||
-I $(LITEOSTOPDIR)/kernel/base/include \
|
||||
LOCAL_INCLUDE := -I $(LITEOSTOPDIR)/compat/posix/src
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
||||
|
||||
include $(MODULE)
|
||||
|
||||
@@ -81,6 +81,11 @@ typedef union send_receive_t {
|
||||
short data;
|
||||
} mode_s;
|
||||
|
||||
struct mqnotify {
|
||||
pid_t pid;
|
||||
struct sigevent notify;
|
||||
};
|
||||
|
||||
/* TYPE DEFINITIONS */
|
||||
struct mqarray {
|
||||
UINT32 mq_id : 31;
|
||||
@@ -90,7 +95,7 @@ struct mqarray {
|
||||
mode_s mode_data; /* mode data of mqueue */
|
||||
uid_t euid; /* euid of mqueue */
|
||||
gid_t egid; /* egid of mqueue */
|
||||
fd_set mq_fdset; /* mqueue sysFd bit map */
|
||||
struct mqnotify mq_notify;
|
||||
LosQueueCB *mqcb;
|
||||
struct mqpersonal *mq_personal;
|
||||
};
|
||||
@@ -417,7 +422,8 @@ extern int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen,
|
||||
extern ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen,
|
||||
unsigned int *msgPrio, const struct timespec *absTimeout);
|
||||
|
||||
extern void mqueue_refer(int sysFd);
|
||||
extern void MqueueRefer(int sysFd);
|
||||
extern int OsMqNotify(mqd_t personal, const struct sigevent *sigev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user