diff --git a/1.log b/1.log index fdabbb9b6..f17ad3421 100644 --- a/1.log +++ b/1.log @@ -1,5 +1,3 @@ -请输入板卡名字,使用默认板卡: -netduino2 [ 0]: ==============================sys flash layer info============================ [ 0]: [0] [0x8000000 0x8001fff] bootstrap 8192B [ 0]: [1] [0x8002000 0x8003fff] dtbo 8192B @@ -27,7 +25,7 @@ netduino2 [ 0]th_knl: create thread 0x20002800 [ 0]th_knl: sema init cnt:1 max:1. [ 0]th_knl: create task is 0x20002200 -[ 0]th_knl: init task text is 0x80ec000. +[ 0]th_knl: init task text is 0x808c000. [ 0]th_knl: task alloc [0x20004000 - 0x2000c197] [ 0]th_knl: mkrtos init done.. [ 0]th_knl: mkrtos running.. @@ -41,26 +39,26 @@ netduino2 [ 0]th_knl: \|__| \|__|\|__| \|__|\|__|\|__| \|__| \|_______|\_________\ [ 0]th_knl: \|_________| [ 0]th_knl: Complie Time:Mar 8 2025 22:49:37 -[ 7]: sema init cnt:1 max:1. +[ 11]: sema init cnt:1 max:1. stack 0x200055c0 1800 stack 0x20006dc0 1800 -[ 17]: sema init cnt:2 max:2. +[ 27]: sema init cnt:2 max:2. init.. -[ 20]th_init: sema init cnt:1 max:1. -[ 27]th_init: sema init cnt:1 max:1. -[ 28]th_init: sema init cnt:0 max:1. -[ 29]th_init: create thread 0x2000d800 +[ 33]th_init: sema init cnt:1 max:1. +[ 43]th_init: sema init cnt:1 max:1. +[ 44]th_init: sema init cnt:0 max:1. +[ 45]th_init: create thread 0x2000d800 cons init... cmd_line:block /dev/block parse_cfg args[0] = block parse_cfg args[1] = /dev/block parse_cfg cmd_params_num:2 -block addr is [0x804e000] -[ 41]th_init: sema init cnt:1 max:1. -[ 41]th_init: create task is 0x2000ede4 -[ 42]th_init: create thread 0x2000f800 -[ 43]th_init: sema init cnt:0 max:1. -[ 44]th_init: task alloc [0x20011000 - 0x2001523b] +block addr is [0x806a000] +[ 59]th_init: sema init cnt:1 max:1. +[ 59]th_init: create task is 0x2000ede4 +[ 61]th_init: create thread 0x2000f800 +[ 61]th_init: sema init cnt:0 max:1. +[ 62]th_init: task alloc [0x20011000 - 0x2001523b] stack:0x200119f0 size:1536. app_load 1 cp_args:0x20011fd0 app_load 1 cp_args:0x20011fc4 @@ -72,15 +70,15 @@ parse_cfg args[0] = appfs parse_cfg args[1] = -m parse_cfg args[2] = /bin parse_cfg args[3] = -d -parse[ 59]: sema init cnt:0 max:1. -_cfg args[4] = /dev/block -parse_cfg cmd_params_num:5 -appfs addr is [0x803a000] -[ 64]th_init: sema init cnt:1 max:1. -[ 64]th_init: create task is 0x2000f194 -[ 66]th_init: create thread 0x20015800 -[ 68]th_init: sema init cnt:0 max:1. -[ 70]th_init: task alloc [0x20017000 - 0x2001c43b] +parse_cfg args[4] = /dev/block +parse_cfg cmd_params[ 83]: sema init cnt:0 max:1. +_num:5 +appfs addr is [0x8056000] +[ 86]th_init: sema init cnt:1 max:1. +[ 86]th_init: create task is 0x2000f194 +[ 88]th_init: create thread 0x20015800 +[ 88]th_init: sema init cnt:0 max:1. +[ 90]th_init: task alloc [0x20017000 - 0x2001c43b] stack:0x20018610 size:2048. app_load 1 cp_args:0x20018df0 app_load 1 cp_args:0x20018dec @@ -88,222 +86,803 @@ app_load 1 cp_args:0x20018de4 app_load 1 cp_args:0x20018de0 app_load 1 cp_args:0x20018dd4 app_load 2 cp_args:0x20018dd4 -app_load 2 cp_args:0x2tty i0018de0 +app_load 2 cp_args:0x20018de0 app_load 2 cp_args:0x20018de4 -app_nit... -load 2 cp_args:0x20018dec +app_load 2 cp_args:0x20018dec app_load 2 cp_args:0x20018df0 pid:27 stack:0x20018d90 -[ 89]: sema init cnt:1 max:1. cmd_line:sh parse_cfg args[0] = sh -parse_cfg cmd_params_num:1 -sh addr is [0x805b000] -[ 96]th_init: sema init cnt:1 max:1. -[ 96]th_init: create task is 0x200100d8 -[ 99]th_init: create thread 0x2001c800 -[ 99]th_init: sema init cnt:0 max:1. -tty init... -[ 102]th_init: task alloc [0x2001e000 - 0x20026d5f] -tty init... -stack:0x200229f0 size:2048. -tty init... -tty app_load 1 cp_args:0x200231d4 -app_l[ 109]: sema init cnt:0 max:1. -init... -oad 2 cp_args:0x200231d4 -pid:29 stack:0x200231tty init... -a0 +parse_cfg tty init... +cmd_params_num:1 +sh addr is [0x80b1000] +[ 113]th_init: sema init cnt:1 max:1. +[ 113]th_init: create task is 0x200100d8 +[ 116]th_init: create thread 0x2001c800 +[ 116]th_init: sema init cnt:0 max:1. +[ 119]th_init: task alloc [0x2001e000 - 0x20026d77] +[ 121]: sema init cnt:1 max:1. +stack:0x20022a08 size:2048. +app_load 1 cp_args:0x200231ec +app_load 2 cp_args:0x200231ec +pid:29 stack:0x200231b8 +[ 129]: sema init cnt:0 max:1. run app num is 3. tty init... -[ 127]: sema init cnt:1 max:1. -[ 129]: sema init cnt:0 max:1. +tty init... +tty init... +tty init... +[ 147]: sema init cnt:0 max:1. +tty init... +tty init... +[ 155]: sema init cnt:1 max:1. +tty init... block init.. tty init... -stack 0x20012000 800tty init... -tty init... +tty init...[ 172]: sema init cnt:1 max:1. -[ 145]th_blk: sema init cnt:1 max:1. +tty init.stack 0x2001200.. tty init... +0 800 tty init... +[ 183]th_blk: sema init cnt:1 max:1. tty init... -[ 152]: sema init cnt:1 max:1. -register [/dev/block] success. -tty init..args[0]:appfs. +register [/dev/blocktty init... +] success. +args[0]:appfs +args[1]:-msh ipc init. -tty init... -args[1]:-m args[2]:/bin args[3]:-d -sh ipc init. -args[4]:/dev/block -stack 0x20018e38 800stack 0x200231 -[ 185]th_appf: sema init cnt:1 max:1. -f0 800 -[ 188]: sema init cnt:1 max:1. -mount patty init... -th:/bintty in -it... +stack 0x20023208 800args[4]:/dev/block +[ 214]: sema init cnt:1 max:1. + tty init... -args[0]:shflash mem_addr:0x8020000 blk_size: -0x1000 blk_nr:0x7e0 -[ 208]th_appf: share mem:[0x20028000 0x20029000] +tty init... +stack 0x20018e38 800tty init... + +[ 221]th_appf: sema init cnt:1 max:1. +args[0]:sh +mount path:/bin -block_buf addrmkrtos:0x20028000 -:/$ register [/bin] success. -[ 300]th_knl: knl main run.. +flash mem_addr:0x8020000 blk_size:0x1000 blk_nr:0x7e0mkrtos: +/$ [ 244]th_appf: share mem:[0x20028000 0x20029000] +block_buf addr:0x20028000 +register [/bin] success. +[ 253]th_knl: knl main run.. -mkrtos:/$ -mkrtos:/$ -mkrtos:/$ fatfs -pm run fatfs. -fatfs addr is [0x80d7000] -[ 3891]th_shel: sema init cnt:1 max:1. -[ 3891]th_shel: create task is 0x20016a90 -[ 3892]th_shel: create thread 0x20029800 -[ 3893]th_shel: sema init cnt:0 max:1. -[ 3894]th_shel: task alloc [0x20030000 - 0x200551f7] -stack:0x200306a0 size:2048. -app_load 1 cp_args:0x20030e80 -app_load 2 cp_args:0x20030e80 -pid:38 stack:0x20030e50 -[pm] watch pid:38, sig hd:37[ 3932]: sema init cnt:0 max:1. +mkrtos:/$ vi /bin/init.cfg +pm run vi. +params[1]: /bin/init.cfg +vi addr is [0x80e7000] +[ 3994]th_shel: sema init cnt:1 max:1. +[ 3994]th_shel: create task is 0x20016a90 +[ 3995]th_shel: create thread 0x20029800 +[ 3996]th_shel: sema init cnt:0 max:1. +[ 3997]th_shel: task alloc [0x20030000 - 0x20053a67] +stack:0x20050480 size:3072. +app_load 1 cp_args:0x20051064 +app_load 1 cp_args:0x20051054 +app_load 2 cp_args:0x20051054 +app_load 2 cp_args:0x20051064 +pid:38 stack:0x20051020 +[pm] watch pid:38, sig hd:37[ 4028]: sema init cnt:0 max:1. . tty init... -[ 3973]: sema init cnt:1 max:1. -tty init... -tty init... -tty init... -tty init... -tty init... -stack 0x20030f38 800 -[ 4002]: sema init cnt:1 max:1. -[ 4003]: sema init cnt:1 max:1. -register [/mnt] success. -[ 6110]: futex_unmap:664 -[ 6110]: sema 0x20016268 free. -[ 6110]: sema 0x20015768 free. -[ 6110]: sema 0x20015704 free. -[ 6110]: sema 0x20010f08 free. -[ 6110]: release thread 0x20029800, name: -[ 6110]: release tk 20016a90, name is: -watch_pid:38 pid:38 -[pm] kill pid:38 code:0. - -mkrtos:/$ -mkrtos:/$ -mkrtos:/$ -mkrtos:/$ ls -/mnt 0B -/bin 0B -/sys 0B -/dev 0B -Return: 0, 0x00000000 - -mkrtos:/$ cd mnt -Return: -2, 0xfffffffe - -mkrtos:/$ -mkrtos:/$ ls -/bin 0B -/sys 0B -/dev 0B -Return: 0, 0x00000000 - -mkrtos:/$ fatfs & -pm run fatfs. -params[1]: & -fatfs addr is [0x80d7000] -[ 13777]th_shel: sema init cnt:1 max:1. -[ 13777]th_shel: create task is 0x2001c454 -[ 13778]th_shel: create thread 0x2002a000 -[ 13779]th_shel: sema init cnt:0 max:1. -[ 13780]th_shel: task alloc [0x20030000 - 0x200551f7] -stack:0x200306a0 size:2048. -app_load 1 cp_args:0x20030e80 -app_load 1 cp_args:0x20030e7c -app_load 2 cp_args:0x20030e7c -app_load 2 cp_args:0x20030e80 -pid:45 stack:0x20030e48 -[ 13788]: sema init cnt:0 max:1. - -mkrtostty init... -[ 13799]: sema init cnt:1 max:1. -:tty init... -/$ tty init... -tty init... -tty init... -tty init... -stack 0x20030f38 800 -[ 13818]: sema init cnt:1 max:1. -[ 13819]: sema init cnt:1 max:1. -register [/mnt] success. - -mkrtos:/$ ls -/mnt 0B -/bin 0B -/sys 0B -/dev 0B -Return: 0, 0x00000000 - -mkrtos:/$ s ls -/mnt 0B -/bin 0B -/sys 0B -/dev 0B -Return: 0, 0x00000000 - -mkrtos:/$ vi /mnt/1.txt -pm run vi. -params[1]: /mnt/1.txt -vi addr is [0x8081000] -[ 25484]th_shel: sema init cnt:1 max:1. -[ 25484]th_shel: create task is 0x20027ca4 -[ 25485]th_shel: create thread 0x2002b800 -[ 25486]th_shel: sema init cnt:0 max:1. -[ 25487]th_shel: task alloc [0x20058000 - 0x2007ba67] -stack:0x20078480 size:3072. -app_load 1 cp_args:0x20079064 -app_load 1 cp_args:0x20079058 -app_load 2 cp_args:0x20079058 -app_load 2 cp_args:0x20079064 -pid:54 stack:0x20079028 -[pm] watch pid:54, sig hd:53. -[ 25618]: sema init cnt:0 max:1. -tty init... -[ 25625]: sema init cnt:1 max:1. +[ 4051]: sema init cnt:1 max:1. tty init... tty init... tty init... tty init... tty init... vi running.. -[?1049h~~~~~~~~~~~~~~~~~~~~~~- /mnt/1.txt 1/1 100%I /mnt/1.txt 1/1 100%iI /mnt/1.txt [Modified] 1/1 100%ntmain(void) I /mnt/1.txt [Modified] 2/2 100%{ I /mnt/1.txt [Modified] 3/3 100%re  return0; I /mnt/1.txt [Modified] 4/4 100%}: - /mnt/1.txt [Modified] 4/4 100%:wq[pm] watch pid:54, sig hd:57. -'/mnt/1.txt' 4L, 30C[?1049lwatch_pid:54 pid:54 +[pm] watch pid:38, sig hd:39. +[?1049h#一次读取一行,每行代表启动的应用程序block /dev/blockappfs -m /bin -d /dev/block# cpiofs -m /bin# fatfs# pin# i2c# pca9555# display# eth# snd# net# nessh~~~~~~~~~- /bin/init.cfg 1/13 7%I /bin/init.cfg 1/13 7%I /bin/init.cfg 2/13 15%I /bin/init.cfg 4/13 30%I /bin/init.cfg 5/13 38%I /bin/init.cfg 7/13 53% I /bin/init.cfg [Modified] 7/13 53%  - /bin/init.cfg [Modified] 7/13 53%:wqpm wath pid -17 err. +'/bin/init.cfg' 13L, 0C[?1049lwatch_pid:38 pid:38 -watch_pid:54 pid:54 mkrtos -:/$ [pm] kill pid:54 code:0. -[ 37135]: futex_unmap:664 -[ 37135]: sema 0x20016b90 free. -[ 37135]: sema 0x20016b2c free. -[ 37135]: sema 0x20016740 free. -[ 37135]: release thread 0x2002b800, name: -[ 37135]: release tk 20027ca4, name is: -ca  cd mnt +mkrtos:/watch_pid:38 pid:38 +$ [pm] kill pid:38 code:0. +[ 9660]: futex_unmap:664 +[ 9660]: sema 0x20016268 free. +[ 9660]: sema 0x20015754 free. +[ 9660]: sema 0x20010f6c free. +[ 9660]: release thread 0x20029800, name: +[ 9660]: release tk 20016a90, name is: + +mkrtos:/$ +mkrtos:/$ +mkrtos:/$ ls +bin 0B +sys 0B +dev 0B +Return: 0, 0x00000000 + +mkrtos:/$ cat /bin/init.cfg +[pm] watch pid:29, sig hd:39. +#一次读取一行,每行代表启动的应用程序 +block /dev/block +appfs -m /bin -d /dev/block +# cpiofs -m /bin +# fatfs +# pin +# i2c +# pca9555 +# display +# eth +# snd +# net +# nes +shReturn: 0, 0x00000000 + +mkrtos:/$ l ls +bin 0B +sys 0B +dev 0B +Return: 0, 0x00000000 + +mkrtos:/$ fatfs & +pm run fatfs. +params[1]: & +fatfs addr is [0x8077000] +[ 1067988]th_shel: sema init cnt:1 max:1. +[ 1067988]th_shel: create task is 0x2001c454 +[ 1067989]th_shel: create thread 0x2002a800 +[ 1067990]th_shel: sema init cnt:0 max:1. +[ 1067991]th_shel: task alloc [0x20030000 - 0x200551f7] +stack:0x200306a0 size:2048. +app_load 1 cp_args:0x20030e80 +app_load 1 cp_args:0x20030e7c +app_load 2 cp_args:0x20030e7c +app_load 2 cp_args:0x20030e80 +pid:44 stack:0x20030e48 + +mkrtos:/$ [ 1068021]: sema init cnt:0 max:1. +tty init... +[ 1068035]: sema init cnt:1 max:1. +tty init... +tty init... +tty init... +tty init... +tty init... +stack 0x20030f38 800 +[ 1068060]: sema init cnt:1 max:1. +[ 1068062]: sema init cnt:1 max:1. +register [/mnt] success. +ls +mnt 0B +bin 0B +sys 0B +dev 0B +Return: 0, 0x00000000 + +mkrtos:/$ cd mnt Return: 0, 0x00000000 mkrtos:/$ ls -[pm] watch pid:29, sig hd:58. -/1.txt 0B +[pm] watch pid:29, sig hd:50. +Return: 0, 0x00000000 + +mkrtos:/$ vi    vi /mnt/1.txt +pm run vi. +params[1]: /mnt/1.txt +vi addr is [0x80e7000] +[ 1075431]th_shel: sema init cnt:1 max:1. +[ 1075431]th_shel: create task is 0x2001dc90 +[ 1075432]th_shel: create thread 0x2002d800 +[ 1075433]th_shel: sema init cnt:0 max:1. +[ 1075434]th_shel: task alloc [0x20058000 - 0x2007ba67] +stack:0x20078480 size:3072. +app_load 1 cp_args:0x20079064 +app_load 1 cp_args:0x20079058 +app_load 2 cp_args:0x20079058 +app_load 2 cp_args:0x20079064 +pid:52 stack:0x20079028 +[ 1075443]: sema init cnt:0 max:1. +tty init... +[ 1075459]: sema init cnt:1 max:1. +[pm] watcttyh pid:52, sig hd:51. + init... +tty init... +tty init... +tty init... +tty init... +vi running.. +[?1049h~~~~~~~~~~~~~~~~~~~~~~- /mnt/1.txt 1/1 100%I /mnt/1.txt 1/1 100% I /mnt/1.txt [Modified] 2/2 100%v intmain(void) I /mnt/1.txt [Modified] 3/3 100%[ { I /mnt/1.txt [Modified] 4/4 100%return0; I /mnt/1.txt [Modified] 5/5 100%}- /mnt/1.txt [Modified] 5/5 100%- /mnt/1.txt [Modified] 5/5 100%:wqpm wath pid -17 err. +'/mnt/1.txt' 5L, 30C[?1049lwatch_pid:29 pid:52 +watch_pid:29 pid:52 +watch_pid:52 pid:52 + +mkrtos:/[pm] kil$ l pid:52 code:0. +[ 1089576]: futex_unmap:664 +[ 1089576]: sema 0x2001d87c free. +[ 1089576]: sema 0x2001c734 free. +[ 1089576]: sema 0x2001679c free. +[ 1089576]: release thread 0x2002d800, name: +[ 1089576]: release tk 2001dc90, name is: + +mkrtos:/$ ls +pm wath pid -17 err. +1.txt 30B Return: 0, 0x00000000 mkrtos:/$ cat 1.txt pm wath pid -17 err. + int main(void) { - return 0; +return 0; } Return: 0, 0x00000000 -mkrtos:/$ QEMU: Terminated - \ No newline at end of file +mkrtos:/$ a_net & +pm run a_net. +params[1]: & +a_net addr is [0x8025000] +[ 1128781]th_shel: sema init cnt:1 max:1. +[ 1128781]th_shel: create task is 0x2001dce0 +[ 1128782]th_shel: create thread 0x20055800 +[ 1128783]th_shel: sema init cnt:0 max:1. +[ 1128784]th_shel: task alloc [0x20058000 - 0x20072ac7] +stack:0x2005cfc8 size:2048. +app_load 1 cp_args:0x2005d7a8 +app_load 1 cp_args:0x2005d7a4 +app_load 2 cp_args:0x2005d7a4 +app_load 2 cp_args:0x2005d7a8 +pid:51 stack:0x2005d770 + +mkrtos:/$ [ 1128812]: sema init cnt:0 max:1. +tty init... +[ 1128826]: sema init cnt:1 max:1. +tty init... +tty init... +[ 1128839]: sema init cnt:1 max:1. +[ 1128840]: sema init cnt:1 max:1. +tty init... +tty init... +tty init... +net startup.. +stack 0x2005d7e8 800 +stack 0x2005dfe8 800 +stack 0x2005e7e8 800 +stack 0x2005efe8 800 +[ 1128864]th_net: sema init cnt:4 max:4. + +mkrtos:/$ +mkrtos:/$ +mkrtos:/$ ip:192.168.3.10 +netmask:255.255.255. +gw:192.168.3.1 +[ 1129919]th_net: sema init cnt:1 max:1. +[ 1129928]th_net: sema init cnt:0 max:2147483647. +[ 1129929]th_net: sema init cnt:0 max:2147483647. +[ 1129930]th_net: sema init cnt:1 max:2147483647. +[ 1129932]th_net: sema init cnt:1 max:1. +[ 1129937]th_net: create thread 0x20056800 +[ 1129947]th_net: share mem:[0x20073000 0x20073800] +lregister [/sys/net] success. +s +pm wath pid -17 err. +1.txt 30B +Return: 0, 0x00000000 + +mkrtos:/$ ls +pm wath pid -17 err. +1.txt 30B +Return: 0, 0x00000000 + +mkrtos:/$ ls +pm wath pid -17 err. +1.txt 30B +Return: 0, 0x00000000 + +mkrtos:/$ sys +sys: + cpu usage:0.0 +Return: 0, 0x00000000 + +mkrtos:/$ ls +pm wath pid -17 err. +1.txt 30B +Return: 0, 0x00000000 + +mkrtos:/$ ls +pm wath pid -17 err. +1.txt 30B +Return: 0, 0x00000000 + +mkrtos:/$ clear + +mkrtos:/$ ls +pm wath pid -17 err. +1.txt 30B +Return: 0, 0x00000000 + +mkrtos:/$ +mkrtos:/$ +mkrtos:/$ +mkrtos:/$ +mkrtos:/$ gea   a game 240  048 +[?25l2048.c 0 pts + +     + ·  ·  ·  ·  +     +     + 2  4  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 0 pts + +     + 2  4  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 0 pts + +     + 2  4  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  2  ·  +     + + ←,↑,→,↓ or q +2048.c 0 pts + +     + 2  4  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + 2  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 0 pts + +     + 2  4  ·  2  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + 2  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 4 pts + +     + 4  4  ·  2  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 4 pts + +     + 4  4  ·  2  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  2  +     + + ←,↑,→,↓ or q +2048.c 12 pts + +     + 8  2  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + 2  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 12 pts + +     + 8  2  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  2  ·  +     +     + 2  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 12 pts + +     + 8  2  2  ·  +     +     + 2  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 12 pts + +     + 8  2  2  ·  +     +     + 2  ·  ·  ·  +     +     + ·  ·  2  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 16 pts + +     + 8  4  ·  ·  +     +     + 2  ·  ·  ·  +     +     + 2  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 16 pts + +     + 8  4  ·  ·  +     +     + 2  ·  ·  ·  +     +     + 2  ·  ·  ·  +     +     + ·  ·  2  ·  +     + + ←,↑,→,↓ or q +2048.c 20 pts + +     + 8  4  2  ·  +     +     + 4  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 20 pts + +     + 8  4  2  ·  +     +     + 4  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + 2  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 20 pts + +     + 8  4  2  ·  +     +     + 4  ·  ·  ·  +     +     + 2  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 20 pts + +     + 8  4  2  ·  +     +     + 4  ·  ·  ·  +     +     + 2  ·  2  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 24 pts + +     + 8  4  2  ·  +     +     + 4  ·  ·  ·  +     +     + 4  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 24 pts + +     + 8  4  2  ·  +     +     + 4  ·  ·  ·  +     +     + 4  ·  ·  ·  +     +     + ·  ·  2  ·  +     + + ←,↑,→,↓ or q +2048.c 36 pts + +     + 8  4  4  ·  +     +     + 8  ·  ·  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 36 pts + +     + 8  4  4  ·  +     +     + 8  ·  2  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 52 pts + +     + 16  4  4  ·  +     +     + ·  ·  2  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  ·  ·  +     + + ←,↑,→,↓ or q +2048.c 52 pts + +     + 16  4  4  ·  +     +     + ·  ·  2  ·  +     +     + ·  ·  ·  ·  +     +     + ·  ·  2  ·  +     + + ←,↑,→,↓ or q + QUIT? (y/n) +[?25h +mkrtos:/$ game pushbox +[?25l + LetterShell PushBox! + ■■■■■■ + ■ ■■ + ■★ ■■● ■ + ■ ★★● ■ + ■ ■● ■ + ■ ♀ ■■■ + ■■■■■ +w,a,s,d or q + + LetterShell PushBox! + ■■■■■■ + ■ ■■ + ■★ ■■● ■ + ■ ★★● ■ + ■ ■● ■ + ■ ♀ ■■■ + ■■■■■ +w,a,s,d or q + + LetterShell PushBox! + ■■■■■■ + ■ ■■ + ■★ ■■● ■ + ■ ★★● ■ + ■ ■● ■ + ■♀ ■■■ + ■■■■■ +w,a,s,d or q + + LetterShell PushBox! + ■■■■■■ + ■ ■■ + ■★ ■■● ■ + ■ ★★● ■ + ■♀ ■● ■ + ■ ■■■ + ■■■■■ +w,a,s,d or q + + LetterShell PushBox! + ■■■■■■ + ■ ■■ + ■★ ■■● ■ + ■♀★★● ■ + ■ ■● ■ + ■ ■■■ + ■■■■■ +w,a,s,d or q + + LetterShell PushBox! + ■■■■■■ + ■ ■■ + ■♀ ■■● ■ + ■ ★★● ■ + ■ ■● ■ + ■ ■■■ + ■■■■■ +w,a,s,d or q + + LetterShell PushBox! + ■■■■■■ + ■ ■■ + ■★♀■■● ■ + ■ ★★● ■ + ■ ■● ■ + ■ ■■■ + ■■■■■ +w,a,s,d or q + + LetterShell PushBox! + ■■■■■■ + ■ ■■ + ■★ ■■● ■ + ■ ♀★● ■ + ■ ■● ■ + ■ ■■■ + ■■■■■ +w,a,s,d or q +[?25l +mkrtos:/$ clear + +mkrtos:/$ he  help + +Command List: +ls CMD -------- ls command +rm CMD -------- rm command +cd CMD -------- cd command +pwd CMD -------- pwd command +cat CMD -------- cat command +hex CMD -------- hex command +kill CMD -------- kill command +symlink CMD -------- symlink command +touch CMD -------- touch command +mkdir CMD -------- mkdir command +reboot CMD -------- reboot command +free CMD -------- free command +sys CMD -------- sys command +exit CMD -------- exit command +test_sig CMD -------- shell_test_sig command +setVar CMD -------- set var +help CMD -------- show command info +users CMD -------- list all user +cmds CMD -------- list all cmd +vars CMD -------- list all var +keys CMD -------- list all key +clear CMD -------- clear console +logSetLevel CMD -------- set log level +hexdump CMD -------- hex dump +game CMD -------- games + +mkrtos:/$ \ No newline at end of file diff --git a/TODO.md b/TODO.md index a464fd03c..501b400c7 100644 --- a/TODO.md +++ b/TODO.md @@ -11,14 +11,16 @@ * [ ] 文件系统&网络协议栈完善自动删除支持(文件描述符自动管理库) * [x] 内核信号量对象完善,支持超时(已完成)。 * [ ] 内核信号量支持优先级反转 -* [ ] FPU完善支持,目前版本偶发压栈错误 -* [ ] console 支持自动切换前后台 +* [x] TTY 支持自动切换前后台 * [x] 重构路径管理(nsfs) * [ ] 线程占用率统计 * [x] 去除原来的ipc机制(使用fastipc机制),并单独实现sleep接口,目前的ipc有概率卡死问题 * [ ] 几大组件稳定性测试 * [ ] dup, dup2等接口支持 -* [ ] fastipc FPU支持 +* [ ] FPU完整支持,fastipc FPU支持 +* [x] TTY驱动支持 +* [ ] proc支持 +* [ ] 新进程中env支持 ### mid prio * [x] net server support * [x] block driver @@ -29,11 +31,13 @@ * [x] pin drvier * [x] snd drvier * [ ] ymodem support +* [x] vi support ### low prio - [ ] toybox support - [ ] ota support - [ ] lvgl support - [ ] modbus support +- [ ] poll/select实现 #### must low prio - [ ] AT proctol support diff --git a/mkrtos_knl/CMakeLists.txt b/mkrtos_knl/CMakeLists.txt index 09041c8fa..41ffd7d22 100755 --- a/mkrtos_knl/CMakeLists.txt +++ b/mkrtos_knl/CMakeLists.txt @@ -6,6 +6,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \ -Wno-unused-function \ -Wno-unused-variable \ -Wno-builtin-declaration-mismatch \ +-Ofast \ ") # message(编译参数:${CMAKE_C_FLAGS}) diff --git a/mkrtos_knl/arch/cortex-m/link.lds b/mkrtos_knl/arch/cortex-m/link.lds index b63054b88..ee27d1a43 100644 --- a/mkrtos_knl/arch/cortex-m/link.lds +++ b/mkrtos_knl/arch/cortex-m/link.lds @@ -1,8 +1,8 @@ ENTRY(Reset_Handler) MEMORY { - RAM (arw) : ORIGIN = 0x20000000, LENGTH = 0x2000000 - FLASH (arx) : ORIGIN = 0x8000000 + 0x2000 + 0x2000, LENGTH = 0x1C000 + RAM (arw) : ORIGIN = 0x20000000, LENGTH = 0x60000 + FLASH (arx) : ORIGIN = 0x8000000 + 0x3000 + 0x1000, LENGTH = 0x10000 } SECTIONS { diff --git a/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_fs_ext.c b/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_fs_ext.c index 324c4c30a..b37412d92 100644 --- a/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_fs_ext.c +++ b/mkrtos_user/lib/letter-shell/demo/mkrtos/shell_fs_ext.c @@ -48,7 +48,7 @@ int ls(int argc, char *agrv[]) while ((ptr = readdir(dir)) != NULL) { struct stat st = {0}; - strcat(path, "/"); + // strcat(path, "/"); strcat(path, ptr->d_name); ret = stat(path, &st); // if (ret >= 0) @@ -238,3 +238,10 @@ int shell_sys_info(int argc, char *argv[]) return 0; } SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), sys, shell_sys_info, sys command); + +int shell_exit(int argc, char *argv[]) +{ + exit(0); + return 0; +} +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), exit, exit, exit command); diff --git a/mkrtos_user/lib/sys/inc/u_mutex.h b/mkrtos_user/lib/sys/inc/u_mutex.h index 104e6db95..745d3e996 100644 --- a/mkrtos_user/lib/sys/inc/u_mutex.h +++ b/mkrtos_user/lib/sys/inc/u_mutex.h @@ -7,6 +7,8 @@ typedef struct u_mutex obj_handler_t obj; } u_mutex_t; +#define U_MUTEX_INIT {.obj = HANDLER_INVALID} + int u_mutex_init(u_mutex_t *lock, obj_handler_t sema_hd); void u_mutex_lock(u_mutex_t *lock, umword_t timeout, umword_t *remain_times); void u_mutex_unlock(u_mutex_t *lock); diff --git a/mkrtos_user/lib/util/inc/u_malloc.h b/mkrtos_user/lib/util/inc/u_malloc.h index 0b5f27489..2adfaee24 100644 --- a/mkrtos_user/lib/util/inc/u_malloc.h +++ b/mkrtos_user/lib/util/inc/u_malloc.h @@ -9,5 +9,6 @@ struct allocmem void *u_malloc(size_t size); void *u_calloc(size_t size, int nmemb); +void *u_realloc(void *old, size_t size); void u_free(void *ptr); // void spurge(); diff --git a/mkrtos_user/lib/util/src/u_malloc.c b/mkrtos_user/lib/util/src/u_malloc.c index 972fb3652..1bcca1494 100644 --- a/mkrtos_user/lib/util/src/u_malloc.c +++ b/mkrtos_user/lib/util/src/u_malloc.c @@ -7,10 +7,34 @@ #include #include #include +#include #include +#include +#include +#include +#include static struct allocmem *memlocs = NULL; +static u_mutex_t lock_mutex = U_MUTEX_INIT; + +static void alloc_lock(void) +{ + obj_handler_t lock_hd; + + if (lock_mutex.obj == HANDLER_INVALID) + { + lock_hd = handler_alloc(); + assert(lock_hd != HANDLER_INVALID); + u_mutex_init(&lock_mutex, lock_hd); + } + u_mutex_lock(&lock_mutex, 0, NULL); +} +static void alloc_unlock(void) +{ + assert(lock_mutex.obj != HANDLER_INVALID); + u_mutex_unlock(&lock_mutex); +} static struct allocmem *new_alloc_mem() { @@ -83,10 +107,13 @@ struct allocmem *find_and_remove(struct allocmem *ptr, void *searchPtr) void *u_malloc(size_t size) { struct allocmem *info = NULL; + + alloc_lock(); memlocs = insert_end(memlocs, &info); if (info == NULL) { /// Failed to initialize metadata info + alloc_unlock(); return NULL; } void *ptr; @@ -101,8 +128,10 @@ void *u_malloc(size_t size) info->ptr = ptr; info->size = size; /// Return this precious pointer + alloc_unlock(); return ptr; } + alloc_unlock(); return NULL; } @@ -127,16 +156,44 @@ void *u_calloc(size_t size, int nmemb) } return newPtr; } +void *u_realloc(void *old, size_t size) +{ + struct allocmem *info; + size_t old_size; + void *new_mem = u_malloc(size); + if (!new_mem) + { + return NULL; + } + alloc_lock(); + info = find(memlocs, old); + if (info == NULL) + { + alloc_unlock(); + u_free(new_mem); + return NULL; + } + old_size = info->size; + alloc_unlock(); + memcpy(new_mem, old, old_size); + u_free(old); + return new_mem; +} void u_free(void *ptr) { if (ptr == NULL) return; + alloc_lock(); struct allocmem *info = find(memlocs, ptr); if (info == NULL) + { + alloc_unlock(); return; + } munmap(info->ptr, info->size); memlocs = find_and_remove(memlocs, ptr); + alloc_unlock(); } /// Violently Remove Everything diff --git a/mkrtos_user/server/fs/CMakeLists.txt b/mkrtos_user/server/fs/CMakeLists.txt index 2dd08bea4..4ae9078dc 100644 --- a/mkrtos_user/server/fs/CMakeLists.txt +++ b/mkrtos_user/server/fs/CMakeLists.txt @@ -4,4 +4,5 @@ cmake_minimum_required(VERSION 3.13) # add_subdirectory(cpiofs) add_subdirectory(fatfs) add_subdirectory(appfs) +# add_subdirectory(procfs) # add_subdirectory(lxext4) diff --git a/mkrtos_user/server/fs/appfs/src/appfs.c b/mkrtos_user/server/fs/appfs/src/appfs.c index e861677e2..58d750256 100644 --- a/mkrtos_user/server/fs/appfs/src/appfs.c +++ b/mkrtos_user/server/fs/appfs/src/appfs.c @@ -337,7 +337,7 @@ int appfs_create_file(fs_info_t *info, const char *path, int size) ret = appfs_check_file_exist(info, path); if (ret < 0) { - return ret; + return -EEXIST; } for (int i = 0; i < info->save.dirinfo_nr; i++) @@ -430,6 +430,8 @@ int appfs_write_file(fs_info_t *info, const char *name, void *data, int size, in // 写入数据 int write_size = MIN(size, info->save.block_size - (offset % info->save.block_size)); + write_size = MIN(dir_info->size - offset, write_size); + if (write_size != info->save.block_size) { ret = info->cb.hw_read_block(info, block_inx + k + block_offset_inx, info->buf, info->save.block_size); @@ -479,6 +481,7 @@ int appfs_read_file(fs_info_t *info, const char *name, void *data, int size, int // 写入数据 int read_size = MIN(size, info->save.block_size - (offset % info->save.block_size)); + read_size = MIN(dir_info->size - offset, read_size); ret = info->cb.hw_read_block(info, block_inx + k + block_offset_inx, info->buf, info->save.block_size); if (ret < 0) { diff --git a/mkrtos_user/server/fs/appfs/src/appfs_open.c b/mkrtos_user/server/fs/appfs/src/appfs_open.c index f2ef05d22..ff8475fe5 100644 --- a/mkrtos_user/server/fs/appfs/src/appfs_open.c +++ b/mkrtos_user/server/fs/appfs/src/appfs_open.c @@ -163,7 +163,8 @@ int appfs_open(const char *name, int flags, int mode) } else { - if (name[0] == '/') { + if (name[0] == '/') + { name++; } type = APPFS_FILE_TYPE; @@ -176,7 +177,10 @@ int appfs_open(const char *name, int flags, int mode) } if (ret < 0) { - return ret; + if (ret != -EEXIST) + { + return ret; + } } file = appfs_find_file_by_name(fs, name); if (file == NULL) @@ -430,6 +434,10 @@ int appfs_stat(const char *path, struct kstat *st) st->st_nlink = 0; return 0; } + if (path[0] == '/') + { + path++; + } file = appfs_find_file_by_name(fs, path); if (file == NULL) { diff --git a/mkrtos_user/server/fs/appfs/src/appfs_open.h b/mkrtos_user/server/fs/appfs/src/appfs_open.h index 4ead45ead..baf83410f 100644 --- a/mkrtos_user/server/fs/appfs/src/appfs_open.h +++ b/mkrtos_user/server/fs/appfs/src/appfs_open.h @@ -2,8 +2,34 @@ #include #include #include "appfs.h" +#ifdef MKRTOS #include "kstat.h" #include +#else +#include +struct kstat { + long st_dev; + int __st_dev_padding; + long __st_ino_truncated; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + long st_rdev; + int __st_rdev_padding; + long st_size; + int st_blksize; + long st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + long st_ino; +}; + +#endif enum appfs_ioctl_cmd_op { APPFS_IOCTOL_GET_ACCESS_ADDR, diff --git a/mkrtos_user/server/fs/procfs/CMakeLists.txt b/mkrtos_user/server/fs/procfs/CMakeLists.txt new file mode 100644 index 000000000..ed43da17e --- /dev/null +++ b/mkrtos_user/server/fs/procfs/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.13) + +file( + GLOB deps + src/*.c +) + +add_executable( + procfs.elf + ${deps} + ${START_SRC} +) +target_link_libraries( + procfs.elf + PUBLIC + -Bstatic + ${LIBC_NAME} + ${START_LIB} + sys + sys_util + sys_svr + fd + ${GCC_LIB_PATH}/libgcc.a +) +target_include_directories( + procfs.elf + PUBLIC + ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc + ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_svr/inc + + ${CMAKE_SOURCE_DIR}/mkrtos_user/server/fs/procfs/inc + ${CMAKE_SOURCE_DIR}/mkrtos_user/server/fs/procfs + + ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/fd +) +add_dependencies( + procfs.elf + ${START_LIB} + sys + sys_util + fd +) +set_target_properties( + procfs.elf PROPERTIES LINK_FLAGS + "-T ${CMAKE_CURRENT_LIST_DIR}/${ARCH_NAME}/link.lds ${CORTEX_M_LINK_FLAGS} --gc-section -no-dynamic-linker " + #--no-warn-rwx-segments +) +add_custom_target( + procfs_dump ALL + COMMAND + ${CMAKE_OBJCOPY} -O binary -S procfs.elf procfs.bin + COMMAND + ${CMAKE_SIZE} procfs.elf + COMMAND + mkdir -p ${CMAKE_SOURCE_DIR}/build/output/cpio + COMMAND + cp procfs.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/procfs + COMMAND + cp procfs.elf ${CMAKE_SOURCE_DIR}/build/output/procfs.elf +) + +add_dependencies(procfs_dump procfs.elf) + \ No newline at end of file diff --git a/mkrtos_user/server/fs/procfs/Readme.md b/mkrtos_user/server/fs/procfs/Readme.md new file mode 100644 index 000000000..c9bb1d632 --- /dev/null +++ b/mkrtos_user/server/fs/procfs/Readme.md @@ -0,0 +1,2 @@ + +procfs只是一个库,用于集成到每个应用中。每个应用都可以作为一个文件系统,对外提供控制方法。 diff --git a/mkrtos_user/server/fs/procfs/src/dummy.c b/mkrtos_user/server/fs/procfs/src/dummy.c new file mode 100644 index 000000000..e69de29bb diff --git a/mkrtos_user/user/app/vi/heap_stack.c b/mkrtos_user/user/app/vi/heap_stack.c index b99946498..ee11e4108 100644 --- a/mkrtos_user/user/app/vi/heap_stack.c +++ b/mkrtos_user/user/app/vi/heap_stack.c @@ -1,6 +1,6 @@ -#define HEAP_SIZE (128*1024) -#define STACK_SIZE (1024 * 3) +#define HEAP_SIZE (512) +#define STACK_SIZE (1024 * 2) #if defined(__CC_ARM) #define HEAP_ATTR SECTION("HEAP") __attribute__((zero_init)) diff --git a/mkrtos_user/user/app/vi/vi-master/vi.c b/mkrtos_user/user/app/vi/vi-master/vi.c index 3271b998f..7da78bed4 100644 --- a/mkrtos_user/user/app/vi/vi-master/vi.c +++ b/mkrtos_user/user/app/vi/vi-master/vi.c @@ -364,7 +364,7 @@ struct globals { \ FREE_PTR_TO_GLOBALS(); \ /* "" but has space for 2 chars: */ \ - IF_FEATURE_VI_SEARCH(free(last_search_pattern);) \ + IF_FEATURE_VI_SEARCH(u_free(last_search_pattern);) \ } while (0) static void edit_file(char *); // edit one file @@ -592,11 +592,11 @@ int vi_main(int argc, char **argv) /* RT-Thread team added */ fflush_all(); - free(text); - free(screen); - free(current_filename); + u_free(text); + u_free(screen); + u_free(current_filename); #if ENABLE_FEATURE_VI_DOT_CMD - free(ioq_start); + u_free(ioq_start); #endif DELETE_G(); return 0; @@ -617,13 +617,13 @@ static int init_text_buffer(char *fn) #endif /* allocate/reallocate text buffer */ - free(text); + u_free(text); text_size = 10240; screenbegin = dot = end = text = xzalloc(text_size); if (fn != current_filename) { - free(current_filename); + u_free(current_filename); current_filename = xstrdup(fn); } rc = file_insert(fn, text, 1); @@ -720,7 +720,7 @@ static void edit_file(char *fn) offset = 0; // no horizontal offset c = '\0'; #if ENABLE_FEATURE_VI_DOT_CMD - free(ioq_start); + u_free(ioq_start); ioq_start = NULL; lmc_len = 0; adding2q = 0; @@ -743,7 +743,7 @@ static void edit_file(char *fn) if (*q) colon(q); } while (p); - free(initial_cmds[n]); + u_free(initial_cmds[n]); initial_cmds[n] = NULL; n++; } @@ -855,7 +855,7 @@ static char *get_one_address(char *p, int *addr) // get colon addr, if present if (p + 1 != q) { // save copy of new pattern - free(last_search_pattern); + u_free(last_search_pattern); last_search_pattern = xstrndup(p, q - p); } p = q; @@ -1181,11 +1181,11 @@ static void colon(char *buf) #if ENABLE_FEATURE_VI_YANKMARK if (Ureg >= 0 && Ureg < 28) { - free(reg[Ureg]); // free orig line reg- for 'U' + u_free(reg[Ureg]); // u_free orig line reg- for 'U' reg[Ureg] = NULL; } /*if (YDreg < 28) - always true*/ { - free(reg[YDreg]); // free default yank/delete register + u_free(reg[YDreg]); // u_free default yank/delete register reg[YDreg] = NULL; } #endif @@ -1209,7 +1209,7 @@ static void colon(char *buf) if (args[0]) { // user wants a new filename - free(current_filename); + u_free(current_filename); current_filename = xstrdup(args); } else @@ -1958,7 +1958,7 @@ static void new_screen(int ro, int co) { char *s; - free(screen); + u_free(screen); screensize = ro * co + 8; s = screen = xmalloc(screensize); // initialize the new screen. assume this will be a empty file. @@ -2413,7 +2413,7 @@ static void flush_undo_data(void) { undo_entry = undo_stack_tail; undo_stack_tail = undo_entry->prev; - free(undo_entry); + u_free(undo_entry); } } @@ -2605,7 +2605,7 @@ static void undo_pop(void) } // Deallocate the undo object we just processed undo_stack_tail = undo_entry->prev; - free(undo_entry); + u_free(undo_entry); modified_count--; // For chained operations, continue popping all the way down the chain. if (repeat) @@ -2853,7 +2853,7 @@ static char *text_yank(char *p, char *q, int dest, int buftype) p = q; cnt = -cnt; } - free(reg[dest]); // if already a yank register, free it + u_free(reg[dest]); // if already a yank register, u_free it reg[dest] = xstrndup(p, cnt + 1); return p; } @@ -3031,7 +3031,7 @@ static int get_one_char(void) if (c != '\0') return c; // the end of the q - free(ioq_start); + u_free(ioq_start); ioq_start = NULL; // read from STDIN: } @@ -4076,7 +4076,7 @@ key_cmd_mode: if (q[0]) { // strlen(q) > 1: new pat- save it and find // there is a new pat - free(last_search_pattern); + u_free(last_search_pattern); last_search_pattern = xstrdup(q); goto dc3; // now find the pattern } diff --git a/mkrtos_user/user/app/vi/vi-master/vi_utils.c b/mkrtos_user/user/app/vi/vi-master/vi_utils.c index d60d12e20..bc7e927c1 100644 --- a/mkrtos_user/user/app/vi/vi-master/vi_utils.c +++ b/mkrtos_user/user/app/vi/vi-master/vi_utils.c @@ -224,7 +224,7 @@ int safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout) void *xzalloc(size_t size) { - void *ptr = malloc(size); + void *ptr = u_malloc(size); memset(ptr, 0, size); return ptr; } diff --git a/mkrtos_user/user/app/vi/vi-master/vi_utils.h b/mkrtos_user/user/app/vi/vi-master/vi_utils.h index c9381a6b4..adc8e5499 100644 --- a/mkrtos_user/user/app/vi/vi-master/vi_utils.h +++ b/mkrtos_user/user/app/vi/vi-master/vi_utils.h @@ -20,6 +20,7 @@ // #include #include #include +#include #define BB_VER "latest: 2021-04-07" #define BB_BT "busybox vi" @@ -262,7 +263,7 @@ } while (0) #define FREE_PTR_TO_GLOBALS() do { \ if (ENABLE_FEATURE_CLEAN_UP) { \ - free(ptr_to_globals); \ + u_free(ptr_to_globals); \ } \ } while (0) @@ -338,11 +339,26 @@ int isatty (int fd); /* At least gcc 3.4.6 on mipsel system needs optimization barrier */ #define barrier() __asm__ __volatile__("":::"memory") #endif - -#define xmalloc malloc -#define xrealloc realloc -#define xstrdup strdup -#define xstrndup strndup +static inline char *u_strdup(const char *s) +{ + size_t l = strlen(s); + char *d = u_malloc(l+1); + if (!d) return NULL; + return memcpy(d, s, l+1); +} +static inline char *u_strndup(const char *s, size_t n) +{ + size_t l = strnlen(s, n); + char *d = u_malloc(l+1); + if (!d) return NULL; + memcpy(d, s, l); + d[l] = 0; + return d; +} +#define xmalloc u_malloc +#define xrealloc u_realloc +#define xstrdup u_strdup +#define xstrndup u_strndup #define bb_putchar putchar #define bb_strtou strtoul #define bb_simple_error_msg_and_die(...) printf(__VA_ARGS__)