Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

stufF

  • Loading branch information...
commit d3cc489bb0d12ccdec980ce096dc03e5f313e2f7 1 parent 23e296b
@charliesome authored
Showing with 32,282 additions and 159 deletions.
  1. +1 −1  bochs.bxrc
  2. +52 −0 bochslinux.bxrc
  3. +15 −11 build.sh
  4. BIN  build/init.bin
  5. BIN  build/kernel.sys
  6. +1 −1  grubscript
  7. BIN  hdd.img
  8. BIN  kbin/aaa_loader_asm.o
  9. BIN  kbin/aaa_panic_asm.o
  10. BIN  kbin/ata.o
  11. BIN  kbin/console.o
  12. BIN  kbin/fs_fat.o
  13. BIN  kbin/fs_vfs.o
  14. BIN  kbin/gdt.o
  15. BIN  kbin/helper_asm.o
  16. BIN  kbin/idt.o
  17. BIN  kbin/io.o
  18. BIN  kbin/isrs_asm.o
  19. BIN  kbin/kb.o
  20. BIN  kbin/kmalloc.o
  21. BIN  kbin/main.o
  22. BIN  kbin/paging.o
  23. BIN  kbin/panic.o
  24. BIN  kbin/part.o
  25. BIN  kbin/realmode.o
  26. BIN  kbin/realmode_asm.bin
  27. BIN  kbin/realmode_asm.o
  28. BIN  kbin/realmode_ata.bin
  29. BIN  kbin/realmode_ata.o
  30. BIN  kbin/realmode_int.bin
  31. BIN  kbin/realmode_int.o
  32. BIN  kbin/string.o
  33. BIN  kbin/syscall.o
  34. BIN  kbin/syscall_asm.o
  35. BIN  kbin/task.o
  36. BIN  kbin/task_asm.o
  37. BIN  kbin/trap.o
  38. BIN  kbin/util.o
  39. +2 −1  kinc/syscall.h
  40. +5 −1 kinc/task.h
  41. +1 −3 kinc/util.h
  42. +30 −8 ksrc/ata.c
  43. +6 −4 ksrc/helper.asm
  44. +5 −1 ksrc/isrs.asm
  45. +1 −1  ksrc/loader.asm
  46. +4 −1 ksrc/main.c
  47. +5 −2 ksrc/panic.asm
  48. +1 −1  ksrc/panic.c
  49. +1 −1  ksrc/string.c
  50. +5 −2 ksrc/syscall.asm
  51. +74 −13 ksrc/syscall.c
  52. +17 −3 ksrc/task.asm
  53. +82 −58 ksrc/task.c
  54. +8 −3 ksrc/trap.c
  55. +1 −17 ksrc/util.c
  56. BIN  ubin/init.o
  57. +7 −3 uinc/csos.h
  58. BIN  user/crt.a
  59. BIN  user/crt.o
  60. BIN  user/crt/crt_asm.o
  61. BIN  user/crt/crt_c.o
  62. +70 −13 user/crt/csos.asm
  63. +147 −0 user/crt/csos.c
  64. +11 −10 user/init.c
  65. BIN  user/lua-5.1.4.tar.gz
  66. +34 −0 user/lua-5.1.4/COPYRIGHT
  67. +183 −0 user/lua-5.1.4/HISTORY
  68. +99 −0 user/lua-5.1.4/INSTALL
  69. +128 −0 user/lua-5.1.4/Makefile
  70. +37 −0 user/lua-5.1.4/README
  71. BIN  user/lua-5.1.4/doc/amazon.gif
  72. +499 −0 user/lua-5.1.4/doc/contents.html
  73. BIN  user/lua-5.1.4/doc/cover.png
  74. BIN  user/lua-5.1.4/doc/logo.gif
  75. +163 −0 user/lua-5.1.4/doc/lua.1
  76. +41 −0 user/lua-5.1.4/doc/lua.css
  77. +172 −0 user/lua-5.1.4/doc/lua.html
  78. +136 −0 user/lua-5.1.4/doc/luac.1
  79. +145 −0 user/lua-5.1.4/doc/luac.html
  80. +13 −0 user/lua-5.1.4/doc/manual.css
  81. +8,801 −0 user/lua-5.1.4/doc/manual.html
  82. +40 −0 user/lua-5.1.4/doc/readme.html
  83. +44 −0 user/lua-5.1.4/etc/Makefile
  84. +37 −0 user/lua-5.1.4/etc/README
  85. +38 −0 user/lua-5.1.4/etc/all.c
  86. +9 −0 user/lua-5.1.4/etc/lua.hpp
  87. BIN  user/lua-5.1.4/etc/lua.ico
  88. +31 −0 user/lua-5.1.4/etc/lua.pc
  89. +28 −0 user/lua-5.1.4/etc/luavs.bat
  90. +39 −0 user/lua-5.1.4/etc/min.c
  91. +50 −0 user/lua-5.1.4/etc/noparser.c
  92. +41 −0 user/lua-5.1.4/etc/strict.lua
  93. +182 −0 user/lua-5.1.4/src/Makefile
  94. +1,087 −0 user/lua-5.1.4/src/lapi.c
  95. +16 −0 user/lua-5.1.4/src/lapi.h
  96. BIN  user/lua-5.1.4/src/lapi.o
  97. +652 −0 user/lua-5.1.4/src/lauxlib.c
  98. +174 −0 user/lua-5.1.4/src/lauxlib.h
  99. BIN  user/lua-5.1.4/src/lauxlib.o
  100. +653 −0 user/lua-5.1.4/src/lbaselib.c
  101. BIN  user/lua-5.1.4/src/lbaselib.o
  102. +839 −0 user/lua-5.1.4/src/lcode.c
  103. +76 −0 user/lua-5.1.4/src/lcode.h
  104. BIN  user/lua-5.1.4/src/lcode.o
  105. +397 −0 user/lua-5.1.4/src/ldblib.c
  106. BIN  user/lua-5.1.4/src/ldblib.o
  107. +638 −0 user/lua-5.1.4/src/ldebug.c
  108. +33 −0 user/lua-5.1.4/src/ldebug.h
  109. BIN  user/lua-5.1.4/src/ldebug.o
  110. +518 −0 user/lua-5.1.4/src/ldo.c
  111. +57 −0 user/lua-5.1.4/src/ldo.h
  112. BIN  user/lua-5.1.4/src/ldo.o
  113. +164 −0 user/lua-5.1.4/src/ldump.c
  114. BIN  user/lua-5.1.4/src/ldump.o
  115. +174 −0 user/lua-5.1.4/src/lfunc.c
  116. +34 −0 user/lua-5.1.4/src/lfunc.h
  117. BIN  user/lua-5.1.4/src/lfunc.o
  118. +711 −0 user/lua-5.1.4/src/lgc.c
  119. +110 −0 user/lua-5.1.4/src/lgc.h
  120. BIN  user/lua-5.1.4/src/lgc.o
  121. BIN  user/lua-5.1.4/src/liblua.a
  122. +38 −0 user/lua-5.1.4/src/linit.c
  123. BIN  user/lua-5.1.4/src/linit.o
  124. +553 −0 user/lua-5.1.4/src/liolib.c
  125. BIN  user/lua-5.1.4/src/liolib.o
  126. +461 −0 user/lua-5.1.4/src/llex.c
  127. +81 −0 user/lua-5.1.4/src/llex.h
  128. BIN  user/lua-5.1.4/src/llex.o
  129. +128 −0 user/lua-5.1.4/src/llimits.h
  130. +263 −0 user/lua-5.1.4/src/lmathlib.c
  131. BIN  user/lua-5.1.4/src/lmathlib.o
  132. +86 −0 user/lua-5.1.4/src/lmem.c
  133. +49 −0 user/lua-5.1.4/src/lmem.h
  134. BIN  user/lua-5.1.4/src/lmem.o
  135. +666 −0 user/lua-5.1.4/src/loadlib.c
  136. BIN  user/lua-5.1.4/src/loadlib.o
  137. +214 −0 user/lua-5.1.4/src/lobject.c
  138. +381 −0 user/lua-5.1.4/src/lobject.h
  139. BIN  user/lua-5.1.4/src/lobject.o
  140. +102 −0 user/lua-5.1.4/src/lopcodes.c
  141. +268 −0 user/lua-5.1.4/src/lopcodes.h
  142. BIN  user/lua-5.1.4/src/lopcodes.o
  143. +243 −0 user/lua-5.1.4/src/loslib.c
  144. BIN  user/lua-5.1.4/src/loslib.o
  145. +1,339 −0 user/lua-5.1.4/src/lparser.c
  146. +82 −0 user/lua-5.1.4/src/lparser.h
  147. BIN  user/lua-5.1.4/src/lparser.o
  148. +214 −0 user/lua-5.1.4/src/lstate.c
  149. +169 −0 user/lua-5.1.4/src/lstate.h
  150. BIN  user/lua-5.1.4/src/lstate.o
  151. +111 −0 user/lua-5.1.4/src/lstring.c
  152. +31 −0 user/lua-5.1.4/src/lstring.h
  153. BIN  user/lua-5.1.4/src/lstring.o
  154. +869 −0 user/lua-5.1.4/src/lstrlib.c
  155. BIN  user/lua-5.1.4/src/lstrlib.o
  156. +588 −0 user/lua-5.1.4/src/ltable.c
  157. +40 −0 user/lua-5.1.4/src/ltable.h
  158. BIN  user/lua-5.1.4/src/ltable.o
  159. +287 −0 user/lua-5.1.4/src/ltablib.c
  160. BIN  user/lua-5.1.4/src/ltablib.o
  161. +75 −0 user/lua-5.1.4/src/ltm.c
  162. +54 −0 user/lua-5.1.4/src/ltm.h
  163. BIN  user/lua-5.1.4/src/ltm.o
  164. BIN  user/lua-5.1.4/src/lua
  165. +392 −0 user/lua-5.1.4/src/lua.c
  166. +388 −0 user/lua-5.1.4/src/lua.h
  167. BIN  user/lua-5.1.4/src/lua.o
  168. BIN  user/lua-5.1.4/src/luac
  169. +200 −0 user/lua-5.1.4/src/luac.c
  170. BIN  user/lua-5.1.4/src/luac.o
  171. +763 −0 user/lua-5.1.4/src/luaconf.h
  172. +53 −0 user/lua-5.1.4/src/lualib.h
  173. +227 −0 user/lua-5.1.4/src/lundump.c
  174. +36 −0 user/lua-5.1.4/src/lundump.h
  175. BIN  user/lua-5.1.4/src/lundump.o
  176. +763 −0 user/lua-5.1.4/src/lvm.c
  177. +36 −0 user/lua-5.1.4/src/lvm.h
  178. BIN  user/lua-5.1.4/src/lvm.o
  179. +82 −0 user/lua-5.1.4/src/lzio.c
  180. +67 −0 user/lua-5.1.4/src/lzio.h
  181. BIN  user/lua-5.1.4/src/lzio.o
  182. +227 −0 user/lua-5.1.4/src/print.c
  183. BIN  user/lua-5.1.4/src/print.o
  184. +26 −0 user/lua-5.1.4/test/README
  185. +27 −0 user/lua-5.1.4/test/bisect.lua
  186. +16 −0 user/lua-5.1.4/test/cf.lua
  187. +5 −0 user/lua-5.1.4/test/echo.lua
  188. +7 −0 user/lua-5.1.4/test/env.lua
  189. +32 −0 user/lua-5.1.4/test/factorial.lua
  190. +40 −0 user/lua-5.1.4/test/fib.lua
  191. +13 −0 user/lua-5.1.4/test/fibfor.lua
  192. +13 −0 user/lua-5.1.4/test/globals.lua
  193. +3 −0  user/lua-5.1.4/test/hello.lua
  194. +111 −0 user/lua-5.1.4/test/life.lua
  195. +7 −0 user/lua-5.1.4/test/luac.lua
  196. +7 −0 user/lua-5.1.4/test/printf.lua
  197. +12 −0 user/lua-5.1.4/test/readonly.lua
  198. +29 −0 user/lua-5.1.4/test/sieve.lua
  199. +66 −0 user/lua-5.1.4/test/sort.lua
  200. +12 −0 user/lua-5.1.4/test/table.lua
  201. +32 −0 user/lua-5.1.4/test/trace-calls.lua
  202. +38 −0 user/lua-5.1.4/test/trace-globals.lua
  203. +14 −0 user/lua-5.1.4/test/xd.lua
  204. BIN  user/pdclib.tar.gz
  205. +121 −0 user/pdclib/Makefile
  206. +104 −0 user/pdclib/Notes.txt
  207. +192 −0 user/pdclib/Readme.txt
  208. +27 −0 user/pdclib/functions/_PDCLIB/Xdigits.c
  209. +9 −0 user/pdclib/functions/_PDCLIB/Xdigits.d
  210. BIN  user/pdclib/functions/_PDCLIB/Xdigits.o
  211. +74 −0 user/pdclib/functions/_PDCLIB/assert.c
  212. +16 −0 user/pdclib/functions/_PDCLIB/assert.d
  213. BIN  user/pdclib/functions/_PDCLIB/assert.o
  214. +43 −0 user/pdclib/functions/_PDCLIB/atomax.c
  215. +11 −0 user/pdclib/functions/_PDCLIB/atomax.d
  216. BIN  user/pdclib/functions/_PDCLIB/atomax.o
  217. +27 −0 user/pdclib/functions/_PDCLIB/digits.c
  218. +9 −0 user/pdclib/functions/_PDCLIB/digits.d
  219. BIN  user/pdclib/functions/_PDCLIB/digits.o
  220. +63 −0 user/pdclib/functions/_PDCLIB/fflush.c
  221. +18 −0 user/pdclib/functions/_PDCLIB/fflush.d
  222. BIN  user/pdclib/functions/_PDCLIB/fflush.o
  223. +85 −0 user/pdclib/functions/_PDCLIB/filemode.c
  224. +12 −0 user/pdclib/functions/_PDCLIB/filemode.d
  225. BIN  user/pdclib/functions/_PDCLIB/filemode.o
  226. +776 −0 user/pdclib/functions/_PDCLIB/print.c
  227. +20 −0 user/pdclib/functions/_PDCLIB/print.d
  228. BIN  user/pdclib/functions/_PDCLIB/print.o
  229. +20 −0 user/pdclib/functions/_PDCLIB/seed.c
  230. +2 −0  user/pdclib/functions/_PDCLIB/seed.d
  231. BIN  user/pdclib/functions/_PDCLIB/seed.o
  232. +115 −0 user/pdclib/functions/_PDCLIB/stdarg.c
  233. +18 −0 user/pdclib/functions/_PDCLIB/stdarg.d
  234. BIN  user/pdclib/functions/_PDCLIB/stdarg.o
  235. +84 −0 user/pdclib/functions/_PDCLIB/strtox_main.c
  236. +14 −0 user/pdclib/functions/_PDCLIB/strtox_main.d
  237. BIN  user/pdclib/functions/_PDCLIB/strtox_main.o
  238. +79 −0 user/pdclib/functions/_PDCLIB/strtox_prelim.c
  239. +12 −0 user/pdclib/functions/_PDCLIB/strtox_prelim.d
  240. BIN  user/pdclib/functions/_PDCLIB/strtox_prelim.o
  241. +58 −0 user/pdclib/functions/stdio/clearerr.c
  242. +11 −0 user/pdclib/functions/stdio/clearerr.d
  243. BIN  user/pdclib/functions/stdio/clearerr.o
  244. +77 −0 user/pdclib/functions/stdio/fclose.c
  245. +16 −0 user/pdclib/functions/stdio/fclose.d
  246. BIN  user/pdclib/functions/stdio/fclose.o
  247. +29 −0 user/pdclib/functions/stdio/feof.c
  248. +11 −0 user/pdclib/functions/stdio/feof.d
  249. BIN  user/pdclib/functions/stdio/feof.o
  250. +29 −0 user/pdclib/functions/stdio/ferror.c
  251. +11 −0 user/pdclib/functions/stdio/ferror.d
  252. BIN  user/pdclib/functions/stdio/ferror.o
  253. +51 −0 user/pdclib/functions/stdio/fflush.c
  254. +14 −0 user/pdclib/functions/stdio/fflush.d
  255. BIN  user/pdclib/functions/stdio/fflush.o
  256. +30 −0 user/pdclib/functions/stdio/fgetc.c
  257. +11 −0 user/pdclib/functions/stdio/fgetc.d
  258. BIN  user/pdclib/functions/stdio/fgetc.o
  259. +30 −0 user/pdclib/functions/stdio/fgetpos.c
  260. +11 −0 user/pdclib/functions/stdio/fgetpos.d
  261. BIN  user/pdclib/functions/stdio/fgetpos.o
  262. +30 −0 user/pdclib/functions/stdio/fgets.c
  263. +11 −0 user/pdclib/functions/stdio/fgets.d
  264. BIN  user/pdclib/functions/stdio/fgets.o
  265. +82 −0 user/pdclib/functions/stdio/fopen.c
  266. +15 −0 user/pdclib/functions/stdio/fopen.d
  267. BIN  user/pdclib/functions/stdio/fopen.o
  268. +250 −0 user/pdclib/functions/stdio/fprintf.c
  269. +13 −0 user/pdclib/functions/stdio/fprintf.d
  270. BIN  user/pdclib/functions/stdio/fprintf.o
  271. +57 −0 user/pdclib/functions/stdio/fputc.c
  272. +11 −0 user/pdclib/functions/stdio/fputc.d
  273. BIN  user/pdclib/functions/stdio/fputc.o
  274. +65 −0 user/pdclib/functions/stdio/fputs.c
  275. +11 −0 user/pdclib/functions/stdio/fputs.d
  276. BIN  user/pdclib/functions/stdio/fputs.o
  277. +30 −0 user/pdclib/functions/stdio/fread.c
  278. +13 −0 user/pdclib/functions/stdio/fread.d
  279. BIN  user/pdclib/functions/stdio/fread.o
  280. +56 −0 user/pdclib/functions/stdio/freopen.c
  281. +16 −0 user/pdclib/functions/stdio/freopen.d
  282. BIN  user/pdclib/functions/stdio/freopen.o
  283. +35 −0 user/pdclib/functions/stdio/fscanf.c
  284. +13 −0 user/pdclib/functions/stdio/fscanf.d
  285. BIN  user/pdclib/functions/stdio/fscanf.o
  286. +34 −0 user/pdclib/functions/stdio/fseek.c
  287. +11 −0 user/pdclib/functions/stdio/fseek.d
  288. BIN  user/pdclib/functions/stdio/fseek.o
  289. +34 −0 user/pdclib/functions/stdio/fsetpos.c
  290. +11 −0 user/pdclib/functions/stdio/fsetpos.d
  291. BIN  user/pdclib/functions/stdio/fsetpos.o
  292. +30 −0 user/pdclib/functions/stdio/ftell.c
  293. +11 −0 user/pdclib/functions/stdio/ftell.d
  294. BIN  user/pdclib/functions/stdio/ftell.o
  295. +35 −0 user/pdclib/functions/stdio/fwrite.c
  296. +14 −0 user/pdclib/functions/stdio/fwrite.d
  297. BIN  user/pdclib/functions/stdio/fwrite.o
  298. +30 −0 user/pdclib/functions/stdio/gets.c
  299. +13 −0 user/pdclib/functions/stdio/gets.d
  300. BIN  user/pdclib/functions/stdio/gets.o
Sorry, we could not display the entire diff because too many files (551) changed.
View
2  bochs.bxrc
@@ -10,7 +10,7 @@ floppy_bootsig_check: disabled=0
# no floppya
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
-ata0-master: type=disk, mode=flat, translation=auto, path="ramdrive/hdd.img", cylinders=65, heads=16, spt=63, biosdetect=auto, model="Generic 1234"
+ata0-master: type=disk, mode=flat, translation=auto, path="hdd.img", cylinders=65, heads=16, spt=63, biosdetect=auto, model="Generic 1234"
ata2: enabled=0
ata3: enabled=0
parport1: enabled=1, file=""
View
52 bochslinux.bxrc
@@ -0,0 +1,52 @@
+# configuration file generated by Bochs
+plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, gameport=1, pci_ide=1, acpi=1, ioapic=1
+config_interface: textconfig
+display_library: wx
+memory: host=32, guest=32
+romimage: file="/usr/share/bochs/BIOS-bochs-latest"
+vgaromimage: file="/usr/share/bochs/VGABIOS-lgpl-latest"
+boot: disk
+floppy_bootsig_check: disabled=0
+# no floppya
+# no floppyb
+ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
+ata0-master: type=disk, mode=flat, translation=auto, path="hdd.img", cylinders=65, heads=16, spt=63, biosdetect=auto, model="Generic 1234"
+ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
+ata2: enabled=0
+ata3: enabled=0
+parport1: enabled=1, file=""
+parport2: enabled=0
+com1: enabled=1, mode=null, dev=""
+com2: enabled=0
+com3: enabled=0
+com4: enabled=0
+usb_uhci: enabled=0
+usb_ohci: enabled=0
+i440fxsupport: enabled=1
+vga_update_interval: 50000
+vga: extension=vbe
+cpu: count=1, ips=2000000, reset_on_triple_fault=0, cpuid_limit_winnt=0
+print_timestamps: enabled=0
+# no gdb stub
+port_e9_hack: enabled=0
+text_snapshot_check: enabled=0
+private_colormap: enabled=0
+clock: sync=none, time0=local
+# no cmosimage
+ne2k: enabled=0
+pnic: enabled=0
+sb16: enabled=0
+# no loader
+log: -
+logprefix: %t%e%d
+panic: action=ignore
+error: action=report
+info: action=report
+debug: action=ignore
+pass: action=fatal
+keyboard_type: mf
+keyboard_serial_delay: 250
+keyboard_paste_delay: 100000
+keyboard_mapping: enabled=0, map=
+user_shortcut: keys=none
+mouse: enabled=0, type=ps2
View
26 build.sh
@@ -8,22 +8,24 @@ done
CFLAGS="-std=c99 -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-stack-protector -c -masm=intel "
KCFLAGS="-iquote kinc $CFLAGS $1"
-USERCFLAGS="-Iuinc $CFLAGS"
+USERCFLAGS="-Iuinc -Iuser/pdclib/includes -Iuser/pdclib/internals $CFLAGS"
nasm -f elf -o kbin/aaa_loader_asm.o ksrc/loader.asm
nasm -f elf -o kbin/helper_asm.o ksrc/helper.asm
-nasm -f elf -o kbin/panic_asm.o ksrc/panic.asm
+nasm -f elf -o kbin/aaa_panic_asm.o ksrc/panic.asm
nasm -f elf -o kbin/isrs_asm.o ksrc/isrs.asm
nasm -f elf -o kbin/task_asm.o ksrc/task.asm
nasm -f elf -o kbin/syscall_asm.o ksrc/syscall.asm
#build the CRT
-nasm -f elf -o user/crt.o user/crt/csos.asm
+nasm -f elf -o user/crt/crt_asm.o user/crt/csos.asm
+gcc $USERCFLAGS -Iuser/pdclib/internals/ user/crt/csos.c -o user/crt/crt_c.o
+#ar q user/crt.a user/crt/*.o
#user mode crap
rm ubin/*
gcc $USERCFLAGS user/init.c -o ubin/init.o
- ld -T user_linker.ld -o build/init.bin ubin/*.o
+ ld -T user_linker.ld -o build/init.bin ubin/*.o user/pdclib/functions/stdlib/*.o user/pdclib/functions/_PDCLIB/*.o user/pdclib/functions/stdio/*.o user/pdclib/functions/string/*.o user/crt/crt_c.o
gcc -std=c99 -o util/bin2nasm util/bin2nasm.c
# custom binaries to include in image!!
@@ -41,7 +43,7 @@ gcc -std=c99 -o util/bin2nasm util/bin2nasm.c
rm kbin/tmp.asm
# int.bin
- nasm -f bin -o kbin/realmode_int.bin ksrc/realmode/int.asm
+nasm -f bin -o kbin/realmode_int.bin ksrc/realmode/int.asm
util/bin2nasm int16 < kbin/realmode_int.bin > kbin/tmp.asm
nasm -f elf -o kbin/realmode_int.o kbin/tmp.asm
rm kbin/tmp.asm
@@ -71,7 +73,7 @@ ld -T kernel_linker.ld -o build/kernel.sys kbin/*.o
gcc -std=c99 -o util/inject_symbols util/inject_symbols.c
perl util/find_symbols.pl build/kernel.sys | util/inject_symbols build/kernel.sys
-HDDIMG=ramdrive/hdd.img
+HDDIMG=hdd.img
dd if=/dev/zero of=$HDDIMG bs=33546240 count=1 status=noxfer &>/dev/null
@@ -82,11 +84,13 @@ parted --script $HDDIMG set 1 boot on
rm -rf mnt
mkdir mnt
-mount -o loop,offset=512 $HDDIMG mnt
-cp -r build/* mnt
-umount mnt
-rm -rf mnt
+sudo chmod -R 0777 mnt
+sudo mount -o loop,offset=512 $HDDIMG mnt
+sudo chmod 0777 mnt
+sudo cp -r build/* mnt
+sudo umount mnt
+sudo rm -rf mnt
grub --device-map=/dev/null --batch < grubscript &> /dev/null
-#gzip -c -9 $HDDIMG > hdd.img.gz
+#gzip -c -9 $HDDIMG > hdd.img.gz
View
BIN  build/init.bin
Binary file not shown
View
BIN  build/kernel.sys
Binary file not shown
View
2  grubscript
@@ -1,4 +1,4 @@
-device (hd0) ramdrive/hdd.img
+device (hd0) hdd.img
root (hd0,0)
setup (hd0,0)
View
BIN  hdd.img
Binary file not shown
View
BIN  kbin/aaa_loader_asm.o
Binary file not shown
View
BIN  kbin/aaa_panic_asm.o
Binary file not shown
View
BIN  kbin/ata.o
Binary file not shown
View
BIN  kbin/console.o
Binary file not shown
View
BIN  kbin/fs_fat.o
Binary file not shown
View
BIN  kbin/fs_vfs.o
Binary file not shown
View
BIN  kbin/gdt.o
Binary file not shown
View
BIN  kbin/helper_asm.o
Binary file not shown
View
BIN  kbin/idt.o
Binary file not shown
View
BIN  kbin/io.o
Binary file not shown
View
BIN  kbin/isrs_asm.o
Binary file not shown
View
BIN  kbin/kb.o
Binary file not shown
View
BIN  kbin/kmalloc.o
Binary file not shown
View
BIN  kbin/main.o
Binary file not shown
View
BIN  kbin/paging.o
Binary file not shown
View
BIN  kbin/panic.o
Binary file not shown
View
BIN  kbin/part.o
Binary file not shown
View
BIN  kbin/realmode.o
Binary file not shown
View
BIN  kbin/realmode_asm.bin
Binary file not shown
View
BIN  kbin/realmode_asm.o
Binary file not shown
View
BIN  kbin/realmode_ata.bin
Binary file not shown
View
BIN  kbin/realmode_ata.o
Binary file not shown
View
BIN  kbin/realmode_int.bin
Binary file not shown
View
BIN  kbin/realmode_int.o
Binary file not shown
View
BIN  kbin/string.o
Binary file not shown
View
BIN  kbin/syscall.o
Binary file not shown
View
BIN  kbin/syscall_asm.o
Binary file not shown
View
BIN  kbin/task.o
Binary file not shown
View
BIN  kbin/task_asm.o
Binary file not shown
View
BIN  kbin/trap.o
Binary file not shown
View
BIN  kbin/util.o
Binary file not shown
View
3  kinc/syscall.h
@@ -14,9 +14,10 @@ void sys_read(regs_t* registers);
void sys_open(regs_t* registers);
void sys_close(regs_t* registers);
void sys_write_ebx(regs_t* registers);
+void sys_exception_handler(regs_t* registers);
void syscall_handler(regs_t* registers);
void syscall_isr();
-#endif
+#endif
View
6 kinc/task.h
@@ -5,6 +5,7 @@
#include "stdbool.h"
#include "fs/vfs.h"
+#define MAX_TASKS 128
#define MAX_FDS 64
typedef struct tss
@@ -83,6 +84,7 @@ typedef struct task
task_state_t state;
char kernel_stack[8192];
vfs_stream_t* fds[MAX_FDS];
+ uint exception_handler;
}
__attribute__((__packed__)) /* so i can access the struct straight from assembly */ task_t;
@@ -103,10 +105,12 @@ typedef struct regs
}
__attribute__((__packed__)) regs_t;
+task_t* task_get(uint pid);
void task_init(uint base_physical, uint high_memory);
uint alloc_page();
void free_page(uint page);
task_t* task_create(uint size, void* code, uint stack_size);
+task_t* task_dup(task_t* task);
void task_kill_and_free(task_t* task);
uint task_add_page(task_t* task);
void task_del_page(task_t* task, uint virtual);
@@ -117,4 +121,4 @@ task_t* task_current();
void task_peek(task_t* task, uint virtual, uint length, void* buffer);
-#endif
+#endif
View
4 kinc/util.h
@@ -11,9 +11,7 @@ typedef struct symbol
__attribute__((__packed__)) symbol_t;
char* cpuid(char* buffer);
-typedef uint(*function_pointer_t)(uint,...);
-function_pointer_t function_by_name(char* name);
void sleep(uint ms);
-#endif
+#endif
View
38 ksrc/ata.c
@@ -69,15 +69,37 @@ bool ata_write_sector(uchar disk, uint lba, void* buffer)
bool ata_read_sectors(uchar disk, uint lba, uint sectors, void* buffer)
{
- if(buffer == NULL)
- panic("Attempt to read to a null buffer in ata_read_sectors");
- // optimize later
- for(uint i = 0; i < sectors; i++)
+ uint at_a_time = 64;
+ if(sectors > at_a_time)
{
- if(!ata_read_sector(disk, lba + i, (char*)buffer + 512*i))
- return false;
+ for(uint i = 0; i < sectors; i += at_a_time)
+ {
+ if(!ata_read_sectors(disk, lba + i, (sectors - i) > at_a_time ? at_a_time : sectors - i, (char*)buffer + (i * 512)))
+ return false;
+ }
+ return true;
}
- return true;
+ struct lba_packet* packet = (struct lba_packet*)0x2000;
+ packet->size = 16;
+ packet->reserved = 0;
+ packet->sectors = sectors;
+ packet->dest_segment = 0x1000;
+ packet->dest_offset = 0x0000;
+ packet->lba_lo = lba;
+ packet->lba_hi = 0;
+
+ *(uchar*)0x2010 = disk; // disk
+ *(uchar*)0x2011 = 0x42; // read
+
+ real_exec(bin_ata16, bin_ata16_len);
+
+ memcpy(buffer, (void*)0x10000, 512 * sectors);
+
+ bool success = !(*(bool*)0x2000);
+ if(!success)
+ panicf("Read failed. LBA = %d, buffer = 0x%x", lba, buffer);
+
+ return success;
}
bool ata_write_sectors(uchar disk, uint lba, uint sectors, void* buffer)
@@ -89,4 +111,4 @@ bool ata_write_sectors(uchar disk, uint lba, uint sectors, void* buffer)
return false;
}
return true;
-}
+}
View
10 ksrc/helper.asm
@@ -1,5 +1,6 @@
+use32
extern memcpy
-extern panic
+global panic
global get_gdt
global gdt_reload_segment_registers
global switch_to_user_mode
@@ -9,8 +10,8 @@ get_gdt:
mov eax, .tmp
ret
.tmp dd 0
- dd 0
-
+ dd 0
+
gdt_reload_segment_registers:
jmp 0x08:.boom
.boom:
@@ -45,4 +46,5 @@ switch_to_user_mode:
int 0x80
jmp $
- hlt
+ hlt
+
View
6 ksrc/isrs.asm
@@ -12,6 +12,8 @@ extern kprintf
jmp isr_%1.fin
isr_%1:
mov [.eax], eax
+ mov ax, 0x10
+ mov ds, ax
mov eax, [esp]
mov [.err], eax
mov eax, [.eax]
@@ -42,6 +44,8 @@ isr_main:
.dont_send_other_clearance:
mov al, 0x20
out 0x20, al
+ mov ax, 0x8b
+ mov ds, ax
popa
sti
iret
@@ -108,4 +112,4 @@ asm_isr_init:
isr 0x80
- ret
+ ret
View
2  ksrc/loader.asm
@@ -32,4 +32,4 @@ loader:
section .bss
align 4
kstack:
- resb STACKSIZE ; reserve 16k stack on a doubleword boundary
+ resb STACKSIZE ; reserve 16k stack on a doubleword boundary
View
5 ksrc/main.c
@@ -60,7 +60,10 @@ void kmain(struct multiboot_info* mbd, unsigned int magic)
uint init_size = vfs_size("/init.bin");
char* buff = kmalloc(((init_size + 4095) / 4096) * 4096);
vfs_readfile("/init.bin", 0, init_size, buff);
+
task_create(init_size, buff, 4096);
+// task_create(init_size, buff, 4096);
+
kfree(buff);
cli();
@@ -69,4 +72,4 @@ void kmain(struct multiboot_info* mbd, unsigned int magic)
__asm__("hlt");
panic("init exited");
-}
+}
View
7 ksrc/panic.asm
@@ -1,10 +1,13 @@
+use32
global panic
global symtable
global get_symtable_addr
extern kprintf
extern panic_backtrace_step
-panic:
+section .text
+
+panic:
push ss
push ds
push cs
@@ -48,4 +51,4 @@ symtable:
dd 0xbadf00de
dd 0xffffffff
- times 65536 db 0 ; reserve 64KiB for the symbol table
+ times 65536 db 0 ; reserve 64KiB for the symbol table
View
2  ksrc/panic.c
@@ -38,4 +38,4 @@ void panic_backtrace_step(size_t address)
}
kprintf(" 0x%x: %s +%x\n", best_offset, best, address - best_offset);
-}
+}
View
2  ksrc/string.c
@@ -218,4 +218,4 @@ char* strtoupper(char* dest, char* src)
dest[i] = src[i];
}
return dest;
-}
+}
View
7 ksrc/syscall.asm
@@ -6,6 +6,8 @@ extern page_directory
syscall_isr:
cli
pusha
+ mov eax, 0
+ mov [multitasking_enabled], eax
mov eax, cr3
mov [.saved_cr3], eax
@@ -35,7 +37,8 @@ syscall_isr:
mov eax, [.saved_cr3]
mov cr3, eax
+ mov eax, 1
+ mov [multitasking_enabled], eax
popa
- sti
iret
- .saved_cr3 dd 0
+ .saved_cr3 dd 0
View
87 ksrc/syscall.c
@@ -22,6 +22,8 @@ static void(*syscall_vectors[])() = {
sys_open,
sys_close,
sys_write_ebx,
+ // 0x0C
+ sys_exception_handler,
};
static uint syscall_max = sizeof(syscall_vectors) / sizeof(*syscall_vectors);
@@ -32,33 +34,65 @@ void syscall_handler(regs_t* registers)
kprintf("Unknown syscall %x\n", registers->eax);
return;
}
+ kprintf("[syscall] %x\n", registers->eax);
syscall_vectors[registers->eax](registers);
}
void sys_alloc_page(__attribute__((unused)) regs_t* registers)
{
-
+ uint page = alloc_page();
+ task_t* t = task_current();
+ uint d_ent = 0;
+ uint* tbl = 0;
+ uint dir;
+ for(dir = 0x10000000 / 4096 / 1024; dir < 0xffffffff / 4096 / 1024; dir++)
+ {
+ if(t->page_directory[dir] & 1)
+ d_ent = t->page_directory[dir] & 0xfffff000;
+ else
+ continue;
+ }
+ tbl = (uint*)d_ent;
+ uint tbl_i;
+ for(tbl_i = 0; tbl_i < 1024; tbl_i++)
+ {
+ if((tbl[tbl_i] & 1) == 0)
+ break;
+ }
+ if(tbl_i == 1024)
+ {
+ dir++;
+ // fuck around and shit
+ }
+ tbl[tbl_i] = page | 1 | 2 | 4;
+ registers->eax = ((dir * 1024) + page) * 4096;
}
void sys_free_page(__attribute__((unused)) regs_t* registers)
{
}
extern uint current_task;
+extern uint multitasking_enabled;
void sys_exit(__attribute__((unused)) regs_t* registers)
-{
- // DANGER DANGER DANGER
- // when we free this task, the stack we are on is no longer valid.
- // we can still use it of course, but we don't have the memory region to ourselves anymore.
- // we'll temporarily disable interrupts and GTFO
- cli();
- //task_kill_and_free(task_current());
- current_task = 0xffffffff; // magic value that indicates to the switcher that there is no valid task running.
-
- __asm__("jmp task_switch"); // trigger a task switch
+{
+ task_kill_and_free(task_get(current_task));
+ current_task = 0xffffffff;
+ sti();
+ multitasking_enabled = true;
+ for(;;) ;
}
void sys_kill(__attribute__((unused)) regs_t* registers)
{
-
+ if(registers->ebx >= MAX_TASKS || task_get(registers->ebx) == NULL)
+ {
+ registers->eax = 0;
+ return;
+ }
+ if(registers->ebx == task_current()->pid)
+ {
+ sys_exit(registers);
+ }
+ task_kill_and_free(task_get(registers->ebx));
}
void sys_get_pid(regs_t* registers)
{
@@ -66,7 +100,30 @@ void sys_get_pid(regs_t* registers)
}
void sys_fork(__attribute__((unused)) regs_t* registers)
{
+ task_t* new = task_dup(task_current());
+
+ if(new == NULL)
+ {
+ registers->eax = 0xffffffff;
+ return;
+ }
+
+ // the really tricky part about this is that the new task won't be returning from a syscall.
+ // it'll be spun up by the switcher so we need to 'fix' the return EIP so that it is switched into properly.
+ // that means we copy the registers from our current registers and modify EAX to be the new pid.
+ new->tss.ss = *(uint*)(task_current()->tss.esp0 - 1*4);
+ new->tss.esp = *(uint*)(task_current()->tss.esp0 - 2*4);
+ new->tss.eflags = *(uint*)(task_current()->tss.esp0 - 3*4);
+ new->tss.cs = *(uint*)(task_current()->tss.esp0 - 4*4);
+ new->tss.eip = *(uint*)(task_current()->tss.esp0 - 5*4);
+
+ // now set return values:
+ registers->eax = new->pid;
+ new->tss.eax = new->pid;
+
+ // all this magic should work in theory, but I haven't tested it yet.
+
}
void sys_write(regs_t* registers)
{
@@ -102,4 +159,8 @@ void sys_close(__attribute__((unused)) regs_t* registers)
void sys_write_ebx(regs_t* registers)
{
kprintf("EBX = 0x%x\n", registers->ebx);
-}
+}
+void sys_exception_handler(regs_t* registers)
+{
+ task_current()->exception_handler = registers->ebx;
+}
View
20 ksrc/task.asm
@@ -7,8 +7,9 @@ extern task_install_next_tss
extern task_find_next
global task_switch
-%define MAX_TASKS 16 ; must be the same as in task.c
+%define TIME_SLICE 3
+which_slice dd 0
task_switch:
cli
@@ -25,7 +26,18 @@ task_switch:
sti
iret
+ mov eax, [which_slice]
+ cmp eax, TIME_SLICE
+ je .perform_switch
+
+ inc eax
+ mov [which_slice], eax
+ sti
+ iret
+
.perform_switch:
+ xor eax, eax
+ mov [which_slice], eax
mov eax, [current_task]
; if current_task is 0xffffffff then that means that there is no current task and we shouldn't save back the registers
@@ -100,6 +112,7 @@ task_switch:
push eax
; EFLAGS:
mov eax, [ebx + 0x24]
+ or eax, 0x200
push eax
; CS:
xor eax, eax
@@ -126,7 +139,7 @@ task_switch:
mov al, 0x20
out 0x20, al
- mov ax, 0x90
+ mov ax, 0x93
ltr ax
mov eax, [ebx + 0x28]
@@ -139,5 +152,6 @@ task_switch:
.ebx dd 0
.ecx dd 0
.edx dd 0
+ .switchmsg db "switching to task %d", 10, 0
.msg db "EIP: %x, CS: %x, EFLAGS: %x, ESP: %x, SS: %x", 0
- .ping db "ping!", 0
+ .ping db "ping!", 0
View
140 ksrc/task.c
@@ -9,8 +9,6 @@
#include "console.h"
#include "syscall.h"
-#define MAX_TASKS 16
-
uint user_base;
uint page_base;
uint total_pages;
@@ -30,11 +28,17 @@ task_t* task_current()
return tasks[current_task];
}
+task_t* task_get(uint pid)
+{
+ return tasks[pid];
+}
+
void task_init(uint base_physical, uint high_memory)
{
user_base = base_physical;
page_base = base_physical / 4096;
- total_pages = (base_physical - high_memory * 1024) / 4096;
+ total_pages = ((high_memory * 1024) - base_physical) / 4096;
+ kprintf("Total pages: %d\n", total_pages);
pagemap = (uchar*)kmalloc(total_pages / 8);
memset(pagemap, 0, total_pages / 8);
@@ -80,8 +84,10 @@ void free_page(uint page)
if(page < page_base || page >= total_pages + page_base)
panic("Freeing non-existent page");
+ page -= page_base;
+
if(((pagemap[page / 8] >> (page % 8)) & 1) == 0)
- panic("Freeing freed page");
+ panicf("Freeing freed page: %x (%x), pagemap %x", page, page << 12, pagemap[page / 8] & 0xff);
pagemap[page / 8] &= ~(1 << (page % 8));
}
@@ -141,8 +147,67 @@ task_t* task_create(uint size, void* code, uint stack_size)
return task;
}
+task_t* task_dup(task_t* task)
+{
+ if(num_tasks == MAX_TASKS)
+ return NULL;
+
+ task_t* copy = (task_t*)kmalloc(sizeof(task_t));
+ memset(copy, 0, sizeof(task_t));
+
+ copy->page_directory = (uint*)(copy->tss.cr3 = alloc_page());
+ memset(copy->page_directory, 0, 4096);
+ memcpy(copy->page_directory, task->page_directory, 4 /* copy only first page directory (4MB) of ram. this is what the kernel will be using */);
+
+ for(uint dir_i = 0x10000000 / 4096 / 1024; dir_i < 1024; dir_i++)
+ {
+ if(task->page_directory[dir_i] & 1)
+ {
+ copy->page_directory[dir_i] = alloc_page() | (task->page_directory[dir_i] & 0xfff);
+ uint* copy_tbl = (uint*)(copy->page_directory[dir_i] & 0xfffff000);
+ uint* task_tbl = (uint*)(task->page_directory[dir_i] & 0xfffff000);
+ for(uint tbl_i = 0; tbl_i < 1024; tbl_i++)
+ {
+ if(task_tbl[tbl_i] & 1)
+ {
+ copy_tbl[tbl_i] = alloc_page() | (task_tbl[tbl_i] & 0xfff);
+ memcpy((uint*)(copy_tbl[tbl_i] & 0xfffff000), (uint*)(task_tbl[tbl_i] & 0xfffff000), 4096);
+ }
+ }
+ }
+ }
+
+ copy->state = task->state;
+ copy->tss.ss0 = 0x10; // kernel stack segment
+ copy->tss.esp0 = (uint)copy->kernel_stack + 8192 - 4;
+ copy->tss.iopb = task->tss.iopb; // don't let it I/O anywhere
+
+ copy->tss.cs = 0x80 | 3;
+ copy->tss.ds = copy->tss.ss = copy->tss.es = copy->tss.fs = copy->tss.gs = 0x88 | 3;
+ copy->tss.eflags = task->tss.eflags;
+ copy->tss.eip = task->tss.eip;
+
+ copy->tss.esp = task->tss.esp;
+
+ copy->exception_handler = task->exception_handler;
+
+ // find free pid
+ uint pid = 0;
+ for(; pid < MAX_TASKS && tasks[pid] != NULL; pid++) ;
+ num_tasks++;
+ kprintf("Forked task with pid %d, parent task is %d\n", pid, task->pid);
+ copy->pid = pid;
+ tasks[pid] = copy;
+
+ memcpy(copy->fds, task->fds, sizeof(vfs_stream_t*) * MAX_FDS);
+
+ return copy;
+}
void task_kill_and_free(task_t* task)
{
+ if(task->state == KILLED)
+ return;
+
task->state = KILLED;
for(uint i = 0; i < MAX_FDS; i++)
{
@@ -156,22 +221,27 @@ void task_kill_and_free(task_t* task)
// work through page directory starting at 0x10000000 freeing pages
for(uint dir_i = 0x10000000 / 4096 / 1024; dir_i < 1024; dir_i++)
{
- if(!(task->page_directory[dir_i] | 1))
+ if(!(task->page_directory[dir_i] & 1))
{
// page directory entry not in use? skip
continue;
}
- uint* table = (uint*)(task->page_directory[dir_i] | 0xfffff000);
+ uint* table = (uint*)(task->page_directory[dir_i] & 0xfffff000);
for(uint tbl_i = 0; tbl_i < 1024; tbl_i++)
{
- if(table[tbl_i] | 1)
+ if(table[tbl_i] & 1)
+ {
free_page(table[tbl_i] & 0xfffff000);
+ }
}
free_page((uint)table);
}
free_page((uint)task->page_directory);
+ tasks[task->pid] = NULL;
kfree(task);
+
+ num_tasks--;
}
void task_switch_isr(uint interrupt, uint error)
@@ -186,45 +256,22 @@ uint task_find_next(uint t)
for(uint i = 1; i <= MAX_TASKS; i++)
{
if(tasks[(i + t) % MAX_TASKS] != NULL && tasks[(i + t) % MAX_TASKS]->state == RUNNING)
+ {
+ //kprintf("--> %d, state: %d\n", (i + t) % MAX_TASKS, tasks[(i + t) % MAX_TASKS]->state);
return (i + t) % MAX_TASKS;
+ }
}
panic("no tasks running");
return 0;
}
void task_install_next_tss(uint t)
-{
- gdt_entry_t task_seg;
- memset(&task_seg, 0, sizeof(gdt_entry_t));
- gdt_raw_entry_t task_seg_raw;
- // setup TSS
- task_seg.base = (uint)&tasks[t]->tss;
- task_seg.limit = sizeof(tss_t);
- task_seg.executable = true;
- task_seg.accessed = true;
- task_seg.bits32 = true;
- task_seg.readwrite = false;
- task_seg.privilege = 3;
- gdt_encode(&task_seg, &task_seg_raw);
- ((uchar*)&task_seg_raw)[5] = 0x89; // hack to set access byte.
- gdt_set_entry(0x90, &task_seg_raw);
-}
-
-/*
-void task_switch()
{
- cli();
- for(uint i = 0; i < MAX_TASKS; i++)
- {
- uint next_task = (current_task + i) % MAX_TASKS;
- if(tasks[next_task] != NULL)
- current_task = next_task;
- }
gdt_entry_t task_seg;
memset(&task_seg, 0, sizeof(gdt_entry_t));
gdt_raw_entry_t task_seg_raw;
// setup TSS
- task_seg.base = (uint)&tasks[current_task]->tss;
+ task_seg.base = (uint)&tasks[t]->tss;
task_seg.limit = sizeof(tss_t);
task_seg.executable = true;
task_seg.accessed = true;
@@ -234,30 +281,7 @@ void task_switch()
gdt_encode(&task_seg, &task_seg_raw);
((uchar*)&task_seg_raw)[5] = 0x89; // hack to set access byte.
gdt_set_entry(0x90, &task_seg_raw);
- gdt_flush();
-
- idt_entry_t syscall;
- idt_entry_factory(&syscall, 0x30, 0, 0, GATE_TASK_32);
-// idt_set_gate(0x80, )
-
- kprintf("TSS ESP: %x, TSS SS: %x, TSS CS: %x, TSS EIP: %x\n", tasks[current_task]->tss.esp, tasks[current_task]->tss.ss, tasks[current_task]->tss.cs, tasks[current_task]->tss.eip);
-
- __asm__ volatile("push %0" :: "r"((uint)tasks[current_task]->tss.ss));
- __asm__ volatile("push %0" :: "r"(tasks[current_task]->tss.esp));
- __asm__ volatile("push %0" :: "r"(tasks[current_task]->tss.eflags | 0x200));
- __asm__ volatile("push %0" :: "r"((uint)tasks[current_task]->tss.cs));
- __asm__ volatile("push %0" :: "r"(tasks[current_task]->tss.eip));
- __asm__ volatile(" cli \n\
- mov eax, %0 \n\
- mov cr3, eax \n\
- mov ax, 0x90 \n\
- ltr ax \n\
- mov al, 0x20 \n\
- out 0x20, al \n\
- iret \n\
- " :: "r"(tasks[current_task]->page_directory));
}
-*/
void task_peek(task_t* task, uint virtual, uint length, void* buffer)
{
@@ -266,4 +290,4 @@ void task_peek(task_t* task, uint virtual, uint length, void* buffer)
{
((char*)buffer)[i] = *(char*)paging_virtual_to_physical(task->page_directory, virtual + i);
}
-}
+}
View
11 ksrc/trap.c
@@ -3,6 +3,7 @@
#include "stddef.h"
#include "idt.h"
#include "panic.h"
+#include "task.h"
static char* traps[] = {
"Divide by zero",
@@ -38,16 +39,20 @@ static char* traps[] = {
"Security Exception"
};
+extern uint multitasking_enabled;
static void trap_handler(uint interrupt, uint error)
{
- uint a = 1 / 0;
uint cr2;
__asm__("mov eax, cr2" : "=a"(cr2));
- kprintf("TRAP: %s, %d\n", traps[interrupt], interrupt == 14 ? cr2 : error);
+ if(multitasking_enabled)
+ {
+ uint retn_addr = *(uint*)(task_current()->tss.esp0 - 5*4);
+ *(uint*)(task_current()->tss.esp0 - 5*4) = task_current()->exception_handler;
+ }
}
void trap_init()
{
for(uint i = 0; i < 31; i++)
subscribe_isr(i, trap_handler);
-}
+}
View
18 ksrc/util.c
@@ -13,25 +13,9 @@ char* cpuid(char* buffer)
return buffer;
}
-char* get_symtable_addr();
-
-function_pointer_t function_by_name(char* name)
-{
- symbol_t* symbols = (symbol_t*)(get_symtable_addr() + 16);
-
- for(int i = 0; i < 2048; i++)
- {
- if(!symbols[i].addr)
- return NULL;
- if(strcmp(symbols[i].name, name) == 0)
- return (function_pointer_t)symbols[i].addr;
- }
- return NULL;
-}
-
void sleep(uint ms)
{
// @TODO
// sleep for how many ms
for(uint i = 0; i < ms*5000; i++) ;
-}
+}
View
BIN  ubin/init.o
Binary file not shown
View
10 uinc/csos.h
@@ -1,12 +1,16 @@
#ifndef CSOS_H
#define CSOS_H
-#define stdin 0
-#define stdout 1
+#include <_PDCLIB_glue.h>
typedef unsigned int uint;
+//extern uint stdin;
+//extern uint stdout;
+//extern uint stderr;
+
void* alloc_page();
+void* alloc_pages(uint n);
void free_page(void* page);
void exit(int status);
@@ -20,4 +24,4 @@ uint read(uint fd, void* buff, uint len);
uint open(char* path);
void close(uint fd);
-#endif
+#endif
View
BIN  user/crt.a
Binary file not shown
View
BIN  user/crt.o
Binary file not shown
View
BIN  user/crt/crt_asm.o
Binary file not shown
View
BIN  user/crt/crt_c.o
Binary file not shown
View
83 user/crt/csos.asm
@@ -1,22 +1,70 @@
extern main
-global alloc_page ; vec 0x01
-global free_page ; vec 0x02
-global exit ; vec 0x03
-global kill ; vec 0x04
+;;;; syscalls
-global get_pid ; vec 0x05
-global fork ; vec 0x06
-global write ; vec 0x07
-global read ; vec 0x08
+global alloc_page ; vec 0x01
+global free_page ; vec 0x02
+global _PDCLIB_Exit ; vec 0x03
+global kill ; vec 0x04
-global open ; vec 0x09
-global close ; vec 0x0a
+global get_pid ; vec 0x05
+global fork ; vec 0x06
+global write ; vec 0x07
+global read ; vec 0x08
+
+global open ; vec 0x09
+global close ; vec 0x0a
+
+global exception_handler ; vec 0x0c
+
+;;;; support for pdclib
+global stdin
+global stdout
+global stderr
+global __divdi3
+global errno
+global __errno_location
+
+push __raw_exception_handler
+call exception_handler
+add esp, 4
call main
-call exit
+push eax
+call _PDCLIB_Exit
jmp $
+stdin dd 0
+stdout dd 1
+stderr dd 1 ; @TODO fix this to have stderr be its own fd
+errno dd 0
+__errno_location dd 0
+
+__raw_exception_handler:
+ push ebx
+ call __c_exception_handler
+ add esp, 4
+ ret
+
+__c_exception_handler:
+ push ebp
+ mov ebp, esp
+
+ push dword 21
+ push .msg
+ push dword 1
+ call write
+ add esp, 12
+
+ push dword 1
+ call _PDCLIB_Exit
+
+section .data
+ align 16
+ .msg db "Unhandled Exception.", 0
+
+section .text
+
alloc_page:
mov eax, 0x01
int 0x80
@@ -30,7 +78,8 @@ free_page:
pop ebx
ret
-exit:
+_PDCLIB_Exit:
+ mov ebx, [esp+4]
mov eax, 0x03
int 0x80
ret
@@ -88,4 +137,12 @@ close:
int 0x80
pop ebx
ret
-
+
+exception_handler:
+ push ebx
+ mov eax, 0x0c
+ mov ebx, [esp+8]
+ int 0x80
+ pop ebx
+ ret
+
View
147 user/crt/csos.c
@@ -0,0 +1,147 @@
+#include <csos.h>
+#include <_PDCLIB_glue.h>
+
+// @TODO IMPROVE THESE FUNCTIONS
+// THEY ARE SHIT SLOW
+// @TODO @TODO @TODO @TODO
+
+long long __divdi3(long long numerator, long long denominator)
+{
+ if(denominator == 0)
+ return 0;
+
+ long long result = 0;
+ long long sign = 1;
+ if(numerator < 0)
+ {
+ numerator = -numerator;
+ sign = -sign;
+ }
+ if(denominator < 0)
+ {
+ denominator = -denominator;
+ sign = -sign;
+ }
+ while(numerator > denominator)
+ {
+ numerator -= denominator;
+ result++;
+ }
+
+ return result * sign;
+}
+
+long long __moddi3(long long numerator, long long denominator)
+{
+ if(denominator == 0)
+ return 0;
+
+ if(numerator < 0)
+ numerator = -numerator;
+ if(denominator < 0)
+ denominator = -denominator;
+
+ while(numerator > denominator)
+ {
+ numerator -= denominator;
+ }
+
+ return numerator;
+}
+
+long long __udivdi3(unsigned long long numerator, unsigned long long denominator)
+{
+ if(denominator == 0)
+ return 0;
+
+ long long result = 0;
+ while(numerator > denominator)
+ {
+ numerator -= denominator;
+ result++;
+ }
+
+ return result;
+}
+
+long long __umoddi3(unsigned long long numerator, unsigned long long denominator)
+{
+ if(denominator == 0)
+ return 0;
+
+ while(numerator > denominator)
+ {
+ numerator -= denominator;
+ }
+
+ return numerator;
+}
+
+int tolower(int c)
+{
+ if(c >= 'A' || c <= 'Z')
+ return c - 'A' + 'a';
+ return c;
+}
+int toupper(int c)
+{
+ if(c >= 'a' || c <= 'z')
+ return c - 'a' + 'A';
+ return c;
+}
+
+void __ctype_b_loc()
+{
+ // lmao should never happen
+}
+
+int _PDCLIB_write( struct _PDCLIB_file_t * stream, char const* buffer, int n )
+{
+ int rc;
+ if ( ( rc = write( stream->handle, (char*)buffer, (uint)n ) ) == -1 )
+ {
+ /* Error encountered */
+ stream->status |= _PDCLIB_ERRORFLAG;
+ /* FIXME: Map the errno of the OS to PDCLib's errno */
+ }
+ return rc;
+}
+
+int _PDCLIB_close( int fd )
+{
+ close( fd );
+ return 0;
+}
+
+int _PDCLIB_fflush( __attribute__((unused)) struct _PDCLIB_file_t * stream )
+{
+ // @TODO
+ return 0;
+}
+int _PDCLIB_open( char const * const filename, __attribute__((unused)) unsigned int mode )
+{
+ return open((char*)filename);
+}
+_PDCLIB_size_t _PDCLIB_read( int fd, char * buffer, _PDCLIB_size_t n )
+{
+ return read( fd, buffer, n );
+}
+int _PDCLIB_remove( __attribute__((unused)) const char * filename )
+{
+ // @TODO
+ return -1;
+}
+int _PDCLIB_rename( __attribute__((unused)) const char * old, __attribute__((unused)) const char * new )
+{
+ // @TODO
+ return -1;
+}
+void * _PDCLIB_allocpages( int const n )
+{
+ // so this relies on allocpages returning some contiguous pages.
+ // i'll fix this later.
+ uint* start = alloc_page();
+ for(int i = 1; i < n; i++)
+ alloc_page();
+ return start;
+}
View
21 user/init.c
@@ -1,17 +1,12 @@
#include <csos.h>
-
-uint strlen(char* str)
-{
- uint len = 0;
- while(*str++)
- len++;
- return len;
-}
+#include <stdio.h>
+#include <string.h>
int main()
{
+ /*
char* msg = "Hello world from init! I am process number: ";
- write(stdout, "Hello world from init! I am process number: ", strlen(msg));
+ write(stdout, msg, strlen(msg));
uint pid = get_pid();
char buff[16];
@@ -25,4 +20,10 @@ int main()
}
while(pid != 0);
write(stdout, bptr, len);
-}
+ write(stdout, "\n", 1);
+
+// write(stdout, &pid, 1);
+ */
+
+ printf("Hello world from init! I am process number: %d\n", get_pid());
+}
View
BIN  user/lua-5.1.4.tar.gz
Binary file not shown
View
34 user/lua-5.1.4/COPYRIGHT
@@ -0,0 +1,34 @@
+Lua License
+-----------
+
+Lua is licensed under the terms of the MIT license reproduced below.
+This means that Lua is free software and can be used for both academic
+and commercial purposes at absolutely no cost.
+
+For details and rationale, see http://www.lua.org/license.html .
+
+===============================================================================
+
+Copyright (C) 1994-2008 Lua.org, PUC-Rio.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+===============================================================================
+
+(end of COPYRIGHT)
View
183 user/lua-5.1.4/HISTORY
@@ -0,0 +1,183 @@
+HISTORY for Lua 5.1
+
+* Changes from version 5.0 to 5.1
+ -------------------------------
+ Language:
+ + new module system.
+ + new semantics for control variables of fors.
+ + new semantics for setn/getn.
+ + new syntax/semantics for varargs.
+ + new long strings and comments.
+ + new `mod' operator (`%')
+ + new length operator #t
+ + metatables for all types
+ API:
+ + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer.
+ + user supplies memory allocator (lua_open becomes lua_newstate).
+ + luaopen_* functions must be called through Lua.
+ Implementation:
+ + new configuration scheme via luaconf.h.
+ + incremental garbage collection.
+ + better handling of end-of-line in the lexer.
+ + fully reentrant parser (new Lua function `load')
+ + better support for 64-bit machines.
+ + native loadlib support for Mac OS X.
+ + standard distribution in only one library (lualib.a merged into lua.a)
+
+* Changes from version 4.0 to 5.0
+ -------------------------------
+ Language:
+ + lexical scoping.
+ + Lua coroutines.
+ + standard libraries now packaged in tables.
+ + tags replaced by metatables and tag methods replaced by metamethods,
+ stored in metatables.
+ + proper tail calls.
+ + each function can have its own global table, which can be shared.
+ + new __newindex metamethod, called when we insert a new key into a table.
+ + new block comments: --[[ ... ]].
+ + new generic for.
+ + new weak tables.
+ + new boolean type.
+ + new syntax "local function".
+ + (f()) returns the first value returned by f.
+ + {f()} fills a table with all values returned by f.
+ + \n ignored in [[\n .
+ + fixed and-or priorities.
+ + more general syntax for function definition (e.g. function a.x.y:f()...end).
+ + more general syntax for function calls (e.g. (print or write)(9)).
+ + new functions (time/date, tmpfile, unpack, require, load*, etc.).
+ API:
+ + chunks are loaded by using lua_load; new luaL_loadfile and luaL_loadbuffer.
+ + introduced lightweight userdata, a simple "void*" without a metatable.
+ + new error handling protocol: the core no longer prints error messages;
+ all errors are reported to the caller on the stack.
+ + new lua_atpanic for host cleanup.
+ + new, signal-safe, hook scheme.
+ Implementation:
+ + new license: MIT.
+ + new, faster, register-based virtual machine.
+ + support for external multithreading and coroutines.
+ + new and consistent error message format.
+ + the core no longer needs "stdio.h" for anything (except for a single
+ use of sprintf to convert numbers to strings).
+ + lua.c now runs the environment variable LUA_INIT, if present. It can
+ be "@filename", to run a file, or the chunk itself.
+ + support for user extensions in lua.c.
+ sample implementation given for command line editing.
+ + new dynamic loading library, active by default on several platforms.
+ + safe garbage-collector metamethods.
+ + precompiled bytecodes checked for integrity (secure binary dostring).
+ + strings are fully aligned.
+ + position capture in string.find.
+ + read('*l') can read lines with embedded zeros.
+
+* Changes from version 3.2 to 4.0
+ -------------------------------
+ Language:
+ + new "break" and "for" statements (both numerical and for tables).
+ + uniform treatment of globals: globals are now stored in a Lua table.
+ + improved error messages.
+ + no more '$debug': full speed *and* full debug information.
+ + new read form: read(N) for next N bytes.
+ + general read patterns now deprecated.
+ (still available with -DCOMPAT_READPATTERNS.)
+ + all return values are passed as arguments for the last function
+ (old semantics still available with -DLUA_COMPAT_ARGRET)
+ + garbage collection tag methods for tables now deprecated.
+ + there is now only one tag method for order.
+ API:
+ + New API: fully re-entrant, simpler, and more efficient.
+ + New debug API.
+ Implementation:
+ + faster than ever: cleaner virtual machine and new hashing algorithm.
+ + non-recursive garbage-collector algorithm.
+ + reduced memory usage for programs with many strings.
+ + improved treatment for memory allocation errors.
+ + improved support for 16-bit machines (we hope).
+ + code now compiles unmodified as both ANSI C and C++.
+ + numbers in bases other than 10 are converted using strtoul.
+ + new -f option in Lua to support #! scripts.
+ + luac can now combine text and binaries.
+
+* Changes from version 3.1 to 3.2
+ -------------------------------
+ + redirected all output in Lua's core to _ERRORMESSAGE and _ALERT.
+ + increased limit on the number of constants and globals per function
+ (from 2^16 to 2^24).
+ + debugging info (lua_debug and hooks) moved into lua_state and new API
+ functions provided to get and set this info.
+ + new debug lib gives full debugging access within Lua.
+ + new table functions "foreachi", "sort", "tinsert", "tremove", "getn".
+ + new io functions "flush", "seek".
+
+* Changes from version 3.0 to 3.1
+ -------------------------------
+ + NEW FEATURE: anonymous functions with closures (via "upvalues").
+ + new syntax:
+ - local variables in chunks.
+ - better scope control with DO block END.
+ - constructors can now be also written: { record-part; list-part }.
+ - more general syntax for function calls and lvalues, e.g.:
+ f(x).y=1
+ o:f(x,y):g(z)
+ f"string" is sugar for f("string")
+ + strings may now contain arbitrary binary data (e.g., embedded zeros).
+ + major code re-organization and clean-up; reduced module interdependecies.
+ + no arbitrary limits on the total number of constants and globals.
+ + support for multiple global contexts.
+ + better syntax error messages.
+ + new traversal functions "foreach" and "foreachvar".
+ + the default for numbers is now double.
+ changing it to use floats or longs is easy.
+ + complete debug information stored in pre-compiled chunks.
+ + sample interpreter now prompts user when run interactively, and also
+ handles control-C interruptions gracefully.
+
+* Changes from version 2.5 to 3.0
+ -------------------------------
+ + NEW CONCEPT: "tag methods".
+ Tag methods replace fallbacks as the meta-mechanism for extending the
+ semantics of Lua. Whereas fallbacks had a global nature, tag methods
+ work on objects having the same tag (e.g., groups of tables).
+ Existing code that uses fallbacks should work without change.
+ + new, general syntax for constructors {[exp] = exp, ... }.
+ + support for handling variable number of arguments in functions (varargs).
+ + support for conditional compilation ($if ... $else ... $end).
+ + cleaner semantics in API simplifies host code.
+ + better support for writing libraries (auxlib.h).
+ + better type checking and error messages in the standard library.
+ + luac can now also undump.
+
+* Changes from version 2.4 to 2.5
+ -------------------------------
+ + io and string libraries are now based on pattern matching;
+ the old libraries are still available for compatibility
+ + dofile and dostring can now return values (via return statement)
+ + better support for 16- and 64-bit machines
+ + expanded documentation, with more examples
+
+* Changes from version 2.2 to 2.4
+ -------------------------------
+ + external compiler creates portable binary files that can be loaded faster
+ + interface for debugging and profiling
+ + new "getglobal" fallback
+ + new functions for handling references to Lua objects
+ + new functions in standard lib
+ + only one copy of each string is stored
+ + expanded documentation, with more examples
+
+* Changes from version 2.1 to 2.2
+ -------------------------------
+ + functions now may be declared with any "lvalue" as a name
+ + garbage collection of functions
+ + support for pipes
+
+* Changes from version 1.1 to 2.1
+ -------------------------------
+ + object-oriented support
+ + fallbacks
+ + simplified syntax for tables
+ + many internal improvements
+
+(end of HISTORY)
View
99 user/lua-5.1.4/INSTALL
@@ -0,0 +1,99 @@
+INSTALL for Lua 5.1
+
+* Building Lua
+ ------------
+ Lua is built in the src directory, but the build process can be
+ controlled from the top-level Makefile.
+
+ Building Lua on Unix systems should be very easy. First do "make" and
+ see if your platform is listed. If so, just do "make xxx", where xxx
+ is your platform name. The platforms currently supported are:
+ aix ansi bsd freebsd generic linux macosx mingw posix solaris
+
+ If your platform is not listed, try the closest one or posix, generic,
+ ansi, in this order.
+
+ See below for customization instructions and for instructions on how
+ to build with other Windows compilers.
+
+ If you want to check that Lua has been built correctly, do "make test"
+ after building Lua. Also, have a look at the example programs in test.
+
+* Installing Lua
+ --------------
+ Once you have built Lua, you may want to install it in an official
+ place in your system. In this case, do "make install". The official
+ place and the way to install files are defined in Makefile. You must
+ have the right permissions to install files.
+
+ If you want to build and install Lua in one step, do "make xxx install",
+ where xxx is your platform name.
+
+ If you want to install Lua locally, then do "make local". This will
+ create directories bin, include, lib, man, and install Lua there as
+ follows:
+
+ bin: lua luac
+ include: lua.h luaconf.h lualib.h lauxlib.h lua.hpp
+ lib: liblua.a
+ man/man1: lua.1 luac.1
+
+ These are the only directories you need for development.
+
+ There are man pages for lua and luac, in both nroff and html, and a
+ reference manual in html in doc, some sample code in test, and some
+ useful stuff in etc. You don't need these directories for development.
+
+ If you want to install Lua locally, but in some other directory, do
+ "make install INSTALL_TOP=xxx", where xxx is your chosen directory.
+
+ See below for instructions for Windows and other systems.
+
+* Customization
+ -------------
+ Three things can be customized by editing a file:
+ - Where and how to install Lua -- edit Makefile.
+ - How to build Lua -- edit src/Makefile.
+ - Lua features -- edit src/luaconf.h.
+
+ You don't actually need to edit the Makefiles because you may set the
+ relevant variables when invoking make.
+
+ On the other hand, if you need to select some Lua features, you'll need
+ to edit src/luaconf.h. The edited file will be the one installed, and
+ it will be used by any Lua clients that you build, to ensure consistency.
+
+ We strongly recommend that you enable dynamic loading. This is done
+ automatically for all platforms listed above that have this feature
+ (and also Windows). See src/luaconf.h and also src/Makefile.
+
+* Building Lua on Windows and other systems
+ -----------------------------------------
+ If you're not using the usual Unix tools, then the instructions for
+ building Lua depend on the compiler you use. You'll need to create
+ projects (or whatever your compiler uses) for building the library,
+ the interpreter, and the compiler, as follows:
+
+ library: lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
+ lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c
+ ltable.c ltm.c lundump.c lvm.c lzio.c
+ lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c
+ ltablib.c lstrlib.c loadlib.c linit.c
+
+ interpreter: library, lua.c
+
+ compiler: library, luac.c print.c
+
+ If you use Visual Studio .NET, you can use etc/luavs.bat in its
+ "Command Prompt".
+
+ If all you want is to build the Lua interpreter, you may put all .c files
+ in a single project, except for luac.c and print.c. Or just use etc/all.c.
+
+ To use Lua as a library in your own programs, you'll need to know how to
+ create and use libraries with your compiler.
+
+ As mentioned above, you may edit luaconf.h to select some features before
+ building Lua.
+
+(end of INSTALL)
View
128 user/lua-5.1.4/Makefile
@@ -0,0 +1,128 @@
+# makefile for installing Lua
+# see INSTALL for installation instructions
+# see src/Makefile and src/luaconf.h for further customization
+
+# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
+
+# Your platform. See PLATS for possible values.
+PLAT= none
+
+# Where to install. The installation starts in the src and doc directories,
+# so take care if INSTALL_TOP is not an absolute path.
+INSTALL_TOP= /usr/local
+INSTALL_BIN= $(INSTALL_TOP)/bin
+INSTALL_INC= $(INSTALL_TOP)/include
+INSTALL_LIB= $(INSTALL_TOP)/lib
+INSTALL_MAN= $(INSTALL_TOP)/man/man1
+#
+# You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
+# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
+INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
+INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
+
+# How to install. If your install program does not support "-p", then you
+# may have to run ranlib on the installed liblua.a (do "make ranlib").
+INSTALL= install -p
+INSTALL_EXEC= $(INSTALL) -m 0755
+INSTALL_DATA= $(INSTALL) -m 0644
+#
+# If you don't have install you can use cp instead.
+# INSTALL= cp -p
+# INSTALL_EXEC= $(INSTALL)
+# INSTALL_DATA= $(INSTALL)
+
+# Utilities.
+MKDIR= mkdir -p
+RANLIB= ranlib
+
+# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
+
+# Convenience platforms targets.
+PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
+
+# What to install.
+TO_BIN= lua luac
+TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
+TO_LIB= liblua.a
+TO_MAN= lua.1 luac.1
+
+# Lua version and release.
+V= 5.1
+R= 5.1.4
+
+all: $(PLAT)
+
+$(PLATS) clean:
+ cd src && $(MAKE) $@
+
+test: dummy
+ src/lua test/hello.lua
+
+install: dummy
+ cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
+ cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
+ cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
+ cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
+ cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+
+ranlib:
+ cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
+
+local:
+ $(MAKE) install INSTALL_TOP=..
+
+none:
+ @echo "Please do"
+ @echo " make PLATFORM"
+ @echo "where PLATFORM is one of these:"
+ @echo " $(PLATS)"
+ @echo "See INSTALL for complete instructions."
+
+# make may get confused with test/ and INSTALL in a case-insensitive OS
+dummy:
+
+# echo config parameters
+echo:
+ @echo ""
+ @echo "These are the parameters currently set in src/Makefile to build Lua $R:"
+ @echo ""
+ @cd src && $(MAKE) -s echo
+ @echo ""
+ @echo "These are the parameters currently set in Makefile to install Lua $R:"
+ @echo ""
+ @echo "PLAT = $(PLAT)"
+ @echo "INSTALL_TOP = $(INSTALL_TOP)"
+ @echo "INSTALL_BIN = $(INSTALL_BIN)"
+ @echo "INSTALL_INC = $(INSTALL_INC)"
+ @echo "INSTALL_LIB = $(INSTALL_LIB)"
+ @echo "INSTALL_MAN = $(INSTALL_MAN)"
+ @echo "INSTALL_LMOD = $(INSTALL_LMOD)"
+ @echo "INSTALL_CMOD = $(INSTALL_CMOD)"
+ @echo "INSTALL_EXEC = $(INSTALL_EXEC)"
+ @echo "INSTALL_DATA = $(INSTALL_DATA)"
+ @echo ""
+ @echo "See also src/luaconf.h ."
+ @echo ""
+
+# echo private config parameters
+pecho:
+ @echo "V = $(V)"
+ @echo "R = $(R)"
+ @echo "TO_BIN = $(TO_BIN)"
+ @echo "TO_INC = $(TO_INC)"
+ @echo "TO_LIB = $(TO_LIB)"
+ @echo "TO_MAN = $(TO_MAN)"
+
+# echo config parameters as Lua code
+# uncomment the last sed expression if you want nil instead of empty strings
+lecho:
+ @echo "-- installation parameters for Lua $R"
+ @echo "VERSION = '$V'"
+ @echo "RELEASE = '$R'"
+ @$(MAKE) echo | grep = | sed -e 's/= /= "/' -e 's/$$/"/' #-e 's/""/nil/'
+ @echo "-- EOF"
+
+# list targets that do not create files (but not all makes understand .PHONY)
+.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho
+
+# (end of Makefile)
View
37 user/lua-5.1.4/README
@@ -0,0 +1,37 @@
+README for Lua 5.1
+
+See INSTALL for installation instructions.
+See HISTORY for a summary of changes since the last released version.
+
+* What is Lua?
+ ------------
+ Lua is a powerful, light-weight programming language designed for extending
+ applications. Lua is also frequently used as a general-purpose, stand-alone
+ language. Lua is free software.
+
+ For complete information, visit Lua's web site at http://www.lua.org/ .
+ For an executive summary, see http://www.lua.org/about.html .
+
+ Lua has been used in many different projects around the world.
+ For a short list, see http://www.lua.org/uses.html .
+
+* Availability
+ ------------
+ Lua is freely available for both academic and commercial purposes.
+ See COPYRIGHT and http://www.lua.org/license.html for details.
+ Lua can be downloaded at http://www.lua.org/download.html .
+
+* Installation
+ ------------
+ Lua is implemented in pure ANSI C, and compiles unmodified in all known
+ platforms that have an ANSI C compiler. In most Unix-like platforms, simply
+ do "make" with a suitable target. See INSTALL for detailed instructions.
+
+* Origin
+ ------
+ Lua is developed at Lua.org, a laboratory of the Department of Computer
+ Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro
+ in Brazil).
+ For more information about the authors, see http://www.lua.org/authors.html .
+
+(end of README)
View
BIN  user/lua-5.1.4/doc/amazon.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
499 user/lua-5.1.4/doc/contents.html
@@ -0,0 +1,499 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML>
+<HEAD>
+<TITLE>Lua 5.1 Reference Manual - contents</TITLE>
+<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
+<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
+<STYLE TYPE="text/css">
+ul {
+ list-style-type: none ;
+ list-style-position: outside ;
+}
+</STYLE>
+</HEAD>
+
+<BODY>
+
+<HR>
+<H1>
+<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="" BORDER=0></A>
+Lua 5.1 Reference Manual
+</H1>
+
+This is an online version of
+<BLOCKQUOTE>
+<A HREF="http://www.amazon.com/exec/obidos/ASIN/8590379833/lua-indexmanual-20">
+<IMG SRC="cover.png" ALT="" TITLE="buy from Amazon" BORDER=1 ALIGN="left" HSPACE=12>
+</A>
+<B>Lua 5.1 Reference Manual</B>
+<BR>by R. Ierusalimschy, L. H. de Figueiredo, W. Celes
+<BR>Lua.org, August 2006
+<BR>ISBN 85-903798-3-3
+<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/8590379833/lua-indexmanual-20">
+<IMG SRC="amazon.gif" ALT="[Buy from Amazon]" BORDER=0></A>
+<BR CLEAR="all">
+</BLOCKQUOTE>
+<P>
+
+Buy a copy of this book and
+<A HREF="http://www.lua.org/donations.html">help to support</A>
+the Lua project.
+<P>
+
+The reference manual is the official definition of the Lua language.
+For a complete introduction to Lua programming, see the book
+<A HREF="http://www.lua.org/docs.html#books">Programming in Lua</A>.
+<P>
+
+<A HREF="manual.html">start</A>
+&middot;
+<A HREF="#contents">contents</A>
+&middot;
+<A HREF="#index">index</A>
+&middot;
+<A HREF="http://www.lua.org/manual/5.1/pt/">português</A>
+&middot;
+<A HREF="http://www.lua.org/manual/5.1/es/">español</A>
+<HR>
+<SMALL>
+Copyright &copy; 2006-2008 Lua.org, PUC-Rio.
+Freely available under the terms of the
+<a href="http://www.lua.org/license.html#5">Lua license</a>.
+</SMALL>
+<P>
+
+<H2><A NAME="contents">Contents</A></H2>
+<UL style="padding: 0">
+<LI><A HREF="manual.html">1 - Introduction</A>
+<P>
+<LI><A HREF="manual.html#2">2 - The Language</A>
+<UL>
+<LI><A HREF="manual.html#2.1">2.1 - Lexical Conventions</A>
+<LI><A HREF="manual.html#2.2">2.2 - Values and Types</A>
+<UL>
+<LI><A HREF="manual.html#2.2.1">2.2.1 - Coercion</A>
+</UL>
+<LI><A HREF="manual.html#2.3">2.3 - Variables</A>
+<LI><A HREF="manual.html#2.4">2.4 - Statements</A>
+<UL>
+<LI><A HREF="manual.html#2.4.1">2.4.1 - Chunks</A>
+<LI><A HREF="manual.html#2.4.2">2.4.2 - Blocks</A>
+<LI><A HREF="manual.html#2.4.3">2.4.3 - Assignment</A>
+<LI><A HREF="manual.html#2.4.4">2.4.4 - Control Structures</A>
+<LI><A HREF="manual.html#2.4.5">2.4.5 - For Statement</A>
+<LI><A HREF="manual.html#2.4.6">2.4.6 - Function Calls as Statements</A>
+<LI><A HREF="manual.html#2.4.7">2.4.7 - Local Declarations</A>
+</UL>
+<LI><A HREF="manual.html#2.5">2.5 - Expressions</A>
+<UL>
+<LI><A HREF="manual.html#2.5.1">2.5.1 - Arithmetic Operators</A>
+<LI><A HREF="manual.html#2.5.2">2.5.2 - Relational Operators</A>
+<LI><A HREF="manual.html#2.5.3">2.5.3 - Logical Operators</A>
+<LI><A HREF="manual.html#2.5.4">2.5.4 - Concatenation</A>
+<LI><A HREF="manual.html#2.5.5">2.5.5 - The Length Operator</A>
+<LI><A HREF="manual.html#2.5.6">2.5.6 - Precedence</A>
+<LI><A HREF="manual.html#2.5.7">2.5.7 - Table Constructors</A>
+<LI><A HREF="manual.html#2.5.8">2.5.8 - Function Calls</A>
+<LI><A HREF="manual.html#2.5.9">2.5.9 - Function Definitions</A>
+</UL>
+<LI><A HREF="manual.html#2.6">2.6 - Visibility Rules</A>
+<LI><A HREF="manual.html#2.7">2.7 - Error Handling</A>
+<LI><A HREF="manual.html#2.8">2.8 - Metatables</A>
+<LI><A HREF="manual.html#2.9">2.9 - Environments</A>
+<LI><A HREF="manual.html#2.10">2.10 - Garbage Collection</A>
+<UL>
+<LI><A HREF="manual.html#2.10.1">2.10.1 - Garbage-Collection Metamethods</A>
+<LI><A HREF="manual.html#2.10.2">2.10.2 - Weak Tables</A>
+</UL>
+<LI><A HREF="manual.html#2.11">2.11 - Coroutines</A>
+</UL>
+<P>
+<LI><A HREF="manual.html#3">3 - The Application Program Interface</A>
+<UL>
+<LI><A HREF="manual.html#3.1">3.1 - The Stack</A>
+<LI><A HREF="manual.html#3.2">3.2 - Stack Size</A>
+<LI><A HREF="manual.html#3.3">3.3 - Pseudo-Indices</A>
+<LI><A HREF="manual.html#3.4">3.4 - C Closures</A>
+<LI><A HREF="manual.html#3.5">3.5 - Registry</A>
+<LI><A HREF="manual.html#3.6">3.6 - Error Handling in C</A>
+<LI><A HREF="manual.html#3.7">3.7 - Functions and Types</A>
+<LI><A HREF="manual.html#3.8">3.8 - The Debug Interface</A>
+</UL>
+<P>
+<LI><A HREF="manual.html#4">4 - The Auxiliary Library</A>
+<UL>
+<LI><A HREF="manual.html#4.1">4.1 - Functions and Types</A>
+</UL>
+<P>
+<LI><A HREF="manual.html#5">5 - Standard Libraries</A>
+<UL>
+<LI><A HREF="manual.html#5.1">5.1 - Basic Functions</A>
+<LI><A HREF="manual.html#5.2">5.2 - Coroutine Manipulation</A>
+<LI><A HREF="manual.html#5.3">5.3 - Modules</A>
+<LI><A HREF="manual.html#5.4">5.4 - String Manipulation</A>
+<UL>
+<LI><A HREF="manual.html#5.4.1">5.4.1 - Patterns</A>
+</UL>
+<LI><A HREF="manual.html#5.5">5.5 - Table Manipulation</A>
+<LI><A HREF="manual.html#5.6">5.6 - Mathematical Functions</A>
+<LI><A HREF="manual.html#5.7">5.7 - Input and Output Facilities</A>
+<LI><A HREF="manual.html#5.8">5.8 - Operating System Facilities</A>
+<LI><A HREF="manual.html#5.9">5.9 - The Debug Library</A>
+</UL>
+<P>
+<LI><A HREF="manual.html#6">6 - Lua Stand-alone</A>
+<P>
+<LI><A HREF="manual.html#7">7 - Incompatibilities with the Previous Version</A>
+<UL>
+<LI><A HREF="manual.html#7.1">7.1 - Changes in the Language</A>
+<LI><A HREF="manual.html#7.2">7.2 - Changes in the Libraries</A>
+<LI><A HREF="manual.html#7.3">7.3 - Changes in the API</A>
+</UL>
+<P>
+<LI><A HREF="manual.html#8">8 - The Complete Syntax of Lua</A>
+</UL>
+
+<H2><A NAME="index&quo