Index: branches/cparm/coding_standards.txt =================================================================== --- branches/cparm/coding_standards.txt (revision 1839) +++ branches/cparm/coding_standards.txt (revision 1840) @@ -81,3 +81,9 @@ 15. Don't optimize your code blindly, always favor readability when in doubt. Very often, optimization is not necessary where you think it is, think about the bubble sort algorithm, where people would code it in assembly, where a heap or quick sort algorithm would be much more efficient (n log(n) instead of quadratic complexity), as an example when values count to be sorted get high. + +16. To avoid duplicate symbols, set your variable as static and implement a setter/getter + +17. LIBSA SHOULDN'T CALL FUNCTION (OR INCLUDE HEADERS) OF LIBSAIO, AS WELL AS LIBSAIO SHOULDN'T CALL FUNCTIONS (OR INCLUDE HEADERS) OF BOOT2 + +18. Always declare your functions (static , implicit-extern or explicit-extern) \ No newline at end of file Index: branches/cparm/TODO =================================================================== --- branches/cparm/TODO (revision 1839) +++ branches/cparm/TODO (revision 1840) @@ -1,6 +1,10 @@ TODO List for Chameleon Boot Loader ==================================== +- Update cpu_intel_amd.c + +- Implement the bundles + - Implement a pool allocator, so each module will run and allocate memory in there own pool, de-alloc all allocated memory by the module, will be done simply by destroying the pool Index: branches/cparm/Chameleon.xcodeproj/project.pbxproj =================================================================== --- branches/cparm/Chameleon.xcodeproj/project.pbxproj (revision 1839) +++ branches/cparm/Chameleon.xcodeproj/project.pbxproj (revision 1840) @@ -3,11 +3,208 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXFileReference section */ AB0E930C14C6223500F798D7 /* cpu_intel_amd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpu_intel_amd.c; sourceTree = ""; }; + AB12D09914FBDAA60022AF9C /* ChangeLog.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ChangeLog.html; sourceTree = ""; }; + AB12D09B14FBDAA60022AF9C /* banner.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = banner.png; sourceTree = ""; }; + AB12D09C14FBDAA60022AF9C /* banner.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = banner.svg; sourceTree = ""; }; + AB12D09D14FBDAA60022AF9C /* grad_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = grad_blue.png; sourceTree = ""; }; + AB12D09E14FBDAA60022AF9C /* grad_blue.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = grad_blue.svg; sourceTree = ""; }; + AB12D09F14FBDAA60022AF9C /* rss.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rss.png; sourceTree = ""; }; + AB12D0A014FBDAA60022AF9C /* uthash-mini.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "uthash-mini.png"; sourceTree = ""; }; + AB12D0A114FBDAA60022AF9C /* uthash-mini.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "uthash-mini.svg"; sourceTree = ""; }; + AB12D0A214FBDAA60022AF9C /* uthash.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = uthash.png; sourceTree = ""; }; + AB12D0A314FBDAA60022AF9C /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = ""; }; + AB12D0A414FBDAA60022AF9C /* license.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = license.html; sourceTree = ""; }; + AB12D0A514FBDAA60022AF9C /* styles.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = styles.css; sourceTree = ""; }; + AB12D0A614FBDAA60022AF9C /* tdh-quirks.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "tdh-quirks.css"; sourceTree = ""; }; + AB12D0A714FBDAA60022AF9C /* tdh.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = tdh.css; sourceTree = ""; }; + AB12D0A814FBDAA60022AF9C /* toc.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = toc.css; sourceTree = ""; }; + AB12D0A914FBDAA60022AF9C /* userguide.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = userguide.html; sourceTree = ""; }; + AB12D0AA14FBDAA60022AF9C /* userguide.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = userguide.pdf; sourceTree = ""; }; + AB12D0AB14FBDAA60022AF9C /* utarray.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = utarray.html; sourceTree = ""; }; + AB12D0AC14FBDAA60022AF9C /* utlist.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = utlist.html; sourceTree = ""; }; + AB12D0AD14FBDAA60022AF9C /* utstring.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = utstring.html; sourceTree = ""; }; + AB12D0AE14FBDAA60022AF9C /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; + AB12D0AF14FBDAA60022AF9C /* NOTES */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NOTES; sourceTree = ""; }; + AB12D0B114FBDAA60022AF9C /* userguide.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = userguide.pdf; sourceTree = ""; }; + AB12D0B314FBDAA60022AF9C /* ChangeLog.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ChangeLog.txt; sourceTree = ""; }; + AB12D0B414FBDAA60022AF9C /* sflogo.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = sflogo.txt; sourceTree = ""; }; + AB12D0B514FBDAA60022AF9C /* toc.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = toc.txt; sourceTree = ""; }; + AB12D0B614FBDAA60022AF9C /* topnav.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = topnav.txt; sourceTree = ""; }; + AB12D0B714FBDAA60022AF9C /* topnav_utarray.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = topnav_utarray.txt; sourceTree = ""; }; + AB12D0B814FBDAA60022AF9C /* topnav_utlist.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = topnav_utlist.txt; sourceTree = ""; }; + AB12D0B914FBDAA60022AF9C /* topnav_utstring.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = topnav_utstring.txt; sourceTree = ""; }; + AB12D0BA14FBDAA60022AF9C /* userguide.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = userguide.txt; sourceTree = ""; }; + AB12D0BB14FBDAA60022AF9C /* utarray.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = utarray.txt; sourceTree = ""; }; + AB12D0BC14FBDAA60022AF9C /* utlist.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = utlist.txt; sourceTree = ""; }; + AB12D0BD14FBDAA60022AF9C /* utstring.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = utstring.txt; sourceTree = ""; }; + AB12D0BE14FBDAA60022AF9C /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; + AB12D0BF14FBDAA60022AF9C /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; + AB12D0C114FBDAA60022AF9C /* utarray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utarray.h; sourceTree = ""; }; + AB12D0C214FBDAA60022AF9C /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; + AB12D0C314FBDAA60022AF9C /* utlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utlist.h; sourceTree = ""; }; + AB12D0C414FBDAA60022AF9C /* utstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utstring.h; sourceTree = ""; }; + AB12D0C614FBDAA60022AF9C /* all_funcs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = all_funcs; sourceTree = ""; }; + AB12D0C714FBDAA60022AF9C /* bloom_perf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bloom_perf.c; sourceTree = ""; }; + AB12D0C814FBDAA60022AF9C /* bloom_perf.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = bloom_perf.sh; sourceTree = ""; }; + AB12D0C914FBDAA60022AF9C /* do_tests */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = do_tests; sourceTree = ""; }; + AB12D0CA14FBDAA60022AF9C /* do_tests.cygwin */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = do_tests.cygwin; sourceTree = ""; }; + AB12D0CB14FBDAA60022AF9C /* do_tests.mingw */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = do_tests.mingw; sourceTree = ""; }; + AB12D0CC14FBDAA60022AF9C /* do_tests_win32.cmd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = do_tests_win32.cmd; sourceTree = ""; }; + AB12D0CD14FBDAA60022AF9C /* emit_keys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = emit_keys.c; sourceTree = ""; }; + AB12D0CE14FBDAA60022AF9C /* example.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = example.c; sourceTree = ""; }; + AB12D0CF14FBDAA60022AF9C /* hashscan.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hashscan.c; sourceTree = ""; }; + AB12D0D014FBDAA60022AF9C /* keystat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = keystat.c; sourceTree = ""; }; + AB12D0D114FBDAA60022AF9C /* keystats */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = keystats; sourceTree = ""; }; + AB12D0D214FBDAA60022AF9C /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; + AB12D0D314FBDAA60022AF9C /* mexpand */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = mexpand; sourceTree = ""; }; + AB12D0D414FBDAA60022AF9C /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; + AB12D0D514FBDAA60022AF9C /* simkeys.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = simkeys.pl; sourceTree = ""; }; + AB12D0D614FBDAA60022AF9C /* sleep_test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sleep_test.c; sourceTree = ""; }; + AB12D0D714FBDAA60022AF9C /* tdiff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tdiff.cpp; sourceTree = ""; }; + AB12D0D814FBDAA60022AF9C /* test1.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test1.ans; sourceTree = ""; }; + AB12D0D914FBDAA60022AF9C /* test1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test1.c; sourceTree = ""; }; + AB12D0DA14FBDAA60022AF9C /* test10.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test10.ans; sourceTree = ""; }; + AB12D0DB14FBDAA60022AF9C /* test10.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test10.c; sourceTree = ""; }; + AB12D0DC14FBDAA60022AF9C /* test11.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test11.ans; sourceTree = ""; }; + AB12D0DD14FBDAA60022AF9C /* test11.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test11.c; sourceTree = ""; }; + AB12D0DE14FBDAA60022AF9C /* test11.dat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test11.dat; sourceTree = ""; }; + AB12D0DF14FBDAA60022AF9C /* test12.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test12.ans; sourceTree = ""; }; + AB12D0E014FBDAA60022AF9C /* test12.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test12.c; sourceTree = ""; }; + AB12D0E114FBDAA60022AF9C /* test13.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test13.ans; sourceTree = ""; }; + AB12D0E214FBDAA60022AF9C /* test13.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test13.c; sourceTree = ""; }; + AB12D0E314FBDAA60022AF9C /* test14.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test14.ans; sourceTree = ""; }; + AB12D0E414FBDAA60022AF9C /* test14.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test14.c; sourceTree = ""; }; + AB12D0E514FBDAA60022AF9C /* test14.dat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test14.dat; sourceTree = ""; }; + AB12D0E614FBDAA60022AF9C /* test15.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test15.ans; sourceTree = ""; }; + AB12D0E714FBDAA60022AF9C /* test15.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test15.c; sourceTree = ""; }; + AB12D0E814FBDAA60022AF9C /* test16.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test16.ans; sourceTree = ""; }; + AB12D0E914FBDAA60022AF9C /* test16.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test16.c; sourceTree = ""; }; + AB12D0EA14FBDAA60022AF9C /* test17.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test17.ans; sourceTree = ""; }; + AB12D0EB14FBDAA60022AF9C /* test17.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test17.c; sourceTree = ""; }; + AB12D0EC14FBDAA60022AF9C /* test18.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test18.ans; sourceTree = ""; }; + AB12D0ED14FBDAA60022AF9C /* test18.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test18.c; sourceTree = ""; }; + AB12D0EE14FBDAA60022AF9C /* test19.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test19.ans; sourceTree = ""; }; + AB12D0EF14FBDAA60022AF9C /* test19.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test19.c; sourceTree = ""; }; + AB12D0F014FBDAA60022AF9C /* test2.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test2.ans; sourceTree = ""; }; + AB12D0F114FBDAA60022AF9C /* test2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test2.c; sourceTree = ""; }; + AB12D0F214FBDAA60022AF9C /* test20.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test20.ans; sourceTree = ""; }; + AB12D0F314FBDAA60022AF9C /* test20.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test20.c; sourceTree = ""; }; + AB12D0F414FBDAA60022AF9C /* test21.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test21.ans; sourceTree = ""; }; + AB12D0F514FBDAA60022AF9C /* test21.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test21.c; sourceTree = ""; }; + AB12D0F614FBDAA60022AF9C /* test22.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test22.ans; sourceTree = ""; }; + AB12D0F714FBDAA60022AF9C /* test22.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test22.c; sourceTree = ""; }; + AB12D0F814FBDAA60022AF9C /* test23.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test23.ans; sourceTree = ""; }; + AB12D0F914FBDAA60022AF9C /* test23.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test23.c; sourceTree = ""; }; + AB12D0FA14FBDAA60022AF9C /* test24.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test24.ans; sourceTree = ""; }; + AB12D0FB14FBDAA60022AF9C /* test24.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test24.c; sourceTree = ""; }; + AB12D0FC14FBDAA60022AF9C /* test25.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test25.ans; sourceTree = ""; }; + AB12D0FD14FBDAA60022AF9C /* test25.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test25.c; sourceTree = ""; }; + AB12D0FE14FBDAA60022AF9C /* test26.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test26.ans; sourceTree = ""; }; + AB12D0FF14FBDAA60022AF9C /* test26.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test26.c; sourceTree = ""; }; + AB12D10014FBDAA60022AF9C /* test27.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test27.ans; sourceTree = ""; }; + AB12D10114FBDAA60022AF9C /* test27.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test27.c; sourceTree = ""; }; + AB12D10214FBDAA60022AF9C /* test28.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test28.ans; sourceTree = ""; }; + AB12D10314FBDAA60022AF9C /* test28.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test28.c; sourceTree = ""; }; + AB12D10414FBDAA60022AF9C /* test29.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test29.ans; sourceTree = ""; }; + AB12D10514FBDAA60022AF9C /* test29.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test29.c; sourceTree = ""; }; + AB12D10614FBDAA60022AF9C /* test3.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test3.ans; sourceTree = ""; }; + AB12D10714FBDAA60022AF9C /* test3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test3.c; sourceTree = ""; }; + AB12D10814FBDAA60022AF9C /* test30.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test30.ans; sourceTree = ""; }; + AB12D10914FBDAA60022AF9C /* test30.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test30.c; sourceTree = ""; }; + AB12D10A14FBDAA60022AF9C /* test31.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test31.ans; sourceTree = ""; }; + AB12D10B14FBDAA60022AF9C /* test31.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test31.c; sourceTree = ""; }; + AB12D10C14FBDAA60022AF9C /* test32.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test32.ans; sourceTree = ""; }; + AB12D10D14FBDAA60022AF9C /* test32.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test32.c; sourceTree = ""; }; + AB12D10E14FBDAA60022AF9C /* test33.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test33.ans; sourceTree = ""; }; + AB12D10F14FBDAA60022AF9C /* test33.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test33.c; sourceTree = ""; }; + AB12D11014FBDAA60022AF9C /* test34.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test34.ans; sourceTree = ""; }; + AB12D11114FBDAA60022AF9C /* test34.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test34.c; sourceTree = ""; }; + AB12D11214FBDAA60022AF9C /* test35.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test35.ans; sourceTree = ""; }; + AB12D11314FBDAA60022AF9C /* test35.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test35.c; sourceTree = ""; }; + AB12D11414FBDAA60022AF9C /* test36.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test36.ans; sourceTree = ""; }; + AB12D11514FBDAA60022AF9C /* test36.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test36.c; sourceTree = ""; }; + AB12D11614FBDAA60022AF9C /* test37.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test37.ans; sourceTree = ""; }; + AB12D11714FBDAA60022AF9C /* test37.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test37.c; sourceTree = ""; }; + AB12D11814FBDAA60022AF9C /* test38.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test38.ans; sourceTree = ""; }; + AB12D11914FBDAA60022AF9C /* test38.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test38.c; sourceTree = ""; }; + AB12D11A14FBDAA60022AF9C /* test39.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test39.ans; sourceTree = ""; }; + AB12D11B14FBDAA60022AF9C /* test39.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test39.c; sourceTree = ""; }; + AB12D11C14FBDAA60022AF9C /* test4.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test4.ans; sourceTree = ""; }; + AB12D11D14FBDAA60022AF9C /* test4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test4.c; sourceTree = ""; }; + AB12D11E14FBDAA60022AF9C /* test40.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test40.ans; sourceTree = ""; }; + AB12D11F14FBDAA60022AF9C /* test40.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test40.c; sourceTree = ""; }; + AB12D12014FBDAA60022AF9C /* test41.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test41.ans; sourceTree = ""; }; + AB12D12114FBDAA60022AF9C /* test41.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test41.c; sourceTree = ""; }; + AB12D12214FBDAA60022AF9C /* test42.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test42.ans; sourceTree = ""; }; + AB12D12314FBDAA60022AF9C /* test42.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test42.c; sourceTree = ""; }; + AB12D12414FBDAA60022AF9C /* test43.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test43.ans; sourceTree = ""; }; + AB12D12514FBDAA60022AF9C /* test43.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test43.c; sourceTree = ""; }; + AB12D12614FBDAA60022AF9C /* test44.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test44.ans; sourceTree = ""; }; + AB12D12714FBDAA60022AF9C /* test44.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test44.c; sourceTree = ""; }; + AB12D12814FBDAA60022AF9C /* test45.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test45.ans; sourceTree = ""; }; + AB12D12914FBDAA60022AF9C /* test45.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test45.c; sourceTree = ""; }; + AB12D12A14FBDAA60022AF9C /* test46.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test46.ans; sourceTree = ""; }; + AB12D12B14FBDAA60022AF9C /* test46.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test46.c; sourceTree = ""; }; + AB12D12C14FBDAA60022AF9C /* test47.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test47.ans; sourceTree = ""; }; + AB12D12D14FBDAA60022AF9C /* test47.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test47.c; sourceTree = ""; }; + AB12D12E14FBDAA60022AF9C /* test48.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test48.ans; sourceTree = ""; }; + AB12D12F14FBDAA60022AF9C /* test48.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test48.c; sourceTree = ""; }; + AB12D13014FBDAA60022AF9C /* test49.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test49.ans; sourceTree = ""; }; + AB12D13114FBDAA60022AF9C /* test49.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test49.c; sourceTree = ""; }; + AB12D13214FBDAA60022AF9C /* test5.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test5.ans; sourceTree = ""; }; + AB12D13314FBDAA60022AF9C /* test5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test5.c; sourceTree = ""; }; + AB12D13414FBDAA60022AF9C /* test50.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test50.ans; sourceTree = ""; }; + AB12D13514FBDAA60022AF9C /* test50.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test50.c; sourceTree = ""; }; + AB12D13614FBDAA60022AF9C /* test51.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test51.ans; sourceTree = ""; }; + AB12D13714FBDAA60022AF9C /* test51.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test51.c; sourceTree = ""; }; + AB12D13814FBDAA60022AF9C /* test52.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test52.ans; sourceTree = ""; }; + AB12D13914FBDAA60022AF9C /* test52.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test52.c; sourceTree = ""; }; + AB12D13A14FBDAA60022AF9C /* test53.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test53.ans; sourceTree = ""; }; + AB12D13B14FBDAA60022AF9C /* test53.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test53.c; sourceTree = ""; }; + AB12D13C14FBDAA60022AF9C /* test54.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test54.ans; sourceTree = ""; }; + AB12D13D14FBDAA60022AF9C /* test54.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test54.c; sourceTree = ""; }; + AB12D13E14FBDAA60022AF9C /* test55.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test55.ans; sourceTree = ""; }; + AB12D13F14FBDAA60022AF9C /* test55.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test55.c; sourceTree = ""; }; + AB12D14014FBDAA60022AF9C /* test56.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test56.ans; sourceTree = ""; }; + AB12D14114FBDAA60022AF9C /* test56.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test56.c; sourceTree = ""; }; + AB12D14214FBDAA60022AF9C /* test57.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test57.ans; sourceTree = ""; }; + AB12D14314FBDAA60022AF9C /* test57.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test57.c; sourceTree = ""; }; + AB12D14414FBDAA60022AF9C /* test58.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test58.ans; sourceTree = ""; }; + AB12D14514FBDAA60022AF9C /* test58.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test58.c; sourceTree = ""; }; + AB12D14614FBDAA60022AF9C /* test59.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test59.ans; sourceTree = ""; }; + AB12D14714FBDAA60022AF9C /* test59.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test59.c; sourceTree = ""; }; + AB12D14814FBDAA60022AF9C /* test6.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test6.ans; sourceTree = ""; }; + AB12D14914FBDAA60022AF9C /* test6.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test6.c; sourceTree = ""; }; + AB12D14A14FBDAA60022AF9C /* test60.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test60.ans; sourceTree = ""; }; + AB12D14B14FBDAA60022AF9C /* test60.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test60.c; sourceTree = ""; }; + AB12D14C14FBDAA60022AF9C /* test61.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test61.ans; sourceTree = ""; }; + AB12D14D14FBDAA60022AF9C /* test61.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test61.c; sourceTree = ""; }; + AB12D14E14FBDAA60022AF9C /* test62.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test62.ans; sourceTree = ""; }; + AB12D14F14FBDAA60022AF9C /* test62.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test62.c; sourceTree = ""; }; + AB12D15014FBDAA60022AF9C /* test63.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test63.ans; sourceTree = ""; }; + AB12D15114FBDAA60022AF9C /* test63.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test63.c; sourceTree = ""; }; + AB12D15214FBDAA60022AF9C /* test64.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test64.ans; sourceTree = ""; }; + AB12D15314FBDAA60022AF9C /* test64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test64.c; sourceTree = ""; }; + AB12D15414FBDAA60022AF9C /* test65.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test65.ans; sourceTree = ""; }; + AB12D15514FBDAA60022AF9C /* test65.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test65.c; sourceTree = ""; }; + AB12D15614FBDAA60022AF9C /* test65.dat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test65.dat; sourceTree = ""; }; + AB12D15714FBDAA60022AF9C /* test7.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test7.ans; sourceTree = ""; }; + AB12D15814FBDAA60022AF9C /* test7.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test7.c; sourceTree = ""; }; + AB12D15914FBDAA60022AF9C /* test8.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test8.ans; sourceTree = ""; }; + AB12D15A14FBDAA60022AF9C /* test8.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test8.c; sourceTree = ""; }; + AB12D15B14FBDAA60022AF9C /* test9.ans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test9.ans; sourceTree = ""; }; + AB12D15C14FBDAA60022AF9C /* test9.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test9.c; sourceTree = ""; }; + AB12D15E14FBDAA60022AF9C /* do_tests */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = do_tests; sourceTree = ""; }; + AB12D15F14FBDAA60022AF9C /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; + AB12D16014FBDAA60022AF9C /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; + AB12D16114FBDAA60022AF9C /* test1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test1.c; sourceTree = ""; }; + AB12D16214FBDAA60022AF9C /* test2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test2.c; sourceTree = ""; }; + AB1FFB0814FF0D8D006F7F4E /* lzss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lzss.c; sourceTree = ""; }; AB43B2B714C37E520018D529 /* boot0.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = boot0.s; sourceTree = ""; }; AB43B2B814C37E520018D529 /* boot0md.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = boot0md.s; sourceTree = ""; }; AB43B2B914C37E520018D529 /* chain0.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = chain0.s; sourceTree = ""; }; @@ -20,7 +217,7 @@ AB43B2C114C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B2C314C37E520018D529 /* appleboot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = appleboot.h; sourceTree = ""; }; AB43B2C414C37E520018D529 /* appleClut8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = appleClut8.h; sourceTree = ""; }; - AB43B2C514C37E520018D529 /* boot.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = boot.c; sourceTree = ""; }; + AB43B2C514C37E520018D529 /* boot.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = boot.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B2C614C37E520018D529 /* boot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = boot.h; sourceTree = ""; }; AB43B2C714C37E520018D529 /* boot2.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = boot2.s; sourceTree = ""; }; AB43B2C814C37E520018D529 /* drivers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = drivers.c; sourceTree = ""; }; @@ -28,14 +225,11 @@ AB43B2CA14C37E520018D529 /* failedboot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = failedboot.h; sourceTree = ""; }; AB43B2CB14C37E520018D529 /* graphics.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = graphics.c; sourceTree = ""; }; AB43B2CC14C37E520018D529 /* graphics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = graphics.h; sourceTree = ""; }; - AB43B2CD14C37E520018D529 /* lzss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lzss.c; sourceTree = ""; }; AB43B2CE14C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B2CF14C37E520018D529 /* mboot.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mboot.c; sourceTree = ""; }; AB43B2D014C37E520018D529 /* mboot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mboot.h; sourceTree = ""; }; - AB43B2D114C37E520018D529 /* modules.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = modules.c; sourceTree = ""; }; - AB43B2D214C37E520018D529 /* modules.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = modules.h; sourceTree = ""; }; AB43B2D314C37E520018D529 /* multiboot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = multiboot.h; sourceTree = ""; }; - AB43B2D414C37E520018D529 /* options.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = options.c; sourceTree = ""; }; + AB43B2D414C37E520018D529 /* options.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = options.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B2D514C37E520018D529 /* options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = options.h; sourceTree = ""; }; AB43B2D614C37E520018D529 /* prompt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = prompt.c; sourceTree = ""; }; AB43B2D814C37E520018D529 /* cdboot.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = cdboot.s; sourceTree = ""; }; @@ -89,7 +283,7 @@ AB43B30D14C37E520018D529 /* exfat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = exfat.h; sourceTree = ""; }; AB43B30E14C37E520018D529 /* ext2fs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ext2fs.c; sourceTree = ""; }; AB43B30F14C37E520018D529 /* ext2fs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ext2fs.h; sourceTree = ""; }; - AB43B31014C37E520018D529 /* fake_efi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fake_efi.c; sourceTree = ""; }; + AB43B31014C37E520018D529 /* fake_efi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = fake_efi.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B31114C37E520018D529 /* fake_efi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fake_efi.h; sourceTree = ""; }; AB43B31214C37E520018D529 /* fdisk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fdisk.h; sourceTree = ""; }; AB43B31314C37E520018D529 /* freebsd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = freebsd.c; sourceTree = ""; }; @@ -118,7 +312,7 @@ AB43B32A14C37E520018D529 /* openbsd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = openbsd.h; sourceTree = ""; }; AB43B32B14C37E520018D529 /* pci.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pci.c; sourceTree = ""; }; AB43B32C14C37E520018D529 /* pci.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pci.h; sourceTree = ""; }; - AB43B32D14C37E520018D529 /* pci_root.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pci_root.c; sourceTree = ""; }; + AB43B32D14C37E520018D529 /* pci_root.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = pci_root.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B32E14C37E520018D529 /* pci_root.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pci_root.h; sourceTree = ""; }; AB43B32F14C37E520018D529 /* platform.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = platform.c; sourceTree = ""; }; AB43B33014C37E520018D529 /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform.h; sourceTree = ""; }; @@ -131,8 +325,8 @@ AB43B33714C37E520018D529 /* SMBIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SMBIOS.h; sourceTree = ""; }; AB43B33814C37E520018D529 /* smp-imps.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "smp-imps.c"; sourceTree = ""; }; AB43B33914C37E520018D529 /* smp-imps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "smp-imps.h"; sourceTree = ""; }; - AB43B33A14C37E520018D529 /* stringTable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stringTable.c; sourceTree = ""; }; - AB43B33B14C37E520018D529 /* sys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sys.c; sourceTree = ""; }; + AB43B33A14C37E520018D529 /* stringTable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = stringTable.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; + AB43B33B14C37E520018D529 /* sys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = sys.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B33C14C37E520018D529 /* table.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = table.c; sourceTree = ""; }; AB43B33D14C37E520018D529 /* ufs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ufs.c; sourceTree = ""; }; AB43B33E14C37E520018D529 /* ufs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ufs.h; sourceTree = ""; }; @@ -149,19 +343,19 @@ AB43B34B14C37E520018D529 /* acpi_codec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpi_codec.h; sourceTree = ""; }; AB43B34C14C37E520018D529 /* acpicode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpicode.c; sourceTree = ""; }; AB43B34D14C37E520018D529 /* acpicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpicode.h; sourceTree = ""; }; - AB43B34E14C37E520018D529 /* ACPICodec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ACPICodec.c; sourceTree = ""; }; + AB43B34E14C37E520018D529 /* ACPICodec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = ACPICodec.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B34F14C37E520018D529 /* acpidecode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpidecode.c; sourceTree = ""; }; AB43B35014C37E520018D529 /* acpidecode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpidecode.h; sourceTree = ""; }; AB43B35114C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B35314C37E520018D529 /* acpi_patcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpi_patcher.c; sourceTree = ""; }; AB43B35414C37E520018D529 /* acpi_patcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpi_patcher.h; sourceTree = ""; }; - AB43B35514C37E520018D529 /* AcpiPatcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = AcpiPatcher.c; sourceTree = ""; }; + AB43B35514C37E520018D529 /* AcpiPatcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = AcpiPatcher.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B35614C37E520018D529 /* aml_generator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = aml_generator.c; sourceTree = ""; }; AB43B35714C37E520018D529 /* aml_generator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aml_generator.h; sourceTree = ""; }; AB43B35814C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B35A14C37E520018D529 /* CPUfreq.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CPUfreq.c; sourceTree = ""; }; AB43B35B14C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - AB43B35D14C37E520018D529 /* ati.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ati.c; sourceTree = ""; }; + AB43B35D14C37E520018D529 /* ati.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = ati.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B35E14C37E520018D529 /* ati.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ati.h; sourceTree = ""; }; AB43B35F14C37E520018D529 /* ati_reg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ati_reg.h; sourceTree = ""; }; AB43B36014C37E520018D529 /* gma.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gma.c; sourceTree = ""; }; @@ -175,7 +369,7 @@ AB43B36914C37E520018D529 /* gui.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gui.c; sourceTree = ""; }; AB43B36A14C37E520018D529 /* gui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gui.h; sourceTree = ""; }; AB43B36B14C37E520018D529 /* GUI_appleboot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUI_appleboot.h; sourceTree = ""; }; - AB43B36C14C37E520018D529 /* GUI_module.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = GUI_module.c; sourceTree = ""; }; + AB43B36C14C37E520018D529 /* GUI_module.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = GUI_module.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B36D14C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B36E14C37E520018D529 /* picopng.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = picopng.c; sourceTree = ""; }; AB43B36F14C37E520018D529 /* picopng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = picopng.h; sourceTree = ""; }; @@ -193,7 +387,7 @@ AB43B37E14C37E520018D529 /* HPET.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = HPET.c; sourceTree = ""; }; AB43B37F14C37E520018D529 /* hpet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hpet.h; sourceTree = ""; }; AB43B38014C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - AB43B38214C37E520018D529 /* kernel_patcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kernel_patcher.c; sourceTree = ""; }; + AB43B38214C37E520018D529 /* kernel_patcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = kernel_patcher.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B38314C37E520018D529 /* kernel_patcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kernel_patcher.h; sourceTree = ""; }; AB43B38414C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B38614C37E520018D529 /* adler32.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = adler32.c; sourceTree = ""; }; @@ -218,9 +412,9 @@ AB43B39914C37E520018D529 /* zlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zlib.h; sourceTree = ""; }; AB43B39A14C37E520018D529 /* zutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zutil.c; sourceTree = ""; }; AB43B39B14C37E520018D529 /* zutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zutil.h; sourceTree = ""; }; - AB43B39D14C37E520018D529 /* Keylayout.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Keylayout.c; sourceTree = ""; }; + AB43B39D14C37E520018D529 /* Keylayout.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = Keylayout.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B39E14C37E520018D529 /* Keylayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Keylayout.h; sourceTree = ""; }; - AB43B39F14C37E520018D529 /* Keymapper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Keymapper.c; sourceTree = ""; }; + AB43B39F14C37E520018D529 /* Keymapper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = Keymapper.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3A014C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B3A114C37E520018D529 /* term.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = term.h; sourceTree = ""; }; AB43B3A214C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; @@ -237,35 +431,35 @@ AB43B3AE14C37E520018D529 /* spd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = spd.c; sourceTree = ""; }; AB43B3AF14C37E520018D529 /* spd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spd.h; sourceTree = ""; }; AB43B3B114C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - AB43B3B214C37E520018D529 /* NBI.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = NBI.c; sourceTree = ""; }; + AB43B3B214C37E520018D529 /* NBI.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = NBI.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3B414C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B3B514C37E520018D529 /* Networking.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Networking.c; sourceTree = ""; }; AB43B3B714C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - AB43B3B814C37E520018D529 /* ramdisk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ramdisk.c; sourceTree = ""; }; + AB43B3B814C37E520018D529 /* ramdisk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = ramdisk.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3B914C37E520018D529 /* ramdisk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ramdisk.h; sourceTree = ""; }; - AB43B3BA14C37E520018D529 /* RamDiskLoader.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = RamDiskLoader.c; sourceTree = ""; }; + AB43B3BA14C37E520018D529 /* RamDiskLoader.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = RamDiskLoader.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3BC14C37E520018D529 /* 915resolution.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = 915resolution.c; sourceTree = ""; }; AB43B3BD14C37E520018D529 /* 915resolution.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 915resolution.h; sourceTree = ""; }; AB43B3BE14C37E520018D529 /* edid.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = edid.c; sourceTree = ""; }; AB43B3BF14C37E520018D529 /* edid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = edid.h; sourceTree = ""; }; AB43B3C014C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - AB43B3C114C37E520018D529 /* Resolution.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Resolution.c; sourceTree = ""; }; + AB43B3C114C37E520018D529 /* Resolution.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = Resolution.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3C214C37E520018D529 /* shortatombios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shortatombios.h; sourceTree = ""; }; AB43B3C414C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - AB43B3C514C37E520018D529 /* mysmbios.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mysmbios.c; sourceTree = ""; }; + AB43B3C514C37E520018D529 /* mysmbios.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = mysmbios.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3C614C37E520018D529 /* mysmbios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mysmbios.h; sourceTree = ""; }; AB43B3C714C37E520018D529 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; AB43B3C814C37E520018D529 /* smbios_decode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = smbios_decode.c; sourceTree = ""; }; AB43B3C914C37E520018D529 /* smbios_getters.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = smbios_getters.c; sourceTree = ""; }; AB43B3CA14C37E520018D529 /* smbios_getters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = smbios_getters.h; sourceTree = ""; }; - AB43B3CB14C37E520018D529 /* SMBiosGetters.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SMBiosGetters.c; sourceTree = ""; }; + AB43B3CB14C37E520018D529 /* SMBiosGetters.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = SMBiosGetters.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3CD14C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B3CE14C37E520018D529 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; - AB43B3CF14C37E520018D529 /* smbios_patcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = smbios_patcher.c; sourceTree = ""; }; + AB43B3CF14C37E520018D529 /* smbios_patcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = smbios_patcher.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3D014C37E520018D529 /* smbios_patcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = smbios_patcher.h; sourceTree = ""; }; - AB43B3D114C37E520018D529 /* SMBiosPatcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SMBiosPatcher.c; sourceTree = ""; }; + AB43B3D114C37E520018D529 /* SMBiosPatcher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = SMBiosPatcher.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3D314C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - AB43B3D414C37E520018D529 /* usb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = usb.c; sourceTree = ""; }; + AB43B3D414C37E520018D529 /* usb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = usb.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; AB43B3D514C37E520018D529 /* USBFix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = USBFix.c; sourceTree = ""; }; AB43B3D714C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; AB43B3D814C37E520018D529 /* YellowIconFixer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = YellowIconFixer.c; sourceTree = ""; }; @@ -293,6 +487,13 @@ AB43B42A14C3A8080018D529 /* arc4random.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = arc4random.c; sourceTree = ""; }; AB79217514F38CF200F5EB39 /* bootXnu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootXnu.h; sourceTree = ""; }; AB79219214F3919E00F5EB39 /* ModuleHelp.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ModuleHelp.txt; sourceTree = ""; }; + ABD521F114F9197900B62550 /* utarray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utarray.h; sourceTree = ""; }; + ABD521F214F9197900B62550 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; + ABD521F314F9197900B62550 /* uterror.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uterror.c; sourceTree = ""; }; + ABD521F414F9197900B62550 /* utlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utlist.h; sourceTree = ""; }; + ABD521F514F9197900B62550 /* utstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utstring.h; sourceTree = ""; }; + ABE5FF4E14F9495500447F78 /* modules.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; path = modules.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; + ABE5FF4F14F9495500447F78 /* modules.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = modules.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; B0056CD611F3868000754B65 /* boot */ = {isa = PBXFileReference; lastKnownFileType = text; path = boot; sourceTree = ""; }; B0056CD711F3868000754B65 /* boot.sys */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.preload"; path = boot.sys; sourceTree = ""; }; B0056CD811F3868000754B65 /* boot0 */ = {isa = PBXFileReference; lastKnownFileType = text; path = boot0; sourceTree = ""; }; @@ -459,6 +660,273 @@ name = Chameleon; sourceTree = ""; }; + AB12D09614FBDAA60022AF9C /* uthash-1.9.5 2 */ = { + isa = PBXGroup; + children = ( + AB12D09714FBDAA60022AF9C /* doc */, + AB12D0BE14FBDAA60022AF9C /* LICENSE */, + AB12D0BF14FBDAA60022AF9C /* README */, + AB12D0C014FBDAA60022AF9C /* src */, + AB12D0C514FBDAA60022AF9C /* tests */, + ); + path = "uthash-1.9.5 2"; + sourceTree = ""; + }; + AB12D09714FBDAA60022AF9C /* doc */ = { + isa = PBXGroup; + children = ( + AB12D09814FBDAA60022AF9C /* html */, + AB12D0AE14FBDAA60022AF9C /* Makefile */, + AB12D0AF14FBDAA60022AF9C /* NOTES */, + AB12D0B014FBDAA60022AF9C /* pdf */, + AB12D0B214FBDAA60022AF9C /* txt */, + ); + path = doc; + sourceTree = ""; + }; + AB12D09814FBDAA60022AF9C /* html */ = { + isa = PBXGroup; + children = ( + AB12D09914FBDAA60022AF9C /* ChangeLog.html */, + AB12D09A14FBDAA60022AF9C /* img */, + AB12D0A314FBDAA60022AF9C /* index.html */, + AB12D0A414FBDAA60022AF9C /* license.html */, + AB12D0A514FBDAA60022AF9C /* styles.css */, + AB12D0A614FBDAA60022AF9C /* tdh-quirks.css */, + AB12D0A714FBDAA60022AF9C /* tdh.css */, + AB12D0A814FBDAA60022AF9C /* toc.css */, + AB12D0A914FBDAA60022AF9C /* userguide.html */, + AB12D0AA14FBDAA60022AF9C /* userguide.pdf */, + AB12D0AB14FBDAA60022AF9C /* utarray.html */, + AB12D0AC14FBDAA60022AF9C /* utlist.html */, + AB12D0AD14FBDAA60022AF9C /* utstring.html */, + ); + path = html; + sourceTree = ""; + }; + AB12D09A14FBDAA60022AF9C /* img */ = { + isa = PBXGroup; + children = ( + AB12D09B14FBDAA60022AF9C /* banner.png */, + AB12D09C14FBDAA60022AF9C /* banner.svg */, + AB12D09D14FBDAA60022AF9C /* grad_blue.png */, + AB12D09E14FBDAA60022AF9C /* grad_blue.svg */, + AB12D09F14FBDAA60022AF9C /* rss.png */, + AB12D0A014FBDAA60022AF9C /* uthash-mini.png */, + AB12D0A114FBDAA60022AF9C /* uthash-mini.svg */, + AB12D0A214FBDAA60022AF9C /* uthash.png */, + ); + path = img; + sourceTree = ""; + }; + AB12D0B014FBDAA60022AF9C /* pdf */ = { + isa = PBXGroup; + children = ( + AB12D0B114FBDAA60022AF9C /* userguide.pdf */, + ); + path = pdf; + sourceTree = ""; + }; + AB12D0B214FBDAA60022AF9C /* txt */ = { + isa = PBXGroup; + children = ( + AB12D0B314FBDAA60022AF9C /* ChangeLog.txt */, + AB12D0B414FBDAA60022AF9C /* sflogo.txt */, + AB12D0B514FBDAA60022AF9C /* toc.txt */, + AB12D0B614FBDAA60022AF9C /* topnav.txt */, + AB12D0B714FBDAA60022AF9C /* topnav_utarray.txt */, + AB12D0B814FBDAA60022AF9C /* topnav_utlist.txt */, + AB12D0B914FBDAA60022AF9C /* topnav_utstring.txt */, + AB12D0BA14FBDAA60022AF9C /* userguide.txt */, + AB12D0BB14FBDAA60022AF9C /* utarray.txt */, + AB12D0BC14FBDAA60022AF9C /* utlist.txt */, + AB12D0BD14FBDAA60022AF9C /* utstring.txt */, + ); + path = txt; + sourceTree = ""; + }; + AB12D0C014FBDAA60022AF9C /* src */ = { + isa = PBXGroup; + children = ( + AB12D0C114FBDAA60022AF9C /* utarray.h */, + AB12D0C214FBDAA60022AF9C /* uthash.h */, + AB12D0C314FBDAA60022AF9C /* utlist.h */, + AB12D0C414FBDAA60022AF9C /* utstring.h */, + ); + path = src; + sourceTree = ""; + }; + AB12D0C514FBDAA60022AF9C /* tests */ = { + isa = PBXGroup; + children = ( + AB12D0C614FBDAA60022AF9C /* all_funcs */, + AB12D0C714FBDAA60022AF9C /* bloom_perf.c */, + AB12D0C814FBDAA60022AF9C /* bloom_perf.sh */, + AB12D0C914FBDAA60022AF9C /* do_tests */, + AB12D0CA14FBDAA60022AF9C /* do_tests.cygwin */, + AB12D0CB14FBDAA60022AF9C /* do_tests.mingw */, + AB12D0CC14FBDAA60022AF9C /* do_tests_win32.cmd */, + AB12D0CD14FBDAA60022AF9C /* emit_keys.c */, + AB12D0CE14FBDAA60022AF9C /* example.c */, + AB12D0CF14FBDAA60022AF9C /* hashscan.c */, + AB12D0D014FBDAA60022AF9C /* keystat.c */, + AB12D0D114FBDAA60022AF9C /* keystats */, + AB12D0D214FBDAA60022AF9C /* Makefile */, + AB12D0D314FBDAA60022AF9C /* mexpand */, + AB12D0D414FBDAA60022AF9C /* README */, + AB12D0D514FBDAA60022AF9C /* simkeys.pl */, + AB12D0D614FBDAA60022AF9C /* sleep_test.c */, + AB12D0D714FBDAA60022AF9C /* tdiff.cpp */, + AB12D0D814FBDAA60022AF9C /* test1.ans */, + AB12D0D914FBDAA60022AF9C /* test1.c */, + AB12D0DA14FBDAA60022AF9C /* test10.ans */, + AB12D0DB14FBDAA60022AF9C /* test10.c */, + AB12D0DC14FBDAA60022AF9C /* test11.ans */, + AB12D0DD14FBDAA60022AF9C /* test11.c */, + AB12D0DE14FBDAA60022AF9C /* test11.dat */, + AB12D0DF14FBDAA60022AF9C /* test12.ans */, + AB12D0E014FBDAA60022AF9C /* test12.c */, + AB12D0E114FBDAA60022AF9C /* test13.ans */, + AB12D0E214FBDAA60022AF9C /* test13.c */, + AB12D0E314FBDAA60022AF9C /* test14.ans */, + AB12D0E414FBDAA60022AF9C /* test14.c */, + AB12D0E514FBDAA60022AF9C /* test14.dat */, + AB12D0E614FBDAA60022AF9C /* test15.ans */, + AB12D0E714FBDAA60022AF9C /* test15.c */, + AB12D0E814FBDAA60022AF9C /* test16.ans */, + AB12D0E914FBDAA60022AF9C /* test16.c */, + AB12D0EA14FBDAA60022AF9C /* test17.ans */, + AB12D0EB14FBDAA60022AF9C /* test17.c */, + AB12D0EC14FBDAA60022AF9C /* test18.ans */, + AB12D0ED14FBDAA60022AF9C /* test18.c */, + AB12D0EE14FBDAA60022AF9C /* test19.ans */, + AB12D0EF14FBDAA60022AF9C /* test19.c */, + AB12D0F014FBDAA60022AF9C /* test2.ans */, + AB12D0F114FBDAA60022AF9C /* test2.c */, + AB12D0F214FBDAA60022AF9C /* test20.ans */, + AB12D0F314FBDAA60022AF9C /* test20.c */, + AB12D0F414FBDAA60022AF9C /* test21.ans */, + AB12D0F514FBDAA60022AF9C /* test21.c */, + AB12D0F614FBDAA60022AF9C /* test22.ans */, + AB12D0F714FBDAA60022AF9C /* test22.c */, + AB12D0F814FBDAA60022AF9C /* test23.ans */, + AB12D0F914FBDAA60022AF9C /* test23.c */, + AB12D0FA14FBDAA60022AF9C /* test24.ans */, + AB12D0FB14FBDAA60022AF9C /* test24.c */, + AB12D0FC14FBDAA60022AF9C /* test25.ans */, + AB12D0FD14FBDAA60022AF9C /* test25.c */, + AB12D0FE14FBDAA60022AF9C /* test26.ans */, + AB12D0FF14FBDAA60022AF9C /* test26.c */, + AB12D10014FBDAA60022AF9C /* test27.ans */, + AB12D10114FBDAA60022AF9C /* test27.c */, + AB12D10214FBDAA60022AF9C /* test28.ans */, + AB12D10314FBDAA60022AF9C /* test28.c */, + AB12D10414FBDAA60022AF9C /* test29.ans */, + AB12D10514FBDAA60022AF9C /* test29.c */, + AB12D10614FBDAA60022AF9C /* test3.ans */, + AB12D10714FBDAA60022AF9C /* test3.c */, + AB12D10814FBDAA60022AF9C /* test30.ans */, + AB12D10914FBDAA60022AF9C /* test30.c */, + AB12D10A14FBDAA60022AF9C /* test31.ans */, + AB12D10B14FBDAA60022AF9C /* test31.c */, + AB12D10C14FBDAA60022AF9C /* test32.ans */, + AB12D10D14FBDAA60022AF9C /* test32.c */, + AB12D10E14FBDAA60022AF9C /* test33.ans */, + AB12D10F14FBDAA60022AF9C /* test33.c */, + AB12D11014FBDAA60022AF9C /* test34.ans */, + AB12D11114FBDAA60022AF9C /* test34.c */, + AB12D11214FBDAA60022AF9C /* test35.ans */, + AB12D11314FBDAA60022AF9C /* test35.c */, + AB12D11414FBDAA60022AF9C /* test36.ans */, + AB12D11514FBDAA60022AF9C /* test36.c */, + AB12D11614FBDAA60022AF9C /* test37.ans */, + AB12D11714FBDAA60022AF9C /* test37.c */, + AB12D11814FBDAA60022AF9C /* test38.ans */, + AB12D11914FBDAA60022AF9C /* test38.c */, + AB12D11A14FBDAA60022AF9C /* test39.ans */, + AB12D11B14FBDAA60022AF9C /* test39.c */, + AB12D11C14FBDAA60022AF9C /* test4.ans */, + AB12D11D14FBDAA60022AF9C /* test4.c */, + AB12D11E14FBDAA60022AF9C /* test40.ans */, + AB12D11F14FBDAA60022AF9C /* test40.c */, + AB12D12014FBDAA60022AF9C /* test41.ans */, + AB12D12114FBDAA60022AF9C /* test41.c */, + AB12D12214FBDAA60022AF9C /* test42.ans */, + AB12D12314FBDAA60022AF9C /* test42.c */, + AB12D12414FBDAA60022AF9C /* test43.ans */, + AB12D12514FBDAA60022AF9C /* test43.c */, + AB12D12614FBDAA60022AF9C /* test44.ans */, + AB12D12714FBDAA60022AF9C /* test44.c */, + AB12D12814FBDAA60022AF9C /* test45.ans */, + AB12D12914FBDAA60022AF9C /* test45.c */, + AB12D12A14FBDAA60022AF9C /* test46.ans */, + AB12D12B14FBDAA60022AF9C /* test46.c */, + AB12D12C14FBDAA60022AF9C /* test47.ans */, + AB12D12D14FBDAA60022AF9C /* test47.c */, + AB12D12E14FBDAA60022AF9C /* test48.ans */, + AB12D12F14FBDAA60022AF9C /* test48.c */, + AB12D13014FBDAA60022AF9C /* test49.ans */, + AB12D13114FBDAA60022AF9C /* test49.c */, + AB12D13214FBDAA60022AF9C /* test5.ans */, + AB12D13314FBDAA60022AF9C /* test5.c */, + AB12D13414FBDAA60022AF9C /* test50.ans */, + AB12D13514FBDAA60022AF9C /* test50.c */, + AB12D13614FBDAA60022AF9C /* test51.ans */, + AB12D13714FBDAA60022AF9C /* test51.c */, + AB12D13814FBDAA60022AF9C /* test52.ans */, + AB12D13914FBDAA60022AF9C /* test52.c */, + AB12D13A14FBDAA60022AF9C /* test53.ans */, + AB12D13B14FBDAA60022AF9C /* test53.c */, + AB12D13C14FBDAA60022AF9C /* test54.ans */, + AB12D13D14FBDAA60022AF9C /* test54.c */, + AB12D13E14FBDAA60022AF9C /* test55.ans */, + AB12D13F14FBDAA60022AF9C /* test55.c */, + AB12D14014FBDAA60022AF9C /* test56.ans */, + AB12D14114FBDAA60022AF9C /* test56.c */, + AB12D14214FBDAA60022AF9C /* test57.ans */, + AB12D14314FBDAA60022AF9C /* test57.c */, + AB12D14414FBDAA60022AF9C /* test58.ans */, + AB12D14514FBDAA60022AF9C /* test58.c */, + AB12D14614FBDAA60022AF9C /* test59.ans */, + AB12D14714FBDAA60022AF9C /* test59.c */, + AB12D14814FBDAA60022AF9C /* test6.ans */, + AB12D14914FBDAA60022AF9C /* test6.c */, + AB12D14A14FBDAA60022AF9C /* test60.ans */, + AB12D14B14FBDAA60022AF9C /* test60.c */, + AB12D14C14FBDAA60022AF9C /* test61.ans */, + AB12D14D14FBDAA60022AF9C /* test61.c */, + AB12D14E14FBDAA60022AF9C /* test62.ans */, + AB12D14F14FBDAA60022AF9C /* test62.c */, + AB12D15014FBDAA60022AF9C /* test63.ans */, + AB12D15114FBDAA60022AF9C /* test63.c */, + AB12D15214FBDAA60022AF9C /* test64.ans */, + AB12D15314FBDAA60022AF9C /* test64.c */, + AB12D15414FBDAA60022AF9C /* test65.ans */, + AB12D15514FBDAA60022AF9C /* test65.c */, + AB12D15614FBDAA60022AF9C /* test65.dat */, + AB12D15714FBDAA60022AF9C /* test7.ans */, + AB12D15814FBDAA60022AF9C /* test7.c */, + AB12D15914FBDAA60022AF9C /* test8.ans */, + AB12D15A14FBDAA60022AF9C /* test8.c */, + AB12D15B14FBDAA60022AF9C /* test9.ans */, + AB12D15C14FBDAA60022AF9C /* test9.c */, + AB12D15D14FBDAA60022AF9C /* threads */, + ); + path = tests; + sourceTree = ""; + }; + AB12D15D14FBDAA60022AF9C /* threads */ = { + isa = PBXGroup; + children = ( + AB12D15E14FBDAA60022AF9C /* do_tests */, + AB12D15F14FBDAA60022AF9C /* Makefile */, + AB12D16014FBDAA60022AF9C /* README */, + AB12D16114FBDAA60022AF9C /* test1.c */, + AB12D16214FBDAA60022AF9C /* test2.c */, + ); + path = threads; + sourceTree = ""; + }; AB43B2B514C37E520018D529 /* i386 */ = { isa = PBXGroup; children = ( @@ -515,12 +983,9 @@ AB43B2CA14C37E520018D529 /* failedboot.h */, AB43B2CB14C37E520018D529 /* graphics.c */, AB43B2CC14C37E520018D529 /* graphics.h */, - AB43B2CD14C37E520018D529 /* lzss.c */, AB43B2CE14C37E520018D529 /* Makefile */, AB43B2CF14C37E520018D529 /* mboot.c */, AB43B2D014C37E520018D529 /* mboot.h */, - AB43B2D114C37E520018D529 /* modules.c */, - AB43B2D214C37E520018D529 /* modules.h */, AB43B2D314C37E520018D529 /* multiboot.h */, AB43B2D414C37E520018D529 /* options.c */, AB43B2D514C37E520018D529 /* options.h */, @@ -562,6 +1027,7 @@ AB43B2DF14C37E520018D529 /* efi_tables.c */, AB43B2E014C37E520018D529 /* efi_tables.h */, AB43B2E214C37E520018D529 /* libsa.h */, + AB1FFB0814FF0D8D006F7F4E /* lzss.c */, AB43B2E314C37E520018D529 /* Makefile */, AB43B2E414C37E520018D529 /* memory.h */, AB43B2E514C37E520018D529 /* prf.c */, @@ -632,6 +1098,8 @@ AB43B31E14C37E520018D529 /* Makefile */, AB43B31F14C37E520018D529 /* md5c.c */, AB43B32014C37E520018D529 /* misc.c */, + ABE5FF4E14F9495500447F78 /* modules.c */, + ABE5FF4F14F9495500447F78 /* modules.h */, AB43B32114C37E520018D529 /* msdos.c */, AB43B32214C37E520018D529 /* msdos.h */, AB43B32314C37E520018D529 /* msdos_private.h */, @@ -665,6 +1133,11 @@ AB43B33E14C37E520018D529 /* ufs.h */, AB43B33F14C37E520018D529 /* ufs_byteorder.c */, AB43B34014C37E520018D529 /* ufs_byteorder.h */, + ABD521F114F9197900B62550 /* utarray.h */, + ABD521F214F9197900B62550 /* uthash.h */, + ABD521F314F9197900B62550 /* uterror.c */, + ABD521F414F9197900B62550 /* utlist.h */, + ABD521F514F9197900B62550 /* utstring.h */, AB43B34114C37E520018D529 /* vbe.c */, AB43B34214C37E520018D529 /* vbe.h */, AB43B34314C37E520018D529 /* xml.c */, @@ -967,6 +1440,7 @@ AB43B3D914C37E520018D529 /* util */ = { isa = PBXGroup; children = ( + AB12D09614FBDAA60022AF9C /* uthash-1.9.5 2 */, AB43B3DA14C37E520018D529 /* amlsgn.m */, AB43B3DB14C37E520018D529 /* bdmesg.c */, AB43B3DC14C37E530018D529 /* Intel_Acpi */, @@ -1361,8 +1835,11 @@ /* Begin PBXProject section */ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0420; + }; buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "Chameleon" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( @@ -1433,7 +1910,6 @@ COPY_PHASE_STRIP = NO; DEBUGGING_SYMBOLS = YES; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_OPTIMIZATION_LEVEL = 0; OTHER_CFLAGS = ""; @@ -1446,7 +1922,6 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - GCC_ENABLE_FIX_AND_CONTINUE = NO; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; PRODUCT_NAME = Chameleon; @@ -1459,9 +1934,9 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = Debug; }; @@ -1471,8 +1946,8 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = macosx10.6; + MACOSX_DEPLOYMENT_TARGET = 10.7; + SDKROOT = macosx; }; name = Release; }; Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 1839) +++ branches/cparm/CHANGES (revision 1840) @@ -1,3 +1,9 @@ +- Many security and bug fixes and improvements +- Added a workaround for some machines that was unable to enter to the startup options during the countdown +- Implemented a new environment platform +- Added mountain lion support +- Improved Xcode4 support (GUI still work only with Xcode3) + - Added mountain lion icons for the default themes and LogintoLion (credit to Blackosx) - Added cpu_intel_amd.c (not by default, you need to edit the makefile in the libsaio directory to compile it) - Implemented a stack_protector (seems to work) Index: branches/cparm/i386/libsaio/fake_efi.h =================================================================== --- branches/cparm/i386/libsaio/fake_efi.h (revision 1839) +++ branches/cparm/i386/libsaio/fake_efi.h (revision 1840) @@ -14,6 +14,8 @@ extern void setupFakeEfi(void); +extern EFI_STATUS setup_acpi (void); + extern EFI_STATUS addConfigurationTable(); extern struct SMBEntryPoint *getSmbiosOriginal(); @@ -22,4 +24,8 @@ extern void finalizeEFIConfigTable(void ); +extern EFI_STATUS Register_Acpi_Efi(void* rsd_p, unsigned char rev ); + +extern void Register_Smbios_Efi(void* smbios); + #endif /* !__LIBSAIO_FAKE_EFI_H */ Index: branches/cparm/i386/libsaio/xml.c =================================================================== --- branches/cparm/i386/libsaio/xml.c (revision 1839) +++ branches/cparm/i386/libsaio/xml.c (revision 1840) @@ -27,12 +27,24 @@ #include "sl.h" #include "xml.h" +#define ASSERT_DICT \ +if (dict == DEFAULT_BOOT_CONFIG_DICT) \ +dict = bootInfo->bootConfig.dictionary ; \ +else if (dict == DEFAULT_SYSTEM_CONFIG_DICT) \ +dict = bootInfo->SystemConfig.dictionary ; \ +else if (dict == DEFAULT_OVERRIDE_CONFIG_DICT) \ +dict = bootInfo->overrideConfig.dictionary ; \ +else if (dict == DEFAULT_SMBIOS_CONFIG_DICT) \ +dict = bootInfo->smbiosConfig.dictionary ; \ +else if (dict == DEFAULT_HELPER_CONFIG_DICT) \ +dict = bootInfo->helperConfig.dictionary ; + string_ref *ref_strings = NULL; /// TODO: remove below static char* buffer_start = NULL; // TODO: redo the next two functions -void SaveRefString(char* string, int id) +static void SaveRefString(char* string, int id) { //printf("Adding Ref String %d (%s)\n", id, string); string_ref* tmp = ref_strings; @@ -55,7 +67,7 @@ ref_strings = new_ref; } -char* GetRefString(int id) +static char* GetRefString(int id) { string_ref* tmp = ref_strings; while(tmp) @@ -67,46 +79,6 @@ return "Unknown"; } - -struct Module { - struct Module *nextModule; - long willLoad; - TagPtr dict; - char *plistAddr; - long plistLength; - char *driverPath; -}; -typedef struct Module Module, *ModulePtr; - -struct DriverInfo { - char *plistAddr; - long plistLength; - void *moduleAddr; - long moduleLength; -}; -typedef struct DriverInfo DriverInfo, *DriverInfoPtr; - -//#define kDriverPackageSignature1 'MKXT' -//#define kDriverPackageSignature2 'MOSX' - -struct DriversPackage { - unsigned long signature1; - unsigned long signature2; - unsigned long length; - unsigned long alder32; - unsigned long version; - unsigned long numDrivers; - unsigned long reserved1; - unsigned long reserved2; -}; -typedef struct DriversPackage DriversPackage; - -enum { - kCFBundleType2, - kCFBundleType3 -}; - - #define USEMALLOC 1 #define DOFREE 1 @@ -133,7 +105,9 @@ XMLGetProperty( TagPtr dict, const char * key ) { TagPtr tagList, tag; - + + ASSERT_DICT + if (dict->type != kTagTypeDict) return 0; tag = 0; @@ -159,7 +133,9 @@ { int count = 0; TagPtr tagList, tag; - + + ASSERT_DICT + if (dict->type != kTagTypeDict && dict->type != kTagTypeArray) return 0; tag = 0; tagList = dict->tag; @@ -173,7 +149,7 @@ ) continue; if(tag->type == kTagTypeKey) printf("Located key %s\n", tag->string); - + count++; } @@ -182,11 +158,13 @@ TagPtr XMLGetElement( TagPtr dict, int id ) { + ASSERT_DICT + if(dict->type != kTagTypeArray) return 0; int element = 0; TagPtr tmp = dict->tag; - + while(element < id) { element++; @@ -207,7 +185,7 @@ } XMLEntity; /* This is ugly, but better than specifying the lengths by hand */ - #define _e(str,c) {str,sizeof(str)-1,c} +#define _e(str,c) {str,sizeof(str)-1,c} const XMLEntity ents[] = { _e("quot;",'"'), _e("apos;",'\''), _e("lt;", '<'), _e("gt;", '>'), @@ -249,7 +227,7 @@ *o++ = *s++; } - + return out; } @@ -274,17 +252,17 @@ strcpy(configBuffer, buffer); buffer_start = configBuffer; - + while (1) { length = XMLParseNextTag(configBuffer + pos, &tag); if (length == -1) break; - + pos += length; - + if (tag == 0) continue; if (tag->type == kTagTypeDict) break; - + XMLFreeTag(tag); } free(configBuffer); @@ -303,7 +281,7 @@ { long length, pos; char * tagName; - + length = GetNextTag(buffer, &tagName, 0); if (length == -1) return -1; @@ -363,7 +341,7 @@ } length = ParseTagString(buffer + pos, tag); - + SaveRefString(buffer + pos, id); } else if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) @@ -390,7 +368,7 @@ } char* str = GetRefString(id); - + TagPtr tmpTag = NewTag(); tmpTag->type = kTagTypeString; tmpTag->string = str; @@ -402,7 +380,7 @@ length = 0; //printf("Located IDREF, id = %d, string = %s\n", id, str); } - + } /***** integer ****/ @@ -470,7 +448,7 @@ tmpTag->tag = 0; tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start + pos : 0; - + *tag = tmpTag; length = 0; @@ -533,10 +511,10 @@ *tag = 0; length = 0; } - - + + if (length == -1) return -1; - + return pos + length; } @@ -548,38 +526,38 @@ { long length, pos; TagPtr tagList, tmpTag; - + tagList = 0; pos = 0; - + if (!empty) { while (1) { length = XMLParseNextTag(buffer + pos, &tmpTag); if (length == -1) break; - + pos += length; - + if (tmpTag == 0) break; tmpTag->tagNext = tagList; tagList = tmpTag; } - + if (length == -1) { XMLFreeTag(tagList); return -1; } } - + tmpTag = NewTag(); if (tmpTag == 0) { XMLFreeTag(tagList); return -1; } - + tmpTag->type = type; tmpTag->string = 0; tmpTag->offset = buffer_start ? buffer - buffer_start : 0; @@ -600,20 +578,20 @@ long length, length2; char *string; TagPtr tmpTag, subTag; - + length = FixDataMatchingTag(buffer, kXMLTagKey); if (length == -1) return -1; - + length2 = XMLParseNextTag(buffer + length, &subTag); if (length2 == -1) return -1; - + tmpTag = NewTag(); if (tmpTag == 0) { XMLFreeTag(subTag); return -1; } - + string = NewSymbol(buffer); if (string == 0) { @@ -621,15 +599,15 @@ XMLFreeTag(tmpTag); return -1; } - + tmpTag->type = kTagTypeKey; tmpTag->string = string; tmpTag->tag = subTag; tmpTag->offset = buffer_start ? buffer - buffer_start: 0; tmpTag->tagNext = 0; - + *tag = tmpTag; - + return length + length2; } @@ -642,26 +620,26 @@ long length; char * string; TagPtr tmpTag; - + length = FixDataMatchingTag(buffer, kXMLTagString); if (length == -1) return -1; - + tmpTag = NewTag(); if (tmpTag == 0) return -1; - + string = NewSymbol(buffer); if (string == 0) { XMLFreeTag(tmpTag); return -1; } - + tmpTag->type = kTagTypeString; tmpTag->string = string; tmpTag->tag = 0; tmpTag->offset = buffer_start ? buffer - buffer_start: 0; tmpTag->tagNext = 0; - + *tag = tmpTag; return length; } @@ -701,7 +679,7 @@ if (tmpTag == 0) return -1; integer = 0; - + if(size > 1 && (val[1] == 'x' || val[1] == 'X')) // Hex value { val += 2; @@ -726,7 +704,7 @@ return -1; } - + } } else if ( size ) // Decimal value @@ -756,7 +734,7 @@ if (negative) integer = -integer; } - + tmpTag->type = kTagTypeInteger; tmpTag->string = (char *)integer; tmpTag->tag = 0; @@ -764,7 +742,7 @@ tmpTag->tagNext = 0; *tag = tmpTag; - + return length; } @@ -776,7 +754,7 @@ { long length; TagPtr tmpTag; - + length = FixDataMatchingTag(buffer, kXMLTagData); if (length == -1) return -1; @@ -859,7 +837,7 @@ GetNextTag( char * buffer, char ** tag, long * start ) { long cnt, cnt2; - + if (tag == 0) return -1; // Find the start of the tag. @@ -871,7 +849,7 @@ cnt2 = cnt + 1; while ((buffer[cnt2] != '\0') && (buffer[cnt2] != '>')) cnt2++; if (buffer[cnt2] == '\0') return -1; - + // Fix the tag data. *tag = buffer + cnt + 1; buffer[cnt2] = '\0'; @@ -919,7 +897,7 @@ { long cnt; TagPtr tag; - + if (gTagsFree == 0) { #if USEMALLOC @@ -938,10 +916,10 @@ tag[cnt].tagNext = tag + cnt + 1; } tag[kTagsPerBlock - 1].tagNext = 0; - + gTagsFree = tag; } - + tag = gTagsFree; gTagsFree = tag->tagNext; @@ -956,12 +934,12 @@ { #if DOFREE if (tag == 0) return; - + if (tag->string) FreeSymbol(tag->string); - + XMLFreeTag(tag->tag); XMLFreeTag(tag->tagNext); - + // Clear and free the tag. tag->type = kTagTypeNone; tag->string = 0; @@ -979,9 +957,9 @@ struct Symbol { - long refCount; - struct Symbol *next; - char string[]; + long refCount; + struct Symbol *next; + char string[]; }; typedef struct Symbol Symbol, *SymbolPtr; @@ -995,12 +973,12 @@ static char * NewSymbol( char * string ) { -static SymbolPtr lastGuy = 0; + static SymbolPtr lastGuy = 0; SymbolPtr symbol; - + // Look for string in the list of symbols. symbol = FindSymbol(string, 0); - + // Add the new symbol. if (symbol == 0) { @@ -1011,20 +989,20 @@ #endif if (symbol == 0) //return 0; stop("NULL symbol!"); - + // Set the symbol's data. symbol->refCount = 0; strcpy(symbol->string, string); - + // Add the symbol to the list. symbol->next = gSymbolsHead; gSymbolsHead = symbol; } - + // Update the refCount and return the string. symbol->refCount++; - - if (lastGuy && lastGuy->next != 0) stop("last guy not last!"); + + if (lastGuy && lastGuy->next != 0) stop("last guy not last!"); return symbol->string; } @@ -1037,7 +1015,7 @@ { SymbolPtr symbol, prev; prev = 0; - + // Look for string in the list of symbols. symbol = FindSymbol(string, &prev); if (symbol == 0) return; @@ -1063,19 +1041,19 @@ FindSymbol( char * string, SymbolPtr * prevSymbol ) { SymbolPtr symbol, prev; - + symbol = gSymbolsHead; prev = 0; - + while (symbol != 0) { if (!strcmp(symbol->string, string)) break; - + prev = symbol; symbol = symbol->next; } - + if ((symbol != 0) && (prevSymbol != 0)) *prevSymbol = prev; - + return symbol; } @@ -1107,7 +1085,7 @@ char* XMLCastString(TagPtr dict) { if(!dict) return NULL; - + if((dict->type == kTagTypeString) || (dict->type == kTagTypeKey)) return dict->string; @@ -1118,7 +1096,7 @@ { if(dict && ((dict->type == kTagTypeString) || - (dict->type == kTagTypeKey))) + (dict->type == kTagTypeKey))) { return dict->offset; } Index: branches/cparm/i386/libsaio/uterror.c =================================================================== --- branches/cparm/i386/libsaio/uterror.c (revision 0) +++ branches/cparm/i386/libsaio/uterror.c (revision 1840) @@ -0,0 +1,16 @@ +// +// uterror.c +// Chameleon +// +// Created by cparm on 24/02/12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#include "libsaio.h" + + +jmp_buf h_buf_error; + +void init_ut_fnc(void) +{ +} \ No newline at end of file Index: branches/cparm/i386/libsaio/console.c =================================================================== --- branches/cparm/i386/libsaio/console.c (revision 1839) +++ branches/cparm/i386/libsaio/console.c (revision 1840) @@ -46,7 +46,7 @@ #include "libsaio.h" #include "bootstruct.h" -#include "modules.h" +#include "platform.h" //extern int vprf(const char * fmt, va_list ap); @@ -80,9 +80,28 @@ { msgbuf = malloc(BOOTER_LOG_SIZE); bzero(msgbuf, BOOTER_LOG_SIZE); - cursor = msgbuf; + cursor = msgbuf; + } +char *getConsoleMsg(void) +{ + return msgbuf; +} +char *getConsoleCursor(void) +{ + return cursor; +} +void setConsoleMsg(char *p) +{ + msgbuf = p; +} +void setConsoleCursor(char *p) +{ + cursor = p; +} + + void msglog(const char * fmt, ...) { va_list ap; @@ -105,8 +124,8 @@ void setupBooterLog(void) { if (!msgbuf) - return; - + return; + Node *node = DT__FindNode("/", false); if (node) DT__AddProperty(node, "boot-log", strlen((char *)msgbuf) + 1, msgbuf); @@ -179,7 +198,8 @@ cursor += strlen((char *)cursor); } - va_end(ap); + va_end(ap); + return 0; } @@ -208,7 +228,8 @@ cursor += strlen((char *)cursor); } - va_end(ap); + va_end(ap); + return(0); } @@ -240,7 +261,7 @@ } /** Print a "Press a key to continue..." message and wait for a key press. */ -void pause() +void pause(void) { printf("Press a key to continue..."); getc(); Index: branches/cparm/i386/libsaio/xml.h =================================================================== --- branches/cparm/i386/libsaio/xml.h (revision 1839) +++ branches/cparm/i386/libsaio/xml.h (revision 1840) @@ -26,16 +26,16 @@ #define __LIBSAIO_XML_H enum xmltype { - kTagTypeNone = 0, - kTagTypeDict, - kTagTypeKey, - kTagTypeString, - kTagTypeInteger, - kTagTypeData, - kTagTypeDate, - kTagTypeFalse, - kTagTypeTrue, - kTagTypeArray + kTagTypeNone = 0, + kTagTypeDict, + kTagTypeKey, + kTagTypeString, + kTagTypeInteger, + kTagTypeData, + kTagTypeDate, + kTagTypeFalse, + kTagTypeTrue, + kTagTypeArray }; @@ -72,13 +72,16 @@ #define kPropIONameMatch ("IONameMatch") -//extern long gImageFirstBootXAddr; -//extern long gImageLastKernelAddr; - +#define DEFAULT_BOOT_CONFIG_DICT (TagPtr)0 +#define DEFAULT_SYSTEM_CONFIG_DICT (TagPtr)1 +#define DEFAULT_OVERRIDE_CONFIG_DICT (TagPtr)2 +#define DEFAULT_SMBIOS_CONFIG_DICT (TagPtr)3 +#define DEFAULT_HELPER_CONFIG_DICT (TagPtr)4 TagPtr XMLGetProperty( TagPtr dict, const char * key ); TagPtr XMLGetElement( TagPtr dict, int id ); int XMLTagCount( TagPtr dict ); + bool XMLIsType(TagPtr dict, enum xmltype type); bool XMLCastBoolean( TagPtr dict ); Index: branches/cparm/i386/libsaio/bootstruct.c =================================================================== --- branches/cparm/i386/libsaio/bootstruct.c (revision 1839) +++ branches/cparm/i386/libsaio/bootstruct.c (revision 1840) @@ -30,13 +30,16 @@ #include "bootstruct.h" #include "platform.h" +boot_args_common *bootArgs; + + /*========================================================================== - * Initialize the structure of parameters passed to + * structure of parameters passed to * the kernel by the booter. */ boot_args_Legacy *bootArgsLegacy; -boot_args_common *bootArgs; boot_args_107 *bootArgs107; +boot_args_108 *bootArgs108; /* ... */ PrivateBootInfo_t *bootInfo; @@ -47,34 +50,34 @@ void initKernBootStruct( void ) { static int init_done = 0; - + if ( !init_done ) { bootArgs = (boot_args_common *)malloc(sizeof(boot_args_common)); bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t)); if (bootArgs == 0 || bootInfo == 0) stop("Couldn't allocate boot info\n"); - + bzero(bootArgs, sizeof(boot_args_common)); bzero(bootInfo, sizeof(PrivateBootInfo_t)); - + // Get system memory map. Also update the size of the // conventional/extended memory for backwards compatibility. - + bootInfo->memoryMapCount = - getMemoryMap( bootInfo->memoryMap, kMemoryMapCountMax, - (unsigned long *) &bootInfo->convmem, - (unsigned long *) &bootInfo->extmem ); + getMemoryMap( bootInfo->memoryMap, kMemoryMapCountMax, + (unsigned long *) &bootInfo->convmem, + (unsigned long *) &bootInfo->extmem ); - + if ( bootInfo->memoryMapCount == 0 ) { // BIOS did not provide a memory map, systems with // discontiguous memory or unusual memory hole locations // may have problems. - + bootInfo->convmem = getConventionalMemorySize(); bootInfo->extmem = getExtendedMemorySize(); @@ -85,7 +88,7 @@ bootArgs->Video.v_display = VGA_TEXT_MODE; DT__Initialize(); - + { Node *node; node = DT__FindNode("/", true); @@ -101,70 +104,94 @@ DT__AddProperty(node, "model", nameLen, platformName); } } - + gMemoryMapNode = DT__FindNode("/chosen/memory-map", true); + safe_set_env(envConvMem, bootInfo->convmem); + safe_set_env(envExtMem, bootInfo->convmem); + safe_set_env(envMemoryMap, (uint32_t)bootInfo->memoryMap); + safe_set_env(envMemoryMapCnt, bootInfo->memoryMapCount); + + init_done = 1; } - + } #define AllocateKernelMemoryForBootArgs(Ver) \ { \ - bootArgs##Ver = (boot_args_##Ver *)AllocateKernelMemory(sizeof(boot_args_##Ver));\ +bootArgs##Ver = (boot_args_##Ver *)AllocateKernelMemory(sizeof(boot_args_##Ver));\ } #define CopyCommonBootArgsHeader(Ver) \ { \ - bootArgs##Ver->Revision = bootArgs->Header.Revision ;\ - bootArgs##Ver->Version = bootArgs->Header.Version ;\ +bootArgs##Ver->Revision = bootArgs->Header.Revision ;\ +bootArgs##Ver->Version = bootArgs->Header.Version ;\ } -// For 10.6, 10.5 and 10.4 please use :Legacy:, for 10.7 use :107: +// For 10.6, 10.5 and 10.4 please use :Legacy:, for 10.7 use :107:, for 10.8 use :108: #define CopyCommonBootArgs(Ver) \ { \ - bcopy(bootArgs->CommandLine, bootArgs##Ver->CommandLine, BOOT_LINE_LENGTH);\ - bootArgs##Ver->MemoryMap = bootArgs->MemoryMap ;\ - bootArgs##Ver->MemoryMapSize = bootArgs->MemoryMapSize ;\ - bootArgs##Ver->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize ;\ - bootArgs##Ver->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion ;\ - bootArgs##Ver->Video = bootArgs->Video ;\ - bootArgs##Ver->deviceTreeP = bootArgs->deviceTreeP ;\ - bootArgs##Ver->deviceTreeLength = bootArgs->deviceTreeLength ;\ - bootArgs##Ver->kaddr = bootArgs->kaddr ;\ - bootArgs##Ver->ksize = bootArgs->ksize ;\ - bootArgs##Ver->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart ;\ - bootArgs##Ver->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount ;\ - bootArgs##Ver->efiSystemTable = bootArgs->efiSystemTable ;\ - bootArgs##Ver->efiMode = bootArgs->efiMode ;\ - bootArgs##Ver->performanceDataStart = bootArgs->performanceDataStart ;\ - bootArgs##Ver->performanceDataSize = bootArgs->performanceDataSize ;\ - bootArgs##Ver->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart ;\ +bcopy(bootArgs->CommandLine, bootArgs##Ver->CommandLine, BOOT_LINE_LENGTH);\ +bootArgs##Ver->MemoryMap = bootArgs->MemoryMap ;\ +bootArgs##Ver->MemoryMapSize = bootArgs->MemoryMapSize ;\ +bootArgs##Ver->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize ;\ +bootArgs##Ver->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion ;\ +bootArgs##Ver->Video = bootArgs->Video ;\ +bootArgs##Ver->deviceTreeP = bootArgs->deviceTreeP ;\ +bootArgs##Ver->deviceTreeLength = bootArgs->deviceTreeLength ;\ +bootArgs##Ver->kaddr = bootArgs->kaddr ;\ +bootArgs##Ver->ksize = bootArgs->ksize ;\ +bootArgs##Ver->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart ;\ +bootArgs##Ver->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount ;\ +bootArgs##Ver->efiSystemTable = bootArgs->efiSystemTable ;\ +bootArgs##Ver->efiMode = bootArgs->efiMode ;\ +bootArgs##Ver->performanceDataStart = bootArgs->performanceDataStart ;\ +bootArgs##Ver->performanceDataSize = bootArgs->performanceDataSize ;\ +bootArgs##Ver->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart ;\ } +/* + * Darwin 10.7+ specific boot arguments + * + * for 10.7 use :107:, for 10.8 use :108: + */ +#define Copy107plusBootArgs(Ver) \ +{ \ +bootArgs##Ver->keyStoreDataStart = bootArgs->keyStoreDataStart ;\ +bootArgs##Ver->keyStoreDataSize = bootArgs->keyStoreDataSize ;\ +bootArgs##Ver->bootMemStart = bootArgs->bootMemStart ;\ +bootArgs##Ver->bootMemSize = bootArgs->bootMemSize ;\ +bootArgs##Ver->PhysicalMemorySize = bootArgs->PhysicalMemorySize ;\ +bootArgs##Ver->FSBFrequency = bootArgs->FSBFrequency ;\ +bootArgs##Ver->debugMode = bootArgs->debugMode ;\ +} + #define init_boot_args(Ver) \ { \ - AllocateKernelMemoryForBootArgs(Ver);\ - CopyCommonBootArgsHeader(Ver);\ - CopyCommonBootArgs(Ver);\ +AllocateKernelMemoryForBootArgs(Ver);\ +CopyCommonBootArgsHeader(Ver);\ +CopyCommonBootArgs(Ver);\ } /* Copy boot args after kernel and record address. */ +/* Copy boot args after kernel and record address. */ + void reserveKern107BootStruct(void) { init_boot_args(107); + Copy107plusBootArgs(107); +} + +void +reserveKern108BootStruct(void) +{ + init_boot_args(108); + Copy107plusBootArgs(108); - /* Darwin 10.7 specific boot arguments */ - bootArgs107->keyStoreDataStart = bootArgs->keyStoreDataStart ; - bootArgs107->keyStoreDataSize = bootArgs->keyStoreDataSize ; - bootArgs107->bootMemStart = bootArgs->bootMemStart ; - bootArgs107->bootMemSize = bootArgs->bootMemSize ; - bootArgs107->PhysicalMemorySize = bootArgs->PhysicalMemorySize ; - bootArgs107->FSBFrequency = bootArgs->FSBFrequency ; - bootArgs107->debugMode = bootArgs->debugMode; - + /* Darwin 10.8 specific boot arguments */ } void @@ -173,6 +200,31 @@ init_boot_args(Legacy); } +void setBootArgsVideoMode(int mode) +{ + bootArgs->Video.v_display = mode; +} +uint32_t getVideoMode(void) +{ + return bootArgs->Video.v_display; +} +uint32_t getBootArgsVideoPtrAtOffset(uint32_t offset) +{ + char *vid = (char *)&bootArgs->Video ; + return (uint32_t)vid[offset]; +} + +void setBootArgsVideoStruct(Boot_Video *Video) +{ + bootArgs->Video.v_display = Video->v_display; + bootArgs->Video.v_width = Video->v_width; + bootArgs->Video.v_height = Video->v_height; + bootArgs->Video.v_depth = Video->v_depth; + bootArgs->Video.v_rowBytes = Video->v_rowBytes; + bootArgs->Video.v_baseAddr = Video->v_baseAddr; + return; +} + void finalizeBootStruct(void) { @@ -271,13 +323,11 @@ sane_size = (sane_size + 128 * MEG - 1) & ~((uint64_t)(128 * MEG - 1)); bootArgs->PhysicalMemorySize = sane_size; - bootArgs->FSBFrequency = Platform->CPU.FSBFrequency; - - } - - // add PCI info somehow into device tree - // XXX - + bootArgs->FSBFrequency = get_env(envFSBFreq); + + } + + { uint32_t size; void *addr; Index: branches/cparm/i386/libsaio/vbe.c =================================================================== --- branches/cparm/i386/libsaio/vbe.c (revision 1839) +++ branches/cparm/i386/libsaio/vbe.c (revision 1840) @@ -93,18 +93,19 @@ +#if UNUSED /* * Default GTF parameter values. */ -//#define kCellGranularity 8.0 // character cell granularity -//#define kMinVSyncPlusBP 550.0 // min VSync + BP interval (us) -//#define kMinFrontPorch 1.0 // minimum front porch in lines(V)/cells(H) -//#define kVSyncLines 3.0 // width of VSync in lines -//#define kHSyncWidth 8.0 // HSync as a percent of total line width -//#define kC 30.0 // C = (C'-J) * (K/256) + J -//#define kM 300.0 // M = K/256 * M' +#define kCellGranularity 8.0 // character cell granularity +#define kMinVSyncPlusBP 550.0 // min VSync + BP interval (us) +#define kMinFrontPorch 1.0 // minimum front porch in lines(V)/cells(H) +#define kVSyncLines 3.0 // width of VSync in lines +#define kHSyncWidth 8.0 // HSync as a percent of total line width +#define kC 30.0 // C = (C'-J) * (K/256) + J +#define kM 300.0 // M = K/256 * M' -int Round(double f) +static int Round(double f) { return (int)(f + 0.5); } @@ -112,7 +113,6 @@ /* * from http://www.azillionmonkeys.com/qed/sqroot.html */ -#if UNUSED double Sqrt( double y ) { double x, z, tempf; Index: branches/cparm/i386/libsaio/bootstruct.h =================================================================== --- branches/cparm/i386/libsaio/bootstruct.h (revision 1839) +++ branches/cparm/i386/libsaio/bootstruct.h (revision 1840) @@ -30,15 +30,16 @@ #include "bios.h" #include "device_tree.h" /*! - Kernel boot args global also used by booter for its own data. + Kernel boot args global also used by booter for its own data. */ extern boot_args_common *bootArgs; /*! - Boot args passed to the kernel. + Boot args passed to the kernel. */ extern boot_args_Legacy *bootArgsLegacy; extern boot_args_107 *bootArgs107; +extern boot_args_108 *bootArgs108; extern Node *gMemoryMapNode; @@ -99,17 +100,17 @@ kMemoryRangeReserved = 2, // Reserved. (Do not use) kMemoryRangeACPI = 3, // ACPI tables. Can be reclaimed. kMemoryRangeNVS = 4, // ACPI NVS memory. (Do not use) - + /* Undefined types should be treated as kMemoryRangeReserved */ }; /*! - PrivateBootInfo has fields used by the booter that used to be part of - KernelBootArgs_t *bootArgs. When the switch was made to EFI the structure - completely changed to boot_args *bootArgs. This (new to boot-132) structure - contains the fields the kernel no longer cares about but the booter still - uses internally. Some fields (e.g. the video information) remain interesting - to the kernel and are thus located in bootArgs although with different field names. + PrivateBootInfo has fields used by the booter that used to be part of + KernelBootArgs_t *bootArgs. When the switch was made to EFI the structure + completely changed to boot_args *bootArgs. This (new to boot-132) structure + contains the fields the kernel no longer cares about but the booter still + uses internally. Some fields (e.g. the video information) remain interesting + to the kernel and are thus located in bootArgs although with different field names. */ typedef struct PrivateBootInfo { int convmem; // conventional memory @@ -118,7 +119,7 @@ int numBootDrivers; // number of drivers loaded #endif char bootFile[128]; // kernel file name - + unsigned long memoryMapCount; MemoryRange memoryMap[kMemoryMapCountMax]; @@ -134,11 +135,9 @@ config_file_t SystemConfig; // system confing found in /Library/Preferences/SystemConfiguration/com.apple.Boot.plist - - config_file_t themeConfig; // theme.plist + config_file_t smbiosConfig; // smbios.plist config_file_t helperConfig; // boot helper partition's boot.plist - config_file_t ramdiskConfig; // RAMDisk.plist unsigned long adler32; @@ -146,6 +145,12 @@ } PrivateBootInfo_t; +#define DEFAULT_BOOT_CONFIG (config_file_t*)0 +#define DEFAULT_SYSTEM_CONFIG (config_file_t*)1 +#define DEFAULT_OVERRIDE_CONFIG (config_file_t*)2 +#define DEFAULT_SMBIOS_CONFIG (config_file_t*)3 +#define DEFAULT_HELPER_CONFIG (config_file_t*)4 + extern PrivateBootInfo_t *bootInfo; #endif /* __BOOTSTRUCT_H */ Index: branches/cparm/i386/libsaio/device_tree.c =================================================================== --- branches/cparm/i386/libsaio/device_tree.c (revision 1839) +++ branches/cparm/i386/libsaio/device_tree.c (revision 1840) @@ -66,8 +66,7 @@ #if DEBUG static void _PrintTree(Node *node, int level); -static void -_PrintFlattenedTree(DTEntry entry, int level); + #endif Property * @@ -364,7 +363,7 @@ #if DEBUG -void +static void DT__PrintNode(Node *node, int level) { char spaces[10], *cp = spaces; @@ -406,147 +405,5 @@ _PrintTree(node, 0); } -#if UNUSED -void -DT__PrintFlattenedNode(DTEntry entry, int level) -{ - char spaces[10], *cp = spaces; - DTPropertyIterator propIter; - char *name; - void *prop; - int propSize; - - if (level > 9) level = 9; - while (level--) *cp++ = ' '; - *cp = '\0'; - - printf("%s===Entry %p===\n", spaces, entry); - if (kSuccess != DTCreatePropertyIterator(entry, &propIter)) { - printf("Couldn't create property iterator\n"); - return; - } - while( kSuccess == DTIterateProperties( propIter, &name)) { - if( kSuccess != DTGetProperty( entry, name, &prop, &propSize )) - continue; - printf("%s Property %s = %s\n", spaces, name, prop); - } - DTDisposePropertyIterator(propIter); - - printf("%s==========\n", spaces); -} #endif -static void -_PrintFlattenedTree(DTEntry entry, int level) -{ - DTEntryIterator entryIter; - - PrintFlattenedNode(entry, level); - - if (kSuccess != DTCreateEntryIterator(entry, &entryIter)) { - printf("Couldn't create entry iterator\n"); - return; - } - level++; - while (kSuccess == DTIterateEntries( entryIter, &entry )) { - _PrintFlattenedTree(entry, level); - } - DTDisposeEntryIterator(entryIter); -} - -#if UNUSED -void -DT__PrintFlattenedTree(DTEntry entry) -{ - _PrintFlattenedTree(entry, 0); -} - -int -main(int argc, char **argv) -{ - DTEntry dtEntry; - DTPropertyIterator propIter; - DTEntryIterator entryIter; - void *prop; - int propSize; - char *name; - void *flatTree; - uint32_t flatSize; - - Node *node; - - node = AddChild(NULL, "device-tree"); - AddProperty(node, "potato", 4, "foo"); - AddProperty(node, "chemistry", 4, "bar"); - AddProperty(node, "physics", 4, "baz"); - - node = AddChild(node, "dev"); - AddProperty(node, "one", 4, "one"); - AddProperty(node, "two", 4, "two"); - AddProperty(node, "three", 6, "three"); - - node = AddChild(rootNode, "foo"); - AddProperty(node, "aaa", 4, "aab"); - AddProperty(node, "bbb", 4, "bbc"); - AddProperty(node, "cccc", 6, "ccccd"); - - node = FindNode("/this/is/a/test", 1); - AddProperty(node, "dddd", 12, "abcdefghijk"); - - printf("In-memory tree:\n\n"); - - PrintTree(rootNode); - - FlattenDeviceTree(&flatTree, &flatSize); - - printf("Flat tree = %p, size %d\n", flatTree, flatSize); - - dtEntry = (DTEntry)flatTree; - - printf("\n\nPrinting flat tree\n\n"); - - DTInit(dtEntry); - - PrintFlattenedTree((DTEntry)flatTree); -#if 0 - printf("=== Entry %p ===\n", dtEntry); - if (kSuccess != DTCreatePropertyIterator(dtEntry, &propIter)) { - printf("Couldn't create property iterator\n"); - return 1; - } - while( kSuccess == DTIterateProperties( propIter, &name)) { - if( kSuccess != DTGetProperty( dtEntry, name, &prop, &propSize )) - continue; - printf(" Property %s = %s\n", name, prop); - } - DTDisposePropertyIterator(propIter); - printf("========\n"); - - if (kSuccess != DTCreateEntryIterator(dtEntry, &entryIter)) { - printf("Couldn't create entry iterator\n"); - return 1; - } - while (kSuccess == DTIterateEntries( entryIter, &dtEntry )) { - printf("=== Entry %p ===\n", dtEntry); - - if (kSuccess != DTCreatePropertyIterator(dtEntry, &propIter)) { - printf("Couldn't create property iterator\n"); - return 1; - } - while( kSuccess == DTIterateProperties( propIter, &name)) { - if( kSuccess != DTGetProperty( dtEntry, name, &prop, &propSize )) - continue; - printf(" Property %s = %s\n", name, prop); - } - DTDisposePropertyIterator(propIter); - printf("========\n"); - } - DTDisposeEntryIterator(entryIter); -#endif - - return 0; -} -#endif - -#endif - Index: branches/cparm/i386/libsaio/libsaio.h =================================================================== --- branches/cparm/i386/libsaio/libsaio.h (revision 1839) +++ branches/cparm/i386/libsaio/libsaio.h (revision 1840) @@ -32,5 +32,6 @@ #include "saio_types.h" #include "saio_internal.h" #include "internal_modules.h" +#include "uthash.h" #endif /* !__LIBSAIO_LIBSAIO_H */ Index: branches/cparm/i386/libsaio/arc4random.c =================================================================== --- branches/cparm/i386/libsaio/arc4random.c (revision 1839) +++ branches/cparm/i386/libsaio/arc4random.c (revision 1840) @@ -203,7 +203,7 @@ /* * Initialize our S-box to its beginning defaults. */ -static void +void arc4_init(void) { int n; Index: branches/cparm/i386/libsaio/Makefile =================================================================== --- branches/cparm/i386/libsaio/Makefile (revision 1839) +++ branches/cparm/i386/libsaio/Makefile (revision 1840) @@ -11,7 +11,7 @@ OPTIM = -Os -Oz DEBUG = -DNOTHING #DEBUG = -DDEBUG_CPU=1 -DDEBUG_MEM=1 -DDEBUG_SPD=1 -DDEBUG_PCI=1 -DDEBUG_SMBIOS=1 -CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -fstack-protector-all \ +CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -fno-stack-protector \ -D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \ -DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \ -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ @@ -33,15 +33,15 @@ VPATH = $(OBJROOT):$(SYMROOT) -SAIO_OBJS = table.o asm.o bios.o biosfn.o arc4random.o stack_protector.o \ +SAIO_OBJS = table.o asm.o bios.o biosfn.o arc4random.o \ disk.o sys.o cache.o bootstruct.o \ stringTable.o load.o pci.o allocate.o misc.o \ vbe.o hfs.o hfs_compare.o \ - xml.o md5c.o device_tree.o \ + xml.o md5c.o device_tree.o modules.o \ cpu.o platform.o \ fake_efi.o \ device_inject.o pci_root.o \ - convert.o acpi_tools.o smbios.o smp-imps.o + convert.o acpi_tools.o smbios.o smp-imps.o uterror.o # example for AcpiCodec #SAIO_OBJS += acpi_codec.o acpicode.o ACPICodec.o acpidecode.o Index: branches/cparm/i386/libsaio/SMBIOS.h =================================================================== --- branches/cparm/i386/libsaio/SMBIOS.h (revision 1839) +++ branches/cparm/i386/libsaio/SMBIOS.h (revision 1840) @@ -31,7 +31,7 @@ #include "libsaio.h" #define kIsServer "IsServer" -extern struct SMBEntryPoint *getSmbiosOriginal(); +extern struct SMBEntryPoint *getSmbiosOriginal(void); #define theUUID 0 #define thePlatformName 1 Index: branches/cparm/i386/libsaio/bootXnu.h =================================================================== --- branches/cparm/i386/libsaio/bootXnu.h (revision 1839) +++ branches/cparm/i386/libsaio/bootXnu.h (revision 1840) @@ -113,26 +113,26 @@ typedef struct boot_args_Legacy { uint16_t Revision; /* Revision of boot_args structure */ uint16_t Version; /* Version of boot_args structure */ - + char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */ - + uint32_t MemoryMap; /* Physical address of memory map */ uint32_t MemoryMapSize; uint32_t MemoryMapDescriptorSize; uint32_t MemoryMapDescriptorVersion; - + Boot_Video Video; /* Video Information */ - + uint32_t deviceTreeP; /* Physical address of flattened device tree */ uint32_t deviceTreeLength; /* Length of flattened tree */ - + uint32_t kaddr; /* Physical address of beginning of kernel text */ uint32_t ksize; /* Size of combined kernel text+data+efi */ - + uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */ uint32_t efiRuntimeServicesPageCount; uint32_t efiSystemTable; /* physical address of system table in runtime area */ - + uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */ uint8_t __reserved1[3]; uint32_t __reserved2[1]; @@ -140,42 +140,42 @@ uint32_t performanceDataSize; uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */ uint32_t __reserved3[2]; - + } boot_args_Legacy; -typedef struct boot_args { +typedef struct boot_args_107 { uint16_t Revision; /* Revision of boot_args structure */ uint16_t Version; /* Version of boot_args structure */ - + uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */ uint8_t debugMode; /* Bit field with behavior changes */ uint8_t __reserved1[2]; - + char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */ - + uint32_t MemoryMap; /* Physical address of memory map */ uint32_t MemoryMapSize; uint32_t MemoryMapDescriptorSize; uint32_t MemoryMapDescriptorVersion; - + Boot_Video Video; /* Video Information */ - + uint32_t deviceTreeP; /* Physical address of flattened device tree */ uint32_t deviceTreeLength; /* Length of flattened tree */ - + uint32_t kaddr; /* Physical address of beginning of kernel text */ uint32_t ksize; /* Size of combined kernel text+data+efi */ - + uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */ uint32_t efiRuntimeServicesPageCount; uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */ - + uint32_t efiSystemTable; /* physical address of system table in runtime area */ uint32_t __reserved2; - + uint32_t performanceDataStart; /* physical address of log */ uint32_t performanceDataSize; - + uint32_t keyStoreDataStart; /* physical address of key store data */ uint32_t keyStoreDataSize; uint64_t bootMemStart; @@ -183,9 +183,54 @@ uint64_t PhysicalMemorySize; uint64_t FSBFrequency; uint32_t __reserved4[734]; - + } boot_args_107; +typedef struct boot_args_108 { + uint16_t Revision; /* Revision of boot_args structure */ + uint16_t Version; /* Version of boot_args structure */ + + uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */ + uint8_t debugMode; /* Bit field with behavior changes */ + uint8_t __reserved1[2]; + + char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */ + + uint32_t MemoryMap; /* Physical address of memory map */ + uint32_t MemoryMapSize; + uint32_t MemoryMapDescriptorSize; + uint32_t MemoryMapDescriptorVersion; + + Boot_Video Video; /* Video Information */ + + uint32_t deviceTreeP; /* Physical address of flattened device tree */ + uint32_t deviceTreeLength; /* Length of flattened tree */ + + uint32_t kaddr; /* Physical address of beginning of kernel text */ + uint32_t ksize; /* Size of combined kernel text+data+efi */ + + uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */ + uint32_t efiRuntimeServicesPageCount; + uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */ + + uint32_t efiSystemTable; /* physical address of system table in runtime area */ + uint32_t __reserved2; + + uint32_t performanceDataStart; /* physical address of log */ + uint32_t performanceDataSize; + + uint32_t keyStoreDataStart; /* physical address of key store data */ + uint32_t keyStoreDataSize; + uint64_t bootMemStart; + uint64_t bootMemSize; + uint64_t PhysicalMemorySize; + uint64_t FSBFrequency; + + uint32_t __reserved3[4]; + uint32_t __reserved4[730]; + +} boot_args_108; + typedef struct boot_args_header { uint16_t Revision; /* Revision of boot_args structure */ uint16_t Version; /* Version of boot_args structure */ @@ -195,7 +240,7 @@ boot_args_header Header; Boot_Video Video; /* Video Information */ - + uint32_t MemoryMap; /* Physical address of memory map */ uint32_t MemoryMapSize; uint32_t MemoryMapDescriptorSize; @@ -209,8 +254,8 @@ uint32_t deviceTreeLength; /* Length of flattened tree */ char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */ - + uint32_t keyStoreDataStart; /* physical address of key store data */ uint32_t keyStoreDataSize; uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */ @@ -219,10 +264,10 @@ uint32_t efiSystemTable; /* physical address of system table in runtime area */ uint64_t FSBFrequency; - + uint32_t performanceDataSize; uint32_t performanceDataStart; /* physical address of log */ - + uint32_t kaddr; /* Physical address of beginning of kernel text */ uint32_t ksize; /* Size of combined kernel text+data+efi */ @@ -230,11 +275,12 @@ uint64_t bootMemSize; uint64_t PhysicalMemorySize; + uint32_t __reserved[4]; } boot_args_10x; typedef struct boot_args_10x boot_args_common; extern char assert_boot_args_107_size_is_4096[sizeof(boot_args_107) == 4096 ? 1 : -1]; +extern char assert_boot_args_108_size_is_4096[sizeof(boot_args_108) == 4096 ? 1 : -1]; #endif /* _PEXPERT_I386_BOOT_H */ - Index: branches/cparm/i386/libsaio/modules.c =================================================================== --- branches/cparm/i386/libsaio/modules.c (revision 0) +++ branches/cparm/i386/libsaio/modules.c (revision 1840) @@ -0,0 +1,1371 @@ +/* + * Copyright 2010 Evan Lojewski. All rights reserved. + * + */ +#include "libsaio.h" +#include "bootstruct.h" +#include "modules.h" + +#ifndef DEBUG_MODULES +#define DEBUG_MODULES 0 +#endif + +#if DEBUG_MODULES +#define DBG(x...) printf(x) +#else +#define DBG(x...) +#endif + +// NOTE: Global so that modules can link with this +unsigned long long textAddress = 0; +unsigned long long textSection = 0; + +moduleHook_t* moduleCallbacks = NULL; +moduleList_t* loadedModules = NULL; +symbolList_t* moduleSymbols = NULL; +unsigned int (*lookup_symbol)(const char*, int(*strcmp_callback)(const char*, const char*)) = NULL; +moduleHook_t* get_callback(const char* name); + +#if DEBUG_MODULES +VOID print_hook_list() +{ + moduleHook_t* hooks = moduleCallbacks; + printf("Hook list: \n"); + while(hooks) + { + printf("* %s\n", hooks->name); + hooks = hooks->next; + } + printf("\n"); +} + +VOID print_symbol_list() +{ + symbolList_t* symbol = moduleSymbols; + printf("Symbol list: \n"); + while(symbol) + { + printf("* %s : %s\n", symbol->module, symbol->symbol); + symbol = symbol->next; + } + printf("\n"); +} +#endif + + +/* + * Initialize the module system by loading the Symbols.dylib module. + * Once loaded, locate the _lookup_symbol function so that internal + * symbols can be resolved. + */ +EFI_STATUS init_module_system(void) +{ + msglog("* Attempting to load system module\n"); + + // Intialize module system + EFI_STATUS status = load_module(SYMBOLS_MODULE); + if((status == EFI_SUCCESS) || (status == EFI_ALREADY_STARTED)/*should never happen*/ ) + { + lookup_symbol = (void*)lookup_all_symbols(SYMBOLS_MODULE,SYMBOL_LOOKUP_SYMBOL); + + if((UInt32)lookup_symbol != 0xFFFFFFFF) + { + return EFI_SUCCESS; + } + + } + + return EFI_LOAD_ERROR; +} + + +/* + * Load all modules in the /Extra/modules/ directory + * Module depencdies will be loaded first + * MOdules will only be loaded once. When loaded a module must + * setup apropriete function calls and hooks as required. + * NOTE: To ensure a module loads after another you may + * link one module with the other. For dyld to allow this, you must + * reference at least one symbol within the module. + */ + +VOID load_all_modules(void) +{ + char* name; + long flags; + long time; + struct dirstuff* moduleDir = opendir("/Extra/modules/"); + while(readdir(moduleDir, (const char**)&name, &flags, &time) >= 0) + { + if ((strcmp(SYMBOLS_MODULE,name)) == 0) continue; // if we found Symbols.dylib, just skip it + + int len = strlen(name); + int ext_size = sizeof("dylib"); + + if (len >= ext_size) + { + if(strcmp(&name[len - ext_size], ".dylib") == 0) + { + char *tmp = newString(name); + if (!tmp) { + continue; + } + msglog("* Attempting to load module: %s\n", tmp); + if(load_module(tmp) != EFI_SUCCESS) + { + // failed to load or already loaded + //free(tmp); + } + } +#if DEBUG_MODULES + else + { + DBG("Ignoring %s\n", name); + } +#endif + } +#if DEBUG_MODULES + else + { + DBG("Ignoring %s\n", name); + } +#endif + + } + + if (moduleDir) + { + closedir(moduleDir); + + } + +#if DEBUG_MODULES + print_symbol_list(); +#endif +} + +/* + * Load a module file in /Extra/modules + * TODO: verify version number of module + */ +EFI_STATUS load_module(char* module) +{ + void (*module_start)(void) = NULL; + + + // Check to see if the module has already been loaded + if(is_module_loaded(module) == EFI_SUCCESS) + { + msglog("Module %s already registred\n", module); + return EFI_ALREADY_STARTED; + } + + int fh = -1; + char *modString=NULL; + modString = newStringWithFormat( "/Extra/modules/%s", module); + if (!modString) { + printf("Unable to allocate module name : /Extra/modules/%s\n", module); + return EFI_OUT_OF_RESOURCES; + } + fh = open(modString); + if(fh < 0) + { +#if DEBUG_MODULES + DBG("Unable to locate module %s\n", modString); + getc(); +#else + msglog("Unable to locate module %s\n", modString); +#endif + free(modString); + return EFI_OUT_OF_RESOURCES; + } + EFI_STATUS ret = EFI_SUCCESS; + + { + int moduleSize = file_size(fh); + + char* module_base = NULL; + + if (moduleSize > 0) + { + module_base = (char*) malloc(moduleSize); + } + + if (module_base && read(fh, module_base, moduleSize) == moduleSize) + { + + DBG("Module %s read in.\n", modString); + + // Module loaded into memory, parse it + module_start = parse_mach(module, module_base, &load_module, &add_symbol); + + if(module_start && (module_start != (void*)0xFFFFFFFF)) + { + module_loaded(module); + // Notify the system that it was laoded + (*module_start)(); // Start the module + msglog("%s successfully Loaded.\n", module); + } + else + { + // The module does not have a valid start function + printf("Unable to start %s\n", module); + ret = EFI_NOT_STARTED; +#if DEBUG_MODULES + getc(); +#endif + } + } + else + { + printf("Unable to read in module %s\n.", module); +#if DEBUG_MODULES + getc(); +#endif + ret = EFI_LOAD_ERROR; + } + } + close(fh); + free(modString); + return ret; +} + +moduleHook_t* get_callback(const char* name) +{ + moduleHook_t* hooks = moduleCallbacks; + + // look for a hook. If it exists, return the moduleHook_t*, + // If not, return NULL. + while(hooks) + { + if(strcmp(name, hooks->name) == 0) + { + //DBG("Located hook %s\n", name); + return hooks; + } + hooks = hooks->next; + } + return NULL; + +} + +/* + * execute_hook( const char* name ) + * name - Name of the module hook + * If any callbacks have been registered for this hook + * they will be executed now in the same order that the + * hooks were added. + */ +EFI_STATUS execute_hook(const char* name, void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) +{ + DBG("Attempting to execute hook '%s'\n", name); + moduleHook_t* hook = get_callback(name); + + if(hook) + { + // Loop through all callbacks for this module + callbackList_t* callbacks = hook->callbacks; + + while(callbacks) + { + // Execute callback + callbacks->callback(arg1, arg2, arg3, arg4, arg5, arg6); + callbacks = callbacks->next; + } + DBG("Hook '%s' executed.\n", name); + return EFI_SUCCESS; + } + + // Callback for this hook doesn't exist; + DBG("No callbacks for '%s' hook.\n", name); + return EFI_NOT_FOUND; + +} + +/* + * register_hook_callback( const char* name, void(*callback)()) + * name - Name of the module hook to attach to. + * callbacks - The funciton pointer that will be called when the + * hook is executed. When registering a new callback name, the callback is added sorted. + * NOTE: the hooks take four void* arguments. + */ +VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*)) +{ + DBG("Adding callback for hook '%s'.\n", name); + + moduleHook_t* hook = get_callback(name); + + if(hook) + { + // append + callbackList_t* newCallback = malloc(sizeof(callbackList_t)); + if (!newCallback) { + DBG("Unable to allocate memory for callback \n"); + return; + } + newCallback->next = hook->callbacks; + hook->callbacks = newCallback; + newCallback->callback = callback; + } + else + { + // create new hook + moduleHook_t* newHook = malloc(sizeof(moduleHook_t)); + if (!newHook) { + DBG("Unable to allocate memory for hook '%s'.\n", name); + return; + } + newHook->name = name; + newHook->callbacks = malloc(sizeof(callbackList_t)); + if (!newHook->callbacks) { + DBG("Unable to allocate memory for callback \n"); + free(newHook); + return; + } + newHook->callbacks->callback = callback; + newHook->callbacks->next = NULL; + + newHook->next = moduleCallbacks; + moduleCallbacks = newHook; + + } + +#if DEBUG_MODULES + print_hook_list(); + getc(); +#endif + +} + +#if DEBUG_MODULES +unsigned long vmaddr; +long vmsize; +#endif + +/* + * Parse through a macho module. The module will be rebased and binded + * as specified in the macho header. If the module is successfully loaded + * the module iinit address will be returned. + * NOTE; all dependecies will be loaded before this module is started + * NOTE: If the module is unable to load ot completeion, the modules + * symbols will still be available (TODO: fix this). This should not + * happen as all dependencies are verified before the sybols are read in. + */ +void* parse_mach(char *module, void* binary, EFI_STATUS(*dylib_loader)(char*), long long(*symbol_handler)(char*, char*, long long, char)) // TODO: add param to specify valid archs +{ + char is64 = false; + void (*module_start)(void) = NULL; + EFI_STATUS bind_status = EFI_SUCCESS; + + // TODO convert all of the structs to a union + struct dyld_info_command* dyldInfoCommand = NULL; + struct symtab_command* symtabCommand = NULL; + + { + struct segment_command *segCommand = NULL; + struct segment_command_64 *segCommand64 = NULL; + struct dylib_command* dylibCommand = NULL; + struct load_command *loadCommand = NULL; + UInt32 binaryIndex = 0; + UInt16 cmd = 0; + + // Parse through the load commands + if(((struct mach_header*)binary)->magic == MH_MAGIC) + { + is64 = false; + binaryIndex += sizeof(struct mach_header); + } + else if(((struct mach_header_64*)binary)->magic == MH_MAGIC_64) + { + // NOTE: modules cannot be 64bit... + is64 = true; + binaryIndex += sizeof(struct mach_header_64); + } + else + { + printf("Modules: Invalid mach magic\n"); + getc(); + return NULL; + } + + + + /*if(((struct mach_header*)binary)->filetype != MH_DYLIB) + { + printf("Module is not a dylib. Unable to load.\n"); + getc(); + return NULL; // Module is in the incorrect format + }*/ + + while(cmd < ((struct mach_header*)binary)->ncmds) + { + cmd++; + + loadCommand = binary + binaryIndex; + UInt32 cmdSize = loadCommand->cmdsize; + + + switch ((loadCommand->cmd & 0x7FFFFFFF)) + { + case LC_SYMTAB: + symtabCommand = binary + binaryIndex; + break; + + case LC_SEGMENT: // 32bit macho + { + segCommand = binary + binaryIndex; + + //printf("Segment name is %s\n", segCommand->segname); + + if(strcmp("__TEXT", segCommand->segname) == 0) + { + UInt32 sectionIndex; + +#if DEBUG_MODULES + unsigned long fileaddr; + long filesize; + vmaddr = (segCommand->vmaddr & 0x3fffffff); + vmsize = segCommand->vmsize; + fileaddr = ((unsigned long)(binary + binaryIndex) + segCommand->fileoff); + filesize = segCommand->filesize; + + printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n", + segCommand->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, + (unsigned) segCommand->nsects, (unsigned)segCommand->flags); +#if DEBUG_MODULES==2 + + getc(); +#endif +#endif + + sectionIndex = sizeof(struct segment_command); + + struct section *sect; + + while(sectionIndex < segCommand->cmdsize) + { + sect = binary + binaryIndex + sectionIndex; + + sectionIndex += sizeof(struct section); + + + if(strcmp("__text", sect->sectname) == 0) + { + // __TEXT,__text found, save the offset and address for when looking for the calls. + textSection = sect->offset; + textAddress = sect->addr; + break; + } + } + } + break; + } + case LC_SEGMENT_64: // 64bit macho's + { + segCommand64 = binary + binaryIndex; + + //printf("Segment name is %s\n", segCommand->segname); + + if(strcmp("__TEXT", segCommand64->segname) == 0) + { + UInt32 sectionIndex; + +#if DEBUG_MODULES + unsigned long fileaddr; + long filesize; + vmaddr = (segCommand64->vmaddr & 0x3fffffff); + vmsize = segCommand64->vmsize; + fileaddr = ((unsigned long)(binary + binaryIndex) + segCommand64->fileoff); + filesize = segCommand64->filesize; + + printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n", + segCommand64->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, + (unsigned) segCommand64->nsects, (unsigned)segCommand64->flags); +#if DEBUG_MODULES==2 + + getc(); +#endif +#endif + + sectionIndex = sizeof(struct segment_command_64); + + struct section_64 *sect; + + while(sectionIndex < segCommand64->cmdsize) + { + sect = binary + binaryIndex + sectionIndex; + + sectionIndex += sizeof(struct section_64); + + + if(strcmp("__text", sect->sectname) == 0) + { + // __TEXT,__text found, save the offset and address for when looking for the calls. + textSection = sect->offset; + textAddress = sect->addr; + + break; + } + } + } + + break; + } + case LC_DYSYMTAB: + break; + + case LC_LOAD_DYLIB: + case LC_LOAD_WEAK_DYLIB ^ LC_REQ_DYLD: + { + dylibCommand = binary + binaryIndex; + char* weak_module = binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name)); + // TODO: verify version + // = dylibCommand->dylib.current_version; + // = dylibCommand->dylib.compatibility_version; + + char *name=NULL; + name = newStringWithFormat( "%s.dylib", weak_module); + if (!name) { + printf("Unable to allocate module name : %s\n", weak_module); + return NULL; + } + if(dylib_loader) + { + EFI_STATUS statue = dylib_loader(weak_module); + + if( statue != EFI_SUCCESS) + { + if (statue != EFI_ALREADY_STARTED) + { + // Unable to load dependancy + //free(weak_module); + return NULL; + } + + } + + } + //free(weak_module); + + break; + } + case LC_ID_DYLIB: + dylibCommand = binary + binaryIndex; + /*moduleName = binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name)); + moduleVersion = dylibCommand->dylib.current_version; + moduleCompat = dylibCommand->dylib.compatibility_version; + */ + break; + + case LC_DYLD_INFO: + // Bind and rebase info is stored here + dyldInfoCommand = binary + binaryIndex; + break; + + case LC_UUID: + break; + + case LC_UNIXTHREAD: + break; + + default: + DBG("Unhandled loadcommand 0x%X\n", loadCommand->cmd & 0x7FFFFFFF); + break; + + } + + binaryIndex += cmdSize; + } + //if(!moduleName) return NULL; + } + + // bind_macho uses the symbols. + module_start = (void*)handle_symtable(module, (UInt32)binary, symtabCommand, symbol_handler, is64); + + // Rebase the module before binding it. + if(dyldInfoCommand && dyldInfoCommand->rebase_off) + { + rebase_macho(binary, (char*)dyldInfoCommand->rebase_off, dyldInfoCommand->rebase_size); + } + + if(dyldInfoCommand && dyldInfoCommand->bind_off) + { + bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->bind_off, dyldInfoCommand->bind_size); + } + + if(dyldInfoCommand && dyldInfoCommand->weak_bind_off && (bind_status == EFI_SUCCESS)) + { + // NOTE: this currently should never happen. + bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->weak_bind_off, dyldInfoCommand->weak_bind_size); + } + + if(dyldInfoCommand && dyldInfoCommand->lazy_bind_off && (bind_status == EFI_SUCCESS)) + { + // NOTE: we are binding the lazy pointers as a module is laoded, + // This should be changed to bind when a symbol is referened at runtime instead. + bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->lazy_bind_off, dyldInfoCommand->lazy_bind_size); + } + + if (bind_status != EFI_SUCCESS) { + module_start = (void*)0xFFFFFFFF; + } + + return module_start; + +} + +// Based on code from dylibinfo.cpp and ImageLoaderMachOCompressed.cpp +void rebase_macho(void* base, char* rebase_stream, UInt32 size) +{ + rebase_stream += (UInt32)base; + + UInt8 immediate = 0; + UInt8 opcode = 0; + UInt8 type = 0; + + UInt32 segmentAddress = 0; + + + + UInt32 tmp = 0; + UInt32 tmp2 = 0; + UInt8 bits = 0; + UInt32 index = 0; + + int done = 0; + unsigned int i = 0; + + while(/*!done &&*/ i < size) + { + immediate = rebase_stream[i] & REBASE_IMMEDIATE_MASK; + opcode = rebase_stream[i] & REBASE_OPCODE_MASK; + + + switch(opcode) + { + case REBASE_OPCODE_DONE: + // Rebase complete. + done = 1; + break; + + + case REBASE_OPCODE_SET_TYPE_IMM: + // Set rebase type (pointer, absolute32, pcrel32) + //DBG("Rebase type = 0x%X\n", immediate); + type = immediate; + break; + + + case REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: + { + // Locate address to begin rebasing + segmentAddress = 0; + + struct segment_command* segCommand = NULL; // NOTE: 32bit only + + { + unsigned int binIndex = 0; + index = 0; + do + { + segCommand = base + sizeof(struct mach_header) + binIndex; + + + binIndex += segCommand->cmdsize; + index++; + } + while(index <= immediate); + } + + segmentAddress = segCommand->fileoff; + + tmp = 0; + bits = 0; + do + { + tmp |= (rebase_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(rebase_stream[i] & 0x80); + + segmentAddress += tmp; + break; + } + case REBASE_OPCODE_ADD_ADDR_ULEB: + // Add value to rebase address + tmp = 0; + bits = 0; + do + { + tmp <<= bits; + tmp |= rebase_stream[++i] & 0x7f; + bits += 7; + } + while(rebase_stream[i] & 0x80); + + segmentAddress += tmp; + break; + + case REBASE_OPCODE_ADD_ADDR_IMM_SCALED: + segmentAddress += immediate * sizeof(void*); + break; + + + case REBASE_OPCODE_DO_REBASE_IMM_TIMES: + index = 0; + for (index = 0; index < immediate; ++index) + { + rebase_location(base + segmentAddress, (char*)base, type); + segmentAddress += sizeof(void*); + } + break; + + + case REBASE_OPCODE_DO_REBASE_ULEB_TIMES: + tmp = 0; + bits = 0; + do + { + tmp |= (rebase_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(rebase_stream[i] & 0x80); + + index = 0; + for (index = 0; index < tmp; ++index) + { + //DBG("\tRebasing 0x%X\n", segmentAddress); + rebase_location(base + segmentAddress, (char*)base, type); + segmentAddress += sizeof(void*); + } + break; + + case REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB: + tmp = 0; + bits = 0; + do + { + tmp |= (rebase_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(rebase_stream[i] & 0x80); + + rebase_location(base + segmentAddress, (char*)base, type); + + segmentAddress += tmp + sizeof(void*); + break; + + case REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: + tmp = 0; + bits = 0; + do + { + tmp |= (rebase_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(rebase_stream[i] & 0x80); + + + tmp2 = 0; + bits = 0; + do + { + tmp2 |= (rebase_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(rebase_stream[i] & 0x80); + + index = 0; + for (index = 0; index < tmp; ++index) + { + + rebase_location(base + segmentAddress, (char*)base, type); + + segmentAddress += tmp2 + sizeof(void*); + } + break; + default: + break; + } + i++; + } +} + +// Based on code from dylibinfo.cpp and ImageLoaderMachOCompressed.cpp +// NOTE: this uses 32bit values, and not 64bit values. +// There is apossibility that this could cause issues, +// however the macho file is 32 bit, so it shouldn't matter too much +EFI_STATUS bind_macho(char* module, void* base, char* bind_stream, UInt32 size) +{ + bind_stream += (UInt32)base; + + UInt8 immediate = 0; + UInt8 opcode = 0; + UInt8 type = 0; + + UInt32 segmentAddress = 0; + + UInt32 address = 0; + + SInt32 addend = 0; // TODO: handle this + SInt32 libraryOrdinal = 0; + + const char* symbolName = NULL; + UInt8 symboFlags = 0; + UInt32 symbolAddr = 0xFFFFFFFF; + + // Temperary variables + UInt8 bits = 0; + UInt32 tmp = 0; + UInt32 tmp2 = 0; + + UInt32 index = 0; + int done = 0; + unsigned int i = 0; + + while(/*!done &&*/ i < size) + { + immediate = bind_stream[i] & BIND_IMMEDIATE_MASK; + opcode = bind_stream[i] & BIND_OPCODE_MASK; + + + switch(opcode) + { + case BIND_OPCODE_DONE: + done = 1; + break; + + case BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: + libraryOrdinal = immediate; + //DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: %d\n", libraryOrdinal); + break; + + case BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: + libraryOrdinal = 0; + bits = 0; + do + { + libraryOrdinal |= (bind_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(bind_stream[i] & 0x80); + + //DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: %d\n", libraryOrdinal); + + break; + + case BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: + // NOTE: this is wrong, fortunately we don't use it + libraryOrdinal = -immediate; + //DBG("BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: %d\n", libraryOrdinal); + + break; + + case BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: + symboFlags = immediate; + symbolName = (char*)&bind_stream[++i]; + i += strlen((char*)&bind_stream[i]); + //DBG("BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: %s, 0x%X\n", symbolName, symboFlags); + + symbolAddr = lookup_all_symbols(NULL ,symbolName); + + break; + + case BIND_OPCODE_SET_TYPE_IMM: + // Set bind type (pointer, absolute32, pcrel32) + type = immediate; + //DBG("BIND_OPCODE_SET_TYPE_IMM: %d\n", type); + + break; + + case BIND_OPCODE_SET_ADDEND_SLEB: + addend = 0; + bits = 0; + do + { + addend |= (bind_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(bind_stream[i] & 0x80); + + if(!(bind_stream[i-1] & 0x40)) addend *= -1; + + //DBG("BIND_OPCODE_SET_ADDEND_SLEB: %d\n", addend); + break; + + case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: + { + segmentAddress = 0; + + // Locate address + struct segment_command* segCommand = NULL; // NOTE: 32bit only + + { + unsigned int binIndex = 0; + index = 0; + do + { + segCommand = base + sizeof(struct mach_header) + binIndex; + binIndex += segCommand->cmdsize; + index++; + }while(index <= immediate); + } + + + segmentAddress = segCommand->fileoff; + + // Read in offset + tmp = 0; + bits = 0; + do + { + tmp |= (bind_stream[++i] & 0x7f) << bits; + bits += 7; + }while(bind_stream[i] & 0x80); + + segmentAddress += tmp; + + //DBG("BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: 0x%X\n", segmentAddress); + break; + } + case BIND_OPCODE_ADD_ADDR_ULEB: + // Read in offset + tmp = 0; + bits = 0; + do + { + tmp |= (bind_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(bind_stream[i] & 0x80); + + segmentAddress += tmp; + //DBG("BIND_OPCODE_ADD_ADDR_ULEB: 0x%X\n", segmentAddress); + break; + + case BIND_OPCODE_DO_BIND: + //DBG("BIND_OPCODE_DO_BIND\n"); + if(symbolAddr != 0xFFFFFFFF) + { + address = segmentAddress + (UInt32)base; + + bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); + } + else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) + { + printf("Unable to bind symbol %s needed by %s\n", symbolName, module); + goto error; + + } + + segmentAddress += sizeof(void*); + break; + + case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: + //DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB\n"); + + + // Read in offset + tmp = 0; + bits = 0; + do + { + tmp |= (bind_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(bind_stream[i] & 0x80); + + + + if(symbolAddr != 0xFFFFFFFF) + { + address = segmentAddress + (UInt32)base; + + bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); + } + else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) + { + printf("Unable to bind symbol %s needed by %s\n", symbolName, module); + goto error; + + + } + segmentAddress += tmp + sizeof(void*); + + + break; + + case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: + //DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED\n"); + + if(symbolAddr != 0xFFFFFFFF) + { + address = segmentAddress + (UInt32)base; + + bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); + } + else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) + { + printf("Unable to bind symbol %s needed by %s\n", symbolName, module); + goto error; + } + segmentAddress += (immediate * sizeof(void*)) + sizeof(void*); + + + break; + + case BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: + + tmp = 0; + bits = 0; + do + { + tmp |= (bind_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(bind_stream[i] & 0x80); + + + tmp2 = 0; + bits = 0; + do + { + tmp2 |= (bind_stream[++i] & 0x7f) << bits; + bits += 7; + } + while(bind_stream[i] & 0x80); + + + //DBG("BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0x%X 0x%X\n", tmp, tmp2); + + + if(symbolAddr != 0xFFFFFFFF) + { + for(index = 0; index < tmp; index++) + { + + address = segmentAddress + (UInt32)base; + + bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); + + segmentAddress += tmp2 + sizeof(void*); + } + } + else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) + { + printf("Unable to bind symbol %s needed by %s\n", symbolName, module); + goto error; + + } + + + break; + default: + break; + + } + i++; + } + return EFI_SUCCESS; +error: + getc(); + return EFI_NOT_FOUND; +} + +void rebase_location(UInt32* location, char* base, int type) +{ + switch(type) + { + case REBASE_TYPE_POINTER: + case REBASE_TYPE_TEXT_ABSOLUTE32: + *location += (UInt32)base; + break; + + default: + break; + } +} + +void bind_location(UInt32* location, char* value, UInt32 addend, int type) +{ + // do actual update + char* newValue = value + addend; + + switch (type) { + case BIND_TYPE_POINTER: + case BIND_TYPE_TEXT_ABSOLUTE32: + break; + + case BIND_TYPE_TEXT_PCREL32: + newValue -= ((UInt32)location + 4); + + break; + default: + return; + } + *location = (UInt32)newValue; + + +} + +/* + * add_symbol + * This function adds a symbol from a module to the list of known symbols + * possibly change to a pointer and add this to the Symbol module so that it can + * adjust it's internal symbol list (sort) to optimize locating new symbols + * NOTE: returns the address if the symbol is "start", else returns 0xFFFFFFFF + */ +long long add_symbol(char* module,char* symbol, long long addr, char is64) +{ + if(is64) return 0xFFFFFFFF; // Fixme + + // This only can handle 32bit symbols + symbolList_t* new_entry= malloc(sizeof(symbolList_t)); + DBG("Adding symbol %s at 0x%X\n", symbol, addr); + if (new_entry) + { + new_entry->next = moduleSymbols; + + moduleSymbols = new_entry; + + new_entry->addr = (UInt32)addr; + new_entry->module = module; + new_entry->symbol = symbol; + return addr; + } + + return 0xFFFFFFFF; + +} + +/* + * print out the information about the loaded module + */ +VOID module_loaded(const char* name) +{ + moduleList_t* new_entry = malloc(sizeof(moduleList_t)); + if (new_entry) + { + new_entry->next = loadedModules; + + loadedModules = new_entry; + + new_entry->module = (char*)name; + } +} + +EFI_STATUS is_module_loaded(const char* name) +{ + moduleList_t* entry = loadedModules; + while(entry) + { + DBG("Comparing %s with %s\n", name, entry->module); + char *fullname = newStringWithFormat("%s.dylib",name); + if(fullname && ((strcmp(entry->module, name) == 0) || (strcmp(entry->module, fullname) == 0))) + { + free(fullname); + DBG("Located module %s\n", name); + return EFI_SUCCESS; + } + else + { + entry = entry->next; + } + + } + DBG("Module %s not found\n", name); + + return EFI_NOT_FOUND; +} + +// Look for symbols using the Smbols moduel function. +// If non are found, look through the list of module symbols +unsigned int lookup_all_symbols(const char* module, const char* name) +{ + + unsigned int addr = 0xFFFFFFFF; + + do { + + if ((module != NULL) && (strcmp(module,SYMBOLS_MODULE) != 0)) + break; + + if(lookup_symbol && (UInt32)lookup_symbol != 0xFFFFFFFF) + { + addr = lookup_symbol(name, &strcmp); + if(addr != 0xFFFFFFFF) + { + DBG("Internal symbol %s located at 0x%X\n", name, addr); + goto out; + } + } + + } while (0); + + + { + symbolList_t* entry = moduleSymbols; + while(entry) + { + if ((module != NULL) && (strcmp(entry->module,module) != 0)) + { + entry = entry->next; + continue; + } + + if(strcmp(entry->symbol, name) == 0) + { + DBG("External symbol %s located at 0x%X\n", name, entry->addr); + addr = entry->addr; + goto out; + } + else + { + entry = entry->next; + } + + } + } + +#if DEBUG_MODULES + if(strcmp(name, SYMBOL_DYLD_STUB_BINDER) != 0) + { + verbose("Unable to locate symbol %s\n", name); + getc(); + } +#endif +out: + return addr; + +} + + +/* + * parse the symbol table + * Lookup any undefined symbols + */ + +unsigned int handle_symtable(char *module, UInt32 base, struct symtab_command* symtabCommand, long long(*symbol_handler)(char*, char*, long long, char), char is64) +{ + unsigned int module_start = 0xFFFFFFFF; + + UInt32 symbolIndex = 0; + char* symbolString = base + (char*)symtabCommand->stroff; + //char* symbolTable = base + symtabCommand->symoff; + if(!is64) + { + struct nlist* symbolEntry = (void*)base + symtabCommand->symoff; + while(symbolIndex < symtabCommand->nsyms) + { + if(symbolEntry->n_value) + { + if(strstr(symbolString + symbolEntry->n_un.n_strx, "module_start") || (strcmp(symbolString + symbolEntry->n_un.n_strx, "start") == 0)) + { + module_start = base + symbolEntry->n_value; + DBG("n_value %x module_start %x\n", (unsigned)symbolEntry->n_value, (unsigned)module_start); + } + else + { + symbol_handler(module, symbolString + symbolEntry->n_un.n_strx, (long long)base + symbolEntry->n_value, is64); + } +#if DEBUG_MODULES + bool isTexT = (((unsigned)symbolEntry->n_value > (unsigned)vmaddr) && ((unsigned)(vmaddr + vmsize) > (unsigned)symbolEntry->n_value )); + printf("%s %s\n", isTexT ? "__TEXT :" : "__DATA(OR ANY) :", symbolString + symbolEntry->n_un.n_strx); +#if DEBUG_MODULES==2 + + if(strcmp(symbolString + symbolEntry->n_un.n_strx, "_BootHelp_txt") == 0) + { + long long addr = (long long)base + symbolEntry->n_value; + unsigned char *BootHelp = NULL; + BootHelp = (unsigned char*)(UInt32)addr; + printf("method 1: __DATA : BootHelp_txt[0] %x\n", BootHelp[0]); + + long long addr2 = symbolEntry->n_value; + unsigned char *BootHelp2 = NULL; + BootHelp2 = (unsigned char*)(UInt32)addr2; + printf("method 2: __DATA : BootHelp_txt[0] %x\n", BootHelp2[0]); + } +#endif +#endif + + } + + symbolEntry++; + symbolIndex++; // TODO remove + } + } + else + { + struct nlist_64* symbolEntry = (void*)base + symtabCommand->symoff; + // NOTE First entry is *not* correct, but we can ignore it (i'm getting radar:// right now) + while(symbolIndex < symtabCommand->nsyms) + { + + if(strstr(symbolString + symbolEntry->n_un.n_strx, "module_start") || (strcmp(symbolString + symbolEntry->n_un.n_strx, "start") == 0)) + { + module_start = (unsigned int)(base + symbolEntry->n_value); + } + else + { + symbol_handler(module, symbolString + symbolEntry->n_un.n_strx, (long long)base + symbolEntry->n_value, is64); + } + + symbolEntry++; + symbolIndex++; // TODO remove + } + } + + return module_start; + +} + + +/* + * Locate the symbol for an already loaded function and modify the beginning of + * the function to jump directly to the new one + * example: replace_system_function("_getc", &replacement); + * replace_function(module_name,"_getc", &replacement); + * replace_function_any("_getc", &replacement); + */ +EFI_STATUS replace_function(const char* module, const char* symbol, void* newAddress) +{ + // TODO: look into using the next four bytes of the function instead + // Most functions should support this, as they probably will be at + // least 10 bytes long, but you never know, this is sligtly safer as + // function can be as small as 6 bytes. + UInt32 addr = lookup_all_symbols(module, symbol); + + char* binary = (char*)addr; + if(addr != 0xFFFFFFFF) + { + UInt32* jumpPointer = malloc(sizeof(UInt32*)); + if (!jumpPointer) { + return EFI_OUT_OF_RESOURCES; + } + + *binary++ = 0xFF; // Jump + *binary++ = 0x25; // Long Jump + *((UInt32*)binary) = (UInt32)jumpPointer; + + *jumpPointer = (UInt32)newAddress; + + return EFI_SUCCESS; + } + + return EFI_NOT_FOUND; + +} + +EFI_STATUS replace_system_function(const char* symbol, void* newAddress) +{ + + return replace_function(SYMBOLS_MODULE,symbol,newAddress); + +} + +EFI_STATUS replace_function_any(const char* symbol, void* newAddress) +{ + + return replace_function(NULL,symbol,newAddress); + +} Index: branches/cparm/i386/libsaio/modules.h =================================================================== --- branches/cparm/i386/libsaio/modules.h (revision 0) +++ branches/cparm/i386/libsaio/modules.h (revision 1840) @@ -0,0 +1,104 @@ +/* + * Module Loading functionality + * Copyright 2009 Evan Lojewski. All rights reserved. + * + */ + +// There is a bug with the module system / rebasing / binding +// that causes static variables to be incorrectly rebased or bound +// Disable static variables for the moment +// #define static + +#ifndef __BOOT_MODULES_H +#define __BOOT_MODULES_H + +#include +#include +#include "efi.h" + +extern unsigned long long textAddress; +extern unsigned long long textSection; + +typedef struct symbolList_t +{ + char* module; + char* symbol; + unsigned int addr; + struct symbolList_t* next; +} symbolList_t; + +typedef struct moduleList_t +{ + char* module; + //struct moduleHook_t* hook_list; + struct moduleList_t* next; +} moduleList_t; + +typedef struct callbackList_t +{ + void(*callback)(void*, void*, void*, void*, void*, void*); + struct callbackList_t* next; +} callbackList_t; + +typedef struct moduleHook_t +{ + const char* name; + callbackList_t* callbacks; + struct moduleHook_t* next; +} moduleHook_t; + +#define SYMBOLS_MODULE "Symbols.dylib" + +#define SYMBOL_DYLD_STUB_BINDER "dyld_stub_binder" +#define SYMBOL_LOOKUP_SYMBOL "_lookup_symbol" +#define STUB_ENTRY_SIZE 6 + +#define SECT_NON_LAZY_SYMBOL_PTR "__nl_symbol_ptr" +#define SECT_SYMBOL_STUBS "__symbol_stub" + +EFI_STATUS init_module_system(void); +VOID load_all_modules(void); + +/* + * Modules Interface + * execute_hook + * Exexutes a registered hook. All callbaks are + * called in the same order that they were added + * + * register_hook_callback + * registers a void function to be executed when a + * hook is executed. + */ +EFI_STATUS execute_hook(const char* name, void*, void*, void*, void*, void*, void*); +VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*)); + +void rebase_location(UInt32* location, char* base, int type); +void bind_location(UInt32* location, char* value, UInt32 addend, int type); +void rebase_macho(void* base, char* rebase_stream, UInt32 size); +EFI_STATUS bind_macho(char* module, void* base, char* bind_stream, UInt32 size); + +EFI_STATUS load_module(char* module); +EFI_STATUS load_bundle(const char* bundle); +VOID load_all_bundles(void); + +EFI_STATUS is_module_loaded(const char* name); +VOID module_loaded(const char* name/*, UInt32 version, UInt32 compat*/); + +long long add_symbol(char* module,char* symbol, long long addr, char is64); + +void* parse_mach(char *module, void* binary, EFI_STATUS(*dylib_loader)(char*), long long(*symbol_handler)(char*, char*, long long, char)); + +unsigned int handle_symtable(char *module, UInt32 base, + struct symtab_command* symtabCommand, + long long(*symbol_handler)(char*, char*, long long, char), + char is64); + +unsigned int lookup_all_symbols(const char* module, const char* name); + +EFI_STATUS replace_function(const char* module, const char* symbol, void* newAddress); +EFI_STATUS replace_system_function(const char* symbol, void* newAddress); +EFI_STATUS replace_function_any(const char* symbol, void* newAddress); + +extern unsigned int (*lookup_symbol)(const char*, int(*strcmp_callback)(const char*, const char*)); + +#endif /* __BOOT_MODULES_H */ \ No newline at end of file Index: branches/cparm/i386/libsaio/pci_root.c =================================================================== --- branches/cparm/i386/libsaio/pci_root.c (revision 1839) +++ branches/cparm/i386/libsaio/pci_root.c (revision 1840) @@ -2,13 +2,12 @@ * Copyright 2009 netkas */ -#include "libsaio.h" -#include "boot.h" +#include "pci_root.h" #include "bootstruct.h" #include "Platform.h" #ifndef DEBUG_PCIROOT -#define DEBUG_PCIROOT 1 +#define DEBUG_PCIROOT 0 #endif #if DEBUG_PCIROOT @@ -28,7 +27,7 @@ if (rootuid < 10) return rootuid; rootuid = 0; /* default uid = 0 */ - if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->bootConfig)) + if (getValueForKey(kPCIRootUID, &val, &len, DEFAULT_BOOT_CONFIG)) { if (isdigit(val[0])) rootuid = val[0] - '0'; @@ -39,11 +38,11 @@ } /* PCEFI compatibility */ - if (getValueForKey("-pci0", &val, &len, &bootInfo->bootConfig)) + if (getValueForKey("-pci0", &val, &len, DEFAULT_BOOT_CONFIG)) { rootuid = 0; } - else if (getValueForKey("-pci1", &val, &len, &bootInfo->bootConfig)) + else if (getValueForKey("-pci1", &val, &len, DEFAULT_BOOT_CONFIG)) { rootuid = 1; } Index: branches/cparm/i386/libsaio/device_inject.c =================================================================== --- branches/cparm/i386/libsaio/device_inject.c (revision 1839) +++ branches/cparm/i386/libsaio/device_inject.c (revision 1840) @@ -6,7 +6,6 @@ */ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" #include "pci.h" #include "pci_root.h" @@ -55,7 +54,7 @@ /* Use the static "device-properties" boot config key contents if available, * otheriwse use the generated one. */ - if (!getValueForKey(kDeviceProperties, &val, &cnt, &bootInfo->bootConfig) && string) + if (!getValueForKey(kDeviceProperties, &val, &cnt, DEFAULT_BOOT_CONFIG) && string) { val = (const char*)string; cnt = strlength * 2; Index: branches/cparm/i386/libsaio/sys.c =================================================================== --- branches/cparm/i386/libsaio/sys.c (revision 1839) +++ branches/cparm/i386/libsaio/sys.c (revision 1840) @@ -61,8 +61,8 @@ #include #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" +#include "platform.h" #include "disk.h" #include "modules.h" #include "xml.h" @@ -686,7 +686,7 @@ return io->i_offset; } - +#endif //========================================================================== // write() - Write up to 'count' bytes of data to the file descriptor // from the buffer pointed to by buf. @@ -710,6 +710,7 @@ return count; } +#if UNUSED int writebyte(int fdesc, char value) { @@ -831,7 +832,7 @@ scanBootVolumes(0x80 + hd, &bvCount); hd++; } - + int gBIOSDev = (int)get_env(envgBIOSDev); // Also scanning CD/DVD drive. if (biosDevIsCDROM(gBIOSDev)) { @@ -850,6 +851,8 @@ if (chain->filtered) filteredChain = true; + int gBIOSDev = (int)get_env(envgBIOSDev); + #if UNUSED if (multiboot_partition_set) for ( bvr = chain; bvr; bvr = bvr->next ) @@ -861,7 +864,7 @@ * to override the default selection. * We accept only kBVFlagSystemVolume or kBVFlagForeignBoot volumes. */ - char *val = XMLDecode(getStringForKey(kDefaultPartition, &bootInfo->bootConfig)); + char *val = XMLDecode(getStringForKey(kDefaultPartition, DEFAULT_BOOT_CONFIG)); if (val) { for ( bvr = chain; bvr; bvr = bvr->next ) { if (matchVolumeToString(bvr, val, false)) { @@ -919,7 +922,6 @@ #define LP '(' #define RP ')' -int gBIOSDev; /*! This is like boot2's gBootVolume except it is for the internal use of @@ -960,7 +962,7 @@ { const char * cp; BVRef bvr = gRootVolume; - int biosdev = gBIOSDev; + int biosdev = (int)get_env(envgBIOSDev); // Search for left parenthesis in the path specification. Index: branches/cparm/i386/libsaio/load.c =================================================================== --- branches/cparm/i386/libsaio/load.c (revision 1839) +++ branches/cparm/i386/libsaio/load.c (revision 1840) @@ -30,7 +30,7 @@ #include #include -#include +#include "sl.h" static long DecodeSegment(long cmdBase, unsigned int*load_addr, unsigned int *load_size); static long DecodeUnixThread(long cmdBase, unsigned int *entry); Index: branches/cparm/i386/libsaio/acpi.h =================================================================== --- branches/cparm/i386/libsaio/acpi.h (revision 1839) +++ branches/cparm/i386/libsaio/acpi.h (revision 1840) @@ -14,8 +14,9 @@ #define EnterpriseServer 4 #define SOHOServer 5 #define AppliancePC 6 +#define PerformanceServer 7 -#define MaxSupportedPMProfile AppliancePC // currently max profile supported +#define MaxSupportedPMProfile PerformanceServer // currently max profile supported #define PMProfileError MaxSupportedPMProfile + 1 #endif /* !__LIBSAIO_ACPI_H */ Index: branches/cparm/i386/libsaio/utstring.h =================================================================== --- branches/cparm/i386/libsaio/utstring.h (revision 0) +++ branches/cparm/i386/libsaio/utstring.h (revision 1840) @@ -0,0 +1,155 @@ +/* +Copyright (c) 2008-2011, Troy D. Hanson http://uthash.sourceforge.net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* a dynamic string implementation using macros + * see http://uthash.sourceforge.net/utstring + */ +#ifndef UTSTRING_H +#define UTSTRING_H + +#define UTSTRING_VERSION 1.9.4 + +#ifdef __GNUC__ +#define _UNUSED_ __attribute__ ((__unused__)) +#else +#define _UNUSED_ +#endif + +#include "libsaio.h" +#define oom() longjmp(h_buf_error,-1) + +typedef struct { + char *d; + size_t n; /* allocd size */ + size_t i; /* index of first unused byte */ +} UT_string; + +#define utstring_reserve(s,amt) \ +do { \ + if (((s)->n - (s)->i) < (size_t)(amt)) { \ + (s)->d = (char*)realloc((s)->d, (s)->n + amt); \ + if ((s)->d == NULL) oom(); \ + (s)->n += amt; \ + } \ +} while(0) + +#define utstring_init(s) \ +do { \ + (s)->n = 0; (s)->i = 0; (s)->d = NULL; \ + utstring_reserve(s,100); \ + (s)->d[0] = '\0'; \ +} while(0) + +#define utstring_done(s) \ +do { \ + if ((s)->d != NULL) free((s)->d); \ + (s)->n = 0; \ +} while(0) + +#define utstring_free(s) \ +do { \ + utstring_done(s); \ + free(s); \ +} while(0) + +#if 0 +#define utstring_new(s) \ +do { \ + s = (UT_string*)calloc(sizeof(UT_string),1); \ + if (!s) oom(); \ + utstring_init(s); \ +} while(0) +#else +#define utstring_new(s) \ +do { \ +s = (UT_string*)malloc(sizeof(UT_string)); \ +if (!s) oom(); \ +utstring_init(s); \ +} while(0) +#endif + +#define utstring_renew(s) \ +do { \ + if (s) { \ + utstring_clear(s); \ + } else { \ + utstring_new(s); \ + } \ +} while(0) + +#define utstring_clear(s) \ +do { \ + (s)->i = 0; \ + (s)->d[0] = '\0'; \ +} while(0) + +#define utstring_bincpy(s,b,l) \ +do { \ + utstring_reserve((s),(l)+1); \ + if (l) memcpy(&(s)->d[(s)->i], b, l); \ + (s)->i += l; \ + (s)->d[(s)->i]='\0'; \ +} while(0) + +#define utstring_concat(dst,src) \ +do { \ + utstring_reserve(dst,(src->i)+1); \ + if (src->i) memcpy(&(dst)->d[(dst)->i], src->d, src->i); \ + dst->i += src->i; \ + dst->d[dst->i]='\0'; \ +} while(0) + +#define utstring_len(s) ((unsigned)((s)->i)) + +#define utstring_body(s) ((s)->d) + +_UNUSED_ static void utstring_printf_va(UT_string *s, const char *fmt, va_list ap) { + int n; + va_list cp; + while (1) { +#ifdef _WIN32 + cp = ap; +#else + va_copy(cp, ap); +#endif + n = vsnprintf (&s->d[s->i], s->n-s->i, fmt, cp); + va_end(cp); + + if ((n > -1) && (n < (int)(s->n-s->i))) { + s->i += n; + return; + } + + /* Else try again with more space. */ + if (n > -1) utstring_reserve(s,n+1); /* exact */ + else utstring_reserve(s,(s->n)*2); /* 2x */ + } +} +_UNUSED_ static void utstring_printf(UT_string *s, const char *fmt, ...) { + va_list ap; + va_start(ap,fmt); + utstring_printf_va(s,fmt,ap); + va_end(ap); +} + +#endif /* UTSTRING_H */ Index: branches/cparm/i386/libsaio/platform.c =================================================================== --- branches/cparm/i386/libsaio/platform.c (revision 1839) +++ branches/cparm/i386/libsaio/platform.c (revision 1840) @@ -1,14 +1,10 @@ /* - * platform.c - * - * AsereBLN: cleanup - * - * ALL functions and struct. here will be DEPRECATED soon, i prefer Hash. (hmm, i mean hashable structures ... of course) - * + * platform_env.c + * + * Copyright 2010,2011 Cadet-petit Armel . All rights reserved. */ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" #include "pci.h" #include "platform.h" @@ -24,54 +20,347 @@ #define DBG(x...) #endif -PlatformInfo_t *Platform; +static char *gboardproduct = NULL; +static char *gPlatformName = NULL; +static char *gRootDevice = NULL; -/** Return if a CPU feature specified by feature is activated (true) or not (false) */ -bool platformCPUFeature(uint32_t feature) +void SetgRootDevice(const char * str) { - return (Platform->CPU.Features & feature) ? true : false; + gRootDevice = (char*)str; } - -/** Return if a CPU Extended feature specified by feature is activated (true) or not (false) */ -bool platformCPUExtFeature(uint32_t feature) +void Setgboardproduct(const char * str) { - return (Platform->CPU.ExtFeatures & feature) ? true : false; + gboardproduct = (char*)str; } - -bool platformIsIntel(void) +void SetgPlatformName(const char * str) { - return (Platform->CPU.Vendor == 0x756E6547) ? true : false; + gPlatformName = (char*)str; } -uint32_t getCPUnCores(void) +char * GetgPlatformName(void) { - return Platform->CPU.NoCores; + return gPlatformName ; } - -uint32_t getCPUnThreads(void) +char * Getgboardproduct(void) { - return Platform->CPU.NoThreads; + return gboardproduct; } +char * GetgRootDevice(void) +{ + return gRootDevice; +} -uint8_t getCPUModel(void) +#ifdef rootpath +static char gRootPath[ROOT_PATH_LEN]; +void SetgRootPath(const char * str) { - return Platform->CPU.Model; + bzero(gRootPath,sizeof(gRootPath)); + memcpy(gRootPath,str, sizeof(gRootPath)); } +char * GetgRootPath(void) +{ + return gRootPath ; +} +#endif -uint8_t getCPUFamily(void) +typedef enum envtype { + kEnvPtr = 0, + kEnvValue = 1 +} envtype; + +struct env_struct { + unsigned long long value; + char name[10]; + void * ptr; + //int lock; + enum envtype Type; + UT_hash_handle hh; /* makes this structure hashable */ +}; + +static void CopyVarPtr (struct env_struct *var, void* ptr, size_t size); +static struct env_struct *find_env(const char *name); +static void _re_set_env_copy(struct env_struct *var , void* ptr,size_t size); +struct env_struct *platform_env = NULL; + + +static void CopyVarPtr (struct env_struct *var, void* ptr, size_t size) { - return Platform->CPU.Family; + var->ptr = malloc(size); + memcpy(var->ptr, ptr, size); } -bool platformIsServer(void) +static struct env_struct *find_env(const char *name) { + struct env_struct *var; + + if (setjmp(h_buf_error) == -1) { +#if DEBUG_PLATFORM + printf("find_env: Unable to find environement variable\n"); + getc(); +#endif + return NULL; + } else { + HASH_FIND_STR( platform_env, name, var ); + } + return var; +} + +static void _re_set_env_copy(struct env_struct *var , void* ptr,size_t size) { + + if (var->Type == kEnvPtr) { + return ; + } + + if (var->ptr) { + free(var->ptr); + var->ptr = NULL; + } + + CopyVarPtr(var, ptr, size); + + return; +} + +void re_set_env_copy(const char *name , void* ptr,size_t size) { + struct env_struct *var; + + var = find_env(name); + if (!var|| (var->Type == kEnvPtr)) { + printf("re_set_env_copy: Unable to find environement variable %s\n",name); +#if DEBUG_PLATFORM + getc(); +#endif + return ; + } + + _re_set_env_copy(var , ptr, size); + + return; +} + +static void _set_env(const char *name, unsigned long long value, enum envtype Type, void* ptr, size_t size ) { + struct env_struct *var; + + var = (struct env_struct*)malloc(sizeof(struct env_struct)); + if (Type == kEnvPtr) { + CopyVarPtr( var, ptr, size); + } + else if (Type == kEnvValue) + var->value = value; + else + return; + + var->Type = Type; + + strlcpy(var->name, name, sizeof(var->name)); + + if (setjmp(h_buf_error) == -1) { + printf("_set_env: Unable to set environement variable"); // don't try to acces to the string 'name', + //'cause we just returned from the longjump, stack as already changed state. +#if DEBUG_PLATFORM + getc(); +#endif + return; + } else { + HASH_ADD_STR( platform_env, name, var ); + } +} + +/* Warning: set_env will create a new variable each time it will be called, + * if you want to set again an existing variable, please use safe_set_env or re_set_env . + * NOTE: If you set several times the "same variable" by using this function, + * the HASH_COUNT will grow up, + * but hopefully find_env will return the last variable that you have set with the same name + * ex: set_env("test",10); + * set_env("test",20); + * + * HASH_COUNT will be equal to 2, get_env("test") will return 20 + * + * safe_set_env("test",10); + * safe_set_env("test",20); + * + * HASH_COUNT will be equal to 1, get_env("test") will return 20 + * + * set_env("test",10); + * re_set_env("test",20); + * + * HASH_COUNT will be equal to 1, get_env("test") will return 20 + * + */ +void set_env(const char *name, unsigned long long value ) { + _set_env(name, value, kEnvValue,0,0); +} + +void set_env_copy(const char *name, void * ptr, size_t size ) { + _set_env(name, 0, kEnvPtr,ptr,size); +} + +unsigned long long get_env_var(const char *name) { + struct env_struct *var; + + var = find_env(name); + if (!var) { +#if DEBUG_PLATFORM + printf("get_env_var: Unable to find environement variable %s\n",name); + getc(); +#endif + return 0; + } + + if (var->Type != kEnvValue) { + printf("get_env_var: Variable %s is not a value\n",name); +#if DEBUG_PLATFORM + getc(); +#endif + return 0; + } + + return var->value; + +} + +unsigned long long get_env(const char *name) { + + return get_env_var(name);; + +} + +void * get_env_ptr(const char *name) { + struct env_struct *var; + + var = find_env(name); + if (!var) { +#if DEBUG_PLATFORM + printf("get_env_ptr: Unable to get environement ptr variable %s\n",name); + getc(); +#endif + return 0; + } + + if (var->Type != kEnvPtr) { + printf("get_env_ptr: Variable %s is not a ptr\n",name); +#if DEBUG_PLATFORM + getc(); +#endif + return 0; + } + + return var->ptr; + +} + +/* If no specified variable exist, safe_set_env will create one, else it only modify the value */ +static void _safe_set_env(const char *name, unsigned long long value, enum envtype Type, void* ptr, size_t size ) { - return (Platform->CPU.isServer) ? true : false; + struct env_struct *var; + + var = find_env(name); + + if (!var) { + if (Type == kEnvPtr) { + _set_env(name, 0, kEnvPtr,ptr,size); + } + else if (Type == kEnvValue) { + _set_env(name, value, kEnvValue,0,0); + } + } + else if (var->Type != Type) { + return; + } + else { + if (Type == kEnvValue) + var->value = value; + else if (Type == kEnvPtr) + _re_set_env_copy(var,ptr,size); + } + + return; } -bool platformIsMobile(void) +void safe_set_env_copy(const char *name , void * ptr, size_t size ) { + + _safe_set_env(name, 0, kEnvPtr,ptr,size); + + return; +} + +void safe_set_env(const char *name , unsigned long long value) { + + _safe_set_env(name, value, kEnvValue,0,0); + + return; +} + +void re_set_env(const char *name , unsigned long long value) { + struct env_struct *var; + + var = find_env(name); + if (!var || (var->Type == kEnvValue)) { + printf("re_set_env: Unable to reset environement value variable %s\n",name); +#if DEBUG_PLATFORM + getc(); +#endif + return ; + } + + var->value = value; + + return; +} + +static void delete_env(struct env_struct *var) { + + if (setjmp(h_buf_error) == -1) { + printf("delete_env: Unable to delete environement variable\n"); +#if DEBUG_PLATFORM + getc(); +#endif + return; + } else { + HASH_DEL( platform_env, var); + } + free(var); +} + +void unset_env(const char *name) { + struct env_struct *var; + + if ((var = find_env(name))) { + delete_env(var); + } +} + +void free_platform_env(void) { + struct env_struct *current_var, *tmp; + + if (setjmp(h_buf_error) == -1) { + printf("free_platform_env: Unable to delete all environement variables\n"); +#if DEBUG_PLATFORM + getc(); +#endif + return; + } else { + HASH_ITER(hh, platform_env, current_var, tmp) { + HASH_DEL(platform_env,current_var); + free(current_var); + } + } +} + +#if DEBUG_PLATFORM +void debug_platform_env(void) { - return (Platform->CPU.isMobile) ? true : false; + struct env_struct *current_var = platform_env; + for(current_var=platform_env;current_var;current_var=(struct env_struct*)(current_var->hh.next)) + { + if (current_var->Type == kEnvValue) + printf(" Name = %s | Type = VALUE | Value = 0x%04x\n",current_var->name,(uint32_t)current_var->value); + else if (current_var->Type == kEnvPtr ) + printf(" Name = %s | Type = PTR(Copy) | Value = 0x%x\n",current_var->name,(uint32_t)current_var->ptr); + + } + getc(); } +#endif /** Scan platform hardware information, called by the main entry point (common_boot() ) @@ -79,8 +368,167 @@ */ void scan_platform(void) { - Platform = malloc(sizeof(PlatformInfo_t)); - memset(Platform, 0, sizeof(PlatformInfo_t)); + //memset(&Platform, 0, sizeof(PlatformInfo_t)); build_pci_dt(); - scan_cpu(Platform); + scan_cpu(); + +#if DEBUG_PLATFORM + DBG("CPU: %s\n", (char*)get_env_ptr(envBrandString)); + if (get_env(envVendor) == CPUID_VENDOR_AMD) + DBG("CPU: Vendor/Model/ExtModel: 0x%x/0x%x/0x%x\n", (uint32_t)get_env(envVendor), (uint32_t)get_env(envModel), (uint32_t)get_env(envExtModel)); + DBG("CPU: Family/ExtFamily: 0x%x/0x%x\n", (uint32_t)get_env(envFamily), (uint32_t)get_env(envExtFamily)); + if (get_env(envVendor) == CPUID_VENDOR_AMD) { + DBG("CPU (AMD): TSCFreq: %dMHz\n", (uint32_t)(get_env(envTSCFreq) / 1000000)); + DBG("CPU (AMD): FSBFreq: %dMHz\n", (uint32_t)(get_env(envFSBFreq) / 1000000)); + DBG("CPU (AMD): CPUFreq: %dMHz\n", (uint32_t)(get_env(envCPUFreq) / 1000000)); + DBG("CPU (AMD): MaxCoef/CurrCoef: 0x%x/0x%x\n", (uint32_t)get_env(envMaxCoef), (uint32_t)get_env(envCurrCoef)); + DBG("CPU (AMD): MaxDiv/CurrDiv: 0x%x/0x%x\n", (uint32_t)get_env(envMaxDiv), (uint32_t)get_env(envCurrDiv)); + } else if (get_env(envVendor) == CPUID_VENDOR_INTEL){ + DBG("CPU: TSCFreq: %dMHz\n", (uint32_t)(get_env(envTSCFreq) / 1000000)); + DBG("CPU: FSBFreq: %dMHz\n", (uint32_t)(get_env(envFSBFreq) / 1000000)); + DBG("CPU: CPUFreq: %dMHz\n", (uint32_t)(get_env(envCPUFreq) / 1000000)); + DBG("CPU: MaxCoef/CurrCoef: 0x%x/0x%x\n", (uint32_t)(get_env(envMaxCoef)), (uint32_t)(get_env(envCurrCoef))); + DBG("CPU: MaxDiv/CurrDiv: 0x%x/0x%x\n", (uint32_t)(get_env(envMaxDiv)), (uint32_t)(get_env(envCurrDiv))); + } + + DBG("CPU: NoCores/NoThreads: %d/%d\n", (uint32_t)(get_env(envNoCores)), (uint32_t)(get_env(envNoThreads))); + DBG("CPU: Features: 0x%08x\n", (uint32_t)(get_env(envFeatures))); + DBG("CPU: ExtFeatures: 0x%08x\n", (uint32_t)(get_env(envExtFeatures))); +#ifndef AMD_SUPPORT + DBG("CPU: MicrocodeVersion: %d\n", (uint32_t)(get_env(envMicrocodeVersion))); +#endif + pause(); +#endif } + +#ifdef ShowCurrentDate + +// shamefully ripped to http://wiki.osdev.org/CMOS + +#define CURRENT_YEAR 2012 // Change this each year! + +static int century_register = 0x00; // Set by ACPI table parsing code if possible(... in FADT table) + +enum { + cmos_address = 0x70, + cmos_data = 0x71 +}; + + +static int get_update_in_progress_flag() { + outb(cmos_address, 0x0A); + return (inb(cmos_data) & 0x80); +} + + +static unsigned char get_RTC_register(int reg) { + outb(cmos_address, reg); + return inb(cmos_data); +} + +static void read_rtc(EFI_TIME *time) { + unsigned char century; + unsigned char last_second; + unsigned char last_minute; + unsigned char last_hour; + unsigned char last_day; + unsigned char last_month; + unsigned char last_year; + unsigned char last_century; + unsigned char registerB; + + unsigned char second; + unsigned char minute; + unsigned char hour; + unsigned char day; + unsigned char month; + unsigned int year; + // Note: This uses the "read registers until you get the same values twice in a row" technique + // to avoid getting dodgy/inconsistent values due to RTC updates + + while (get_update_in_progress_flag()); // Make sure an update isn't in progress + second = get_RTC_register(0x00); + minute = get_RTC_register(0x02); + hour = get_RTC_register(0x04); + day = get_RTC_register(0x07); + month = get_RTC_register(0x08); + year = get_RTC_register(0x09); + if(century_register != 0) { + century = get_RTC_register(century_register); + } + + do { + last_second = second; + last_minute = minute; + last_hour = hour; + last_day = day; + last_month = month; + last_year = year; + last_century = century; + + while (get_update_in_progress_flag()); // Make sure an update isn't in progress + second = get_RTC_register(0x00); + minute = get_RTC_register(0x02); + hour = get_RTC_register(0x04); + day = get_RTC_register(0x07); + month = get_RTC_register(0x08); + year = get_RTC_register(0x09); + if(century_register != 0) { + century = get_RTC_register(century_register); + } + } while( (last_second == second) && (last_minute == minute) && (last_hour == hour) && + (last_day == day) && (last_month == month) && (last_year == year) && + (last_century == century) ); + + registerB = get_RTC_register(0x0B); + + // Convert BCD to binary values if necessary + + if (!(registerB & 0x04)) { + second = (second & 0x0F) + ((second / 16) * 10); + minute = (minute & 0x0F) + ((minute / 16) * 10); + hour = ( (hour & 0x0F) + (((hour & 0x70) / 16) * 10) ) | (hour & 0x80); + day = (day & 0x0F) + ((day / 16) * 10); + month = (month & 0x0F) + ((month / 16) * 10); + year = (year & 0x0F) + ((year / 16) * 10); + if(century_register != 0) { + century = (century & 0x0F) + ((century / 16) * 10); + } + } + + // Calculate the full (4-digit) year + + if(century_register != 0) { + year += century * 100; + } else { + //year += (CURRENT_YEAR / 100) * 100; + //if(year < CURRENT_YEAR) year += 100; + + if ((year += 1900) < 1970) + year += 100; + } + + time->Second = second; + time->Minute = minute; + time->Hour = hour; + time->Day = day; + time->Month = month; + time->Year = year; +} + +void rtc_time(EFI_TIME *time) { + + read_rtc(time); + + return ; +} + +char * Date(void) +{ + EFI_TIME rtctime; + rtc_time(&rtctime); + + return newStringWithFormat("%02d/%02d/%04d %02d:%02d:%02d",rtctime.Month,rtctime.Day,rtctime.Year, + rtctime.Hour,rtctime.Minute,rtctime.Second)); +} +#endif \ No newline at end of file Index: branches/cparm/i386/libsaio/cpu.c =================================================================== --- branches/cparm/i386/libsaio/cpu.c (revision 1839) +++ branches/cparm/i386/libsaio/cpu.c (revision 1840) @@ -39,7 +39,7 @@ #endif #define LEGACY_CPU INTEL_SUPPORT #endif -// (?) : if AMD_SUPPORT then LEGACY_CPU = 1, INTEL_SUPPORT = disabled +// (?) : if AMD_SUPPORT then (LEGACY_CPU = 1 && INTEL_SUPPORT = disabled) // else LEGACY_CPU = INTEL_SUPPORT @@ -420,19 +420,52 @@ * - cpuFrequency = fsbFrequency * multi */ -void scan_cpu(PlatformInfo_t *p) -{ - uint64_t tscFrequency = 0, fsbFrequency = 0, cpuFrequency = 0; - uint64_t msr; - uint8_t maxcoef = 0, maxdiv = 0, currcoef = 0, currdiv = 0; +void scan_cpu(void) +{ + uint64_t msr = 0; + + + uint64_t Features = 0; // CPU Features like MMX, SSE2, VT ... + uint64_t ExtFeatures = 0; // CPU Extended Features like SYSCALL, XD, EM64T, LAHF ... + uint64_t TSCFreq = 0 ; + uint64_t FSBFreq = 0 ; + uint64_t CPUFreq = 0; + uint32_t reg[4]; - uint32_t cores_per_package = 0; - uint32_t logical_per_package = 0; + uint32_t cores_per_package = 0; + uint32_t logical_per_package = 0; + uint32_t Vendor = 0; // Vendor + uint32_t Signature = 0; // Signature + uint8_t Stepping = 0; // Stepping + uint8_t Model = 0; // Model + uint8_t ExtModel = 0; // Extended Model + uint8_t Family = 0; // Family + uint8_t ExtFamily = 0; // Extended Family + uint32_t NoCores = 0; // No Cores per Package + uint32_t NoThreads = 0; // Threads per Package + uint8_t Brand = 0; + uint32_t MicrocodeVersion = 0; // The microcode version number a.k.a. signature a.k.a. BIOS ID + + uint8_t isMobile = 0; + + boolean_t dynamic_acceleration = 0; + boolean_t invariant_APIC_timer = 0; + boolean_t fine_grain_clock_mod = 0; + + uint32_t cpuid_max_basic = 0; + uint32_t cpuid_max_ext = 0; + uint32_t sub_Cstates = 0; + uint32_t extensions = 0; + + uint8_t maxcoef = 0, maxdiv = 0, currcoef = 0, currdiv = 0; + char CpuBrandString[48]; // 48 Byte Branding String + + do_cpuid(0, reg); - p->CPU.Vendor = reg[ebx]; - p->CPU.cpuid_max_basic = reg[eax]; - + Vendor = reg[ebx]; + cpuid_max_basic = reg[eax]; + #ifndef AMD_SUPPORT do_cpuid2(0x00000004, 0, reg); cores_per_package = bitfield(reg[eax], 31, 26) + 1; @@ -440,12 +473,12 @@ /* get extended cpuid results */ do_cpuid(0x80000000, reg); - p->CPU.cpuid_max_ext = reg[eax]; + cpuid_max_ext = reg[eax]; /* Begin of Copyright: from Apple's XNU cpuid.c */ /* get brand string (if supported) */ - if (p->CPU.cpuid_max_ext > 0x80000004) + if (cpuid_max_ext > 0x80000004) { char str[128], *s; /* @@ -463,15 +496,15 @@ if (*s != ' ') break; } - strlcpy(p->CPU.BrandString, s, sizeof(p->CPU.BrandString)); + strlcpy(CpuBrandString, s, sizeof(CpuBrandString)); - if (!strncmp(p->CPU.BrandString, CPUID_STRING_UNKNOWN, min(sizeof(p->CPU.BrandString), (unsigned)strlen(CPUID_STRING_UNKNOWN) + 1))) + if (!strncmp(CpuBrandString, CPUID_STRING_UNKNOWN, min(sizeof(CpuBrandString), (unsigned)strlen(CPUID_STRING_UNKNOWN) + 1))) { /* * This string means we have a firmware-programmable brand string, * and the firmware couldn't figure out what sort of CPU we have. */ - p->CPU.BrandString[0] = '\0'; + CpuBrandString[0] = '\0'; } } @@ -483,63 +516,63 @@ #ifndef AMD_SUPPORT wrmsr64(MSR_IA32_BIOS_SIGN_ID, 0); do_cpuid(1, reg); - p->CPU.MicrocodeVersion = - (uint32_t) (rdmsr64(MSR_IA32_BIOS_SIGN_ID) >> 32); + MicrocodeVersion = (uint32_t) (rdmsr64(MSR_IA32_BIOS_SIGN_ID) >> 32); #else do_cpuid(1, reg); #endif - p->CPU.Signature = reg[eax]; - p->CPU.Stepping = bitfield(reg[eax], 3, 0); - p->CPU.Model = bitfield(reg[eax], 7, 4); - p->CPU.Family = bitfield(reg[eax], 11, 8); - p->CPU.ExtModel = bitfield(reg[eax], 19, 16); - p->CPU.ExtFamily = bitfield(reg[eax], 27, 20); - p->CPU.Brand = bitfield(reg[ebx], 7, 0); - p->CPU.Features = quad(reg[ecx], reg[edx]); - + Signature = reg[eax]; + Stepping = bitfield(reg[eax], 3, 0); + Model = bitfield(reg[eax], 7, 4); + Family = bitfield(reg[eax], 11, 8); + ExtModel = bitfield(reg[eax], 19, 16); + ExtFamily = bitfield(reg[eax], 27, 20); + Brand = bitfield(reg[ebx], 7, 0); + Features = quad(reg[ecx], reg[edx]); + /* Fold extensions into family/model */ - if (p->CPU.Family == 0x0f) - p->CPU.Family += p->CPU.ExtFamily; - if (p->CPU.Family == 0x0f || p->CPU.Family == 0x06) - p->CPU.Model += (p->CPU.ExtModel << 4); + if (Family == 0x0f) + Family += ExtFamily; + if (Family == 0x0f || Family == 0x06) + Model += (ExtModel << 4); - if (p->CPU.Features & CPUID_FEATURE_HTT) + if (Features & CPUID_FEATURE_HTT) logical_per_package = bitfield(reg[ebx], 23, 16); else - logical_per_package = 1; + logical_per_package = 1; - if (p->CPU.cpuid_max_ext >= 0x80000001) + + if (cpuid_max_ext >= 0x80000001) { do_cpuid(0x80000001, reg); - p->CPU.ExtFeatures = + ExtFeatures = quad(reg[ecx], reg[edx]); } - if (p->CPU.cpuid_max_ext >= 0x80000007) + if (cpuid_max_ext >= 0x80000007) { do_cpuid(0x80000007, reg); /* Fold in the Invariant TSC feature bit, if present */ - p->CPU.ExtFeatures |= + ExtFeatures |= reg[edx] & (uint32_t)CPUID_EXTFEATURE_TSCI; #ifdef AMD_SUPPORT /* Fold in the Hardware P-State control feature bit, if present */ - p->CPU.ExtFeatures |= + ExtFeatures |= reg[edx] & (uint32_t)_Bit(7); /* Fold in the read-only effective frequency interface feature bit, if present */ - p->CPU.ExtFeatures |= + ExtFeatures |= reg[edx] & (uint32_t)_Bit(10); #endif } #ifdef AMD_SUPPORT - if (p->CPU.cpuid_max_ext >= 0x80000008) + if (cpuid_max_ext >= 0x80000008) { - if (p->CPU.Features & CPUID_FEATURE_HTT) + if (Features & CPUID_FEATURE_HTT) { do_cpuid(0x80000008, reg); cores_per_package = bitfield(reg[ecx], 7 , 0) + 1; // NC + 1 @@ -547,37 +580,37 @@ } #endif - if (p->CPU.cpuid_max_basic >= 0x5) { + if (cpuid_max_basic >= 0x5) { /* * Extract the Monitor/Mwait Leaf info: */ do_cpuid(5, reg); #ifndef AMD_SUPPORT - p->CPU.sub_Cstates = reg[edx]; + sub_Cstates = reg[edx]; #endif - p->CPU.extensions = reg[ecx]; + extensions = reg[ecx]; } #ifndef AMD_SUPPORT - if (p->CPU.cpuid_max_basic >= 0x6) + if (cpuid_max_basic >= 0x6) { /* * The thermal and Power Leaf: */ do_cpuid(6, reg); - p->CPU.dynamic_acceleration = bitfield(reg[eax], 1, 1); // "Dynamic Acceleration Technology (Turbo Mode)" - p->CPU.invariant_APIC_timer = bitfield(reg[eax], 2, 2); // "Invariant APIC Timer" - p->CPU.fine_grain_clock_mod = bitfield(reg[eax], 4, 4); + dynamic_acceleration = bitfield(reg[eax], 1, 1); // "Dynamic Acceleration Technology (Turbo Mode)" + invariant_APIC_timer = bitfield(reg[eax], 2, 2); // "Invariant APIC Timer" + fine_grain_clock_mod = bitfield(reg[eax], 4, 4); } - if ((p->CPU.Vendor == 0x756E6547 /* Intel */) && - (p->CPU.Family == 0x06)) + if ((Vendor == CPUID_VENDOR_INTEL) && + (Family == 0x06)) { /* * Find the number of enabled cores and threads * (which determines whether SMT/Hyperthreading is active). */ - switch (p->CPU.Model) + switch (Model) { case CPUID_MODEL_DALES_32NM: @@ -585,8 +618,8 @@ case CPUID_MODEL_WESTMERE_EX: { msr = rdmsr64(MSR_CORE_THREAD_COUNT); - p->CPU.NoThreads = bitfield((uint32_t)msr, 15, 0); - p->CPU.NoCores = bitfield((uint32_t)msr, 19, 16); + NoThreads = bitfield((uint32_t)msr, 15, 0); + NoCores = bitfield((uint32_t)msr, 19, 16); break; } @@ -598,47 +631,47 @@ case CPUID_MODEL_JAKETOWN: { msr = rdmsr64(MSR_CORE_THREAD_COUNT); - p->CPU.NoThreads = bitfield((uint32_t)msr, 15, 0); - p->CPU.NoCores = bitfield((uint32_t)msr, 31, 16); + NoThreads = bitfield((uint32_t)msr, 15, 0); + NoCores = bitfield((uint32_t)msr, 31, 16); break; } } } #endif - if (p->CPU.NoCores == 0) + if (NoCores == 0) { #ifdef AMD_SUPPORT if (!cores_per_package) { //legacy method - if ((p->CPU.ExtFeatures & _HBit(1)/* CmpLegacy */) && ( p->CPU.Features & CPUID_FEATURE_HTT) ) + if ((ExtFeatures & _HBit(1)/* CmpLegacy */) && ( Features & CPUID_FEATURE_HTT) ) cores_per_package = logical_per_package; else cores_per_package = 1; } #endif - p->CPU.NoThreads = logical_per_package; - p->CPU.NoCores = cores_per_package ? cores_per_package : 1 ; + NoThreads = logical_per_package; + NoCores = cores_per_package ? cores_per_package : 1 ; } /* End of Copyright: from Apple's XNU cpuid.c */ - fsbFrequency = (uint64_t)(compute_bclk() * 1000000); - + FSBFreq = (uint64_t)(compute_bclk() * 1000000); + #if LEGACY_CPU - tscFrequency = measure_tsc_frequency(); + TSCFreq = measure_tsc_frequency(); #endif #ifdef AMD_SUPPORT #define K8_FIDVID_STATUS 0xC0010042 #define K10_COFVID_STATUS 0xC0010071 - if (p->CPU.ExtFeatures & _Bit(10)) + if (ExtFeatures & _Bit(10)) { - cpuFrequency = measure_aperf_frequency(); + CPUFreq = measure_aperf_frequency(); } - if ((p->CPU.Vendor == 0x68747541 /* AMD */) && (p->CPU.Family == 0x0f)) + if ((Vendor == CPUID_VENDOR_AMD) && (Family == 0x0f)) { - switch(p->CPU.ExtFamily) + switch(ExtFamily) { case 0x00: /* K8 */ msr = rdmsr64(K8_FIDVID_STATUS); @@ -651,14 +684,14 @@ //uint32_t reg[4]; msr = rdmsr64(K10_COFVID_STATUS); /* - do_cpuid2(0x00000006, 0, reg); + do_cpuid2(0x00000006, 0, reg); EffFreq: effective frequency interface - if (bitfield(reg[ecx], 0, 0) == 1) - { - uint64_t aperf = measure_aperf_frequency(); - cpuFrequency = aperf; - } - */ + if (bitfield(reg[ecx], 0, 0) == 1) + { + uint64_t aperf = measure_aperf_frequency(); + CPUFreq = aperf; + } + */ // NOTE: tsc runs at the maccoeff (non turbo) // *not* at the turbo frequency. maxcoef = bitfield(msr, 54, 49) / 2 + 4; @@ -681,24 +714,24 @@ break; } - if (!fsbFrequency) + if (!FSBFreq) { if (maxcoef) { if (currdiv) { if (!currcoef) currcoef = maxcoef; - if (!cpuFrequency) - fsbFrequency = ((tscFrequency * currdiv) / currcoef); + if (!CPUFreq) + FSBFreq = ((TSCFreq * currdiv) / currcoef); else - fsbFrequency = ((cpuFrequency * currdiv) / currcoef); + FSBFreq = ((CPUFreq * currdiv) / currcoef); DBG("%d.%d\n", currcoef / currdiv, ((currcoef % currdiv) * 100) / currdiv); } else { - if (!cpuFrequency) - fsbFrequency = (tscFrequency / maxcoef); + if (!CPUFreq) + FSBFreq = (TSCFreq / maxcoef); else - fsbFrequency = (cpuFrequency / maxcoef); + FSBFreq = (CPUFreq / maxcoef); DBG("%d\n", currcoef); } } @@ -706,10 +739,10 @@ { if (currdiv) { - fsbFrequency = ((tscFrequency * currdiv) / currcoef); + FSBFreq = ((TSCFreq * currdiv) / currcoef); DBG("%d.%d\n", currcoef / currdiv, ((currcoef % currdiv) * 100) / currdiv); } else { - fsbFrequency = (tscFrequency / currcoef); + FSBFreq = (TSCFreq / currcoef); DBG("%d\n", currcoef); } } @@ -719,32 +752,32 @@ // NOTE: This is not the approved method, // the method provided by AMD is: - // if ((PowerNow == enabled (p->CPU.cpuid_max_ext >= 0x80000007)) && (StartupFID(??) != MaxFID(??))) then "mobile processor present" + // if ((PowerNow == enabled (p->cpu->cpuid_max_ext >= 0x80000007)) && (StartupFID(??) != MaxFID(??))) then "mobile processor present" - if (strstr(p->CPU.BrandString, "obile")) - p->CPU.isMobile = true; + if (strstr(CpuBrandString, "obile")) + isMobile = 1; else - p->CPU.isMobile = false; + isMobile = 0; - DBG("%s platform detected.\n", p->CPU.isMobile?"Mobile":"Desktop"); + DBG("%s platform detected.\n", isMobile?"Mobile":"Desktop"); #else - if ((p->CPU.Vendor == 0x756E6547 /* Intel */) && - ((p->CPU.Family == 0x06) || - (p->CPU.Family == 0x0f))) + if ((Vendor == CPUID_VENDOR_INTEL) && + ((Family == 0x06) || + (Family == 0x0f))) { - if ((p->CPU.Family == 0x06 && p->CPU.Model >= 0x0c) || - (p->CPU.Family == 0x0f && p->CPU.Model >= 0x03)) + if ((Family == 0x06 && Model >= 0x0c) || + (Family == 0x0f && Model >= 0x03)) { /* Nehalem CPU model */ - if (p->CPU.Family == 0x06 && (p->CPU.Model == CPUID_MODEL_NEHALEM || - p->CPU.Model == CPUID_MODEL_FIELDS || - p->CPU.Model == CPUID_MODEL_DALES || - p->CPU.Model == CPUID_MODEL_DALES_32NM || - p->CPU.Model == CPUID_MODEL_WESTMERE || - p->CPU.Model == CPUID_MODEL_NEHALEM_EX || - p->CPU.Model == CPUID_MODEL_WESTMERE_EX || - p->CPU.Model == CPUID_MODEL_SANDYBRIDGE || - p->CPU.Model == CPUID_MODEL_JAKETOWN)) + if (Family == 0x06 && (Model == CPUID_MODEL_NEHALEM || + Model == CPUID_MODEL_FIELDS || + Model == CPUID_MODEL_DALES || + Model == CPUID_MODEL_DALES_32NM || + Model == CPUID_MODEL_WESTMERE || + Model == CPUID_MODEL_NEHALEM_EX || + Model == CPUID_MODEL_WESTMERE_EX || + Model == CPUID_MODEL_SANDYBRIDGE || + Model == CPUID_MODEL_JAKETOWN)) { uint8_t bus_ratio_max = 0, bus_ratio_min = 0; uint32_t max_ratio = 0; @@ -791,30 +824,30 @@ #if LEGACY_CPU if (bus_ratio_max) { - fsbFrequency = (tscFrequency / bus_ratio_max); + FSBFreq = (TSCFreq / bus_ratio_max); } #endif //valv: Turbo Ratio Limit - if ((p->CPU.Model != 0x2e) && (p->CPU.Model != 0x2f)) + if ((Model != 0x2e) && (Model != 0x2f)) { //msr = rdmsr64(MSR_TURBO_RATIO_LIMIT); - cpuFrequency = bus_ratio_max * fsbFrequency; + CPUFreq = bus_ratio_max * FSBFreq; max_ratio = bus_ratio_max * 10; } else { #if LEGACY_CPU - cpuFrequency = tscFrequency; + CPUFreq = TSCFreq; #else - cpuFrequency = bus_ratio_max * fsbFrequency; + CPUFreq = bus_ratio_max * FSBFreq; #endif } #if DEBUG_CPU - DBG("Sticking with [BCLK: %dMhz, Bus-Ratio: %d]\n", fsbFrequency / 1000000, max_ratio); + DBG("Sticking with [BCLK: %dMhz, Bus-Ratio: %d]\n", FSBFreq / 1000000, max_ratio); #endif currcoef = bus_ratio_max; - tscFrequency = cpuFrequency; + TSCFreq = CPUFreq; } else { @@ -828,8 +861,8 @@ /* Non-integer bus ratio for the current-multi (undocumented)*/ currdiv = (msr >> 14) & 0x01; - if ((p->CPU.Family == 0x06 && p->CPU.Model >= 0x0e) || - (p->CPU.Family == 0x0f)) // This will always be model >= 3 + if ((Family == 0x06 && Model >= 0x0e) || + (Family == 0x0f)) // This will always be model >= 3 { /* On these models, maxcoef defines TSC freq */ maxcoef = (msr >> 40) & 0x1f; @@ -847,20 +880,20 @@ if (maxdiv) { - fsbFrequency = ((tscFrequency * 2) / ((maxcoef * 2) + 1)); + FSBFreq = ((TSCFreq * 2) / ((maxcoef * 2) + 1)); } else { - fsbFrequency = (tscFrequency / maxcoef); + FSBFreq = (TSCFreq / maxcoef); } if (currdiv) { - cpuFrequency = (fsbFrequency * ((currcoef * 2) + 1) / 2); + CPUFreq = (FSBFreq * ((currcoef * 2) + 1) / 2); } else { - cpuFrequency = (fsbFrequency * currcoef); + CPUFreq = (FSBFreq * currcoef); } #if DEBUG_CPU DBG("max: %d%s current: %d%s\n", maxcoef, maxdiv ? ".5" : "",currcoef, currdiv ? ".5" : ""); @@ -871,22 +904,22 @@ if (currdiv) { - cpuFrequency = (fsbFrequency * ((currcoef * 2) + 1) / 2); + CPUFreq = (FSBFreq * ((currcoef * 2) + 1) / 2); } else { - cpuFrequency = (fsbFrequency * currcoef); + CPUFreq = (FSBFreq * currcoef); } if (maxcoef) { if (maxdiv) { - tscFrequency = (fsbFrequency * ((maxcoef * 2) + 1)) / 2; + TSCFreq = (FSBFreq * ((maxcoef * 2) + 1)) / 2; } else { - tscFrequency = fsbFrequency * maxcoef; + TSCFreq = FSBFreq * maxcoef; } } #if DEBUG_CPU @@ -899,64 +932,70 @@ } /* Mobile CPU ? */ //Slice - p->CPU.isMobile = false; - switch (p->CPU.Model) + isMobile = 0; + switch (Model) { case 0x0D: - p->CPU.isMobile = true; + isMobile = 1; break; case 0x02: case 0x03: case 0x04: case 0x06: - p->CPU.isMobile = (rdmsr64(0x2C) & (1 << 21)); + isMobile = (rdmsr64(0x2C) & (1 << 21))? 1 : 0; break; default: - p->CPU.isMobile = (rdmsr64(0x17) & (1 << 28)); + isMobile = (rdmsr64(0x17) & (1 << 28)) ? 1 : 0; break; } - - DBG("%s platform detected.\n", p->CPU.isMobile?"Mobile":"Desktop"); + + DBG("%s platform detected.\n", isMobile?"Mobile":"Desktop"); } #endif - if (!cpuFrequency) cpuFrequency = tscFrequency; - if (!tscFrequency) tscFrequency = cpuFrequency; + if (!CPUFreq) CPUFreq = TSCFreq; + if (!TSCFreq) TSCFreq = CPUFreq; - p->CPU.MaxCoef = maxcoef; - p->CPU.MaxDiv = maxdiv; - p->CPU.CurrCoef = currcoef; - p->CPU.CurrDiv = currdiv; + set_env(envVendor, Vendor); + set_env(envModel, Model); + set_env(envExtModel, ExtModel); + + set_env(envCPUIDMaxBasic, cpuid_max_basic); + set_env(envCPUIDMaxBasic, cpuid_max_ext); +#ifndef AMD_SUPPORT + set_env(envMicrocodeVersion, MicrocodeVersion); +#endif + set_env_copy(envBrandString, CpuBrandString, sizeof(CpuBrandString)); + set_env(envSignature, Signature); + set_env(envStepping, Stepping); + set_env(envFamily, Family); + set_env(envExtModel, ExtModel); + set_env(envExtFamily, ExtFamily); + set_env(envBrand, Brand); + set_env(envFeatures, Features); + set_env(envExtFeatures, ExtFeatures); +#ifndef AMD_SUPPORT + set_env(envSubCstates, sub_Cstates); +#endif + set_env(envExtensions, extensions); +#ifndef AMD_SUPPORT + set_env(envDynamicAcceleration, dynamic_acceleration); + set_env(envInvariantAPICTimer, invariant_APIC_timer); + set_env(envFineGrainClockMod, fine_grain_clock_mod); +#endif + set_env(envNoThreads, NoThreads); + set_env(envNoCores, NoCores); + set_env(envIsMobile, isMobile); - p->CPU.TSCFrequency = tscFrequency ; - p->CPU.FSBFrequency = fsbFrequency ; - p->CPU.CPUFrequency = cpuFrequency ; + set_env(envMaxCoef, maxcoef); + set_env(envMaxDiv, maxdiv); + set_env(envCurrCoef, currcoef); + set_env(envCurrDiv, currdiv); + set_env(envTSCFreq, TSCFreq); + set_env(envFSBFreq, FSBFreq); + set_env(envCPUFreq, CPUFreq); + #ifdef AMD_SUPPORT msglog("AMD CPU Detection Enabled\n"); #endif - DBG("CPU: Vendor/Model/ExtModel: 0x%x/0x%x/0x%x\n", p->CPU.Vendor, p->CPU.Model, p->CPU.ExtModel); - DBG("CPU: Family/ExtFamily: 0x%x/0x%x\n", p->CPU.Family, p->CPU.ExtFamily); -#ifdef AMD_SUPPORT - DBG("CPU (AMD): TSCFreq: %dMHz\n", p->CPU.TSCFrequency / 1000000); - DBG("CPU (AMD): FSBFreq: %dMHz\n", p->CPU.FSBFrequency / 1000000); - DBG("CPU (AMD): CPUFreq: %dMHz\n", p->CPU.CPUFrequency / 1000000); - DBG("CPU (AMD): MaxCoef/CurrCoef: 0x%x/0x%x\n", p->CPU.MaxCoef, p->CPU.CurrCoef); - DBG("CPU (AMD): MaxDiv/CurrDiv: 0x%x/0x%x\n", p->CPU.MaxDiv, p->CPU.CurrDiv); -#else - DBG("CPU: TSCFreq: %dMHz\n", p->CPU.TSCFrequency / 1000000); - DBG("CPU: FSBFreq: %dMHz\n", p->CPU.FSBFrequency / 1000000); - DBG("CPU: CPUFreq: %dMHz\n", p->CPU.CPUFrequency / 1000000); - DBG("CPU: MaxCoef/CurrCoef: 0x%x/0x%x\n", p->CPU.MaxCoef, p->CPU.CurrCoef); - DBG("CPU: MaxDiv/CurrDiv: 0x%x/0x%x\n", p->CPU.MaxDiv, p->CPU.CurrDiv); -#endif - DBG("CPU: NoCores/NoThreads: %d/%d\n", p->CPU.NoCores, p->CPU.NoThreads); - DBG("CPU: Features: 0x%08x\n", p->CPU.Features); - DBG("CPU: ExtFeatures: 0x%08x\n", p->CPU.ExtFeatures); -#ifndef AMD_SUPPORT - DBG("CPU: MicrocodeVersion: %d\n", p->CPU.MicrocodeVersion); -#endif -#if DEBUG_CPU - pause(); -#endif - -} +} \ No newline at end of file Index: branches/cparm/i386/libsaio/platform.h =================================================================== --- branches/cparm/i386/libsaio/platform.h (revision 1839) +++ branches/cparm/i386/libsaio/platform.h (revision 1840) @@ -21,6 +21,10 @@ #define CPUID_MODEL_DOTHAN 0x0D #define CPUID_MODEL_ATOM 0x1C +/* CPUID Vendor */ +#define CPUID_VENDOR_INTEL 0x756E6547 +#define CPUID_VENDOR_AMD 0x68747541 + /* SMBIOS Memory Types */ #define SMB_MEM_TYPE_UNDEFINED 0 #define SMB_MEM_TYPE_OTHER 1 @@ -75,8 +79,110 @@ } RamSlotInfo_t; +#define envVendor "Vendor" +#define envCPUIDMaxBasic "max_basic" +#define envCPUIDMaxExt "max_ext" +#define envMicrocodeVersion "Microcode" +#define envSignature "Signature" +#define envStepping "Stepping" +#define envModel "Model" +#define envFamily "Family" +#define envExtModel "ExtModel" +#define envExtFamily "ExtFamily" +#define envBrand "Brand" +#define envFeatures "Feat" +#define envExtFeatures "ExtFeat" +#define envSubCstates "sub_Csta" +#define envExtensions "CPUIDext" +#define envBrandString "BrandStr" +#define envDynamicAcceleration "dynAcc" +#define envInvariantAPICTimer "invAPIC" +#define envFineGrainClockMod "fineGrain" +#define envNoThreads "NoThreads" +#define envNoCores "NoCores" +#define envIsMobile "isMobile" +#define envMaxCoef "MaxCoef" +#define envMaxDiv "MaxDiv" +#define envCurrCoef "CurrCoef" +#define envCurrDiv "CurrDiv" +#define envTSCFreq "TSCFreq" +#define envFSBFreq "FSBFreq" +#define envCPUFreq "CPUFreq" +#define envIsServer "isServer" + + +#define envCurrCoef "CurrCoef" +#define envCurrDiv "CurrDiv" +#define envTSCFreq "TSCFreq" +#define envFSBFreq "FSBFreq" +#define envCPUFreq "CPUFreq" + +#define envHardwareSignature "HdwSign" +#define envType "Type" +#define envUUID "UUID" +#define envSysId "SysId" + +#define envgBootMode "gBootMode" +#define envgBIOSDev "gBIOSDev" +#define envSysConfigValid "IsSysConf" +#define envgOverrideKernel "IsKover" +#define envgEnableCDROMRescan "CDRescan" +#define envgScanSingleDrive "1Drive" +#define envgDeviceCount "DevCnt" +#define envShouldboot "shldboot" + + +#define envDriverExtSpec "DrvXSpec" +#define envDriverSpec "DrvSpec" +#define envDriverFileSpec "DrvFSpes" +#define envDriverTempSpec "DrvTSpes" +#define envDriverFileName "DrvFName" + +#define envkCache "kCache" +#define envMKextName "MCache" + +#define envBootBanner "Banner" +#define envBootPrompt "Prompt" +#define envBootRescanPrompt "PromptBis" + +#define envgMenuRow "MenuRow" +#define envgMenuHeight "MenuH" +#define envgMenuItemCount "MenuCnt" +#define envgMenuTop "MenuTop" +#define envgMenuBottom "MenuB" +#define envgMenuSelection "MenuSel" +#define envgMenuStart "MenuStart" +#define envgMenuEnd "MenuEnd" +#define envArgCntRemaining "ArgCntRem" + +#define envgBootArgs "gBootArgs" + +#define envConvMem "ConvMem" +#define envExtMem "ExtMem" +#define envMemoryMap "MemoryMap" +#define envMemoryMapCnt "MemMapCnt" + + +#define envRamFrequency "RamFreq" +#define envRamCas "tCAS" +#define envRamTrc "tRCD" +#define envRamRas "tRAS" +#define envRamTrp "tRP" +#define envRamChannels "RamChans" +#define envRamType "RamType" +#define envRamCas "tCAS" +#define envRamCas "tCAS" +#define envRamCas "tCAS" +#define envRamCas "tCAS" +#define envDMIMemModules "DmiMemMod" +#define envDMIMaxMemorySlots "DmiMaxSlt" +#define envDMICntMemorySlots "DmiCntSlt" +#define envRamDimm "RamDimm" +#define envDmiDimm "DmiDimm" + +#if UNUSED typedef struct _PlatformInfo_t { struct CPU_t { @@ -142,6 +248,12 @@ int8_t sysid[16]; } PlatformInfo_t; +#endif -extern PlatformInfo_t *Platform; +#ifdef ShowCurrentDate +#include "efi.h" +extern char * Date(void); +extern void rtc_time(EFI_TIME *time); +#endif + #endif /* !__LIBSAIO_PLATFORM_H */ Index: branches/cparm/i386/libsaio/disk.c =================================================================== --- branches/cparm/i386/libsaio/disk.c (revision 1839) +++ branches/cparm/i386/libsaio/disk.c (revision 1840) @@ -52,8 +52,10 @@ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" +#include "platform.h" +#include "sl.h" + #include "fdisk.h" #ifdef UFS_SUPPORT #include "ufs.h" @@ -131,9 +133,9 @@ ((((value) + (multiple) - 1) / (multiple)) * (multiple)) /* -#define IOTrunc(value,multiple) \ -(((value) / (multiple)) * (multiple)); -*/ + #define IOTrunc(value,multiple) \ + (((value) / (multiple)) * (multiple)); + */ /* * trackbuf points to the start of the track cache. Biosread() @@ -198,6 +200,7 @@ #endif static TagPtr XMLGetElementWithID( TagPtr dict, const char* id ); static bool getOSVersion(BVRef bvr, char *str); +static bool CheckDarwin(BVRef bvr); //========================================================================== @@ -378,7 +381,7 @@ } printf(" BIOS read error: %s\n", bios_error(rc), rc); printf(" Block %d, Cyl %d Head %d Sector %d\n", - secno, cyl, head, sec); + secno, cyl, head, sec); sleep(1); } } @@ -416,7 +419,7 @@ if(biosdev >= 0x100 && (execute_hook("isRamDiskRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS)){ - + int ret = -1; execute_hook("p_ramdiskReadBytes", &biosdev, (void*)(unsigned long)&blkno, &byteoff, &byteCount, buffer, &ret); return ret; @@ -899,8 +902,8 @@ #ifndef UFS_SUPPORT break; #else - - //case FDISK_BOOTER: + + //case FDISK_BOOTER: booterUFS = newFDiskBVRef( biosdev, partno, ((part->relsect + spc - 1) / spc) * spc, @@ -951,7 +954,7 @@ 0, kBIOSDevTypeHardDrive, 0); break; #endif - + #ifndef NO_LINUX_SUPPORT case FDISK_LINUX: @@ -1191,7 +1194,7 @@ #ifndef NO_WIN_SUPPORT int fatbits; #endif - + // Allocating buffer for 4 sectors. const void * probeBuffer = malloc(PROBEFS_SIZE); if (probeBuffer == NULL) @@ -1407,7 +1410,7 @@ continue; else bvrFlags = 0; - + #endif bvr = newGPTBVRef(biosdev, gptID, @@ -1433,7 +1436,7 @@ switch (fsType) { #ifndef NO_WIN_SUPPORT - + case FDISK_NTFS: bvr = newGPTBVRef(biosdev, gptID, gptMap->ent_lba_start, gptMap, 0, 0, 0, 0, 0, 0, NTFSGetDescription, @@ -1488,7 +1491,7 @@ break; #endif default: - if (biosdev == gBIOSDev) + if (biosdev == (int)get_env(envgBIOSDev)) gBIOSBootVolume = bvr; break; } @@ -1618,6 +1621,48 @@ return valid; } +static bool CheckDarwin(BVRef bvr) +{ + long flags, time, ret = -1; + + char dirspec[128]; + + char *kdirspec[] = { + "hd(%d,%d)/mach_kernel", +#if UNUSED + "hd(%d,%d)/System/Library/CoreServices/mach_kernel" +#endif + }; + + bvr->kernelfound = true; + + sprintf(dirspec,kdirspec[0],BIOS_DEV_UNIT(bvr), bvr->part_no); + + ret = GetFileInfo(NULL, dirspec, &flags, &time); + + if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) { +#if UNUSED + + sprintf(dirspec,kdirspec[1],BIOS_DEV_UNIT(bvr), bvr->part_no); + + ret = GetFileInfo(NULL, dirspec, &flags, &time); + + if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) +#endif + { + bvr->kernelfound = false; // Non fatal, let the booter determine the directory + } + + } + + if (bvr->kernelfound == true) { + DBG("Kernel found !!, path : %s\n",dirspec); + } + + + return getOSVersion(bvr,bvr->OSVersion); +} + //========================================================================== static void scanFSLevelBVRSettings(BVRef chain) @@ -1633,7 +1678,7 @@ ret = -1; #ifdef BOOT_HELPER_SUPPORT error = 0; - + // // Check for alternate volume label on boot helper partitions. // @@ -1670,7 +1715,7 @@ // if (bvr->flags & kBVFlagNativeBoot) { - if (getOSVersion(bvr,bvr->OSVersion) == true) + if (CheckDarwin(bvr) == true) { bvr->flags |= kBVFlagSystemVolume; } @@ -1796,7 +1841,7 @@ char* val = 0; int len; - getValueForKey(kHidePartition, &raw, &len, &bootInfo->bootConfig); + getValueForKey(kHidePartition, &raw, &len, DEFAULT_BOOT_CONFIG); if(raw) { val = XMLDecode(raw); @@ -1986,7 +2031,7 @@ if ( !str || strMaxLen <= 0) return false; - aliasList = XMLDecode(getStringForKey(kRenamePartition, &bootInfo->bootConfig)); + aliasList = XMLDecode(getStringForKey(kRenamePartition, DEFAULT_BOOT_CONFIG)); if ( !aliasList ) return false; Index: branches/cparm/i386/libsaio/cpu.h =================================================================== --- branches/cparm/i386/libsaio/cpu.h (revision 1839) +++ branches/cparm/i386/libsaio/cpu.h (revision 1840) @@ -8,7 +8,7 @@ #include "libsaio.h" -extern void scan_cpu(PlatformInfo_t *); +extern void scan_cpu(void); #define MSR_IA32_PERF_STATUS 0x198 #define MSR_IA32_PERF_CONTROL 0x199 Index: branches/cparm/i386/libsaio/smbios.c =================================================================== --- branches/cparm/i386/libsaio/smbios.c (revision 1839) +++ branches/cparm/i386/libsaio/smbios.c (revision 1840) @@ -1,8 +1,8 @@ +#include "libsaio.h" #include "SMBIOS.h" #include "Platform.h" -#include "boot.h" static const char * const SMTAG = "_SM_"; static const char* const DMITAG= "_DMI_"; @@ -116,7 +116,7 @@ { switch (value) { case theUUID: - Platform->UUID = ((SMBSystemInformation *)structHeader)->uuid; + safe_set_env(envUUID,(uint32_t)((SMBSystemInformation *)structHeader)->uuid); return 1; break; case thePlatformName: @@ -131,8 +131,8 @@ field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1)); //DBG("original SMBIOS Product name: %s\n",(char *)stringPtr); - gPlatformName = (char *)stringPtr; - if (gPlatformName) return 1; + SetgPlatformName((char *)stringPtr); + if (GetgPlatformName()) return 1; break; } default: @@ -155,8 +155,8 @@ for (field--; field != 0 && strlen((char *)stringPtr) > 0; field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1)); - gboardproduct = (char *)stringPtr; - if (gboardproduct) return 1; + Setgboardproduct((char *)stringPtr); + if (Getgboardproduct()) return 1; break; } default: Index: branches/cparm/i386/libsaio/uthash.h =================================================================== --- branches/cparm/i386/libsaio/uthash.h (revision 0) +++ branches/cparm/i386/libsaio/uthash.h (revision 1840) @@ -0,0 +1,895 @@ +/* +Copyright (c) 2003-2011, Troy D. Hanson http://uthash.sourceforge.net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef UTHASH_H +#define UTHASH_H + +#include "libsaio.h" + +/* These macros use decltype or the earlier __typeof GNU extension. + As decltype is only available in newer compilers (VS2010 or gcc 4.3+ + when compiling c++ source) this code uses whatever method is needed + or, for VS2008 where neither is available, uses casting workarounds. */ +#ifdef _MSC_VER /* MS compiler */ +#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ +#define DECLTYPE(x) (decltype(x)) +#else /* VS2008 or older (or VS2010 in C mode) */ +#define NO_DECLTYPE +#define DECLTYPE(x) +#endif +#else /* GNU, Sun and other compilers */ +#define DECLTYPE(x) (__typeof(x)) +#endif + +#ifdef NO_DECLTYPE +#define DECLTYPE_ASSIGN(dst,src) \ +do { \ + char **_da_dst = (char**)(&(dst)); \ + *_da_dst = (char*)(src); \ +} while(0) +#else +#define DECLTYPE_ASSIGN(dst,src) \ +do { \ + (dst) = DECLTYPE(dst)(src); \ +} while(0) +#endif + +#define UTHASH_VERSION 1.9.4 + +#define uthash_fatal(msg) longjmp(h_buf_error,-1) /* fatal error (out of memory,etc) */ +#define uthash_malloc(sz) malloc(sz) /* malloc fcn */ +#define uthash_free(ptr,sz) free(ptr) /* free fcn */ + +#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ +#define uthash_expand_fyi(tbl) /* can be defined to log expands */ + +/* initial number of buckets */ +#define HASH_INITIAL_NUM_BUCKETS 32 /* initial number of buckets */ +#define HASH_INITIAL_NUM_BUCKETS_LOG2 5 /* lg2 of initial number of buckets */ +#define HASH_BKT_CAPACITY_THRESH 10 /* expand when bucket count reaches */ + +/* calculate the element whose hash handle address is hhe */ +#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) + +#define HASH_FIND(hh,head,keyptr,keylen,out) \ +do { \ + unsigned _hf_bkt,_hf_hashv; \ + out=NULL; \ + if (head) { \ + HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \ + if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \ + HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \ + keyptr,keylen,out); \ + } \ + } \ +} while (0) + +#ifdef HASH_BLOOM +#define HASH_BLOOM_BITLEN (1ULL << HASH_BLOOM) +#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8) + ((HASH_BLOOM_BITLEN%8) ? 1:0) +#define HASH_BLOOM_MAKE(tbl) \ +do { \ + (tbl)->bloom_nbits = HASH_BLOOM; \ + (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ + if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \ + memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \ + (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ +} while (0); + +#define HASH_BLOOM_FREE(tbl) \ +do { \ + uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ +} while (0); + +#define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8))) +#define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8))) + +#define HASH_BLOOM_ADD(tbl,hashv) \ + HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) + +#define HASH_BLOOM_TEST(tbl,hashv) \ + HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) + +#else +#define HASH_BLOOM_MAKE(tbl) +#define HASH_BLOOM_FREE(tbl) +#define HASH_BLOOM_ADD(tbl,hashv) +#define HASH_BLOOM_TEST(tbl,hashv) (1) +#endif + +#define HASH_MAKE_TABLE(hh,head) \ +do { \ + (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \ + sizeof(UT_hash_table)); \ + if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \ + memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \ + (head)->hh.tbl->tail = &((head)->hh); \ + (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ + (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ + (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ + (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ + HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ + if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \ + memset((head)->hh.tbl->buckets, 0, \ + HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ + HASH_BLOOM_MAKE((head)->hh.tbl); \ + (head)->hh.tbl->signature = HASH_SIGNATURE; \ +} while(0) + +#define HASH_ADD(hh,head,fieldname,keylen_in,add) \ + HASH_ADD_KEYPTR(hh,head,&((add)->fieldname),keylen_in,add) + +#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ +do { \ + unsigned _ha_bkt; \ + (add)->hh.next = NULL; \ + (add)->hh.key = (char*)keyptr; \ + (add)->hh.keylen = keylen_in; \ + if (!(head)) { \ + head = (add); \ + (head)->hh.prev = NULL; \ + HASH_MAKE_TABLE(hh,head); \ + } else { \ + (head)->hh.tbl->tail->next = (add); \ + (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ + (head)->hh.tbl->tail = &((add)->hh); \ + } \ + (head)->hh.tbl->num_items++; \ + (add)->hh.tbl = (head)->hh.tbl; \ + HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \ + (add)->hh.hashv, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \ + HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \ + HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \ + HASH_FSCK(hh,head); \ +} while(0) + +#define HASH_TO_BKT( hashv, num_bkts, bkt ) \ +do { \ + bkt = ((hashv) & ((num_bkts) - 1)); \ +} while(0) + +/* delete "delptr" from the hash table. + * "the usual" patch-up process for the app-order doubly-linked-list. + * The use of _hd_hh_del below deserves special explanation. + * These used to be expressed using (delptr) but that led to a bug + * if someone used the same symbol for the head and deletee, like + * HASH_DELETE(hh,users,users); + * We want that to work, but by changing the head (users) below + * we were forfeiting our ability to further refer to the deletee (users) + * in the patch-up process. Solution: use scratch space to + * copy the deletee pointer, then the latter references are via that + * scratch pointer rather than through the repointed (users) symbol. + */ +#define HASH_DELETE(hh,head,delptr) \ +do { \ + unsigned _hd_bkt; \ + struct UT_hash_handle *_hd_hh_del; \ + if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \ + uthash_free((head)->hh.tbl->buckets, \ + (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \ + HASH_BLOOM_FREE((head)->hh.tbl); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + head = NULL; \ + } else { \ + _hd_hh_del = &((delptr)->hh); \ + if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \ + (head)->hh.tbl->tail = \ + (UT_hash_handle*)((char*)((delptr)->hh.prev) + \ + (head)->hh.tbl->hho); \ + } \ + if ((delptr)->hh.prev) { \ + ((UT_hash_handle*)((char*)((delptr)->hh.prev) + \ + (head)->hh.tbl->hho))->next = (delptr)->hh.next; \ + } else { \ + DECLTYPE_ASSIGN(head,(delptr)->hh.next); \ + } \ + if (_hd_hh_del->next) { \ + ((UT_hash_handle*)((char*)_hd_hh_del->next + \ + (head)->hh.tbl->hho))->prev = \ + _hd_hh_del->prev; \ + } \ + HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ + (head)->hh.tbl->num_items--; \ + } \ + HASH_FSCK(hh,head); \ +} while (0) + + +/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ +#define HASH_FIND_STR(head,findstr,out) \ + HASH_FIND(hh,head,findstr,strlen(findstr),out) +#define HASH_ADD_STR(head,strfield,add) \ + HASH_ADD(hh,head,strfield,strlen(add->strfield),add) +#define HASH_FIND_INT(head,findint,out) \ + HASH_FIND(hh,head,findint,sizeof(int),out) +#define HASH_ADD_INT(head,intfield,add) \ + HASH_ADD(hh,head,intfield,sizeof(int),add) +#define HASH_FIND_PTR(head,findptr,out) \ + HASH_FIND(hh,head,findptr,sizeof(void *),out) +#define HASH_ADD_PTR(head,ptrfield,add) \ + HASH_ADD(hh,head,ptrfield,sizeof(void *),add) +#define HASH_DEL(head,delptr) \ + HASH_DELETE(hh,head,delptr) + +/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined. + * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. + */ +#ifdef HASH_DEBUG +#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); longjmp(h_buf_error,-1); } while (0) +#define HASH_FSCK(hh,head) \ +do { \ + unsigned _bkt_i; \ + unsigned _count, _bkt_count; \ + char *_prev; \ + struct UT_hash_handle *_thh; \ + if (head) { \ + _count = 0; \ + for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \ + _bkt_count = 0; \ + _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ + _prev = NULL; \ + while (_thh) { \ + if (_prev != (char*)(_thh->hh_prev)) { \ + HASH_OOPS("invalid hh_prev %p, actual %p\n", \ + _thh->hh_prev, _prev ); \ + } \ + _bkt_count++; \ + _prev = (char*)(_thh); \ + _thh = _thh->hh_next; \ + } \ + _count += _bkt_count; \ + if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ + HASH_OOPS("invalid bucket count %d, actual %d\n", \ + (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ + } \ + } \ + if (_count != (head)->hh.tbl->num_items) { \ + HASH_OOPS("invalid hh item count %d, actual %d\n", \ + (head)->hh.tbl->num_items, _count ); \ + } \ + /* traverse hh in app order; check next/prev integrity, count */ \ + _count = 0; \ + _prev = NULL; \ + _thh = &(head)->hh; \ + while (_thh) { \ + _count++; \ + if (_prev !=(char*)(_thh->prev)) { \ + HASH_OOPS("invalid prev %p, actual %p\n", \ + _thh->prev, _prev ); \ + } \ + _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \ + _thh = ( _thh->next ? (UT_hash_handle*)((char*)(_thh->next) + \ + (head)->hh.tbl->hho) : NULL ); \ + } \ + if (_count != (head)->hh.tbl->num_items) { \ + HASH_OOPS("invalid app item count %d, actual %d\n", \ + (head)->hh.tbl->num_items, _count ); \ + } \ + } \ +} while (0) +#else +#define HASH_FSCK(hh,head) +#endif + +/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to + * the descriptor to which this macro is defined for tuning the hash function. + * The app can #include to get the prototype for write(2). */ +#ifdef HASH_EMIT_KEYS +#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ +do { \ + unsigned _klen = fieldlen; \ + write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ + write(HASH_EMIT_KEYS, keyptr, fieldlen); \ +} while (0) +#else +#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) +#endif + +/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ +#ifdef HASH_FUNCTION +#define HASH_FCN HASH_FUNCTION +#else +#define HASH_FCN HASH_JEN +#endif + +/* The Bernstein hash function, used in Perl prior to v5.6 */ +#define HASH_BER(key,keylen,num_bkts,hashv,bkt) \ +do { \ + unsigned _hb_keylen=keylen; \ + char *_hb_key=(char*)(key); \ + (hashv) = 0; \ + while (_hb_keylen--) { (hashv) = ((hashv) * 33) + *_hb_key++; } \ + bkt = (hashv) & (num_bkts-1); \ +} while (0) + + +/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at + * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ +#define HASH_SAX(key,keylen,num_bkts,hashv,bkt) \ +do { \ + unsigned _sx_i; \ + char *_hs_key=(char*)(key); \ + hashv = 0; \ + for(_sx_i=0; _sx_i < keylen; _sx_i++) \ + hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ + bkt = hashv & (num_bkts-1); \ +} while (0) + +#define HASH_FNV(key,keylen,num_bkts,hashv,bkt) \ +do { \ + unsigned _fn_i; \ + char *_hf_key=(char*)(key); \ + hashv = 2166136261UL; \ + for(_fn_i=0; _fn_i < keylen; _fn_i++) \ + hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \ + bkt = hashv & (num_bkts-1); \ +} while(0); + +#define HASH_OAT(key,keylen,num_bkts,hashv,bkt) \ +do { \ + unsigned _ho_i; \ + char *_ho_key=(char*)(key); \ + hashv = 0; \ + for(_ho_i=0; _ho_i < keylen; _ho_i++) { \ + hashv += _ho_key[_ho_i]; \ + hashv += (hashv << 10); \ + hashv ^= (hashv >> 6); \ + } \ + hashv += (hashv << 3); \ + hashv ^= (hashv >> 11); \ + hashv += (hashv << 15); \ + bkt = hashv & (num_bkts-1); \ +} while(0) + +#define HASH_JEN_MIX(a,b,c) \ +do { \ + a -= b; a -= c; a ^= ( c >> 13 ); \ + b -= c; b -= a; b ^= ( a << 8 ); \ + c -= a; c -= b; c ^= ( b >> 13 ); \ + a -= b; a -= c; a ^= ( c >> 12 ); \ + b -= c; b -= a; b ^= ( a << 16 ); \ + c -= a; c -= b; c ^= ( b >> 5 ); \ + a -= b; a -= c; a ^= ( c >> 3 ); \ + b -= c; b -= a; b ^= ( a << 10 ); \ + c -= a; c -= b; c ^= ( b >> 15 ); \ +} while (0) + +#define HASH_JEN(key,keylen,num_bkts,hashv,bkt) \ +do { \ + unsigned _hj_i,_hj_j,_hj_k; \ + char *_hj_key=(char*)(key); \ + hashv = 0xfeedbeef; \ + _hj_i = _hj_j = 0x9e3779b9; \ + _hj_k = keylen; \ + while (_hj_k >= 12) { \ + _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \ + + ( (unsigned)_hj_key[2] << 16 ) \ + + ( (unsigned)_hj_key[3] << 24 ) ); \ + _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \ + + ( (unsigned)_hj_key[6] << 16 ) \ + + ( (unsigned)_hj_key[7] << 24 ) ); \ + hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \ + + ( (unsigned)_hj_key[10] << 16 ) \ + + ( (unsigned)_hj_key[11] << 24 ) ); \ + \ + HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ + \ + _hj_key += 12; \ + _hj_k -= 12; \ + } \ + hashv += keylen; \ + switch ( _hj_k ) { \ + case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); \ + case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); \ + case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); \ + case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); \ + case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); \ + case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); \ + case 5: _hj_j += _hj_key[4]; \ + case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); \ + case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); \ + case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); \ + case 1: _hj_i += _hj_key[0]; \ + } \ + HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ + bkt = hashv & (num_bkts-1); \ +} while(0) + +/* The Paul Hsieh hash function */ +#undef get16bits +#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ + || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) +#define get16bits(d) (*((const uint16_t *) (d))) +#endif + +#if !defined (get16bits) +#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \ + +(uint32_t)(((const uint8_t *)(d))[0]) ) +#endif +#define HASH_SFH(key,keylen,num_bkts,hashv,bkt) \ +do { \ + char *_sfh_key=(char*)(key); \ + uint32_t _sfh_tmp, _sfh_len = keylen; \ + \ + int _sfh_rem = _sfh_len & 3; \ + _sfh_len >>= 2; \ + hashv = 0xcafebabe; \ + \ + /* Main loop */ \ + for (;_sfh_len > 0; _sfh_len--) { \ + hashv += get16bits (_sfh_key); \ + _sfh_tmp = (get16bits (_sfh_key+2) << 11) ^ hashv; \ + hashv = (hashv << 16) ^ _sfh_tmp; \ + _sfh_key += 2*sizeof (uint16_t); \ + hashv += hashv >> 11; \ + } \ + \ + /* Handle end cases */ \ + switch (_sfh_rem) { \ + case 3: hashv += get16bits (_sfh_key); \ + hashv ^= hashv << 16; \ + hashv ^= _sfh_key[sizeof (uint16_t)] << 18; \ + hashv += hashv >> 11; \ + break; \ + case 2: hashv += get16bits (_sfh_key); \ + hashv ^= hashv << 11; \ + hashv += hashv >> 17; \ + break; \ + case 1: hashv += *_sfh_key; \ + hashv ^= hashv << 10; \ + hashv += hashv >> 1; \ + } \ + \ + /* Force "avalanching" of final 127 bits */ \ + hashv ^= hashv << 3; \ + hashv += hashv >> 5; \ + hashv ^= hashv << 4; \ + hashv += hashv >> 17; \ + hashv ^= hashv << 25; \ + hashv += hashv >> 6; \ + bkt = hashv & (num_bkts-1); \ +} while(0); + +#ifdef HASH_USING_NO_STRICT_ALIASING +/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. + * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. + * MurmurHash uses the faster approach only on CPU's where we know it's safe. + * + * Note the preprocessor built-in defines can be emitted using: + * + * gcc -m64 -dM -E - < /dev/null (on gcc) + * cc -## a.c (where a.c is a simple test file) (Sun Studio) + */ +#if (defined(__i386__) || defined(__x86_64__)) +#define MUR_GETBLOCK(p,i) p[i] +#else /* non intel */ +#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 0x3) == 0) +#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 0x3) == 1) +#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 0x3) == 2) +#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 0x3) == 3) +#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) +#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) +#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) +#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) +#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) +#else /* assume little endian non-intel */ +#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) +#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) +#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) +#endif +#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \ + (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ + (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ + MUR_ONE_THREE(p)))) +#endif +#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) +#define MUR_FMIX(_h) \ +do { \ + _h ^= _h >> 16; \ + _h *= 0x85ebca6b; \ + _h ^= _h >> 13; \ + _h *= 0xc2b2ae35l; \ + _h ^= _h >> 16; \ +} while(0) + +#define HASH_MUR(key,keylen,num_bkts,hashv,bkt) \ +do { \ + const uint8_t *_mur_data = (const uint8_t*)(key); \ + const int _mur_nblocks = (keylen) / 4; \ + uint32_t _mur_h1 = 0xf88D5353; \ + uint32_t _mur_c1 = 0xcc9e2d51; \ + uint32_t _mur_c2 = 0x1b873593; \ + const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+_mur_nblocks*4); \ + int _mur_i; \ + for(_mur_i = -_mur_nblocks; _mur_i; _mur_i++) { \ + uint32_t _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \ + _mur_k1 *= _mur_c1; \ + _mur_k1 = MUR_ROTL32(_mur_k1,15); \ + _mur_k1 *= _mur_c2; \ + \ + _mur_h1 ^= _mur_k1; \ + _mur_h1 = MUR_ROTL32(_mur_h1,13); \ + _mur_h1 = _mur_h1*5+0xe6546b64; \ + } \ + const uint8_t *_mur_tail = (const uint8_t*)(_mur_data + _mur_nblocks*4); \ + uint32_t _mur_k1=0; \ + switch((keylen) & 3) { \ + case 3: _mur_k1 ^= _mur_tail[2] << 16; \ + case 2: _mur_k1 ^= _mur_tail[1] << 8; \ + case 1: _mur_k1 ^= _mur_tail[0]; \ + _mur_k1 *= _mur_c1; \ + _mur_k1 = MUR_ROTL32(_mur_k1,15); \ + _mur_k1 *= _mur_c2; \ + _mur_h1 ^= _mur_k1; \ + } \ + _mur_h1 ^= (keylen); \ + MUR_FMIX(_mur_h1); \ + hashv = _mur_h1; \ + bkt = hashv & (num_bkts-1); \ +} while(0) +#endif /* HASH_USING_NO_STRICT_ALIASING */ + +/* key comparison function; return 0 if keys equal */ +#define HASH_KEYCMP(a,b,len) memcmp(a,b,len) + +/* iterate over items in a known bucket to find desired item */ +#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \ +do { \ + if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \ + else out=NULL; \ + while (out) { \ + if (out->hh.keylen == keylen_in) { \ + if ((HASH_KEYCMP(out->hh.key,keyptr,keylen_in)) == 0) break; \ + } \ + if (out->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,out->hh.hh_next)); \ + else out = NULL; \ + } \ +} while(0) + +/* add an item to a bucket */ +#define HASH_ADD_TO_BKT(head,addhh) \ +do { \ + head.count++; \ + (addhh)->hh_next = head.hh_head; \ + (addhh)->hh_prev = NULL; \ + if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \ + (head).hh_head=addhh; \ + if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \ + && (addhh)->tbl->noexpand != 1) { \ + HASH_EXPAND_BUCKETS((addhh)->tbl); \ + } \ +} while(0) + +/* remove an item from a given bucket */ +#define HASH_DEL_IN_BKT(hh,head,hh_del) \ + (head).count--; \ + if ((head).hh_head == hh_del) { \ + (head).hh_head = hh_del->hh_next; \ + } \ + if (hh_del->hh_prev) { \ + hh_del->hh_prev->hh_next = hh_del->hh_next; \ + } \ + if (hh_del->hh_next) { \ + hh_del->hh_next->hh_prev = hh_del->hh_prev; \ + } + +/* Bucket expansion has the effect of doubling the number of buckets + * and redistributing the items into the new buckets. Ideally the + * items will distribute more or less evenly into the new buckets + * (the extent to which this is true is a measure of the quality of + * the hash function as it applies to the key domain). + * + * With the items distributed into more buckets, the chain length + * (item count) in each bucket is reduced. Thus by expanding buckets + * the hash keeps a bound on the chain length. This bounded chain + * length is the essence of how a hash provides constant time lookup. + * + * The calculation of tbl->ideal_chain_maxlen below deserves some + * explanation. First, keep in mind that we're calculating the ideal + * maximum chain length based on the *new* (doubled) bucket count. + * In fractions this is just n/b (n=number of items,b=new num buckets). + * Since the ideal chain length is an integer, we want to calculate + * ceil(n/b). We don't depend on floating point arithmetic in this + * hash, so to calculate ceil(n/b) with integers we could write + * + * ceil(n/b) = (n/b) + ((n%b)?1:0) + * + * and in fact a previous version of this hash did just that. + * But now we have improved things a bit by recognizing that b is + * always a power of two. We keep its base 2 log handy (call it lb), + * so now we can write this with a bit shift and logical AND: + * + * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) + * + */ +#define HASH_EXPAND_BUCKETS(tbl) \ +do { \ + unsigned _he_bkt; \ + unsigned _he_bkt_i; \ + struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ + UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ + _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ + 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ + if (!_he_new_buckets) { uthash_fatal( "out of memory"); } \ + memset(_he_new_buckets, 0, \ + 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ + tbl->ideal_chain_maxlen = \ + (tbl->num_items >> (tbl->log2_num_buckets+1)) + \ + ((tbl->num_items & ((tbl->num_buckets*2)-1)) ? 1 : 0); \ + tbl->nonideal_items = 0; \ + for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \ + { \ + _he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \ + while (_he_thh) { \ + _he_hh_nxt = _he_thh->hh_next; \ + HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \ + _he_newbkt = &(_he_new_buckets[ _he_bkt ]); \ + if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \ + tbl->nonideal_items++; \ + _he_newbkt->expand_mult = _he_newbkt->count / \ + tbl->ideal_chain_maxlen; \ + } \ + _he_thh->hh_prev = NULL; \ + _he_thh->hh_next = _he_newbkt->hh_head; \ + if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \ + _he_thh; \ + _he_newbkt->hh_head = _he_thh; \ + _he_thh = _he_hh_nxt; \ + } \ + } \ + uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \ + tbl->num_buckets *= 2; \ + tbl->log2_num_buckets++; \ + tbl->buckets = _he_new_buckets; \ + tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \ + (tbl->ineff_expands+1) : 0; \ + if (tbl->ineff_expands > 1) { \ + tbl->noexpand=1; \ + uthash_noexpand_fyi(tbl); \ + } \ + uthash_expand_fyi(tbl); \ +} while(0) + + +/* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ +/* Note that HASH_SORT assumes the hash handle name to be hh. + * HASH_SRT was added to allow the hash handle name to be passed in. */ +#define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) +#define HASH_SRT(hh,head,cmpfcn) \ +do { \ + unsigned _hs_i; \ + unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \ + struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ + if (head) { \ + _hs_insize = 1; \ + _hs_looping = 1; \ + _hs_list = &((head)->hh); \ + while (_hs_looping) { \ + _hs_p = _hs_list; \ + _hs_list = NULL; \ + _hs_tail = NULL; \ + _hs_nmerges = 0; \ + while (_hs_p) { \ + _hs_nmerges++; \ + _hs_q = _hs_p; \ + _hs_psize = 0; \ + for ( _hs_i = 0; _hs_i < _hs_insize; _hs_i++ ) { \ + _hs_psize++; \ + _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ + ((void*)((char*)(_hs_q->next) + \ + (head)->hh.tbl->hho)) : NULL); \ + if (! (_hs_q) ) break; \ + } \ + _hs_qsize = _hs_insize; \ + while ((_hs_psize > 0) || ((_hs_qsize > 0) && _hs_q )) { \ + if (_hs_psize == 0) { \ + _hs_e = _hs_q; \ + _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ + ((void*)((char*)(_hs_q->next) + \ + (head)->hh.tbl->hho)) : NULL); \ + _hs_qsize--; \ + } else if ( (_hs_qsize == 0) || !(_hs_q) ) { \ + _hs_e = _hs_p; \ + _hs_p = (UT_hash_handle*)((_hs_p->next) ? \ + ((void*)((char*)(_hs_p->next) + \ + (head)->hh.tbl->hho)) : NULL); \ + _hs_psize--; \ + } else if (( \ + cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \ + DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \ + ) <= 0) { \ + _hs_e = _hs_p; \ + _hs_p = (UT_hash_handle*)((_hs_p->next) ? \ + ((void*)((char*)(_hs_p->next) + \ + (head)->hh.tbl->hho)) : NULL); \ + _hs_psize--; \ + } else { \ + _hs_e = _hs_q; \ + _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ + ((void*)((char*)(_hs_q->next) + \ + (head)->hh.tbl->hho)) : NULL); \ + _hs_qsize--; \ + } \ + if ( _hs_tail ) { \ + _hs_tail->next = ((_hs_e) ? \ + ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \ + } else { \ + _hs_list = _hs_e; \ + } \ + _hs_e->prev = ((_hs_tail) ? \ + ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \ + _hs_tail = _hs_e; \ + } \ + _hs_p = _hs_q; \ + } \ + _hs_tail->next = NULL; \ + if ( _hs_nmerges <= 1 ) { \ + _hs_looping=0; \ + (head)->hh.tbl->tail = _hs_tail; \ + DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ + } \ + _hs_insize *= 2; \ + } \ + HASH_FSCK(hh,head); \ + } \ +} while (0) + +/* This function selects items from one hash into another hash. + * The end result is that the selected items have dual presence + * in both hashes. There is no copy of the items made; rather + * they are added into the new hash through a secondary hash + * hash handle that must be present in the structure. */ +#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ +do { \ + unsigned _src_bkt, _dst_bkt; \ + void *_last_elt=NULL, *_elt; \ + UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \ + ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \ + if (src) { \ + for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ + for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \ + _src_hh; \ + _src_hh = _src_hh->hh_next) { \ + _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ + if (cond(_elt)) { \ + _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ + _dst_hh->key = _src_hh->key; \ + _dst_hh->keylen = _src_hh->keylen; \ + _dst_hh->hashv = _src_hh->hashv; \ + _dst_hh->prev = _last_elt; \ + _dst_hh->next = NULL; \ + if (_last_elt_hh) { _last_elt_hh->next = _elt; } \ + if (!dst) { \ + DECLTYPE_ASSIGN(dst,_elt); \ + HASH_MAKE_TABLE(hh_dst,dst); \ + } else { \ + _dst_hh->tbl = (dst)->hh_dst.tbl; \ + } \ + HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ + HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \ + (dst)->hh_dst.tbl->num_items++; \ + _last_elt = _elt; \ + _last_elt_hh = _dst_hh; \ + } \ + } \ + } \ + } \ + HASH_FSCK(hh_dst,dst); \ +} while (0) + +#define HASH_CLEAR(hh,head) \ +do { \ + if (head) { \ + uthash_free((head)->hh.tbl->buckets, \ + (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \ + HASH_BLOOM_FREE((head)->hh.tbl); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head)=NULL; \ + } \ +} while(0) + +#ifdef NO_DECLTYPE +#define HASH_ITER(hh,head,el,tmp) \ +for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \ + el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL)) +#else +#define HASH_ITER(hh,head,el,tmp) \ +for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \ + el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)->hh.next:NULL)) +#endif + +/* obtain a count of items in the hash */ +#define HASH_COUNT(head) HASH_CNT(hh,head) +#define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0) + +typedef struct UT_hash_bucket { + struct UT_hash_handle *hh_head; + unsigned count; + + /* expand_mult is normally set to 0. In this situation, the max chain length + * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If + * the bucket's chain exceeds this length, bucket expansion is triggered). + * However, setting expand_mult to a non-zero value delays bucket expansion + * (that would be triggered by additions to this particular bucket) + * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. + * (The multiplier is simply expand_mult+1). The whole idea of this + * multiplier is to reduce bucket expansions, since they are expensive, in + * situations where we know that a particular bucket tends to be overused. + * It is better to let its chain length grow to a longer yet-still-bounded + * value, than to do an O(n) bucket expansion too often. + */ + unsigned expand_mult; + +} UT_hash_bucket; + +/* random signature used only to find hash tables in external analysis */ +#define HASH_SIGNATURE 0xa0111fe1 +#define HASH_BLOOM_SIGNATURE 0xb12220f2 + +typedef struct UT_hash_table { + UT_hash_bucket *buckets; + unsigned num_buckets, log2_num_buckets; + unsigned num_items; + struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ + ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ + + /* in an ideal situation (all buckets used equally), no bucket would have + * more than ceil(#items/#buckets) items. that's the ideal chain length. */ + unsigned ideal_chain_maxlen; + + /* nonideal_items is the number of items in the hash whose chain position + * exceeds the ideal chain maxlen. these items pay the penalty for an uneven + * hash distribution; reaching them in a chain traversal takes >ideal steps */ + unsigned nonideal_items; + + /* ineffective expands occur when a bucket doubling was performed, but + * afterward, more than half the items in the hash had nonideal chain + * positions. If this happens on two consecutive expansions we inhibit any + * further expansion, as it's not helping; this happens when the hash + * function isn't a good fit for the key domain. When expansion is inhibited + * the hash will still work, albeit no longer in constant time. */ + unsigned ineff_expands, noexpand; + + uint32_t signature; /* used only to find hash tables in external analysis */ +#ifdef HASH_BLOOM + uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ + uint8_t *bloom_bv; + char bloom_nbits; +#endif + +} UT_hash_table; + +typedef struct UT_hash_handle { + struct UT_hash_table *tbl; + void *prev; /* prev element in app order */ + void *next; /* next element in app order */ + struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ + struct UT_hash_handle *hh_next; /* next hh in bucket order */ + void *key; /* ptr to enclosing struct's key */ + unsigned keylen; /* enclosing struct's key len */ + unsigned hashv; /* result of hash-fcn(key) */ +} UT_hash_handle; + +#endif /* UTHASH_H */ Index: branches/cparm/i386/libsaio/cache.c =================================================================== --- branches/cparm/i386/libsaio/cache.c (revision 1839) +++ branches/cparm/i386/libsaio/cache.c (revision 1840) @@ -27,8 +27,7 @@ * DRI: Josh de Cesare */ -#include -// #include +#include "sl.h" struct CacheEntry { CICell ih; Index: branches/cparm/i386/libsaio/stack_protector.c =================================================================== --- branches/cparm/i386/libsaio/stack_protector.c (revision 1839) +++ branches/cparm/i386/libsaio/stack_protector.c (revision 1840) @@ -32,7 +32,8 @@ long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -void __guard_setup(void) __attribute__ ((visibility ("hidden"))); +//__private_extern__ void __guard_setup(void) /*__attribute__ ((visibility ("hidden")))*/; +static void __guard_setup(void) __attribute__((constructor)); void __stack_chk_fail(void); Index: branches/cparm/i386/libsaio/stringTable.c =================================================================== --- branches/cparm/i386/libsaio/stringTable.c (revision 1839) +++ branches/cparm/i386/libsaio/stringTable.c (revision 1840) @@ -26,14 +26,26 @@ * All rights reserved. */ +#include "libsaio.h" #include "bootstruct.h" -#include "libsaio.h" +#include "platform.h" #include "xml.h" static char * AllocInitStringWithLength(const char * oldString, int len); static char * AllocInitZeroEndedStringWithLength(const char * oldString, int len); -bool sysConfigValid; +#define ASSERT_CONFIG \ +if (config == DEFAULT_BOOT_CONFIG) \ +config = &bootInfo->bootConfig ; \ +else if (config == DEFAULT_SYSTEM_CONFIG) \ +config = &bootInfo->SystemConfig ; \ +else if (config == DEFAULT_OVERRIDE_CONFIG) \ +config = &bootInfo->overrideConfig ; \ +else if (config == DEFAULT_SMBIOS_CONFIG) \ +config = &bootInfo->smbiosConfig ; \ +else if (config == DEFAULT_HELPER_CONFIG) \ +config = &bootInfo->helperConfig ; + #if UNUSED /* * Compare a string to a key with quoted characters @@ -189,6 +201,8 @@ bool getValueForConfigTableKey(config_file_t *config, const char *key, const char **val, int *size) { + ASSERT_CONFIG + if (config->dictionary != 0 ) { // Look up key in XML dictionary TagPtr value; @@ -229,6 +243,8 @@ char *newstr, *p; int size; + ASSERT_CONFIG + if (getValueForConfigTableKey(config, key, &val, &size)) { newstr = (char *)malloc(size+1); for (p = newstr; size; size--, p++, val++) { @@ -266,6 +282,8 @@ char *newstr; int size; + ASSERT_CONFIG + if (getValueForKey(key, &val, &size, config) && size) { newstr = (char *)malloc(size + 1); strlcpy(newstr, val, size + 1); @@ -332,6 +350,9 @@ { static const char* value =0; int len=0; + + ASSERT_CONFIG + if(!getValueForKey(key, &value, &len, config)) value = 0; return value; } @@ -346,6 +367,8 @@ const char *key_val; int size; + ASSERT_CONFIG + if (getValueForKey(key, &key_val, &size, config)) { if ( (size >= 1) && (key_val[0] == 'Y' || key_val[0] == 'y') ) { *result_val = true; @@ -363,6 +386,8 @@ int size, sum; bool negative = false; + ASSERT_CONFIG + if (getValueForKey(key, &val, &size, config)) { if ( size ) @@ -405,6 +430,8 @@ bool negative = false; bool percentage = false; + + ASSERT_CONFIG if (getValueForKey(key, &val, &size, config)) { @@ -452,7 +479,7 @@ // key not found return false; -} +} /* * get color value from plist format #RRGGBB @@ -463,6 +490,8 @@ const char *val; int size; + ASSERT_CONFIG + if (getValueForKey(key, &val, &size, config)) { if (*val == '#') @@ -479,11 +508,13 @@ { const char *overrideVal; int overrideSize; - bool ret; + bool ret; if (getValueForBootKey(bootArgs->CommandLine, key, val, size)) return true; + ASSERT_CONFIG + ret = getValueForConfigTableKey(config, key, val, size); // Try to find alternate keys in bootInfo->overrideConfig @@ -577,6 +608,8 @@ { int fd, count; + ASSERT_CONFIG + if ((fd = open(configFile)) < 0) { return -1; } @@ -594,7 +627,7 @@ * Returns 0 - successful. * -1 - unsuccesful. */ -int loadBooterConfig(config_file_t *config) +int loadBooterConfig(void) { char *dirspec[] = { "rd(0,0)/Extra/com.apple.Boot.plist", @@ -606,6 +639,9 @@ }; + + config_file_t *config = &bootInfo->bootConfig; + int i,fd, count, ret=-1; for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++) @@ -618,7 +654,7 @@ // build xml dictionary ParseXMLFile(config->plist, &config->dictionary); - sysConfigValid = true; + safe_set_env(envSysConfigValid,true); ret=0; // enable canOverride flag @@ -630,7 +666,7 @@ #ifdef BOOT_HELPER_SUPPORT if(ret == -1) { - ret = loadHelperConfig(config); + ret = loadHelperConfig(); } #endif @@ -642,13 +678,16 @@ * Returns 0 - successful. * -1 - unsuccesful. */ -int loadOverrideConfig(config_file_t *config) +int loadOverrideConfig(void) { char *dirspec[] = { "/Extra/com.apple.Boot.plist", "/Extra/org.chameleon.Boot.plist" }; + config_file_t *config = &bootInfo->overrideConfig; + + int i,fd, count, ret=-1; for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++) @@ -661,7 +700,7 @@ // build xml dictionary ParseXMLFile(config->plist, &config->dictionary); - sysConfigValid = true; + safe_set_env(envSysConfigValid,true); ret=0; break; } @@ -669,7 +708,7 @@ #ifdef BOOT_HELPER_SUPPORT if(ret == -1) { - ret = loadHelperConfig(config); + ret = loadHelperConfig(); } #endif @@ -681,7 +720,7 @@ * Returns 0 - successful. * -1 - unsuccesful. */ -int loadSystemConfig(config_file_t *config) +int loadSystemConfig(void) { char *dirspec[] = { "rd(0,0)/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", @@ -691,6 +730,10 @@ "/Mac OS X Install Data/com.apple.Boot.plist", "bt(0,0)/Mac OS X Install Data/com.apple.Boot.plist" }; + + config_file_t *config = &bootInfo->SystemConfig; + + int i,fd, count, ret=-1; for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++) @@ -703,7 +746,7 @@ // build xml dictionary ParseXMLFile(config->plist, &config->dictionary); - sysConfigValid = true; + safe_set_env(envSysConfigValid,true); ret=0; break; } @@ -719,7 +762,7 @@ * Returns 0 - successful. * -1 - unsuccesful. */ -int loadHelperConfig(config_file_t *config) +int loadHelperConfig(void) { int rfd, pfd, sfd, count, ret=-1; @@ -729,6 +772,9 @@ "/com.apple.boot.S/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" }; + config_file_t *config = &bootInfo->helperConfig; + + // This is a simple rock - paper scissors algo. R beats S, P beats R, S beats P // If all three, S is used for now. This should be change dto something else (say, timestamp?) @@ -745,7 +791,7 @@ // build xml dictionary ParseXMLFile(config->plist, &config->dictionary); - sysConfigValid = true; + safe_set_env(envSysConfigValid,true); ret=0; } @@ -757,7 +803,7 @@ // build xml dictionary ParseXMLFile(config->plist, &config->dictionary); - sysConfigValid = true; + safe_set_env(envSysConfigValid,true); ret=0; } @@ -777,7 +823,7 @@ // build xml dictionary ParseXMLFile(config->plist, &config->dictionary); - sysConfigValid = true; + safe_set_env(envSysConfigValid,true); ret=0; } @@ -789,7 +835,7 @@ // build xml dictionary ParseXMLFile(config->plist, &config->dictionary); - sysConfigValid = true; + safe_set_env(envSysConfigValid,true); ret=0; } @@ -806,7 +852,7 @@ // build xml dictionary ParseXMLFile(config->plist, &config->dictionary); - sysConfigValid = true; + safe_set_env(envSysConfigValid,true); ret=0; } Index: branches/cparm/i386/libsaio/biosfn.c =================================================================== --- branches/cparm/i386/libsaio/biosfn.c (revision 1839) +++ branches/cparm/i386/libsaio/biosfn.c (revision 1840) @@ -39,12 +39,25 @@ 2007-12-29 dfe - Added ebiosEjectMedia */ + +#include "libsaio.h" #include "bootstruct.h" -#include "libsaio.h" //#define MAX_DRIVES 8 +#ifndef DEBUG_BIOS +#define DEBUG_BIOS 0 +#endif +#if DEBUG_BIOS +#define DBG(x...) printf(x) +#else +#define DBG(x...) +#endif + static biosBuf_t bb; +#if DEBUG_BIOS +static void print_drive_info(boot_drive_info_t *dp); +#endif int bgetc(void) { @@ -100,6 +113,45 @@ return time.i; } +#if UNUSED +static inline +int bin2bcd (int x) +{ + return (x%10) | ((x/10) << 4); +} + + +static inline +int bcd2bin (int x) +{ + return (x >> 4) * 10 + (x & 0x0f); +} + +time_t time(time_t *t) +{ + static time_t lasttime, now; + int hr, minute, sec; + + bb.intno = 0x1a; + bb.eax.r.h = 0x02; + bios(&bb); + + hr = bcd2bin((bb.ecx.rr & 0xff00) >> 8); /* hour in %ch */ + minute = bcd2bin(bb.ecx.rr & 0xff); /* minute in %cl */ + sec = bcd2bin((bb.edx.rr & 0xff00) >> 8); /* second in %dh */ + + now = hr * 3600 + minute * 60 + sec; + if (now < lasttime) + now += 24 * 3600; + lasttime = now; + + if (t != NULL) + *t = now; + return(now); + +} +#endif + #if 0 static unsigned long rerangeMemoryMap(unsigned long count); static unsigned long rerangeMemoryMap(unsigned long count) @@ -249,7 +301,7 @@ // Copy out data bcopy((char *)BIOS_ADDR, rangeArray, ((char *)range - (char *)BIOS_ADDR)); -#if DEBUG +#if DEBUG_BIOS { int i; printf("%d total ranges\n", count);getc(); @@ -264,7 +316,7 @@ return count; } -unsigned long getExtendedMemorySize() +unsigned long getExtendedMemorySize(void) { // Get extended memory size for large configurations. Not used unless // the INT15, E820H call (Get System Address Map) failed. @@ -315,7 +367,7 @@ return bb.flags.cf ? 0 : bb.eax.rr; } -unsigned long getConventionalMemorySize() +unsigned long getConventionalMemorySize(void) { bb.intno = 0x12; bios(&bb); @@ -501,7 +553,7 @@ bb.ds = NORMALIZED_SEGMENT((unsigned)&pkt); bios(&bb); -#if DEBUG +#if DEBUG_BIOS printf("el_torito info drive %x\n", drive); printf("--> cf %x, eax %x\n", bb.flags.cf, bb.eax.rr); @@ -525,11 +577,11 @@ return 0; } -#if DEBUG +#if DEBUG_BIOS /* * BIOS drive information. */ -void print_drive_info(boot_drive_info_t *dp) +static void print_drive_info(boot_drive_info_t *dp) { // printf("buf_size = %x\n", dp->params.buf_size); printf("info_flags = %x\n", dp->params.info_flags); @@ -671,7 +723,7 @@ */ dp->uses_ebios |= EBIOS_FIXED_DISK_ACCESS; } -#if DEBUG +#if DEBUG_BIOS print_drive_info(di); printf("uses_ebios = 0x%x\n", dp->uses_ebios); printf("result %d\n", ret); @@ -748,9 +800,9 @@ bios(&bb); } -#if DEBUG +#if DEBUG_BIOS -int terminateDiskEmulation() +static int terminateDiskEmulation(void) { static char cd_spec[0x13]; @@ -763,7 +815,7 @@ return bb.eax.r.h; } -int readDriveParameters(int drive, struct driveParameters *dp) +static int readDriveParameters(int drive, struct driveParameters *dp) { bb.intno = 0x13; bb.edx.r.l = drive; Index: branches/cparm/i386/libsaio/ppmsetup.h =================================================================== --- branches/cparm/i386/libsaio/ppmsetup.h (revision 1839) +++ branches/cparm/i386/libsaio/ppmsetup.h (revision 1840) @@ -31,8 +31,6 @@ #include "datatype.h" -//U32 ppm_init(void); - #define CURRENT_PPM_RCM_INTERFACE_SPECIFICATION 11 #ifndef nameseg_defined @@ -370,9 +368,4 @@ U32 performance_per_watt; } PPM_SETUP_OPTIONS; -#ifndef RCMSTART_TYPEDEF -#define RCMSTART_TYPEDEF -typedef U32 (*RCMSTART)(struct ppm_setup_options *); -#endif - #endif // ppmsetup_h Index: branches/cparm/i386/libsaio/saio_types.h =================================================================== --- branches/cparm/i386/libsaio/saio_types.h (revision 1839) +++ branches/cparm/i386/libsaio/saio_types.h (revision 1840) @@ -43,6 +43,50 @@ #endif /* + * Keys used in system Boot.plist + */ +#define kGraphicsModeKey "Graphics Mode" +#define kTextModeKey "Text Mode" +#define kQuietBootKey "Quiet Boot" +#define kKernelFlagsKey "Kernel Flags" +#define kMKextCacheKey "MKext Cache" +#define kKernelNameKey "Kernel" +#define kKernelCacheKey "Kernel Cache" +#define kUseKernelCache "UseKernelCache" +#define kBootDeviceKey "Boot Device" +#define kTimeoutKey "Timeout" +#define kRootDeviceKey "rd" +#define kBootUUIDKey "boot-uuid" +#define kHelperRootUUIDKey "Root UUID" +#define kPlatformKey "platform" +#define kCDROMPromptKey "CD-ROM Prompt" +#define kCDROMOptionKey "CD-ROM Option Key" +#define kRescanPromptKey "Rescan Prompt" +#define kRescanKey "Rescan" +#define kScanSingleDriveKey "Scan Single Drive" +#define kInsantMenuKey "Instant Menu" +#define kDefaultKernel "mach_kernel" +#define kWaitForKeypressKey "Wait" +/* AsereBLN: added the other keys */ + +#define kProductVersion "ProductVersion" /* boot.c */ +#define karch "arch" /* boot.c */ +#define kDeviceProperties "device-properties" /* device_inject.c */ +#define kHidePartition "Hide Partition" /* disk.c */ +#define kRenamePartition "Rename Partition" /* disk.c */ +#define kSMBIOSKey "SMBIOS" /* fake_efi.c */ +#define kSystemID "SystemId" /* fake_efi.c */ +#define kSystemType "SystemType" /* fake_efi.c */ +#define kPCIRootUID "PCIRootUID" /* pci_root.c */ +#define kDefaultPartition "Default Partition" /* sys.c */ + +#define PLATFORM_NAME_LEN 64 +#define ROOT_PATH_LEN 256 + +#define DEFAULT_SCREEN_WIDTH 1024 +#define DEFAULT_SCREEN_HEIGHT 768 + +/* * Max size fo config data array, in bytes. */ #define IO_CONFIG_DATA_SIZE 40960 // was 4096 // was 163840 @@ -55,6 +99,17 @@ int n; }; +typedef struct tm_t +{ + int tm_sec ; /* seconds after minute [0-61] (61 allows for 2 leap-seconds)*/ + int tm_min ; /* minutes after hour [0-59] */ + int tm_hour ; /* hours after midnight [0-23] */ + int tm_mday ; /* day of the month [1-31] */ + int tm_mon ; /* month of year [0-11] */ + int tm_year ; /* current year-1900 */ + +}tm_t; + typedef unsigned long entry_t; typedef struct { @@ -208,6 +263,7 @@ bool filtered; /* newFilteredBVChain() will set to TRUE */ bool visible; /* will shown in the device list */ char OSVersion[8]; + bool kernelfound; /* mach_kernel found in default location, currently only /mach_kernel is supported */ bool OSisServer; /* 1 = OS X server , 0 = OS X client, not to be confused with Platform->CPU.isServer which means it tries to emulate an xserve in the smbios */ }; Index: branches/cparm/i386/libsaio/md5c.c =================================================================== --- branches/cparm/i386/libsaio/md5c.c (revision 1839) +++ branches/cparm/i386/libsaio/md5c.c (revision 1840) @@ -145,7 +145,7 @@ * MD5 padding. Adds padding followed by original length. */ -void +static void MD5Pad (context) MD5_CTX *context; { Index: branches/cparm/i386/libsaio/fake_efi.c =================================================================== --- branches/cparm/i386/libsaio/fake_efi.c (revision 1839) +++ branches/cparm/i386/libsaio/fake_efi.c (revision 1840) @@ -8,7 +8,6 @@ */ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" #include "efi.h" #include "acpi.h" @@ -64,10 +63,9 @@ static inline char * mallocStringForGuid(EFI_GUID const *pGuid); static VOID EFI_ST_FIX_CRC32(void); static EFI_STATUS setupAcpiNoMod(); -static EFI_STATUS setup_acpi (void); static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len); static EFI_CHAR8* getSmbiosUUID(); -static EFI_STATUS getSystemID(); +static int8_t *getSystemID(); static VOID setupSystemType(); static VOID setupEfiDeviceTree(void); static VOID setup_Smbios(); @@ -99,8 +97,8 @@ /* Info About the current Firmware */ #define FIRMWARE_MAINTENER "cparm, armelcadetpetit@gmail.com" -static EFI_CHAR16 const FIRMWARE_NAME[] = {'S','a','v','a','n','n','a', 0}; -static EFI_UINT32 const FIRMWARE_REVISION = 0x00010700; //1.7 +static EFI_CHAR16 const FIRMWARE_NAME[] = {'C','u','p','e','r','t','i','n','o', 0}; +static EFI_UINT32 const FIRMWARE_REVISION = 0x00010800; //1.8 static EFI_UINT32 const DEVICE_SUPPORTED = 0x00000001; /* Default platform system_id (fix by IntVar) */ @@ -268,8 +266,8 @@ Guid = gEfiConfigurationTable64[i].VendorGuid; } - char id[4]; - + char id[5]; + bzero(id,sizeof(id)); if (memcmp(&Guid, &gEfiSmbiosTableGuid, sizeof(EFI_GUID)) == 0) { sprintf(id, "%s", "_SM_"); @@ -434,15 +432,42 @@ * SMBIOS */ -uint64_t smbios_p; +static uint64_t smbios_p; +void Register_Smbios_Efi(void* smbios) +{ + smbios_p = ((uint64_t)((uint32_t)smbios)); +} + /*========================================================================== * ACPI */ -static uint64_t local_rsd_p; -static ACPI_TABLES acpi_tables; +static uint64_t local_rsd_p; +static ACPI_TABLES acpi_tables; +static uint64_t kFSBFrequency; +static uint32_t kHardware_signature; +static uint8_t kType; +EFI_STATUS Register_Acpi_Efi(void* rsd_p, unsigned char rev ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + local_rsd_p = ((U64)((U32)rsd_p)); + + if (local_rsd_p) { + if (rev == 2) + { + Status = addConfigurationTable(&gEfiAcpi20TableGuid, &local_rsd_p, "ACPI_20"); + } + else + { + Status = addConfigurationTable(&gEfiAcpiTableGuid, &local_rsd_p, "ACPI"); + } + } + + return Status; +} + /* Setup ACPI without any patch. */ static EFI_STATUS setupAcpiNoMod() { @@ -461,34 +486,30 @@ return ret; } -static EFI_STATUS setup_acpi (void) +EFI_STATUS setup_acpi (void) { EFI_STATUS ret = EFI_UNSUPPORTED; - execute_hook("setupAcpiEfi", &ret, NULL, NULL, NULL, NULL, NULL); - do { - if (ret != EFI_SUCCESS) - { - if (!FindAcpiTables(&acpi_tables)) - { - printf("Failed to detect ACPI tables.\n"); - ret = EFI_NOT_FOUND; - break; - } + if (!FindAcpiTables(&acpi_tables)) + { + printf("Failed to detect ACPI tables.\n"); + ret = EFI_NOT_FOUND; + break; + } + + local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer)); + + { + ACPI_TABLE_FADT *FacpPointer = (acpi_tables.FacpPointer64 != (void*)0ul) ? (ACPI_TABLE_FADT *)acpi_tables.FacpPointer64 : (ACPI_TABLE_FADT *)acpi_tables.FacpPointer; + + uint8_t type = FacpPointer->PreferredProfile; + if (type <= MaxSupportedPMProfile) + safe_set_env(envType,type); + } + + ret = setupAcpiNoMod(); - local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer)); - - { - ACPI_TABLE_FADT *FacpPointer = (acpi_tables.FacpPointer64 != (void*)0ul) ? (ACPI_TABLE_FADT *)acpi_tables.FacpPointer64 : (ACPI_TABLE_FADT *)acpi_tables.FacpPointer; - - uint8_t type = FacpPointer->PreferredProfile; - if (type <= MaxSupportedPMProfile) - Platform->Type = type; - } - - ret = setupAcpiNoMod(); - } } while (0); return ret; @@ -524,11 +545,13 @@ static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len) { - if (!gPlatformName && strcmp(key, "SMproductname") == 0) + if (!GetgPlatformName() && strcmp(key, "SMproductname") == 0) readSMBIOS(thePlatformName); + + const char *PlatformName = GetgPlatformName() ; + + const char *src = (strcmp(key, "SMproductname") == 0) ? PlatformName : getStringForKey(key, DEFAULT_SMBIOS_CONFIG); - const char *src = (strcmp(key, "SMproductname") == 0) ? gPlatformName : getStringForKey(key, &bootInfo->smbiosConfig); - EFI_CHAR16* dst = 0; if (!key || !(*key) || !src) return 0; @@ -553,15 +576,15 @@ static EFI_CHAR8 uuid[UUID_LEN]; int i, isZero, isOnes; SMBByte *p; - - p = (SMBByte*)Platform->UUID; + + p = (SMBByte*)(uint32_t)get_env(envUUID); if ( p == NULL ) { DBG("No patched UUID found, fallback to original UUID (if exist) \n"); readSMBIOS(theUUID); - p = (SMBByte*)Platform->UUID; + p = (SMBByte*)(uint32_t)get_env(envUUID); } @@ -590,13 +613,13 @@ * or from the bios if not, or from a fixed value if no bios value is found */ -static EFI_STATUS getSystemID() +static int8_t *getSystemID() { + static int8_t sysid[16]; // unable to determine UUID for host. Error: 35 fix // Rek: new SMsystemid option conforming to smbios notation standards, this option should // belong to smbios config only ... - EFI_STATUS status = EFI_NOT_FOUND; - EFI_CHAR8* ret = getUUIDFromString(getStringForKey(kSystemID, &bootInfo->bootConfig)); + EFI_CHAR8* ret = getUUIDFromString(getStringForKey(kSystemID, DEFAULT_BOOT_CONFIG)); if (!ret) // try bios dmi info UUID extraction ret = getSmbiosUUID(); @@ -616,12 +639,12 @@ } if (ret) - { - memcpy(Platform->sysid, ret, UUID_LEN); - status = EFI_SUCCESS; + { + memcpy(sysid, ret, UUID_LEN); + set_env_copy(envSysId, sysid, sizeof(sysid)); } - return status; + return sysid; } /* @@ -635,7 +658,8 @@ if (node == 0) stop("Couldn't get root node"); // we need to write this property after facp parsing // Export system-type only if it has been overrriden by the SystemType option - DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(Platform->Type), &Platform->Type); + kType = get_env(envType); + DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(uint8_t), &kType); } struct boot_progress_element { @@ -683,6 +707,10 @@ ((boot_progress_element *)bootPict)->width = kFailedBootWidth; ((boot_progress_element *)bootPict)->height = kFailedBootHeight; ((boot_progress_element *)bootPict)->yOffset = kFailedBootOffset; + if (gBootVolume->OSVersion[3] == '8') + { + ((boot_progress_element *)bootPict)->res[0] = size - 32; + } bcopy((char *)gFailedBootPict, (char *)(bootPict + 32), size - 32); } } @@ -690,15 +718,14 @@ //Fix an error with the Lion's (DP2+) installer if (execute_hook("getboardproductPatched", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS) { + Setgboardproduct(getStringForKey("SMboardproduct", DEFAULT_SMBIOS_CONFIG)); - gboardproduct = (char *)getStringForKey("SMboardproduct", &bootInfo->smbiosConfig); + if (!Getgboardproduct()) readSMBIOS(theProducBoard); - if (!gboardproduct) readSMBIOS(theProducBoard); - } - if (gboardproduct) + if (Getgboardproduct()) { - DT__AddProperty(node, "board-id", strlen(gboardproduct)+1, gboardproduct); + DT__AddProperty(node, "board-id", strlen(Getgboardproduct())+1, Getgboardproduct()); } { @@ -711,21 +738,23 @@ // additionally this value can be used by third-party apps or osx components (ex: pre-10.7 kextcache, ...) if (bootInfo->uuidStr[0]) DT__AddProperty(chosenNode, kBootUUIDKey, strlen(bootInfo->uuidStr)+1, bootInfo->uuidStr); -#if 0 - if (gRootPath[0]) - { - - DT__AddProperty(chosenNode, "rootpath" or try "root-matching", strlen(gRootPath)+1, gRootPath); - - } - else -#endif - if (gRootDevice) + + if (GetgRootDevice()) { - DT__AddProperty(chosenNode, "boot-device-path", strlen(gRootDevice)+1, gRootDevice); + DT__AddProperty(chosenNode, "boot-device-path", strlen(GetgRootDevice())+1, GetgRootDevice()); } +#ifdef rootpath + else + if (gRootPath[0]) + { + + DT__AddProperty(chosenNode, "rootpath", strlen(gRootPath)+1, gRootPath); + + } + +#endif // "boot-file" is not used by kextcache if there is no "boot-device-path" or if there is a valid "rootpath" , // but i let it by default since it may be used by another service @@ -782,7 +811,7 @@ DT__AddProperty(efiNode, FIRMWARE_PUBLISH_PROP, strlen(FIRMWARE_PUBLISHER)+1, FIRMWARE_PUBLISHER); { - // Export it for later use + // Export it for amlsgn support char * DefaultPlatform = readDefaultPlatformName(); if (DefaultPlatform) { @@ -797,6 +826,7 @@ { EFI_CHAR16 *serial = 0, *productname = 0; + int8_t *sysid = 0; size_t len = 0; // Now fill in the /efi/platform Node @@ -807,22 +837,25 @@ // NOTE WELL: If you do add FSB Frequency detection, make sure to store // the value in the fsbFrequency global and not an malloc'd pointer // because the DT_AddProperty function does not copy its args. + + kFSBFrequency = get_env(envFSBFreq); + if (kFSBFrequency != 0) + DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &kFSBFrequency); - if (Platform->CPU.FSBFrequency != 0) - DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform->CPU.FSBFrequency); - #if UNUSED // Export TSC and CPU frequencies for use by the kernel or KEXTs - if (Platform->CPU.TSCFrequency != 0) - DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform->CPU.TSCFrequency); + Platform.CPU.TSCFrequency = get_env(envTSCFreq); + if (Platform.CPU.TSCFrequency != 0) + DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform.CPU.TSCFrequency); - if (Platform->CPU.CPUFrequency != 0) - DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform->CPU.CPUFrequency); + Platform.CPU.CPUFrequency = get_env(envCPUFreq); + if (Platform.CPU.CPUFrequency != 0) + DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency); #endif // Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist - if (getSystemID() == EFI_SUCCESS) - DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) Platform->sysid); + if ((sysid = getSystemID())) + DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) sysid); // Export SystemSerialNumber if present if ((serial=getSmbiosChar16("SMserial", &len))) @@ -852,21 +885,21 @@ int len = 0, err = 0; // Take in account user overriding - if (getValueForKey("SMBIOS", &override_pathname, &len, &bootInfo->bootConfig) && len > 0) + if (getValueForKey("SMBIOS", &override_pathname, &len, DEFAULT_BOOT_CONFIG) && len > 0) { // Specify a path to a file, e.g. SMBIOS=/Extra/macProXY.plist sprintf(dirSpecSMBIOS, override_pathname); - err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig); + err = loadConfigFile(dirSpecSMBIOS, DEFAULT_SMBIOS_CONFIG); } else { // Check selected volume's Extra. sprintf(dirSpecSMBIOS, "/Extra/%s", filename); - if ((err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig))) + if ((err = loadConfigFile(dirSpecSMBIOS, DEFAULT_SMBIOS_CONFIG))) { // Check booter volume/rdbt Extra. sprintf(dirSpecSMBIOS, "bt(0,0)/Extra/%s", filename); - err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig); + err = loadConfigFile(dirSpecSMBIOS, DEFAULT_SMBIOS_CONFIG); } } @@ -893,7 +926,7 @@ Node *chosenNode = DT__FindNode("/chosen", false); if (chosenNode) { - if (Platform->hardware_signature == 0xFFFFFFFF) + if (get_env(envHardwareSignature) == 0xFFFFFFFF) { do { if (!local_rsd_p) @@ -906,21 +939,22 @@ local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer)); } - ACPI_TABLE_FACS *FacsPointer = (acpi_tables.FacsPointer64 != (void*)0ul) ? (ACPI_TABLE_FACS *)acpi_tables.FacsPointer64:(ACPI_TABLE_FACS *)acpi_tables.FacsPointer; + ACPI_TABLE_FACS *FacsPointer = (acpi_tables.FacsPointer64 != (void*)0ul) ? (ACPI_TABLE_FACS *)acpi_tables.FacsPointer64:(ACPI_TABLE_FACS *)acpi_tables.FacsPointer; + + safe_set_env(envHardwareSignature , FacsPointer->HardwareSignature); - Platform->hardware_signature = FacsPointer->HardwareSignature; - } while (0); // Verify that we have a valid hardware signature - if (Platform->hardware_signature == 0xFFFFFFFF) + if (get_env(envHardwareSignature) == 0xFFFFFFFF) { - verbose("Warning: hardware_signature is invalid, defaulting to 0 \n"); - Platform->hardware_signature = 0; + verbose("Warning: hardware_signature is invalid, defaulting to 0 \n"); + safe_set_env(envHardwareSignature , 0); } } - DT__AddProperty(chosenNode, "machine-signature", sizeof(uint32_t), &Platform->hardware_signature); + kHardware_signature = get_env(envHardwareSignature); + DT__AddProperty(chosenNode, "machine-signature", sizeof(uint32_t), &kHardware_signature); } } @@ -934,7 +968,7 @@ if (smbios_p) addConfigurationTable(&gEfiSmbiosTableGuid, &smbios_p, NULL); - if (Platform->CPU.Vendor == 0x756E6547 /* Intel */) + if (get_env(envVendor) == CPUID_VENDOR_INTEL ) { int num_cpus; @@ -948,32 +982,32 @@ } #if DEBUG_EFI - if (num_cpus != Platform->CPU.NoCores) + if (num_cpus != get_env(envNoCores)) { - printf("Warning: SMP nb of core (%d) mismatch with the value found in cpu.c (%d) \n",num_cpus,Platform->CPU.NoCores); + printf("Warning: SMP nb of core (%d) mismatch with the value found in cpu.c (%d) \n",num_cpus,get_env(envNoCores)); } #endif } // PM_Model - if (Platform->CPU.isServer == true) + if (get_env(envIsServer)) { - Platform->Type = Workstation; + safe_set_env(envType , Workstation); } - else if (Platform->CPU.isMobile == true)//Slice + else if (get_env(envIsMobile))//Slice { - Platform->Type = Mobile; + safe_set_env(envType , Mobile); } else { - Platform->Type = Desktop; + safe_set_env(envType , Desktop); } // Invalidate the platform hardware signature (this needs to be verified with acpica, but i guess that 0xFFFFFFFF is an invalid signature) - Platform->hardware_signature = 0xFFFFFFFF; + safe_set_env(envHardwareSignature , 0xFFFFFFFF); - // Setup ACPI (mackerintel's patch) - setup_acpi(); + // Setup ACPI (based on the mackerintel's patch) + (VOID)setup_acpi(); setup_machine_signature(); Index: branches/cparm/i386/libsaio/utlist.h =================================================================== --- branches/cparm/i386/libsaio/utlist.h (revision 0) +++ branches/cparm/i386/libsaio/utlist.h (revision 1840) @@ -0,0 +1,522 @@ +/* +Copyright (c) 2007-2011, Troy D. Hanson http://uthash.sourceforge.net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef UTLIST_H +#define UTLIST_H + +#define UTLIST_VERSION 1.9.4 + +#include + +/* + * This file contains macros to manipulate singly and doubly-linked lists. + * + * 1. LL_ macros: singly-linked lists. + * 2. DL_ macros: doubly-linked lists. + * 3. CDL_ macros: circular doubly-linked lists. + * + * To use singly-linked lists, your structure must have a "next" pointer. + * To use doubly-linked lists, your structure must "prev" and "next" pointers. + * Either way, the pointer to the head of the list must be initialized to NULL. + * + * ----------------.EXAMPLE ------------------------- + * struct item { + * int id; + * struct item *prev, *next; + * } + * + * struct item *list = NULL: + * + * int main() { + * struct item *item; + * ... allocate and populate item ... + * DL_APPEND(list, item); + * } + * -------------------------------------------------- + * + * For doubly-linked lists, the append and delete macros are O(1) + * For singly-linked lists, append and delete are O(n) but prepend is O(1) + * The sort macro is O(n log(n)) for all types of single/double/circular lists. + */ + +/* These macros use decltype or the earlier __typeof GNU extension. + As decltype is only available in newer compilers (VS2010 or gcc 4.3+ + when compiling c++ code), this code uses whatever method is needed + or, for VS2008 where neither is available, uses casting workarounds. */ +#ifdef _MSC_VER /* MS compiler */ +#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ +#define LDECLTYPE(x) decltype(x) +#else /* VS2008 or older (or VS2010 in C mode) */ +#define NO_DECLTYPE +#define LDECLTYPE(x) char* +#endif +#else /* GNU, Sun and other compilers */ +#define LDECLTYPE(x) __typeof(x) +#endif + +/* for VS2008 we use some workarounds to get around the lack of decltype, + * namely, we always reassign our tmp variable to the list head if we need + * to dereference its prev/next pointers, and save/restore the real head.*/ +#ifdef NO_DECLTYPE +#define _SV(elt,list) _tmp = (char*)(list); {char **_alias = (char**)&(list); *_alias = (elt); } +#define _NEXT(elt,list) ((char*)((list)->next)) +#define _NEXTASGN(elt,list,to) { char **_alias = (char**)&((list)->next); *_alias=(char*)(to); } +#define _PREV(elt,list) ((char*)((list)->prev)) +#define _PREVASGN(elt,list,to) { char **_alias = (char**)&((list)->prev); *_alias=(char*)(to); } +#define _RS(list) { char **_alias = (char**)&(list); *_alias=_tmp; } +#define _CASTASGN(a,b) { char **_alias = (char**)&(a); *_alias=(char*)(b); } +#else +#define _SV(elt,list) +#define _NEXT(elt,list) ((elt)->next) +#define _NEXTASGN(elt,list,to) ((elt)->next)=(to) +#define _PREV(elt,list) ((elt)->prev) +#define _PREVASGN(elt,list,to) ((elt)->prev)=(to) +#define _RS(list) +#define _CASTASGN(a,b) (a)=(b) +#endif + +/****************************************************************************** + * The sort macro is an adaptation of Simon Tatham's O(n log(n)) mergesort * + * Unwieldy variable names used here to avoid shadowing passed-in variables. * + *****************************************************************************/ +#define LL_SORT(list, cmp) \ +do { \ + LDECLTYPE(list) _ls_p; \ + LDECLTYPE(list) _ls_q; \ + LDECLTYPE(list) _ls_e; \ + LDECLTYPE(list) _ls_tail; \ + LDECLTYPE(list) _ls_oldhead; \ + LDECLTYPE(list) _tmp; \ + int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ + if (list) { \ + _ls_insize = 1; \ + _ls_looping = 1; \ + while (_ls_looping) { \ + _CASTASGN(_ls_p,list); \ + _CASTASGN(_ls_oldhead,list); \ + list = NULL; \ + _ls_tail = NULL; \ + _ls_nmerges = 0; \ + while (_ls_p) { \ + _ls_nmerges++; \ + _ls_q = _ls_p; \ + _ls_psize = 0; \ + for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ + _ls_psize++; \ + _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); \ + if (!_ls_q) break; \ + } \ + _ls_qsize = _ls_insize; \ + while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ + if (_ls_psize == 0) { \ + _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \ + } else if (_ls_qsize == 0 || !_ls_q) { \ + _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \ + } else if (cmp(_ls_p,_ls_q) <= 0) { \ + _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \ + } else { \ + _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \ + } \ + if (_ls_tail) { \ + _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e); _RS(list); \ + } else { \ + _CASTASGN(list,_ls_e); \ + } \ + _ls_tail = _ls_e; \ + } \ + _ls_p = _ls_q; \ + } \ + _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL); _RS(list); \ + if (_ls_nmerges <= 1) { \ + _ls_looping=0; \ + } \ + _ls_insize *= 2; \ + } \ + } else _tmp=NULL; /* quiet gcc unused variable warning */ \ +} while (0) + +#define DL_SORT(list, cmp) \ +do { \ + LDECLTYPE(list) _ls_p; \ + LDECLTYPE(list) _ls_q; \ + LDECLTYPE(list) _ls_e; \ + LDECLTYPE(list) _ls_tail; \ + LDECLTYPE(list) _ls_oldhead; \ + LDECLTYPE(list) _tmp; \ + int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ + if (list) { \ + _ls_insize = 1; \ + _ls_looping = 1; \ + while (_ls_looping) { \ + _CASTASGN(_ls_p,list); \ + _CASTASGN(_ls_oldhead,list); \ + list = NULL; \ + _ls_tail = NULL; \ + _ls_nmerges = 0; \ + while (_ls_p) { \ + _ls_nmerges++; \ + _ls_q = _ls_p; \ + _ls_psize = 0; \ + for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ + _ls_psize++; \ + _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); \ + if (!_ls_q) break; \ + } \ + _ls_qsize = _ls_insize; \ + while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ + if (_ls_psize == 0) { \ + _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \ + } else if (_ls_qsize == 0 || !_ls_q) { \ + _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \ + } else if (cmp(_ls_p,_ls_q) <= 0) { \ + _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \ + } else { \ + _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \ + } \ + if (_ls_tail) { \ + _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e); _RS(list); \ + } else { \ + _CASTASGN(list,_ls_e); \ + } \ + _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail); _RS(list); \ + _ls_tail = _ls_e; \ + } \ + _ls_p = _ls_q; \ + } \ + _CASTASGN(list->prev, _ls_tail); \ + _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL); _RS(list); \ + if (_ls_nmerges <= 1) { \ + _ls_looping=0; \ + } \ + _ls_insize *= 2; \ + } \ + } else _tmp=NULL; /* quiet gcc unused variable warning */ \ +} while (0) + +#define CDL_SORT(list, cmp) \ +do { \ + LDECLTYPE(list) _ls_p; \ + LDECLTYPE(list) _ls_q; \ + LDECLTYPE(list) _ls_e; \ + LDECLTYPE(list) _ls_tail; \ + LDECLTYPE(list) _ls_oldhead; \ + LDECLTYPE(list) _tmp; \ + LDECLTYPE(list) _tmp2; \ + int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ + if (list) { \ + _ls_insize = 1; \ + _ls_looping = 1; \ + while (_ls_looping) { \ + _CASTASGN(_ls_p,list); \ + _CASTASGN(_ls_oldhead,list); \ + list = NULL; \ + _ls_tail = NULL; \ + _ls_nmerges = 0; \ + while (_ls_p) { \ + _ls_nmerges++; \ + _ls_q = _ls_p; \ + _ls_psize = 0; \ + for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ + _ls_psize++; \ + _SV(_ls_q,list); \ + if (_NEXT(_ls_q,list) == _ls_oldhead) { \ + _ls_q = NULL; \ + } else { \ + _ls_q = _NEXT(_ls_q,list); \ + } \ + _RS(list); \ + if (!_ls_q) break; \ + } \ + _ls_qsize = _ls_insize; \ + while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ + if (_ls_psize == 0) { \ + _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \ + if (_ls_q == _ls_oldhead) { _ls_q = NULL; } \ + } else if (_ls_qsize == 0 || !_ls_q) { \ + _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \ + if (_ls_p == _ls_oldhead) { _ls_p = NULL; } \ + } else if (cmp(_ls_p,_ls_q) <= 0) { \ + _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \ + if (_ls_p == _ls_oldhead) { _ls_p = NULL; } \ + } else { \ + _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \ + if (_ls_q == _ls_oldhead) { _ls_q = NULL; } \ + } \ + if (_ls_tail) { \ + _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e); _RS(list); \ + } else { \ + _CASTASGN(list,_ls_e); \ + } \ + _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail); _RS(list); \ + _ls_tail = _ls_e; \ + } \ + _ls_p = _ls_q; \ + } \ + _CASTASGN(list->prev,_ls_tail); \ + _CASTASGN(_tmp2,list); \ + _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_tmp2); _RS(list); \ + if (_ls_nmerges <= 1) { \ + _ls_looping=0; \ + } \ + _ls_insize *= 2; \ + } \ + } else _tmp=NULL; /* quiet gcc unused variable warning */ \ +} while (0) + +/****************************************************************************** + * singly linked list macros (non-circular) * + *****************************************************************************/ +#define LL_PREPEND(head,add) \ +do { \ + (add)->next = head; \ + head = add; \ +} while (0) + +#define LL_CONCAT(head1,head2) \ +do { \ + LDECLTYPE(head1) _tmp; \ + if (head1) { \ + _tmp = head1; \ + while (_tmp->next) { _tmp = _tmp->next; } \ + _tmp->next=(head2); \ + } else { \ + (head1)=(head2); \ + } \ +} while (0) + +#define LL_APPEND(head,add) \ +do { \ + LDECLTYPE(head) _tmp; \ + (add)->next=NULL; \ + if (head) { \ + _tmp = head; \ + while (_tmp->next) { _tmp = _tmp->next; } \ + _tmp->next=(add); \ + } else { \ + (head)=(add); \ + } \ +} while (0) + +#define LL_DELETE(head,del) \ +do { \ + LDECLTYPE(head) _tmp; \ + if ((head) == (del)) { \ + (head)=(head)->next; \ + } else { \ + _tmp = head; \ + while (_tmp->next && (_tmp->next != (del))) { \ + _tmp = _tmp->next; \ + } \ + if (_tmp->next) { \ + _tmp->next = ((del)->next); \ + } \ + } \ +} while (0) + +/* Here are VS2008 replacements for LL_APPEND and LL_DELETE */ +#define LL_APPEND_VS2008(head,add) \ +do { \ + if (head) { \ + (add)->next = head; /* use add->next as a temp variable */ \ + while ((add)->next->next) { (add)->next = (add)->next->next; } \ + (add)->next->next=(add); \ + } else { \ + (head)=(add); \ + } \ + (add)->next=NULL; \ +} while (0) + +#define LL_DELETE_VS2008(head,del) \ +do { \ + if ((head) == (del)) { \ + (head)=(head)->next; \ + } else { \ + char *_tmp = (char*)(head); \ + while (head->next && (head->next != (del))) { \ + head = head->next; \ + } \ + if (head->next) { \ + head->next = ((del)->next); \ + } \ + { \ + char **_head_alias = (char**)&(head); \ + *_head_alias = _tmp; \ + } \ + } \ +} while (0) +#ifdef NO_DECLTYPE +#undef LL_APPEND +#define LL_APPEND LL_APPEND_VS2008 +#undef LL_DELETE +#define LL_DELETE LL_DELETE_VS2008 +#undef LL_CONCAT /* no LL_CONCAT_VS2008 */ +#undef DL_CONCAT /* no DL_CONCAT_VS2008 */ +#endif +/* end VS2008 replacements */ + +#define LL_FOREACH(head,el) \ + for(el=head;el;el=el->next) + +#define LL_FOREACH_SAFE(head,el,tmp) \ + for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp) + +#define LL_SEARCH_SCALAR(head,out,field,val) \ +do { \ + LL_FOREACH(head,out) { \ + if ((out)->field == (val)) break; \ + } \ +} while(0) + +#define LL_SEARCH(head,out,elt,cmp) \ +do { \ + LL_FOREACH(head,out) { \ + if ((cmp(out,elt))==0) break; \ + } \ +} while(0) + +/****************************************************************************** + * doubly linked list macros (non-circular) * + *****************************************************************************/ +#define DL_PREPEND(head,add) \ +do { \ + (add)->next = head; \ + if (head) { \ + (add)->prev = (head)->prev; \ + (head)->prev = (add); \ + } else { \ + (add)->prev = (add); \ + } \ + (head) = (add); \ +} while (0) + +#define DL_APPEND(head,add) \ +do { \ + if (head) { \ + (add)->prev = (head)->prev; \ + (head)->prev->next = (add); \ + (head)->prev = (add); \ + (add)->next = NULL; \ + } else { \ + (head)=(add); \ + (head)->prev = (head); \ + (head)->next = NULL; \ + } \ +} while (0); + +#define DL_CONCAT(head1,head2) \ +do { \ + LDECLTYPE(head1) _tmp; \ + if (head2) { \ + if (head1) { \ + _tmp = (head2)->prev; \ + (head2)->prev = (head1)->prev; \ + (head1)->prev->next = (head2); \ + (head1)->prev = _tmp; \ + } else { \ + (head1)=(head2); \ + } \ + } \ +} while (0); + +#define DL_DELETE(head,del) \ +do { \ + assert((del)->prev != NULL); \ + if ((del)->prev == (del)) { \ + (head)=NULL; \ + } else if ((del)==(head)) { \ + (del)->next->prev = (del)->prev; \ + (head) = (del)->next; \ + } else { \ + (del)->prev->next = (del)->next; \ + if ((del)->next) { \ + (del)->next->prev = (del)->prev; \ + } else { \ + (head)->prev = (del)->prev; \ + } \ + } \ +} while (0); + + +#define DL_FOREACH(head,el) \ + for(el=head;el;el=el->next) + +/* this version is safe for deleting the elements during iteration */ +#define DL_FOREACH_SAFE(head,el,tmp) \ + for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp) + +/* these are identical to their singly-linked list counterparts */ +#define DL_SEARCH_SCALAR LL_SEARCH_SCALAR +#define DL_SEARCH LL_SEARCH + +/****************************************************************************** + * circular doubly linked list macros * + *****************************************************************************/ +#define CDL_PREPEND(head,add) \ +do { \ + if (head) { \ + (add)->prev = (head)->prev; \ + (add)->next = (head); \ + (head)->prev = (add); \ + (add)->prev->next = (add); \ + } else { \ + (add)->prev = (add); \ + (add)->next = (add); \ + } \ +(head)=(add); \ +} while (0) + +#define CDL_DELETE(head,del) \ +do { \ + if ( ((head)==(del)) && ((head)->next == (head))) { \ + (head) = 0L; \ + } else { \ + (del)->next->prev = (del)->prev; \ + (del)->prev->next = (del)->next; \ + if ((del) == (head)) (head)=(del)->next; \ + } \ +} while (0); + +#define CDL_FOREACH(head,el) \ + for(el=head;el;el=(el->next==head ? 0L : el->next)) + +#define CDL_FOREACH_SAFE(head,el,tmp1,tmp2) \ + for((el)=(head), ((tmp1)=(head)?((head)->prev):NULL); \ + (el) && ((tmp2)=(el)->next, 1); \ + ((el) = (((el)==(tmp1)) ? 0L : (tmp2)))) + +#define CDL_SEARCH_SCALAR(head,out,field,val) \ +do { \ + CDL_FOREACH(head,out) { \ + if ((out)->field == (val)) break; \ + } \ +} while(0) + +#define CDL_SEARCH(head,out,elt,cmp) \ +do { \ + CDL_FOREACH(head,out) { \ + if ((cmp(out,elt))==0) break; \ + } \ +} while(0) + +#endif /* UTLIST_H */ + Index: branches/cparm/i386/libsaio/misc.c =================================================================== --- branches/cparm/i386/libsaio/misc.c (revision 1839) +++ branches/cparm/i386/libsaio/misc.c (revision 1840) @@ -254,4 +254,4 @@ { strcpy(nameBuf, "ACPI"); } -#endif +#endif \ No newline at end of file Index: branches/cparm/i386/libsaio/saio_internal.h =================================================================== --- branches/cparm/i386/libsaio/saio_internal.h (revision 1839) +++ branches/cparm/i386/libsaio/saio_internal.h (revision 1840) @@ -28,6 +28,7 @@ #include "saio_types.h" /* arc4random.c */ +extern void arc4_init(void); extern void arc4rand(void *ptr, u_int len, int reseed); extern uint32_t arc4random(void); @@ -76,9 +77,11 @@ extern void setActiveDisplayPage( int page ); extern unsigned long getMemoryMap(struct MemoryRange * rangeArray, unsigned long maxRangeCount, unsigned long * conMemSizePtr, unsigned long * extMemSizePtr); -extern unsigned long getExtendedMemorySize(); -extern unsigned long getConventionalMemorySize(); +extern unsigned long getExtendedMemorySize(void); +extern unsigned long getConventionalMemorySize(void); extern void sleep(int n); +extern time_t time(time_t *t); +extern int is_no_emulation(int drive); /* bootstruct.c */ extern void initKernBootStruct(void); @@ -86,7 +89,13 @@ extern void finalizeBootStruct(void); extern void reserveKernLegacyBootStruct(void); extern void reserveKern107BootStruct(void); +extern void reserveKern108BootStruct(void); +extern void setBootArgsVideoMode(int mode); +extern void setBootArgsVideoStruct(Boot_Video *Video); +extern uint32_t getBootArgsVideoPtrAtOffset(uint32_t offset); +extern uint32_t getVideoMode(void); + /* cache.c */ extern void CacheReset(); extern void CacheInit(CICell ih, long blockSize); @@ -106,6 +115,11 @@ extern int verbose(const char *format, ...); extern void stop(const char *format, ...); extern char * newStringWithFormat(const char * fmt, ...); +extern char *getConsoleMsg(void); +extern char *getConsoleCursor(void); +extern void setConsoleMsg(char *p); +extern void setConsoleCursor(char *p); +extern void pause(void); /* disk.c */ extern void rescanBIOSDevice(int biosdev); @@ -156,7 +170,7 @@ extern struct ran_obj* random_init (int rmin, int rmax); extern void usefixedrandom (bool opt); -extern void getPlatformName(char *nameBuf); +extern void getPlatformName(char *nameBuf); #ifdef NBP_SUPPORT /* nbp.c */ @@ -165,18 +179,34 @@ #endif /* platform.h */ -extern bool platformCPUExtFeature(uint32_t); -extern bool platformCPUFeature(uint32_t); extern void scan_platform(void); -extern bool platformIsIntel(void); -extern uint8_t getCPUModel(void); -extern uint8_t getCPUFamily(void); -extern uint32_t getCPUnCores(void); -extern uint32_t getCPUnThread(void); -extern bool platformIsMobile(void); -extern bool platformIsServer(void); +extern void SetgRootDevice(const char * str); +extern void Setgboardproduct(const char * str); +extern void SetgPlatformName(const char * str); +extern char * GetgPlatformName(void); +extern char * Getgboardproduct(void); +extern char * GetgRootDevice(void); +#ifdef rootpath +extern void SetgRootPath(const char * str); +extern char * GetgRootPath(void); +#endif +extern void re_set_env_copy(const char *name , void* ptr,size_t size); +extern void set_env(const char *name, unsigned long long value ); +extern void set_env_copy(const char *name, void * ptr, size_t size ); +extern unsigned long long get_env_var(const char *name); +extern unsigned long long get_env(const char *name); +extern void * get_env_ptr(const char *name); +extern void safe_set_env_copy(const char *name , void * ptr, size_t size ); +extern void safe_set_env(const char *name , unsigned long long value); +extern void re_set_env(const char *name , unsigned long long value) ; +extern void unset_env(const char *name); +extern void free_platform_env(void); + +void debug_platform_env(void); + + /* stringTable.c */ extern char * newStringFromList(char **list, int *size); extern int stringLength(const char *table, int compress); @@ -192,12 +222,12 @@ extern bool getColorForKey(const char *key, unsigned int *val, config_file_t *configBuff); extern bool getDimensionForKey( const char *key, unsigned int *value, config_file_t *config, unsigned int dimension_max, unsigned int object_size ); extern int loadConfigFile(const char *configFile, config_file_t *configBuff); -extern int loadBooterConfig(config_file_t *configBuff); -extern int loadSystemConfig(config_file_t *configBuff); +extern int loadBooterConfig(void); +extern int loadSystemConfig(void); #ifdef BOOT_HELPER_SUPPORT -extern int loadHelperConfig(config_file_t *configBuff); +extern int loadHelperConfig(void); #endif -extern int loadOverrideConfig(config_file_t *configBuff); +extern int loadOverrideConfig(void); extern char * newString(const char *oldString); extern char * newEmptyStringWithLength(int len); extern char * newStringWithLength(const char * oldString, int len); @@ -257,7 +287,6 @@ extern void setBootGlobals(BVRef chain); extern int getDeviceDescription(BVRef volume, char *str); -extern int gBIOSDev; extern int gBootFileType; extern BVRef gBootVolume; extern BVRef gBIOSBootVolume; @@ -265,5 +294,8 @@ /* smp.c */ extern void * getMPSTable(); +/* uterror.c */ +extern jmp_buf h_buf_error; +extern void init_ut_fnc(void); #endif /* !__LIBSAIO_SAIO_INTERNAL_H */ Index: branches/cparm/i386/libsaio/utarray.h =================================================================== --- branches/cparm/i386/libsaio/utarray.h (revision 0) +++ branches/cparm/i386/libsaio/utarray.h (revision 1840) @@ -0,0 +1,230 @@ +/* +Copyright (c) 2008-2011, Troy D. Hanson http://uthash.sourceforge.net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* a dynamic array implementation using macros + * see http://uthash.sourceforge.net/utarray + */ +#ifndef UTARRAY_H +#define UTARRAY_H + +#define UTARRAY_VERSION 1.9.4 + +#ifdef __GNUC__ +#define _UNUSED_ __attribute__ ((__unused__)) +#else +#define _UNUSED_ +#endif + +#include "libsaio.h" + +#define oom() longjmp(h_buf_error,-1) + +typedef void (ctor_f)(void *dst, const void *src); +typedef void (dtor_f)(void *elt); +typedef void (init_f)(void *elt); +typedef struct { + size_t sz; + init_f *init; + ctor_f *copy; + dtor_f *dtor; +} UT_icd; + +typedef struct { + unsigned i,n;/* i: index of next available slot, n: num slots */ + UT_icd icd; /* initializer, copy and destructor functions */ + char *d; /* n slots of size icd->sz*/ +} UT_array; + +#define utarray_init(a,_icd) do { \ + memset(a,0,sizeof(UT_array)); \ + (a)->icd=*_icd; \ +} while(0) + +#define utarray_done(a) do { \ + if ((a)->n) { \ + if ((a)->icd.dtor) { \ + size_t _ut_i; \ + for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \ + (a)->icd.dtor(utarray_eltptr(a,_ut_i)); \ + } \ + } \ + free((a)->d); \ + } \ + (a)->n=0; \ +} while(0) + +#define utarray_new(a,_icd) do { \ + a=(UT_array*)malloc(sizeof(UT_array)); \ + utarray_init(a,_icd); \ +} while(0) + +#define utarray_free(a) do { \ + utarray_done(a); \ + free(a); \ +} while(0) + +#define utarray_reserve(a,by) do { \ + if (((a)->i+by) > ((a)->n)) { \ + while(((a)->i+by) > ((a)->n)) { (a)->n = ((a)->n ? (2*(a)->n) : 8); } \ + if ( ((a)->d=(char*)realloc((a)->d, (a)->n*(a)->icd.sz)) == NULL) oom(); \ + } \ +} while(0) + +#define utarray_push_back(a,p) do { \ + utarray_reserve(a,1); \ + if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,(a)->i++), p); } \ + else { memcpy(_utarray_eltptr(a,(a)->i++), p, (a)->icd.sz); }; \ +} while(0) + +#define utarray_pop_back(a) do { \ + if ((a)->icd.dtor) { (a)->icd.dtor( _utarray_eltptr(a,--((a)->i))); } \ + else { (a)->i--; } \ +} while(0) + +#define utarray_extend_back(a) do { \ + utarray_reserve(a,1); \ + if ((a)->icd.init) { (a)->icd.init(_utarray_eltptr(a,(a)->i)); } \ + else { memset(_utarray_eltptr(a,(a)->i),0,(a)->icd.sz); } \ + (a)->i++; \ +} while(0) + +#define utarray_len(a) ((a)->i) + +#define utarray_eltptr(a,j) (((j) < (a)->i) ? _utarray_eltptr(a,j) : NULL) +#define _utarray_eltptr(a,j) ((char*)((a)->d + ((a)->icd.sz*(j) ))) + +#define utarray_insert(a,p,j) do { \ + utarray_reserve(a,1); \ + if (j > (a)->i) break; \ + if ((j) < (a)->i) { \ + memmove( _utarray_eltptr(a,(j)+1), _utarray_eltptr(a,j), \ + ((a)->i - (j))*((a)->icd.sz)); \ + } \ + if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,j), p); } \ + else { memcpy(_utarray_eltptr(a,j), p, (a)->icd.sz); }; \ + (a)->i++; \ +} while(0) + +#define utarray_inserta(a,w,j) do { \ + if (utarray_len(w) == 0) break; \ + if (j > (a)->i) break; \ + utarray_reserve(a,utarray_len(w)); \ + if ((j) < (a)->i) { \ + memmove(_utarray_eltptr(a,(j)+utarray_len(w)), \ + _utarray_eltptr(a,j), \ + ((a)->i - (j))*((a)->icd.sz)); \ + } \ + if ((a)->icd.copy) { \ + size_t _ut_i; \ + for(_ut_i=0;_ut_i<(w)->i;_ut_i++) { \ + (a)->icd.copy(_utarray_eltptr(a,j+_ut_i), _utarray_eltptr(w,_ut_i)); \ + } \ + } else { \ + memcpy(_utarray_eltptr(a,j), _utarray_eltptr(w,0), \ + utarray_len(w)*((a)->icd.sz)); \ + } \ + (a)->i += utarray_len(w); \ +} while(0) + +#define utarray_resize(dst,num) do { \ + size_t _ut_i; \ + if (dst->i > (size_t)(num)) { \ + if ((dst)->icd.dtor) { \ + for(_ut_i=num; _ut_i < dst->i; _ut_i++) { \ + (dst)->icd.dtor(utarray_eltptr(dst,_ut_i)); \ + } \ + } \ + } else if (dst->i < (size_t)(num)) { \ + utarray_reserve(dst,num-dst->i); \ + if ((dst)->icd.init) { \ + for(_ut_i=dst->i; _ut_i < num; _ut_i++) { \ + (dst)->icd.init(utarray_eltptr(dst,_ut_i)); \ + } \ + } else { \ + memset(_utarray_eltptr(dst,dst->i),0,(dst)->icd.sz*(num-dst->i)); \ + } \ + } \ + dst->i = num; \ +} while(0) + +#define utarray_concat(dst,src) do { \ + utarray_inserta((dst),(src),utarray_len(dst)); \ +} while(0) + +#define utarray_erase(a,pos,len) do { \ + if ((a)->icd.dtor) { \ + size_t _ut_i; \ + for(_ut_i=0; _ut_i < len; _ut_i++) { \ + (a)->icd.dtor(utarray_eltptr((a),pos+_ut_i)); \ + } \ + } \ + if ((a)->i > (pos+len)) { \ + memmove( _utarray_eltptr((a),pos), _utarray_eltptr((a),pos+len), \ + (((a)->i)-(pos+len))*((a)->icd.sz)); \ + } \ + (a)->i -= (len); \ +} while(0) + +#define utarray_renew(a,u) do { \ + if (a) utarray_clear(a); \ + else utarray_new((a),(u)); \ +} while(0); + +#define utarray_clear(a) do { \ + if ((a)->i > 0) { \ + if ((a)->icd.dtor) { \ + size_t _ut_i; \ + for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \ + (a)->icd.dtor(utarray_eltptr(a,_ut_i)); \ + } \ + } \ + (a)->i = 0; \ + } \ +} while(0) + +#define utarray_sort(a,cmp) do { \ + qsort((a)->d, (a)->i, (a)->icd.sz, cmp); \ +} while(0) + +#define utarray_find(a,v,cmp) bsearch((v),(a)->d,(a)->i,(a)->icd.sz,cmp) + +#define utarray_front(a) (((a)->i) ? (_utarray_eltptr(a,0)) : NULL) +#define utarray_next(a,e) (((e)==NULL) ? utarray_front(a) : ((((a)->i) > (utarray_eltidx(a,e)+1)) ? _utarray_eltptr(a,utarray_eltidx(a,e)+1) : NULL)) +#define utarray_back(a) (((a)->i) ? (_utarray_eltptr(a,(a)->i-1)) : NULL) +#define utarray_eltidx(a,e) (((char*)(e) >= (char*)((a)->d)) ? (((char*)(e) - (char*)((a)->d))/(a)->icd.sz) : -1) + +/* last we pre-define a few icd for common utarrays of ints and strings */ +static void utarray_str_cpy(void *dst, const void *src) { + char **_src = (char**)src, **_dst = (char**)dst; + *_dst = (*_src == NULL) ? NULL : strdup(*_src); +} +static void utarray_str_dtor(void *elt) { + char **eltc = (char**)elt; + if (*eltc) free(*eltc); +} +static const UT_icd ut_str_icd _UNUSED_ = {sizeof(char*),NULL,utarray_str_cpy,utarray_str_dtor}; +static const UT_icd ut_int_icd _UNUSED_ = {sizeof(int),NULL,NULL,NULL}; +static const UT_icd ut_ptr_icd _UNUSED_ = {sizeof(void*),NULL,NULL,NULL}; + + +#endif /* UTARRAY_H */ Index: branches/cparm/i386/boot2/modules.c =================================================================== --- branches/cparm/i386/boot2/modules.c (revision 1839) +++ branches/cparm/i386/boot2/modules.c (revision 1840) @@ -1,1330 +0,0 @@ -/* - * Copyright 2010 Evan Lojewski. All rights reserved. - * - */ - -#include "boot.h" -#include "bootstruct.h" -#include "multiboot.h" -#include "modules.h" - -#ifndef DEBUG_MODULES -#define DEBUG_MODULES 0 -#endif - -#if DEBUG_MODULES -#define DBG(x...) printf(x) -#else -#define DBG(x...) -#endif - -// NOTE: Global so that modules can link with this -unsigned long long textAddress = 0; -unsigned long long textSection = 0; - -moduleHook_t* moduleCallbacks = NULL; -moduleList_t* loadedModules = NULL; -symbolList_t* moduleSymbols = NULL; -unsigned int (*lookup_symbol)(const char*, int(*strcmp_callback)(const char*, const char*)) = NULL; - -#if DEBUG_MODULES -VOID print_hook_list() -{ - moduleHook_t* hooks = moduleCallbacks; - printf("Hook list: \n"); - while(hooks) - { - printf("* %s\n", hooks->name); - hooks = hooks->next; - } - printf("\n"); -} - -VOID print_symbol_list() -{ - symbolList_t* symbol = moduleSymbols; - printf("Symbol list: \n"); - while(symbol) - { - printf("* %s\n", symbol->symbol); - symbol = symbol->next; - } - printf("\n"); -} -#endif - - -/* - * Initialize the module system by loading the Symbols.dylib module. - * Once loaded, locate the _lookup_symbol function so that internal - * symbols can be resolved. - */ -EFI_STATUS init_module_system() -{ - msglog("* Attempting to load system module\n"); - - // Intialize module system - EFI_STATUS status = load_module(SYMBOLS_MODULE); - if((status == EFI_SUCCESS) || (status == EFI_ALREADY_STARTED)/*should never happen*/ ) - { - lookup_symbol = (void*)lookup_all_symbols(SYMBOL_LOOKUP_SYMBOL); - - if((UInt32)lookup_symbol != 0xFFFFFFFF) - { - return EFI_SUCCESS; - } - - } - - return EFI_LOAD_ERROR; -} - - -/* - * Load all modules in the /Extra/modules/ directory - * Module depencdies will be loaded first - * MOdules will only be loaded once. When loaded a module must - * setup apropriete function calls and hooks as required. - * NOTE: To ensure a module loads after another you may - * link one module with the other. For dyld to allow this, you must - * reference at least one symbol within the module. - */ - -VOID load_all_modules() -{ - char* name; - long flags; - long time; - struct dirstuff* moduleDir = opendir("/Extra/modules/"); - while(readdir(moduleDir, (const char**)&name, &flags, &time) >= 0) - { - if ((strcmp(SYMBOLS_MODULE,name)) == 0) continue; // if we found Symbols.dylib, just skip it - - int len = strlen(name); - int ext_size = sizeof("dylib"); - - if (len >= ext_size) - { - if(strcmp(&name[len - ext_size], ".dylib") == 0) - { - char *tmp = newString(name); - if (!tmp) { - continue; - } - msglog("* Attempting to load module: %s\n", tmp); - if(load_module(tmp) != EFI_SUCCESS) - { - // failed to load or already loaded - free(tmp); - } - } -#if DEBUG_MODULES - else - { - DBG("Ignoring %s\n", name); - } -#endif - } -#if DEBUG_MODULES - else - { - DBG("Ignoring %s\n", name); - } -#endif - - } - - if (moduleDir) - { - closedir(moduleDir); - - } - -#if DEBUG_MODULES - print_symbol_list(); -#endif -} - -/* - * Load a module file in /Extra/modules - * TODO: verify version number of module - */ -EFI_STATUS load_module(char* module) -{ - void (*module_start)(void) = NULL; - - - // Check to see if the module has already been loaded - if(is_module_loaded(module) == EFI_SUCCESS) - { - msglog("Module %s already registred\n", module); - return EFI_ALREADY_STARTED; - } - - int fh = -1; - char *modString=NULL; - modString = newStringWithFormat( "/Extra/modules/%s", module); - if (!modString) { - printf("Unable to allocate module name : /Extra/modules/%s\n", module); - return EFI_OUT_OF_RESOURCES; - } - fh = open(modString); - if(fh < 0) - { -#if DEBUG_MODULES - DBG("Unable to locate module %s\n", modString); - getc(); -#else - msglog("Unable to locate module %s\n", modString); -#endif - free(modString); - return EFI_OUT_OF_RESOURCES; - } - EFI_STATUS ret = EFI_SUCCESS; - - { - int moduleSize = file_size(fh); - - char* module_base = NULL; - - if (moduleSize > 0) - { - module_base = (char*) malloc(moduleSize); - } - - if (module_base && read(fh, module_base, moduleSize) == moduleSize) - { - - DBG("Module %s read in.\n", modString); - - // Module loaded into memory, parse it - module_start = parse_mach(module_base, &load_module, &add_symbol); - - if(module_start && (module_start != (void*)0xFFFFFFFF)) - { - module_loaded(module/*moduleName, moduleVersion, moduleCompat*/); - // Notify the system that it was laoded - (*module_start)(); // Start the module - msglog("%s successfully Loaded.\n", module); - } - else - { - // The module does not have a valid start function - printf("Unable to start %s\n", module); - ret = EFI_NOT_STARTED; -#if DEBUG_MODULES - getc(); -#endif - } - } - else - { - printf("Unable to read in module %s\n.", module); -#if DEBUG_MODULES - getc(); -#endif - ret = EFI_LOAD_ERROR; - } - } - close(fh); - free(modString); - return ret; -} - -moduleHook_t* get_callback(const char* name) -{ - moduleHook_t* hooks = moduleCallbacks; - - // look for a hook. If it exists, return the moduleHook_t*, - // If not, return NULL. - while(hooks) - { - if(strcmp(name, hooks->name) == 0) - { - //DBG("Located hook %s\n", name); - return hooks; - } - hooks = hooks->next; - } - return NULL; - -} - -/* - * execute_hook( const char* name ) - * name - Name of the module hook - * If any callbacks have been registered for this hook - * they will be executed now in the same order that the - * hooks were added. - */ -EFI_STATUS execute_hook(const char* name, void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) -{ - DBG("Attempting to execute hook '%s'\n", name); - moduleHook_t* hook = get_callback(name); - - if(hook) - { - // Loop through all callbacks for this module - callbackList_t* callbacks = hook->callbacks; - - while(callbacks) - { - // Execute callback - callbacks->callback(arg1, arg2, arg3, arg4, arg5, arg6); - callbacks = callbacks->next; - } - DBG("Hook '%s' executed.\n", name); - return EFI_SUCCESS; - } - - // Callback for this hook doesn't exist; - DBG("No callbacks for '%s' hook.\n", name); - return EFI_NOT_FOUND; - -} - -/* - * register_hook_callback( const char* name, void(*callback)()) - * name - Name of the module hook to attach to. - * callbacks - The funciton pointer that will be called when the - * hook is executed. When registering a new callback name, the callback is added sorted. - * NOTE: the hooks take four void* arguments. - */ -VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*)) -{ - DBG("Adding callback for hook '%s'.\n", name); - - moduleHook_t* hook = get_callback(name); - - if(hook) - { - // append - callbackList_t* newCallback = malloc(sizeof(callbackList_t)); - if (!newCallback) { - DBG("Unable to allocate memory for callback \n"); - return; - } - newCallback->next = hook->callbacks; - hook->callbacks = newCallback; - newCallback->callback = callback; - } - else - { - // create new hook - moduleHook_t* newHook = malloc(sizeof(moduleHook_t)); - if (!newHook) { - DBG("Unable to allocate memory for hook '%s'.\n", name); - return; - } - newHook->name = name; - newHook->callbacks = malloc(sizeof(callbackList_t)); - if (!newHook->callbacks) { - DBG("Unable to allocate memory for callback \n"); - free(newHook); - return; - } - newHook->callbacks->callback = callback; - newHook->callbacks->next = NULL; - - newHook->next = moduleCallbacks; - moduleCallbacks = newHook; - - } - -#if DEBUG_MODULES - print_hook_list(); - getc(); -#endif - -} - -#if DEBUG_MODULES -unsigned long vmaddr; -long vmsize; -#endif - -/* - * Parse through a macho module. The module will be rebased and binded - * as specified in the macho header. If the module is successfully loaded - * the module iinit address will be returned. - * NOTE; all dependecies will be loaded before this module is started - * NOTE: If the module is unable to load ot completeion, the modules - * symbols will still be available (TODO: fix this). This should not - * happen as all dependencies are verified before the sybols are read in. - */ -void* parse_mach(void* binary, EFI_STATUS(*dylib_loader)(char*), long long(*symbol_handler)(char*, long long, char)) // TODO: add param to specify valid archs -{ - char is64 = false; - void (*module_start)(void) = NULL; - - // Module info - /*char* moduleName = NULL; - UInt32 moduleVersion = 0; - UInt32 moduleCompat = 0; - */ - - // TODO convert all of the structs to a union - struct dyld_info_command* dyldInfoCommand = NULL; - struct symtab_command* symtabCommand = NULL; - - { - struct segment_command *segCommand = NULL; - struct segment_command_64 *segCommand64 = NULL; - struct dylib_command* dylibCommand = NULL; - struct load_command *loadCommand = NULL; - UInt32 binaryIndex = 0; - UInt16 cmd = 0; - - // Parse through the load commands - if(((struct mach_header*)binary)->magic == MH_MAGIC) - { - is64 = false; - binaryIndex += sizeof(struct mach_header); - } - else if(((struct mach_header_64*)binary)->magic == MH_MAGIC_64) - { - // NOTE: modules cannot be 64bit... - is64 = true; - binaryIndex += sizeof(struct mach_header_64); - } - else - { - printf("Modules: Invalid mach magic\n"); - getc(); - return NULL; - } - - - - /*if(((struct mach_header*)binary)->filetype != MH_DYLIB) - { - printf("Module is not a dylib. Unable to load.\n"); - getc(); - return NULL; // Module is in the incorrect format - }*/ - - while(cmd < ((struct mach_header*)binary)->ncmds) - { - cmd++; - - loadCommand = binary + binaryIndex; - UInt32 cmdSize = loadCommand->cmdsize; - - - switch ((loadCommand->cmd & 0x7FFFFFFF)) - { - case LC_SYMTAB: - symtabCommand = binary + binaryIndex; - break; - - case LC_SEGMENT: // 32bit macho - { - segCommand = binary + binaryIndex; - - //printf("Segment name is %s\n", segCommand->segname); - - if(strcmp("__TEXT", segCommand->segname) == 0) - { - UInt32 sectionIndex; - -#if DEBUG_MODULES - unsigned long fileaddr; - long filesize; - vmaddr = (segCommand->vmaddr & 0x3fffffff); - vmsize = segCommand->vmsize; - fileaddr = ((unsigned long)(binary + binaryIndex) + segCommand->fileoff); - filesize = segCommand->filesize; - - printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n", - segCommand->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, - (unsigned) segCommand->nsects, (unsigned)segCommand->flags); -#if DEBUG_MODULES==2 - - getc(); -#endif -#endif - - sectionIndex = sizeof(struct segment_command); - - struct section *sect; - - while(sectionIndex < segCommand->cmdsize) - { - sect = binary + binaryIndex + sectionIndex; - - sectionIndex += sizeof(struct section); - - - if(strcmp("__text", sect->sectname) == 0) - { - // __TEXT,__text found, save the offset and address for when looking for the calls. - textSection = sect->offset; - textAddress = sect->addr; - break; - } - } - } - break; - } - case LC_SEGMENT_64: // 64bit macho's - { - segCommand64 = binary + binaryIndex; - - //printf("Segment name is %s\n", segCommand->segname); - - if(strcmp("__TEXT", segCommand64->segname) == 0) - { - UInt32 sectionIndex; - -#if DEBUG_MODULES - unsigned long fileaddr; - long filesize; - vmaddr = (segCommand64->vmaddr & 0x3fffffff); - vmsize = segCommand64->vmsize; - fileaddr = ((unsigned long)(binary + binaryIndex) + segCommand64->fileoff); - filesize = segCommand64->filesize; - - printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n", - segCommand64->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, - (unsigned) segCommand64->nsects, (unsigned)segCommand64->flags); -#if DEBUG_MODULES==2 - - getc(); -#endif -#endif - - sectionIndex = sizeof(struct segment_command_64); - - struct section_64 *sect; - - while(sectionIndex < segCommand64->cmdsize) - { - sect = binary + binaryIndex + sectionIndex; - - sectionIndex += sizeof(struct section_64); - - - if(strcmp("__text", sect->sectname) == 0) - { - // __TEXT,__text found, save the offset and address for when looking for the calls. - textSection = sect->offset; - textAddress = sect->addr; - - break; - } - } - } - - break; - } - case LC_DYSYMTAB: - break; - - case LC_LOAD_DYLIB: - case LC_LOAD_WEAK_DYLIB ^ LC_REQ_DYLD: - { - dylibCommand = binary + binaryIndex; - char* module = binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name)); - // TODO: verify version - // = dylibCommand->dylib.current_version; - // = dylibCommand->dylib.compatibility_version; - - char *name=NULL; - name = newStringWithFormat( "%s.dylib", module); - if (!name) { - printf("Unable to allocate module name : %s\n", module); - return NULL; - } - if(dylib_loader) - { - EFI_STATUS statue = dylib_loader(name); - - if( statue != EFI_SUCCESS) - { - if (statue != EFI_ALREADY_STARTED) - { - // Unable to load dependancy - free(name); - return NULL; - } - - } - - } - free(name); - - break; - } - case LC_ID_DYLIB: - dylibCommand = binary + binaryIndex; - /*moduleName = binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name)); - moduleVersion = dylibCommand->dylib.current_version; - moduleCompat = dylibCommand->dylib.compatibility_version; - */ - break; - - case LC_DYLD_INFO: - // Bind and rebase info is stored here - dyldInfoCommand = binary + binaryIndex; - break; - - case LC_UUID: - break; - - case LC_UNIXTHREAD: - break; - - default: - DBG("Unhandled loadcommand 0x%X\n", loadCommand->cmd & 0x7FFFFFFF); - break; - - } - - binaryIndex += cmdSize; - } - //if(!moduleName) return NULL; - } - - // bind_macho uses the symbols. - module_start = (void*)handle_symtable((UInt32)binary, symtabCommand, symbol_handler, is64); - - // Rebase the module before binding it. - if(dyldInfoCommand && dyldInfoCommand->rebase_off) - { - rebase_macho(binary, (char*)dyldInfoCommand->rebase_off, dyldInfoCommand->rebase_size); - } - - if(dyldInfoCommand && dyldInfoCommand->bind_off) - { - bind_macho(binary, (char*)dyldInfoCommand->bind_off, dyldInfoCommand->bind_size); - } - - if(dyldInfoCommand && dyldInfoCommand->weak_bind_off) - { - // NOTE: this currently should never happen. - bind_macho(binary, (char*)dyldInfoCommand->weak_bind_off, dyldInfoCommand->weak_bind_size); - } - - if(dyldInfoCommand && dyldInfoCommand->lazy_bind_off) - { - // NOTE: we are binding the lazy pointers as a module is laoded, - // This should be changed to bind when a symbol is referened at runtime instead. - bind_macho(binary, (char*)dyldInfoCommand->lazy_bind_off, dyldInfoCommand->lazy_bind_size); - } - - return module_start; - -} - -// Based on code from dylibinfo.cpp and ImageLoaderMachOCompressed.cpp -void rebase_macho(void* base, char* rebase_stream, UInt32 size) -{ - rebase_stream += (UInt32)base; - - UInt8 immediate = 0; - UInt8 opcode = 0; - UInt8 type = 0; - - UInt32 segmentAddress = 0; - - - - UInt32 tmp = 0; - UInt32 tmp2 = 0; - UInt8 bits = 0; - UInt32 index = 0; - - int done = 0; - unsigned int i = 0; - - while(/*!done &&*/ i < size) - { - immediate = rebase_stream[i] & REBASE_IMMEDIATE_MASK; - opcode = rebase_stream[i] & REBASE_OPCODE_MASK; - - - switch(opcode) - { - case REBASE_OPCODE_DONE: - // Rebase complete. - done = 1; - break; - - - case REBASE_OPCODE_SET_TYPE_IMM: - // Set rebase type (pointer, absolute32, pcrel32) - //DBG("Rebase type = 0x%X\n", immediate); - type = immediate; - break; - - - case REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: - { - // Locate address to begin rebasing - segmentAddress = 0; - - struct segment_command* segCommand = NULL; // NOTE: 32bit only - - { - unsigned int binIndex = 0; - index = 0; - do - { - segCommand = base + sizeof(struct mach_header) + binIndex; - - - binIndex += segCommand->cmdsize; - index++; - } - while(index <= immediate); - } - - segmentAddress = segCommand->fileoff; - - tmp = 0; - bits = 0; - do - { - tmp |= (rebase_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(rebase_stream[i] & 0x80); - - segmentAddress += tmp; - break; - } - case REBASE_OPCODE_ADD_ADDR_ULEB: - // Add value to rebase address - tmp = 0; - bits = 0; - do - { - tmp <<= bits; - tmp |= rebase_stream[++i] & 0x7f; - bits += 7; - } - while(rebase_stream[i] & 0x80); - - segmentAddress += tmp; - break; - - case REBASE_OPCODE_ADD_ADDR_IMM_SCALED: - segmentAddress += immediate * sizeof(void*); - break; - - - case REBASE_OPCODE_DO_REBASE_IMM_TIMES: - index = 0; - for (index = 0; index < immediate; ++index) - { - rebase_location(base + segmentAddress, (char*)base, type); - segmentAddress += sizeof(void*); - } - break; - - - case REBASE_OPCODE_DO_REBASE_ULEB_TIMES: - tmp = 0; - bits = 0; - do - { - tmp |= (rebase_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(rebase_stream[i] & 0x80); - - index = 0; - for (index = 0; index < tmp; ++index) - { - //DBG("\tRebasing 0x%X\n", segmentAddress); - rebase_location(base + segmentAddress, (char*)base, type); - segmentAddress += sizeof(void*); - } - break; - - case REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB: - tmp = 0; - bits = 0; - do - { - tmp |= (rebase_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(rebase_stream[i] & 0x80); - - rebase_location(base + segmentAddress, (char*)base, type); - - segmentAddress += tmp + sizeof(void*); - break; - - case REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: - tmp = 0; - bits = 0; - do - { - tmp |= (rebase_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(rebase_stream[i] & 0x80); - - - tmp2 = 0; - bits = 0; - do - { - tmp2 |= (rebase_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(rebase_stream[i] & 0x80); - - index = 0; - for (index = 0; index < tmp; ++index) - { - - rebase_location(base + segmentAddress, (char*)base, type); - - segmentAddress += tmp2 + sizeof(void*); - } - break; - default: - break; - } - i++; - } -} - -// Based on code from dylibinfo.cpp and ImageLoaderMachOCompressed.cpp -// NOTE: this uses 32bit values, and not 64bit values. -// There is apossibility that this could cause issues, -// however the macho file is 32 bit, so it shouldn't matter too much -void bind_macho(void* base, char* bind_stream, UInt32 size) -{ - bind_stream += (UInt32)base; - - UInt8 immediate = 0; - UInt8 opcode = 0; - UInt8 type = 0; - - UInt32 segmentAddress = 0; - - UInt32 address = 0; - - SInt32 addend = 0; // TODO: handle this - SInt32 libraryOrdinal = 0; - - const char* symbolName = NULL; - UInt8 symboFlags = 0; - UInt32 symbolAddr = 0xFFFFFFFF; - - // Temperary variables - UInt8 bits = 0; - UInt32 tmp = 0; - UInt32 tmp2 = 0; - - UInt32 index = 0; - int done = 0; - unsigned int i = 0; - - while(/*!done &&*/ i < size) - { - immediate = bind_stream[i] & BIND_IMMEDIATE_MASK; - opcode = bind_stream[i] & BIND_OPCODE_MASK; - - - switch(opcode) - { - case BIND_OPCODE_DONE: - done = 1; - break; - - case BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: - libraryOrdinal = immediate; - //DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: %d\n", libraryOrdinal); - break; - - case BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: - libraryOrdinal = 0; - bits = 0; - do - { - libraryOrdinal |= (bind_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(bind_stream[i] & 0x80); - - //DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: %d\n", libraryOrdinal); - - break; - - case BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: - // NOTE: this is wrong, fortunately we don't use it - libraryOrdinal = -immediate; - //DBG("BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: %d\n", libraryOrdinal); - - break; - - case BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: - symboFlags = immediate; - symbolName = (char*)&bind_stream[++i]; - i += strlen((char*)&bind_stream[i]); - //DBG("BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: %s, 0x%X\n", symbolName, symboFlags); - - symbolAddr = lookup_all_symbols(symbolName); - - break; - - case BIND_OPCODE_SET_TYPE_IMM: - // Set bind type (pointer, absolute32, pcrel32) - type = immediate; - //DBG("BIND_OPCODE_SET_TYPE_IMM: %d\n", type); - - break; - - case BIND_OPCODE_SET_ADDEND_SLEB: - addend = 0; - bits = 0; - do - { - addend |= (bind_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(bind_stream[i] & 0x80); - - if(!(bind_stream[i-1] & 0x40)) addend *= -1; - - //DBG("BIND_OPCODE_SET_ADDEND_SLEB: %d\n", addend); - break; - - case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: - { - segmentAddress = 0; - - // Locate address - struct segment_command* segCommand = NULL; // NOTE: 32bit only - - { - unsigned int binIndex = 0; - index = 0; - do - { - segCommand = base + sizeof(struct mach_header) + binIndex; - binIndex += segCommand->cmdsize; - index++; - }while(index <= immediate); - } - - - segmentAddress = segCommand->fileoff; - - // Read in offset - tmp = 0; - bits = 0; - do - { - tmp |= (bind_stream[++i] & 0x7f) << bits; - bits += 7; - }while(bind_stream[i] & 0x80); - - segmentAddress += tmp; - - //DBG("BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: 0x%X\n", segmentAddress); - break; - } - case BIND_OPCODE_ADD_ADDR_ULEB: - // Read in offset - tmp = 0; - bits = 0; - do - { - tmp |= (bind_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(bind_stream[i] & 0x80); - - segmentAddress += tmp; - //DBG("BIND_OPCODE_ADD_ADDR_ULEB: 0x%X\n", segmentAddress); - break; - - case BIND_OPCODE_DO_BIND: - //DBG("BIND_OPCODE_DO_BIND\n"); - if(symbolAddr != 0xFFFFFFFF) - { - address = segmentAddress + (UInt32)base; - - bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); - } - else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) - { - printf("Unable to bind symbol %s\n", symbolName); - getc(); - } - - segmentAddress += sizeof(void*); - break; - - case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: - //DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB\n"); - - - // Read in offset - tmp = 0; - bits = 0; - do - { - tmp |= (bind_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(bind_stream[i] & 0x80); - - - - if(symbolAddr != 0xFFFFFFFF) - { - address = segmentAddress + (UInt32)base; - - bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); - } - else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) - { - printf("Unable to bind symbol %s\n", symbolName); - } - segmentAddress += tmp + sizeof(void*); - - - break; - - case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: - //DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED\n"); - - if(symbolAddr != 0xFFFFFFFF) - { - address = segmentAddress + (UInt32)base; - - bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); - } - else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) - { - printf("Unable to bind symbol %s\n", symbolName); - } - segmentAddress += (immediate * sizeof(void*)) + sizeof(void*); - - - break; - - case BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: - - tmp = 0; - bits = 0; - do - { - tmp |= (bind_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(bind_stream[i] & 0x80); - - - tmp2 = 0; - bits = 0; - do - { - tmp2 |= (bind_stream[++i] & 0x7f) << bits; - bits += 7; - } - while(bind_stream[i] & 0x80); - - - //DBG("BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0x%X 0x%X\n", tmp, tmp2); - - - if(symbolAddr != 0xFFFFFFFF) - { - for(index = 0; index < tmp; index++) - { - - address = segmentAddress + (UInt32)base; - - bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); - - segmentAddress += tmp2 + sizeof(void*); - } - } - else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) - { - printf("Unable to bind symbol %s\n", symbolName); - } - - - break; - default: - break; - - } - i++; - } -} - -void rebase_location(UInt32* location, char* base, int type) -{ - switch(type) - { - case REBASE_TYPE_POINTER: - case REBASE_TYPE_TEXT_ABSOLUTE32: - *location += (UInt32)base; - break; - - default: - break; - } -} - -void bind_location(UInt32* location, char* value, UInt32 addend, int type) -{ - // do actual update - char* newValue = value + addend; - - switch (type) { - case BIND_TYPE_POINTER: - case BIND_TYPE_TEXT_ABSOLUTE32: - break; - - case BIND_TYPE_TEXT_PCREL32: - newValue -= ((UInt32)location + 4); - - break; - default: - return; - } - *location = (UInt32)newValue; - - -} - -/* - * add_symbol - * This function adds a symbol from a module to the list of known symbols - * possibly change to a pointer and add this to the Symbol module so that it can - * adjust it's internal symbol list (sort) to optimize locating new symbols - * NOTE: returns the address if the symbol is "start", else returns 0xFFFFFFFF - */ -long long add_symbol(char* symbol, long long addr, char is64) -{ - if(is64) return 0xFFFFFFFF; // Fixme - - // This only can handle 32bit symbols - symbolList_t* new_entry= malloc(sizeof(symbolList_t)); - DBG("Adding symbol %s at 0x%X\n", symbol, addr); - if (new_entry) - { - new_entry->next = moduleSymbols; - - moduleSymbols = new_entry; - - new_entry->addr = (UInt32)addr; - new_entry->symbol = symbol; - return addr; - } - - return 0xFFFFFFFF; - -} - -/* - * print out the information about the loaded module - */ -VOID module_loaded(const char* name/*, UInt32 version, UInt32 compat*/) -{ - moduleList_t* new_entry = malloc(sizeof(moduleList_t)); - if (new_entry) - { - new_entry->next = loadedModules; - - loadedModules = new_entry; - - new_entry->module = (char*)name; - // new_entry->version = version; - // new_entry->compat = compat; - } -} - -EFI_STATUS is_module_loaded(const char* name) -{ - moduleList_t* entry = loadedModules; - while(entry) - { - DBG("Comparing %s with %s\n", name, entry->module); - char *fullname = newStringWithFormat("%s.dylib",name); - if(fullname && ((strcmp(entry->module, name) == 0) || (strcmp(entry->module, fullname) == 0))) - { - free(fullname); - DBG("Located module %s\n", name); - return EFI_SUCCESS; - } - else - { - entry = entry->next; - } - - } - DBG("Module %s not found\n", name); - - return EFI_NOT_FOUND; -} - -// Look for symbols using the Smbols moduel function. -// If non are found, look through the list of module symbols -unsigned int lookup_all_symbols(const char* name) -{ - { - unsigned int addr = 0xFFFFFFFF; - if(lookup_symbol && (UInt32)lookup_symbol != 0xFFFFFFFF) - { - addr = lookup_symbol(name, &strcmp); - if(addr != 0xFFFFFFFF) - { - DBG("Internal symbol %s located at 0x%X\n", name, addr); - return addr; - } - } - } - - { - symbolList_t* entry = moduleSymbols; - while(entry) - { - if(strcmp(entry->symbol, name) == 0) - { - DBG("External symbol %s located at 0x%X\n", name, entry->addr); - return entry->addr; - } - else - { - entry = entry->next; - } - - } - } - -#if DEBUG_MODULES - if(strcmp(name, SYMBOL_DYLD_STUB_BINDER) != 0) - { - verbose("Unable to locate symbol %s\n", name); - getc(); - } -#endif - return 0xFFFFFFFF; -} - - -/* - * parse the symbol table - * Lookup any undefined symbols - */ - -unsigned int handle_symtable(UInt32 base, struct symtab_command* symtabCommand, long long(*symbol_handler)(char*, long long, char), char is64) -{ - unsigned int module_start = 0xFFFFFFFF; - - UInt32 symbolIndex = 0; - char* symbolString = base + (char*)symtabCommand->stroff; - //char* symbolTable = base + symtabCommand->symoff; - if(!is64) - { - struct nlist* symbolEntry = (void*)base + symtabCommand->symoff; - while(symbolIndex < symtabCommand->nsyms) - { - if(symbolEntry->n_value) - { - if(strstr(symbolString + symbolEntry->n_un.n_strx, "module_start") || (strcmp(symbolString + symbolEntry->n_un.n_strx, "start") == 0)) - { - module_start = base + symbolEntry->n_value; - DBG("n_value %x module_start %x\n", (unsigned)symbolEntry->n_value, (unsigned)module_start); - } - else - { - symbol_handler(symbolString + symbolEntry->n_un.n_strx, (long long)base + symbolEntry->n_value, is64); - } -#if DEBUG_MODULES - bool isTexT = (((unsigned)symbolEntry->n_value > (unsigned)vmaddr) && ((unsigned)(vmaddr + vmsize) > (unsigned)symbolEntry->n_value )); - printf("%s %s\n", isTexT ? "__TEXT :" : "__DATA(OR ANY) :", symbolString + symbolEntry->n_un.n_strx); -#if DEBUG_MODULES==2 - - if(strcmp(symbolString + symbolEntry->n_un.n_strx, "_BootHelp_txt") == 0) - { - long long addr = (long long)base + symbolEntry->n_value; - unsigned char *BootHelp = NULL; - BootHelp = (unsigned char*)(UInt32)addr; - printf("method 1: __DATA : BootHelp_txt[0] %x\n", BootHelp[0]); - - long long addr2 = symbolEntry->n_value; - unsigned char *BootHelp2 = NULL; - BootHelp2 = (unsigned char*)(UInt32)addr2; - printf("method 2: __DATA : BootHelp_txt[0] %x\n", BootHelp2[0]); - } -#endif -#endif - - } - - symbolEntry++; - symbolIndex++; // TODO remove - } - } - else - { - struct nlist_64* symbolEntry = (void*)base + symtabCommand->symoff; - // NOTE First entry is *not* correct, but we can ignore it (i'm getting radar:// right now) - while(symbolIndex < symtabCommand->nsyms) - { - - if(strstr(symbolString + symbolEntry->n_un.n_strx, "module_start") || (strcmp(symbolString + symbolEntry->n_un.n_strx, "start") == 0)) - { - module_start = base + symbolEntry->n_value; - } - else - { - symbol_handler(symbolString + symbolEntry->n_un.n_strx, (long long)base + symbolEntry->n_value, is64); - } - - symbolEntry++; - symbolIndex++; // TODO remove - } - } - - return module_start; - -} - - -/* - * Locate the symbol for an already loaded function and modify the beginning of - * the function to jump directly to the new one - * example: replace_function("_HelloWorld_start", &replacement_start); - */ -EFI_STATUS replace_function(const char* symbol, void* newAddress) -{ - // TODO: look into using the next four bytes of the function instead - // Most functions should support this, as they probably will be at - // least 10 bytes long, but you never know, this is sligtly safer as - // function can be as small as 6 bytes. - UInt32 addr = lookup_all_symbols(symbol); - - char* binary = (char*)addr; - if(addr != 0xFFFFFFFF) - { - UInt32* jumpPointer = malloc(sizeof(UInt32*)); - if (!jumpPointer) { - return EFI_OUT_OF_RESOURCES; - } - - *binary++ = 0xFF; // Jump - *binary++ = 0x25; // Long Jump - *((UInt32*)binary) = (UInt32)jumpPointer; - - *jumpPointer = (UInt32)newAddress; - - return EFI_SUCCESS; - } - - return EFI_NOT_FOUND; - -} Index: branches/cparm/i386/boot2/modules.h =================================================================== --- branches/cparm/i386/boot2/modules.h (revision 1839) +++ branches/cparm/i386/boot2/modules.h (revision 1840) @@ -1,101 +0,0 @@ -/* - * Module Loading functionality - * Copyright 2009 Evan Lojewski. All rights reserved. - * - */ - -// There is a bug with the module system / rebasing / binding -// that causes static variables to be incorrectly rebased or bound -// Disable static variables for the moment -// #define static - -#ifndef __BOOT_MODULES_H -#define __BOOT_MODULES_H - -#include -#include -#include "efi.h" - -extern unsigned long long textAddress; -extern unsigned long long textSection; - -typedef struct symbolList_t -{ - char* symbol; - unsigned int addr; - struct symbolList_t* next; -} symbolList_t; - -typedef struct moduleList_t -{ - char* module; - //struct moduleHook_t* hook_list; - struct moduleList_t* next; -} moduleList_t; - -typedef struct callbackList_t -{ - void(*callback)(void*, void*, void*, void*, void*, void*); - struct callbackList_t* next; -} callbackList_t; - -typedef struct moduleHook_t -{ - const char* name; - callbackList_t* callbacks; - struct moduleHook_t* next; -} moduleHook_t; - -#define SYMBOLS_MODULE "Symbols.dylib" - -#define SYMBOL_DYLD_STUB_BINDER "dyld_stub_binder" -#define SYMBOL_LOOKUP_SYMBOL "_lookup_symbol" -#define STUB_ENTRY_SIZE 6 - -#define SECT_NON_LAZY_SYMBOL_PTR "__nl_symbol_ptr" -#define SECT_SYMBOL_STUBS "__symbol_stub" - -EFI_STATUS init_module_system(); -VOID load_all_modules(); - -/* - * Modules Interface - * execute_hook - * Exexutes a registered hook. All callbaks are - * called in the same order that they were added - * - * register_hook_callback - * registers a void function to be executed when a - * hook is executed. - */ -EFI_STATUS execute_hook(const char* name, void*, void*, void*, void*, void*, void*); -VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*)); - -void rebase_location(UInt32* location, char* base, int type); -void bind_location(UInt32* location, char* value, UInt32 addend, int type); -void rebase_macho(void* base, char* rebase_stream, UInt32 size); -void bind_macho(void* base, char* bind_stream, UInt32 size); - -EFI_STATUS load_module(char* module); -EFI_STATUS is_module_loaded(const char* name); -VOID module_loaded(const char* name/*, UInt32 version, UInt32 compat*/); - -long long add_symbol(char* symbol, long long addr, char is64); - -VOID* parse_mach(void* binary, - EFI_STATUS(*dylib_loader)(char*), - long long(*symbol_handler)(char*, long long, char) - ); - -unsigned int handle_symtable(UInt32 base, - struct symtab_command* symtabCommand, - long long(*symbol_handler)(char*, long long, char), - char is64); - -unsigned int lookup_all_symbols(const char* name); - -EFI_STATUS replace_function(const char* symbol, void* newAddress); - -extern unsigned int (*lookup_symbol)(const char*, int(*strcmp_callback)(const char*, const char*)); - -#endif /* __BOOT_MODULES_H */ \ No newline at end of file Index: branches/cparm/i386/boot2/lzss.c =================================================================== --- branches/cparm/i386/boot2/lzss.c (revision 1839) +++ branches/cparm/i386/boot2/lzss.c (revision 1840) @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 2.0 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/************************************************************** - LZSS.C -- A Data Compression Program -*************************************************************** - 4/6/1989 Haruhiko Okumura - Use, distribute, and modify this program freely. - Please send me your improved versions. - PC-VAN SCIENCE - NIFTY-Serve PAF01022 - CompuServe 74050,1022 - -**************************************************************/ -/* - * lzss.c - Package for decompressing lzss compressed objects - * - * Copyright (c) 2003 Apple Computer, Inc. - * - * DRI: Josh de Cesare - */ - -#include - -#define N 4096 /* size of ring buffer - must be power of 2 */ -#define F 18 /* upper limit for match_length */ -#define THRESHOLD 2 /* encode string into position and length - if match_length is greater than this */ -//#define NIL N /* index for root of binary search trees */ - -int -decompress_lzss(u_int8_t *dst, u_int8_t *src, u_int32_t srclen) -{ - /* ring buffer of size N, with extra F-1 bytes to aid string comparison */ - u_int8_t text_buf[N + F - 1]; - u_int8_t *dststart = dst; - u_int8_t *srcend = src + srclen; - int i, j, k, r, c; - unsigned int flags; - - dst = dststart; - srcend = src + srclen; - for (i = 0; i < N - F; i++) - text_buf[i] = ' '; - r = N - F; - flags = 0; - for ( ; ; ) { - if (((flags >>= 1) & 0x100) == 0) { - if (src < srcend) c = *src++; else break; - flags = c | 0xFF00; /* uses higher byte cleverly */ - } /* to count eight */ - if (flags & 1) { - if (src < srcend) c = *src++; else break; - *dst++ = c; - text_buf[r++] = c; - r &= (N - 1); - } else { - if (src < srcend) i = *src++; else break; - if (src < srcend) j = *src++; else break; - i |= ((j & 0xF0) << 4); - j = (j & 0x0F) + THRESHOLD; - for (k = 0; k <= j; k++) { - c = text_buf[(i + k) & (N - 1)]; - *dst++ = c; - text_buf[r++] = c; - r &= (N - 1); - } - } - } - - return dst - dststart; -} Index: branches/cparm/i386/boot2/graphics.c =================================================================== --- branches/cparm/i386/boot2/graphics.c (revision 1839) +++ branches/cparm/i386/boot2/graphics.c (revision 1840) @@ -33,12 +33,6 @@ #include "bootstruct.h" #include "modules.h" -/* - * for spinning disk - */ -#if TEXT_SPINNER -static int currentIndicator = 0; -#endif int previewTotalSectors = 0; int previewLoadedSectors = 0; @@ -54,12 +48,17 @@ unsigned short rows, unsigned char bitsPerPixel ); +static int initGraphicsMode (); + +static unsigned long lookUpCLUTIndex( unsigned char index, + unsigned char depth ); + #ifndef OPTION_ROM int -convertImage( unsigned short width, - unsigned short height, - const unsigned char *imageData, - unsigned char **newImageData ) +__convertImage( unsigned short width, + unsigned short height, + const unsigned char *imageData, + unsigned char **newImageData ) { int cnt; unsigned char *img = 0; @@ -95,11 +94,11 @@ //========================================================================== // drawDataRectangle -void drawDataRectangle( unsigned short x, - unsigned short y, - unsigned short width, - unsigned short height, - unsigned char * data ) +void __drawDataRectangle( unsigned short x, + unsigned short y, + unsigned short width, + unsigned short height, + unsigned char * data ) { unsigned short drawWidth; long pixelBytes = VIDEO(depth) / 8; @@ -123,13 +122,13 @@ // If a mode is not found, then return the "best" available mode. unsigned short -getVESAModeWithProperties( unsigned short width, - unsigned short height, - unsigned char bitsPerPixel, - unsigned short attributesSet, - unsigned short attributesClear, - VBEModeInfoBlock * outModeInfo, - unsigned short * vesaVersion ) +__getVESAModeWithProperties( unsigned short width, + unsigned short height, + unsigned char bitsPerPixel, + unsigned short attributesSet, + unsigned short attributesClear, + VBEModeInfoBlock * outModeInfo, + unsigned short * vesaVersion ) { VBEInfoBlock vbeInfo; unsigned short * modePtr; @@ -290,9 +289,9 @@ //========================================================================== // setVESAGraphicsMode #if UNUSED -int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate ) +int __setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate ) #else -int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel) +int __setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel) #endif { VBEModeInfoBlock minfo; @@ -301,13 +300,13 @@ int err = errFuncNotSupported; do { - mode = getVESAModeWithProperties( width, height, bitsPerPixel, - maColorModeBit | - maModeIsSupportedBit | - maGraphicsModeBit | - maLinearFrameBufferAvailBit, - 0, - &minfo, &vesaVersion ); + mode = __getVESAModeWithProperties( width, height, bitsPerPixel, + maColorModeBit | + maModeIsSupportedBit | + maGraphicsModeBit | + maLinearFrameBufferAvailBit, + 0, + &minfo, &vesaVersion ); if ( mode == modeEndOfList ) { break; @@ -318,7 +317,7 @@ // // if ( (vesaVersion >> 8) >= 3 && refreshRate >= 60 && - // (gBootMode & kBootModeSafe) == 0 ) + // (get_env(envgBootMode) & kBootModeSafe) == 0 ) // { // VBECRTCInfoBlock timing; // @@ -395,12 +394,10 @@ } -#ifndef OPTION_ROM - //========================================================================== // Simple decompressor for boot images encoded in RLE format. -char * decodeRLE( const void * rleData, int rleBlocks, int outBytes ) +char * __decodeRLE( const void * rleData, int rleBlocks, int outBytes ) { char *out, *cp; @@ -425,8 +422,8 @@ //========================================================================== // LookUpCLUTIndex -unsigned long lookUpCLUTIndex( unsigned char index, - unsigned char depth ) +static unsigned long lookUpCLUTIndex( unsigned char index, + unsigned char depth ) { long result, red, green, blue; @@ -458,7 +455,7 @@ //========================================================================== // drawColorRectangle -void * stosl(void * dst, long val, long len) +static void * stosl(void * dst, long val, long len) { asm volatile ( "rep; stosl" : "=c" (len), "=D" (dst) @@ -468,11 +465,11 @@ return dst; } -void drawColorRectangle( unsigned short x, - unsigned short y, - unsigned short width, - unsigned short height, - unsigned char colorIndex ) +void __drawColorRectangle( unsigned short x, + unsigned short y, + unsigned short width, + unsigned short height, + unsigned char colorIndex ) { long pixelBytes; long color = lookUpCLUTIndex( colorIndex, VIDEO(depth) ); @@ -494,9 +491,6 @@ } } -#endif - - //========================================================================== // setVESATextMode @@ -510,11 +504,11 @@ if ( (cols != 80) || (rows != 25) ) // not 80x25 mode { - mode = getVESAModeWithProperties( cols, rows, bitsPerPixel, - maColorModeBit | - maModeIsSupportedBit, - maGraphicsModeBit, - &minfo, NULL ); + mode = __getVESAModeWithProperties( cols, rows, bitsPerPixel, + maColorModeBit | + maModeIsSupportedBit, + maGraphicsModeBit, + &minfo, NULL ); } if ( ( mode == modeEndOfList ) || ( setVBEMode(mode, NULL) != errSuccess ) ) @@ -541,14 +535,14 @@ // getNumberArrayFromProperty int -getNumberArrayFromProperty( const char * propKey, - unsigned long numbers[], - unsigned long maxArrayCount ) +__getNumberArrayFromProperty( const char * propKey, + unsigned long numbers[], + unsigned long maxArrayCount ) { char * propStr; unsigned long count = 0; - propStr = newStringForKey( (char *) propKey , &bootInfo->bootConfig ); + propStr = newStringForKey( (char *) propKey , DEFAULT_BOOT_CONFIG ); if ( propStr ) { char * delimiter = propStr; @@ -572,13 +566,13 @@ return count; } -int initGraphicsMode () +static int initGraphicsMode () { unsigned long params[4]; int count; params[3] = 0; - count = getNumberArrayFromProperty( kGraphicsModeKey, params, 4 ); + count = __getNumberArrayFromProperty( kGraphicsModeKey, params, 4 ); // Try to find a resolution if "Graphics Mode" setting is not available. if ( count < 3 ) @@ -594,9 +588,9 @@ if ( params[2] == 555 ) params[2] = 16; if ( params[2] == 888 ) params[2] = 32; #if UNUSED - return setVESAGraphicsMode( params[0], params[1], params[2], params[3] ); + return __setVESAGraphicsMode( params[0], params[1], params[2], params[3] ); #else - return setVESAGraphicsMode( params[0], params[1], params[2] ); + return __setVESAGraphicsMode( params[0], params[1], params[2] ); #endif } @@ -606,10 +600,10 @@ // Set the video mode to VGA_TEXT_MODE or GRAPHICS_MODE. #if UNUSED void -setVideoMode( int mode, int drawgraphics) +__setVideoMode( int mode, int drawgraphics) #else void -setVideoMode( int mode) +__setVideoMode( int mode) #endif { unsigned long params[4]; @@ -630,7 +624,7 @@ if ( (mode == VGA_TEXT_MODE) || (err != errSuccess) ) { - count = getNumberArrayFromProperty( kTextModeKey, params, 2 ); + count = __getNumberArrayFromProperty( kTextModeKey, params, 2 ); if ( count < 2 ) { params[0] = 80; // Default text mode is 80x25. @@ -640,69 +634,12 @@ setVESATextMode( params[0], params[1], 4 ); bootArgs->Video.v_display = VGA_TEXT_MODE; } - -#if TEXT_SPINNER - currentIndicator = 0; -#endif } //========================================================================== // Return the current video mode, VGA_TEXT_MODE or GRAPHICS_MODE. -int getVideoMode(void) +inline int __getVideoMode(void) { return bootArgs->Video.v_display; } -#if TEXT_SPINNER - -//========================================================================== -// Display and clear the activity indicator. - -static char indicator[] = {'-', '\\', '|', '/', '-', '\\', '|', '/', '\0'}; -//static char indicator[] = {'_', ' ','\0'}; - -// To prevent a ridiculously fast-spinning indicator, -// ensure a minimum of 1/9 sec between animation frames. -#define MIN_TICKS 2 - -void -spinActivityIndicator(int sectors) -{ - static unsigned long lastTickTime = 0, currentTickTime; - - bool doreturn = false; - execute_hook("spinActivity_hook", §ors, &doreturn, NULL, NULL, NULL, NULL); - if (doreturn == true) return; - - currentTickTime = time18(); // late binding - if (currentTickTime < lastTickTime + MIN_TICKS) - { - return; - } - else - { - lastTickTime = currentTickTime; - } - - if (getVideoMode() == VGA_TEXT_MODE) - { - if (currentIndicator >= sizeof(indicator)) - { - currentIndicator = 0; - } - putc(indicator[currentIndicator++]); - putc('\b'); - } -} - -void -clearActivityIndicator( void ) -{ - if ( getVideoMode() == VGA_TEXT_MODE ) - { - putc(' '); - putc('\b'); - } -} - -#endif \ No newline at end of file Index: branches/cparm/i386/boot2/options.h =================================================================== --- branches/cparm/i386/boot2/options.h (revision 1839) +++ branches/cparm/i386/boot2/options.h (revision 1840) @@ -27,77 +27,36 @@ #ifndef __BOOT2_OPTIONS_H #define __BOOT2_OPTIONS_H -#include "boot.h" #include "bootstruct.h" #include "graphics.h" -typedef struct { - int x; - int y; - int type; -} CursorState; +/* + * options.c + */ +extern int getBootOptions(bool firstRun); +extern int processBootOptions(void); +extern bool promptForRescanOption(void); +extern bool copyArgument(const char *argName, const char *val, int cnt, char **argP, int *cntRemainingP); -extern MenuItem * menuItems; -extern const MenuItem * gMenuItems; +void showHelp(void); +void showTextFile(const char * filename); +char *getMemoryInfoString(void); +void showMessage(char * message); +void showTextBuffer(char *buf, int size); void clearBootArgs(void); void addBootArg(const char * argStr); -void changeCursor( int col, int row, int type, CursorState * cs ); -void moveCursor( int col, int row ); -void restoreCursor( const CursorState * cs ); void printMemoryInfo(void); void lspci(void); -void printMenuItem( const MenuItem * item, int highlight ); -bool flushKeyboardBuffer(void); +char *getMemoryInfoString(void); - -extern bool shouldboot; - #ifdef UNUSED extern int multiboot_timeout; extern int multiboot_timeout_set; #endif -extern BVRef bvChain; -//extern int menucount; -extern int gDeviceCount; - -extern int selectIndex; - -enum { - kMenuTopRow = 5, - kMenuMaxItems = 10, - kScreenLastRow = 24 -}; - - -//========================================================================== - -extern char gBootArgs[BOOT_STRING_LEN]; -extern char * gBootArgsPtr; -extern char * gBootArgsEnd; -extern char booterCommand[BOOT_STRING_LEN]; -extern char booterParam[BOOT_STRING_LEN]; - - -//========================================================================== - -extern int gMenuItemCount; -extern int gMenuRow; -extern int gMenuHeight; -extern int gMenuTop; -extern int gMenuBottom; -extern int gMenuSelection; - -extern int gMenuStart; -extern int gMenuEnd; - -extern unsigned char chainbootdev; -extern unsigned char chainbootflag; - - // Maximum config table value size #define VALUE_SIZE 2048 Index: branches/cparm/i386/boot2/boot.c =================================================================== --- branches/cparm/i386/boot2/boot.c (revision 1839) +++ branches/cparm/i386/boot2/boot.c (revision 1840) @@ -62,6 +62,7 @@ #endif #include "modules.h" #include "xml.h" +#include "options.h" #ifndef DEBUG_BOOT #define DEBUG_BOOT 0 @@ -79,28 +80,10 @@ char rootPath[ROOT_PATH_LEN]; } PlatformInfo; +static char gBootKernelCacheFile[Cache_len_name]; +static char gMKextName[Cache_len_name]; -char *gboardproduct = NULL; -char *gPlatformName = NULL; -//char gRootPath[256]; -long gBootMode; /* defaults to 0 == kBootModeNormal */ -bool gOverrideKernel; -char gBootKernelCacheFile[512]; -char gMKextName[512]; -char *gRootDevice = NULL; - -#ifndef OPTION_ROM -bool gEnableCDROMRescan; -bool gScanSingleDrive; -#endif - -int bvCount = 0; -//int menucount = 0; -int gDeviceCount = 0; - -BVRef bvr; -BVRef menuBVR; -BVRef bvChain; +static BVRef bvChain; static bool forcecache = false; static void zeroBSS(void); @@ -118,10 +101,9 @@ static bool found_extra_kext(void); static void determineCpuArch(void); static void init_pic(void); +void getKernelCachePath(void); -void getKernelCachePath(); - /* * How long to wait (in seconds) to load the * kernel after displaying the "boot:" prompt. @@ -169,6 +151,12 @@ } #endif +BVRef getBvChain(void) +{ + return bvChain; +} + + //========================================================================== //Initializes the runtime. Right now this means zeroing the BSS and initializing malloc. // @@ -183,6 +171,18 @@ static void init_pic(void) { + /* Remap IRQ's */ + outb(0x20, 0x11); + outb(0xA0, 0x11); + outb(0x21, 0x20); + outb(0xA1, 0x28); + outb(0x21, 0x04); + outb(0xA1, 0x02); + outb(0x21, 0x01); + outb(0xA1, 0x01); + + outb(0x70,0x80); /* Disable NMI */ + outb(0x21, 0xff); /* Maskout all interrupts Pic1 */ outb(0xa1, 0xff); /* Maskout all interrupts Pic2 */ } @@ -209,7 +209,7 @@ bootArgs->Header.Version = kBootArgsVersion; bootArgs->Header.Revision = kBootArgsRevision; #else - if(gBootVolume->OSVersion[3] == '7') + if(gBootVolume->OSVersion[3] >= '7') { bootArgs->Header.Version = 2; bootArgs->Header.Revision = 0; @@ -233,11 +233,7 @@ { LoadDrivers("/"); } - -#if TEXT_SPINNER - clearActivityIndicator(); -#endif - + if (gErrors) { printf("Errors encountered while starting up the computer.\n"); @@ -269,7 +265,7 @@ const char *strval = 0; int dummysize /*= 0*/; - getBoolForKey(kWaitForKeypressKey, &wait, &bootInfo->bootConfig); + getBoolForKey(kWaitForKeypressKey, &wait, DEFAULT_BOOT_CONFIG); if (getValueForBootKey(bootArgs->CommandLine, "-wait", &strval, &dummysize)) { @@ -286,21 +282,23 @@ pause(); } } + + //debug_platform_env(); if ((execute_hook("GUI_ExecKernel", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS)) // (bootArgs->Video.v_display == VGA_TEXT_MODE) { #if UNUSED - setVideoMode( GRAPHICS_MODE, 0 ); + __setVideoMode( GRAPHICS_MODE, 0 ); #else - setVideoMode( GRAPHICS_MODE ); + __setVideoMode( GRAPHICS_MODE ); #endif #ifndef OPTION_ROM - + if(!gVerboseMode) { - drawColorRectangle(0, 0, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 0x01); - + __drawColorRectangle(0, 0, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 0x01); + uint8_t *appleBootPict; uint16_t bootImageWidth = kAppleBootWidth; uint16_t bootImageHeight = kAppleBootHeight; @@ -309,36 +307,47 @@ unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0}; // here we store the used screen resolution // Prepare the data for the default Apple boot image. - appleBootPict = (uint8_t *) decodeRLE(gAppleBootPictRLE, kAppleBootRLEBlocks, bootImageWidth * bootImageHeight); + appleBootPict = (uint8_t *) __decodeRLE(gAppleBootPictRLE, kAppleBootRLEBlocks, bootImageWidth * bootImageHeight); if (appleBootPict) { - convertImage(bootImageWidth, bootImageHeight, appleBootPict, &bootImageData); + __convertImage(bootImageWidth, bootImageHeight, appleBootPict, &bootImageData); if (bootImageData) { x = (screen_params[0] - MIN(kAppleBootWidth, screen_params[0])) / 2; y = (screen_params[1] - MIN(kAppleBootHeight, screen_params[1])) / 2; - drawDataRectangle(x, y, kAppleBootWidth, kAppleBootHeight, bootImageData); + __drawDataRectangle(x, y, kAppleBootWidth, kAppleBootHeight, bootImageData); free(bootImageData); } free(appleBootPict); } - + } #endif } - + finalizeEFIConfigTable(); setupBooterLog(); - finalizeBootStruct(); + finalizeBootStruct(); execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL, NULL, NULL); // Notify modules that the kernel is about to be started - if (gBootVolume->OSVersion[3] <= '6') - reserveKernLegacyBootStruct(); - else if (gBootVolume->OSVersion[3] == '7') - reserveKern107BootStruct(); + switch (gBootVolume->OSVersion[3]) { + case '4': + case '5': + case '6': + reserveKernLegacyBootStruct(); + break; + case '7': + reserveKern107BootStruct(); + break; + case '8': + reserveKern108BootStruct(); + break; + default: + break; + } #if UNUSED turnOffFloppy(); @@ -350,7 +359,7 @@ #endif switch (gBootVolume->OSVersion[3]) { - case '4': + case '4': case '5': case '6': // Jump to kernel's entry point. There's no going back now. XXX LEGACY OS XXX @@ -360,11 +369,15 @@ init_pic(); // Jump to kernel's entry point. There's no going back now. XXX LION XXX startprog( kernelEntry, bootArgs107 ); + break; + case '8': + init_pic(); + // Jump to kernel's entry point. There's no going back now. XXX MOUNTAIN LION XXX + startprog( kernelEntry, bootArgs108 ); + break; default: -#if DEBUG_BOOT printf("Error: Unsupported Darwin version\n"); getc(); -#endif break; } @@ -397,10 +410,13 @@ // booting was unsuccessful. This allows the PXE firmware to try the // next boot device on its list. void common_boot(int biosdev) -{ +{ int status; bool firstRun = true; + int devcnt = 0; + int bvCount = 0; + unsigned int allowBVFlags = kBVFlagSystemVolume|kBVFlagForeignBoot; unsigned int denyBVFlags = kBVFlagEFISystem; @@ -410,10 +426,9 @@ gUnloadPXEOnExit = true; #endif // Record the device that the booter was loaded from. - gBIOSDev = biosdev & kBIOSDevMask; + safe_set_env(envgBIOSDev,biosdev & kBIOSDevMask); - // Setup VGA text mode. // Not sure if it is safe to call setVideoMode() before the // config table has been loaded. Call video_mode() instead. @@ -424,12 +439,14 @@ #if DEBUG printf("after video_mode\n"); #endif -#if !TEXT_SPINNER printf("Starting Chameleon ...\n"); -#endif - - initBooterLog(); - + + init_ut_fnc(); + + arc4_init(); + + initBooterLog(); + // Initialize boot info structure. initKernBootStruct(); @@ -437,61 +454,77 @@ // Scan and record the system's hardware information. scan_platform(); + safe_set_env(envgBootMode, kBootModeNormal); /* defaults to 0 == kBootModeNormal */ + safe_set_env(envShouldboot, false); + safe_set_env(envkCache, (uint32_t)gBootKernelCacheFile); + safe_set_env(envMKextName, (uint32_t)gMKextName); + InitBootPrompt(); + // First get info for boot volume. - scanBootVolumes(gBIOSDev, 0); - bvChain = getBVChainForBIOSDev(gBIOSDev); + scanBootVolumes((int)get_env(envgBIOSDev), 0); + bvChain = getBVChainForBIOSDev((int)get_env(envgBIOSDev)); setBootGlobals(bvChain); // Load Booter boot.plist config file - status = loadBooterConfig(&bootInfo->bootConfig); + status = loadBooterConfig(); - Platform->CPU.isServer = false; - getBoolForKey(kIsServer, &Platform->CPU.isServer, &bootInfo->bootConfig); // set this as soon as possible + { + bool isServer = get_env(envIsServer); + getBoolForKey(kIsServer, &isServer, DEFAULT_BOOT_CONFIG); // set this as soon as possible + safe_set_env(envIsServer , isServer); + } + { bool quiet = false; - if (getBoolForKey(kQuietBootKey, &quiet, &bootInfo->bootConfig) && quiet) + if (getBoolForKey(kQuietBootKey, &quiet, DEFAULT_BOOT_CONFIG) && quiet) { + long gBootMode = kBootModeNormal; gBootMode |= kBootModeQuiet; + safe_set_env(envgBootMode, gBootMode); } } { bool instantMenu = false; // Override firstRun to get to the boot menu instantly by setting "Instant Menu"=y in system config - if (getBoolForKey(kInsantMenuKey, &instantMenu, &bootInfo->bootConfig) && instantMenu) + if (getBoolForKey(kInsantMenuKey, &instantMenu, DEFAULT_BOOT_CONFIG) && instantMenu) { firstRun = false; } -#if virtualM - firstRun = false; -#endif } - + + { #ifndef OPTION_ROM - // Enable touching a single BIOS device only if "Scan Single Drive"=y is set in system config. - if (getBoolForKey(kScanSingleDriveKey, &gScanSingleDrive, &bootInfo->bootConfig) && gScanSingleDrive) - { - gScanSingleDrive = true; - } - - // Create a list of partitions on device(s). - if (gScanSingleDrive) - { - scanBootVolumes(gBIOSDev, &bvCount); - } - else + bool ScanSingleDrive = false; + // Enable touching a single BIOS device only if "Scan Single Drive"=y is set in system config. + if (getBoolForKey(kScanSingleDriveKey, &ScanSingleDrive, DEFAULT_BOOT_CONFIG) && ScanSingleDrive) + { + ScanSingleDrive = true; + } + safe_set_env(envgScanSingleDrive, ScanSingleDrive); + // Create a list of partitions on device(s). + if (ScanSingleDrive) + { + scanBootVolumes((int)get_env(envgBIOSDev), &bvCount); + } + else #endif - { + { #if UNUSED - scanDisks(gBIOSDev, &bvCount); + scanDisks((int)get_env(envgBIOSDev), &bvCount); #else - scanDisks(); + scanDisks(); #endif - } - - // Create a separated bvr chain using the specified filters. - bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount); + } + + } + + // Create a separated bvr chain using the specified filters. + bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &devcnt); + safe_set_env(envgDeviceCount,devcnt); + + gBootVolume = selectBootVolume(bvChain); { @@ -510,21 +543,29 @@ #ifndef OPTION_ROM - // Disable rescan option by default - gEnableCDROMRescan = false; + - // Enable it with Rescan=y in system config - if (getBoolForKey(kRescanKey, &gEnableCDROMRescan, &bootInfo->bootConfig) && gEnableCDROMRescan) - { - gEnableCDROMRescan = true; + { + // Disable rescan option by default + bool CDROMRescan = false; + + // Enable it with Rescan=y in system config + if (getBoolForKey(kRescanKey, &CDROMRescan, DEFAULT_BOOT_CONFIG) && CDROMRescan) + { + CDROMRescan = true; + + } + safe_set_env(envgEnableCDROMRescan, CDROMRescan); + } + { bool rescanPrompt = false; // Ask the user for Rescan option by setting "Rescan Prompt"=y in system config. - if (getBoolForKey(kRescanPromptKey, &rescanPrompt , &bootInfo->bootConfig) && rescanPrompt && biosDevIsCDROM(gBIOSDev)) + if (getBoolForKey(kRescanPromptKey, &rescanPrompt , DEFAULT_BOOT_CONFIG) && rescanPrompt && biosDevIsCDROM((int)get_env(envgBIOSDev))) { - gEnableCDROMRescan = promptForRescanOption(); + safe_set_env(envgEnableCDROMRescan, promptForRescanOption()); } } @@ -558,9 +599,8 @@ // additional variable for testing alternate kernel image locations on boot helper partitions. char bootFileSpec[512]; - // Initialize globals. - - sysConfigValid = false; + // Initialize globals. + safe_set_env(envSysConfigValid, false); gErrors = false; status = getBootOptions(firstRun); @@ -578,20 +618,22 @@ { freeFilteredBVChain(bvChain); #ifndef OPTION_ROM - if (gEnableCDROMRescan) - rescanBIOSDevice(gBIOSDev); + if (get_env(envgEnableCDROMRescan)) + rescanBIOSDevice((int)get_env(envgBIOSDev)); #endif - bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount); + bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &devcnt); + safe_set_env(envgDeviceCount,devcnt); + setBootGlobals(bvChain); } continue; - } - + } + // Other status (e.g. 0) means that we should proceed with boot. execute_hook("GUI_PreBoot", NULL, NULL, NULL, NULL, NULL, NULL); - if (getValueForKey(karch, &val, &len, &bootInfo->bootConfig) && val) + if (getValueForKey(karch, &val, &len, DEFAULT_BOOT_CONFIG) && val) { if (strncmp(val, "x86_64", 4) == 0) { @@ -620,13 +662,13 @@ readSMBIOS(thePlatformName); // read smbios Platform Name - if (((gBootMode & kBootModeSafe) == 0) && - !gOverrideKernel && + if (((get_env(envgBootMode) & kBootModeSafe) == 0) && + !get_env(envgOverrideKernel) && (gBootFileType == kBlockDeviceType) && (gMKextName[0] == '\0') && !getValueForBootKey(bootArgs->CommandLine, kIgnorePrelinkKern, &val, &len)) { - getBoolForKey(kUseKernelCache, &trycache, &bootInfo->bootConfig); + getBoolForKey(kUseKernelCache, &trycache, DEFAULT_BOOT_CONFIG); if (trycache == true) { // try to find the cache and fill the gBootKernelCacheFile string @@ -647,15 +689,23 @@ long cachetime, kerneltime, exttime; if (trycache && !forcecache) do { - // if we haven't found the kernel yet, don't use the cache - ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime); - if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) - { - trycache = 0; - bootInfo->adler32 = 0; - DBG("No kernel found, kernelcache disabled !!!\n"); - break; - } + if (strcmp(bootInfo->bootFile, kDefaultKernel) != 0) { + // if we haven't found the kernel yet, don't use the cache + ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime); + if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) + { + trycache = 0; + bootInfo->adler32 = 0; + DBG("No kernel found, kernelcache disabled !!!\n"); + break; + } + } + else if (gBootVolume->kernelfound != true) // Should never happen. + { + bootFile = kDefaultKernel; + goto out; + } + ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime); if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat) || (cachetime < kerneltime)) @@ -735,12 +785,12 @@ if (ret == -1) { // Not found any alternate locations, using the original kernel image path. - strlcpy(bootFileSpec, bootFile,sizeof(bootFileSpec)+1); + strlcpy(bootFileSpec, bootFile,sizeof(bootFileSpec)); } } } #else - strlcpy(bootFileSpec, bootFile,sizeof(bootFileSpec)+1); + strlcpy(bootFileSpec, bootFile,sizeof(bootFileSpec)); #endif verbose("Loading kernel %s\n", bootFileSpec); @@ -752,9 +802,6 @@ } } while (0); -#if TEXT_SPINNER - clearActivityIndicator(); -#endif #if DEBUG printf("Pausing..."); @@ -763,6 +810,7 @@ if (ret <= 0) { +out: printf("Can't find %s\n", bootFile); sleep(1); @@ -785,12 +833,12 @@ // chainboot if (status==1) { - if (getVideoMode() == GRAPHICS_MODE) + if (__getVideoMode() == GRAPHICS_MODE) { // if we are already in graphics-mode, #if UNUSED - setVideoMode(VGA_TEXT_MODE, 0); // switch back to text mode + __setVideoMode(VGA_TEXT_MODE, 0); // switch back to text mode #else - setVideoMode(VGA_TEXT_MODE); // switch back to text mode + __setVideoMode(VGA_TEXT_MODE); // switch back to text mode #endif } } @@ -814,7 +862,7 @@ } } -void getKernelCachePath() +void getKernelCachePath(void) { { // If there is an extra kext/mkext, we return immediatly and we skip the kernelCache @@ -827,7 +875,7 @@ const char *val; int len; - if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) + if (getValueForKey(kKernelCacheKey, &val, &len, DEFAULT_BOOT_CONFIG)) { char * buffer = newString(val); @@ -843,7 +891,7 @@ len++; } } - strlcpy(gBootKernelCacheFile, buffer, sizeof(gBootKernelCacheFile)+1); + strlcpy(gBootKernelCacheFile, buffer, sizeof(gBootKernelCacheFile)); forcecache = true; } else @@ -861,18 +909,18 @@ bzero(platformInfo, sizeof(PlatformInfo)); - if (gPlatformName) - strlcpy(platformInfo->platformName,gPlatformName, sizeof(platformInfo->platformName)+1); + if (GetgPlatformName()) + strlcpy(platformInfo->platformName,GetgPlatformName(), sizeof(platformInfo->platformName)+1); - if (gRootDevice) + if (GetgRootDevice()) { char *rootPath_p = platformInfo->rootPath; - len = strlen(gRootDevice) + 1; + len = strlen(GetgRootDevice()) + 1; if ((unsigned)len > sizeof(platformInfo->rootPath)) { len = sizeof(platformInfo->rootPath); } - memcpy(rootPath_p, gRootDevice,len); + memcpy(rootPath_p, GetgRootDevice(),len); rootPath_p += len; @@ -893,9 +941,10 @@ { platformInfo->platformName[0] = platformInfo->rootPath[0] = 0; } - //memcpy(gRootPath,platformInfo->rootPath, sizeof(gRootPath)); +#ifdef rootpath + SetgRootPath(platformInfo->rootPath); +#endif - bootInfo->adler32 = OSSwapHostToBigInt32(adler32((unsigned char *)platformInfo, sizeof(*platformInfo))); free(platformInfo); @@ -923,7 +972,6 @@ } } - static void getRootDevice() { // Maximum config table value size @@ -932,7 +980,7 @@ const char *val = 0; int cnt = 0; - if (getValueForKey(kBootUUIDKey, &val, &cnt, &bootInfo->bootConfig)) + if (getValueForKey(kBootUUIDKey, &val, &cnt, DEFAULT_BOOT_CONFIG)) { uuidSet = true; } @@ -949,7 +997,7 @@ else if (*val == '*' && *(val + 1) == 'u') { - if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->bootConfig)) + if ( getValueForKey( kBootDeviceKey, &val, &cnt, DEFAULT_BOOT_CONFIG)) uuidSet = true; } @@ -962,7 +1010,7 @@ // if (gBootVolume->flags & kBVFlagBooter) { - if((loadHelperConfig(&bootInfo->helperConfig) == 0) + if((loadHelperConfig() == 0) && getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig) ) { getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig); @@ -971,9 +1019,9 @@ } } #endif - if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->bootConfig)) + if ( getValueForKey( kBootDeviceKey, &val, &cnt, DEFAULT_BOOT_CONFIG)) { - extern int ArgCntRemaining; + int ArgCntRemaining = (int)get_env(envArgCntRemaining); uuidSet = false; char * valueBuffer; valueBuffer = malloc(VALUE_SIZE); @@ -983,7 +1031,6 @@ { cnt = VALUE_SIZE; } - //cnt++; strlcpy(valueBuffer + 1, val, cnt+1); if (!copyArgument( kRootDeviceKey, valueBuffer, cnt, &argP, &ArgCntRemaining)) { @@ -992,6 +1039,7 @@ getc(); return; } + safe_set_env(envArgCntRemaining,ArgCntRemaining); free(valueBuffer); goto out; } @@ -999,8 +1047,8 @@ if (gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, bootInfo->uuidStr) == 0) { verbose("Setting boot-uuid to: %s\n", bootInfo->uuidStr); - uuidSet = true; - gRootDevice = bootInfo->uuidStr; + uuidSet = true; + SetgRootDevice(bootInfo->uuidStr); return; } @@ -1008,8 +1056,8 @@ } out: - verbose("Setting %s to: %s\n", uuidSet ? kBootUUIDKey : "root device", (char* )val); - gRootDevice = (char* )val; + verbose("Setting %s to: %s\n", uuidSet ? kBootUUIDKey : "root device", (char* )val); + SetgRootDevice(val); } static bool find_file_with_ext(const char* dir, const char *ext, const char * name_compare, size_t ext_size) @@ -1160,7 +1208,7 @@ if (!bootFileWithDevice && (str)[0] != '/') sprintf(bootFile, "/%s", str); // append a leading / else - strlcpy(bootFile, bootInfo->bootFile, sizeof(bootInfo->bootFile)+1); + strlcpy(bootFile, bootInfo->bootFile, sizeof(bootInfo->bootFile)); return bootfile; } Index: branches/cparm/i386/boot2/graphics.h =================================================================== --- branches/cparm/i386/boot2/graphics.h (revision 1839) +++ branches/cparm/i386/boot2/graphics.h (revision 1840) @@ -11,54 +11,53 @@ #ifndef __BOOT_GRAPHICS_H #define __BOOT_GRAPHICS_H -#include "boot.h" #include "bootstruct.h" #include "vbe.h" -#define DEFAULT_SCREEN_WIDTH 1024 -#define DEFAULT_SCREEN_HEIGHT 768 +int __getVideoMode(void); -unsigned long lookUpCLUTIndex( unsigned char index, unsigned char depth ); +char * __decodeRLE( const void * rleData, int rleBlocks, int outBytes ); -void drawColorRectangle( unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char colorIndex ); -void drawDataRectangle( unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char * data ); -int convertImage( unsigned short width, unsigned short height, const unsigned char *imageData, unsigned char **newImageData ); +void __drawColorRectangle( unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char colorIndex ); +void __drawDataRectangle( unsigned short x, + unsigned short y, + unsigned short width, + unsigned short height, + unsigned char * data ); +int +__convertImage( unsigned short width, + unsigned short height, + const unsigned char *imageData, + unsigned char **newImageData ); -int initGraphicsMode (); - -void drawCheckerBoard(); - -void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data); - -void drawCheckerBoard(); -void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data); - - -char *getVBEInfoString(); -char *getVBEModeInfoString(); -void getGraphicModeParams(unsigned long params[]); - #if UNUSED -int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate ); +int __setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate ); #else -int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel); +int __setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel); #endif -int getNumberArrayFromProperty( const char * propKey, - unsigned long numbers[], - unsigned long maxArrayCount ); +int __getNumberArrayFromProperty( const char * propKey, + unsigned long numbers[], + unsigned long maxArrayCount ); unsigned short -getVESAModeWithProperties( unsigned short width, - unsigned short height, - unsigned char bitsPerPixel, - unsigned short attributesSet, - unsigned short attributesClear, - VBEModeInfoBlock * outModeInfo, - unsigned short * vesaVersion ); +__getVESAModeWithProperties( unsigned short width, + unsigned short height, + unsigned char bitsPerPixel, + unsigned short attributesSet, + unsigned short attributesClear, + VBEModeInfoBlock * outModeInfo, + unsigned short * vesaVersion ); +#if UNUSED +void +__setVideoMode( int mode, int drawgraphics); +#else +void +__setVideoMode( int mode); +#endif #endif /* !__BOOT_GRAPHICS_H */ Index: branches/cparm/i386/boot2/boot.h =================================================================== --- branches/cparm/i386/boot2/boot.h (revision 1839) +++ branches/cparm/i386/boot2/boot.h (revision 1840) @@ -31,44 +31,8 @@ #include "libsaio.h" -/* - * Keys used in system Boot.plist - */ -#define kGraphicsModeKey "Graphics Mode" -#define kTextModeKey "Text Mode" -#define kQuietBootKey "Quiet Boot" -#define kKernelFlagsKey "Kernel Flags" -#define kMKextCacheKey "MKext Cache" -#define kKernelNameKey "Kernel" -#define kKernelCacheKey "Kernel Cache" -#define kUseKernelCache "UseKernelCache" -#define kBootDeviceKey "Boot Device" -#define kTimeoutKey "Timeout" -#define kRootDeviceKey "rd" -#define kBootUUIDKey "boot-uuid" -#define kHelperRootUUIDKey "Root UUID" -#define kPlatformKey "platform" -#define kCDROMPromptKey "CD-ROM Prompt" -#define kCDROMOptionKey "CD-ROM Option Key" -#define kRescanPromptKey "Rescan Prompt" -#define kRescanKey "Rescan" -#define kScanSingleDriveKey "Scan Single Drive" -#define kInsantMenuKey "Instant Menu" -#define kDefaultKernel "mach_kernel" -#define kWaitForKeypressKey "Wait" -/* AsereBLN: added the other keys */ +void boot(int biosdev); -#define kProductVersion "ProductVersion" /* boot.c */ -#define karch "arch" /* boot.c */ -#define kDeviceProperties "device-properties" /* device_inject.c */ -#define kHidePartition "Hide Partition" /* disk.c */ -#define kRenamePartition "Rename Partition" /* disk.c */ -#define kSMBIOSKey "SMBIOS" /* fake_efi.c */ -#define kSystemID "SystemId" /* fake_efi.c */ -#define kSystemType "SystemType" /* fake_efi.c */ -#define kPCIRootUID "PCIRootUID" /* pci_root.c */ -#define kDefaultPartition "Default Partition" /* sys.c */ - enum { kBackspaceKey = 0x08, kTabKey = 0x09, @@ -81,9 +45,8 @@ kF10Key = 0x4400 }; -#define PLATFORM_NAME_LEN 64 -#define ROOT_PATH_LEN 256 + /* * Flags to the booter or kernel */ @@ -104,22 +67,8 @@ * A global set by boot() to record the device that the booter * was loaded from. */ -extern int gBIOSDev; -extern long gBootMode; -extern bool sysConfigValid; -extern char bootBanner[]; -extern char bootPrompt[]; -extern bool gOverrideKernel; -extern char gMKextName[]; -extern bool gEnableCDROMRescan; -extern bool gScanSingleDrive; -extern char *gPlatformName; -extern char *gboardproduct; +#define Cache_len_name 512 -//extern char gRootPath[]; - -extern char *gRootDevice; - /* * Boot Modes */ @@ -130,43 +79,11 @@ kBootModeQuiet = 4 }; -extern void initialize_runtime(); +extern void initialize_runtime(void); extern void common_boot(int biosdev); +extern BVRef getBvChain(void); /* - * graphics.c - */ -extern void printVBEModeInfo(); -#if UNUSED -extern void setVideoMode(int mode, int drawgraphics); -#else -extern void setVideoMode(int mode); -#endif -#if TEXT_SPINNER -extern void spinActivityIndicator(); -extern void clearActivityIndicator(); -#endif -extern void drawColorRectangle( unsigned short x, - unsigned short y, - unsigned short width, - unsigned short height, - unsigned char colorIndex ); -extern void drawDataRectangle( unsigned short x, - unsigned short y, - unsigned short width, - unsigned short height, - unsigned char * data ); -extern int -convertImage( unsigned short width, - unsigned short height, - const unsigned char *imageData, - unsigned char **newImageData ); -extern char * decodeRLE( const void * rleData, int rleBlocks, int outBytes ); -extern void drawPreview(void *src, uint8_t * saveunder); -extern int getVideoMode(void); -extern void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or); - -/* * drivers.c */ extern long LoadDrivers(char * dirSpec); @@ -174,45 +91,28 @@ typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin); /*! - Hookable function pointer called during the driver loading phase that - allows other code to cause additional drivers to be loaded. + Hookable function pointer called during the driver loading phase that + allows other code to cause additional drivers to be loaded. */ extern struct multiboot_info *gMI; -/* - * options.c - */ -extern int getBootOptions(bool firstRun); -extern int processBootOptions(); -extern bool promptForRescanOption(void); -extern bool copyArgument(const char *argName, const char *val, int cnt, char **argP, int *cntRemainingP); -void showHelp(); -void showTextFile(); -char *getMemoryInfoString(); -void showMessage(char * message); - -typedef struct { - char name[80]; - void * param; -} MenuItem; - -/* - * lzss.c - */ -extern int decompress_lzss(u_int8_t *dst, u_int8_t *src, u_int32_t srclen); - struct compressed_kernel_header { - u_int32_t signature; - u_int32_t compress_type; - u_int32_t adler32; - u_int32_t uncompressed_size; - u_int32_t compressed_size; - u_int32_t reserved[11]; - char platform_name[PLATFORM_NAME_LEN]; - char root_path[ROOT_PATH_LEN]; - u_int8_t data[0]; + u_int32_t signature; + u_int32_t compress_type; + u_int32_t adler32; + u_int32_t uncompressed_size; + u_int32_t compressed_size; + u_int32_t reserved[11]; + char platform_name[PLATFORM_NAME_LEN]; + char root_path[ROOT_PATH_LEN]; + u_int8_t data[0]; }; typedef struct compressed_kernel_header compressed_kernel_header; +/* + * prompt.c + */ +extern void InitBootPrompt(void); + #endif /* !__BOOT2_BOOT_H */ Index: branches/cparm/i386/boot2/drivers.c =================================================================== --- branches/cparm/i386/boot2/drivers.c (revision 1839) +++ branches/cparm/i386/boot2/drivers.c (revision 1840) @@ -36,19 +36,60 @@ #include "sl.h" #include "boot.h" #include "bootstruct.h" +#include "platform.h" #include "xml.h" #include "drivers.h" #include "modules.h" -extern char gBootKernelCacheFile[]; +struct Module { + struct Module *nextModule; + long willLoad; + TagPtr dict; + char *plistAddr; + long plistLength; + char *executablePath; + char *bundlePath; + long bundlePathLength; +}; +typedef struct Module Module, *ModulePtr; +struct DriverInfo { + char *plistAddr; + long plistLength; + void *executableAddr; + long executableLength; + void *bundlePathAddr; + long bundlePathLength; +}; +typedef struct DriverInfo DriverInfo, *DriverInfoPtr; + +#define kDriverPackageSignature1 'MKXT' +#define kDriverPackageSignature2 'MOSX' + +struct DriversPackage { + unsigned long signature1; + unsigned long signature2; + unsigned long length; + unsigned long alder32; + unsigned long version; + unsigned long numDrivers; + unsigned long reserved1; + unsigned long reserved2; +}; +typedef struct DriversPackage DriversPackage; + +enum { + kCFBundleType2, + kCFBundleType3 +}; + static ModulePtr gModuleHead, gModuleTail; static TagPtr gPersonalityHead, gPersonalityTail; -char * gExtensionsSpec; -char * gDriverSpec; -char * gFileSpec; -char * gTempSpec; -char * gFileName; +static char * gExtensionsSpec; +static char * gDriverSpec; +static char * gFileSpec; +static char * gTempSpec; +static char * gFileName; long InitDriverSupport(void); long FileLoadDrivers(char *dirSpec, long plugin); @@ -75,15 +116,26 @@ long InitDriverSupport( void ) { + static bool DriverSet = false; + + if (DriverSet == true) return 0; + gExtensionsSpec = malloc( 4096 ); gDriverSpec = malloc( 4096 ); gFileSpec = malloc( 4096 ); gTempSpec = malloc( 4096 ); - gFileName = malloc( 4096 ); - + gFileName = malloc( 4096 ); + if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName ) stop("InitDriverSupport error"); - + + DriverSet = true; + set_env(envDriverExtSpec,(uint32_t)gExtensionsSpec); + set_env(envDriverSpec,(uint32_t)gDriverSpec); + set_env(envDriverFileSpec,(uint32_t)gFileSpec); + set_env(envDriverTempSpec,(uint32_t)gTempSpec); + set_env(envDriverFileName,(uint32_t)gFileName); + return 0; } @@ -125,7 +177,7 @@ #endif // First try a specfic OS version folder ie 10.5 - sprintf(dirSpecExtra, "/Extra/%s/", &gBootVolume->OSVersion); + sprintf(dirSpecExtra, "/Extra/%s/", (char*)gBootVolume->OSVersion); if (FileLoadDrivers(dirSpecExtra, 0) != 0) { // Next try to load Extra extensions from the selected root partition. @@ -137,7 +189,7 @@ if (!(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no)) { // First try a specfic OS version folder ie 10.5 - sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gBootVolume->OSVersion); + sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", (char*)gBootVolume->OSVersion); if (FileLoadDrivers(dirSpecExtra, 0) != 0) { // Next we'll try the base @@ -169,13 +221,13 @@ } } #endif - - if (gMKextName[0] != '\0') + char * MKextName = (char*)(uint32_t)get_env(envMKextName); + if (MKextName[0] != '\0') { - verbose("LoadDrivers: Loading from [%s]\n", gMKextName); - if ( LoadDriverMKext(gMKextName) != 0 ) + verbose("LoadDrivers: Loading from [%s]\n", MKextName); + if ( LoadDriverMKext(MKextName) != 0 ) { - error("Could not load %s\n", gMKextName); + error("Could not load %s\n", MKextName); return -1; } } @@ -216,7 +268,7 @@ { ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2); if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeDirectory) || - (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1)))) + (((get_env(envgBootMode) & kBootModeSafe) == 0) && (time == (time2 + 1)))) { sprintf(gDriverSpec, "%sExtensions.mkext", altDirSpec); verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec); @@ -764,7 +816,8 @@ printf("adler mismatch\n"); return -1; } - if (((gBootMode & kBootModeSafe) == 0) && (gBootKernelCacheFile[0] != '\0') && gBootVolume->OSVersion[3] > '6') + char* BootKernelCacheFile = (char*)(uint32_t)get_env(envkCache); + if (((get_env(envgBootMode) & kBootModeSafe) == 0) && (BootKernelCacheFile[0] != '\0') && gBootVolume->OSVersion[3] > '6') bootInfo->adler32 = kernel_header->adler32; } Index: branches/cparm/i386/boot2/mboot.c =================================================================== --- branches/cparm/i386/boot2/mboot.c (revision 1839) +++ branches/cparm/i386/boot2/mboot.c (revision 1840) @@ -41,12 +41,18 @@ #define FIX_RETURN_ADDRESS_USING_FIRST_ARG(arg) \ RETURN_ADDRESS_USING_FIRST_ARG(arg) -= OFFSET_1MEG -extern void jump_to_chainbooter(); +extern void jump_to_chainbooter(void); extern unsigned char chainbootdev; extern unsigned char chainbootflag; -void chainLoad(); -void waitThenReload(); +void chainLoad(void); +void waitThenReload(void); +void multiboot_to_boot(int multiboot_magic, struct multiboot_info *mi_orig); +void *determine_safe_hi_addr(int multiboot_magic, struct multiboot_info *mi_orig); +void * _hi_malloc(void **hi_addr, size_t size); +char * _hi_strdup(void **hi_addr, char *src); +struct multiboot_info * copyMultibootInfo(int multiboot_magic, struct multiboot_info *mi_orig); +static inline uint32_t multiboot(int multiboot_magic, struct multiboot_info *mi); // Starts off in the multiboot context 1 MB high but eventually gets into low memory // and winds up with a bootdevice in eax which is all that boot() wants @@ -80,7 +86,7 @@ // particularly when the remaining code merely halts the processor. } -void chainLoad() +void chainLoad(void) { /* TODO: We ought to load the appropriate partition table, for example the MBR if booting a primary partition or the particular extended @@ -108,7 +114,7 @@ } } -void waitThenReload() +void waitThenReload(void) { /* FIXME: Ctrl+Alt+Del does not work under Boot Camp */ uint8_t i = 5; Index: branches/cparm/i386/boot2/prompt.c =================================================================== --- branches/cparm/i386/boot2/prompt.c (revision 1839) +++ branches/cparm/i386/boot2/prompt.c (revision 1840) @@ -27,12 +27,14 @@ */ #include "vers.h" +#include "boot.h" +#include "platform.h" -char bootBanner[] = "\nDarwin/x86 boot v" I386BOOT_VERSION " - Chameleon v" I386BOOT_CHAMELEONVERSION /*" r" I386BOOT_CHAMELEONREVISION*/ "\n" +static char bootBanner[] = "\nDarwin/x86 boot v" I386BOOT_VERSION " - Chameleon v" I386BOOT_CHAMELEONVERSION /*" r" I386BOOT_CHAMELEONREVISION*/ "\n" "Build date: " I386BOOT_BUILDDATE "\n" "%dMB memory\n"; -char bootPrompt[] = +static char bootPrompt[] = "Press Enter to start up Darwin/x86 with no options, or you can:\n" " Type -v and press Enter to start up with diagnostic messages\n" #ifndef OPTION_ROM @@ -41,10 +43,17 @@ "boot: "; #ifndef OPTION_ROM -char bootRescanPrompt[] = +static char bootRescanPrompt[] = "Press Enter to start up Darwin/x86 with no options, or you can:\n" " Press F5 after you swapped the media. The drive will be rescanned.\n" " Type -v and press Enter to start up with diagnostic messages\n" " Type ? and press Enter to learn about advanced startup options\n\n" "boot: "; #endif + +void InitBootPrompt(void) +{ + safe_set_env(envBootBanner,(uint32_t)bootBanner); + safe_set_env(envBootPrompt,(uint32_t)bootPrompt); + safe_set_env(envBootRescanPrompt,(uint32_t)bootRescanPrompt); +} Index: branches/cparm/i386/boot2/drivers.h =================================================================== --- branches/cparm/i386/boot2/drivers.h (revision 1839) +++ branches/cparm/i386/boot2/drivers.h (revision 1840) @@ -36,53 +36,10 @@ #include #include "sl.h" -#include "boot.h" #include "bootstruct.h" #include "xml.h" #include "modules.h" -struct Module { - struct Module *nextModule; - long willLoad; - TagPtr dict; - char *plistAddr; - long plistLength; - char *executablePath; - char *bundlePath; - long bundlePathLength; -}; -typedef struct Module Module, *ModulePtr; - -struct DriverInfo { - char *plistAddr; - long plistLength; - void *executableAddr; - long executableLength; - void *bundlePathAddr; - long bundlePathLength; -}; -typedef struct DriverInfo DriverInfo, *DriverInfoPtr; - -#define kDriverPackageSignature1 'MKXT' -#define kDriverPackageSignature2 'MOSX' - -struct DriversPackage { - unsigned long signature1; - unsigned long signature2; - unsigned long length; - unsigned long alder32; - unsigned long version; - unsigned long numDrivers; - unsigned long reserved1; - unsigned long reserved2; -}; -typedef struct DriversPackage DriversPackage; - -enum { - kCFBundleType2, - kCFBundleType3 -}; - long LoadDrivers( char * dirSpec ); long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize); Index: branches/cparm/i386/boot2/options.c =================================================================== --- branches/cparm/i386/boot2/options.c (revision 1839) +++ branches/cparm/i386/boot2/options.c (revision 1840) @@ -24,6 +24,7 @@ #include "boot.h" #include "bootstruct.h" +#include "platform.h" #include "graphics.h" #include "fdisk.h" #include "pci.h" @@ -38,23 +39,32 @@ #include "embedded.h" //+ 1376 bytes #endif +typedef struct { + char name[80]; + void * param; +} MenuItem; -bool shouldboot = false; +typedef struct { + int x; + int y; + int type; +} CursorState; #if UNUSED extern int multiboot_timeout; extern int multiboot_timeout_set; #endif -extern BVRef bvChain; -//extern int menucount; +enum { + kMenuTopRow = 5, + kMenuMaxItems = 10, + kScreenLastRow = 24 +}; -extern int gDeviceCount; +static int selectIndex = 0; +static MenuItem * menuItems = NULL; -int selectIndex = 0; -MenuItem * menuItems = NULL; - -static int countdown( const char * msg, int row, int timeout ); +static int countdown( const char * msg, int row, int timeout, int *optionKey ); static void showBootPrompt(int row, bool visible); static void updateBootArgs( int key ); static void showMenu( const MenuItem * items, int count, @@ -62,22 +72,27 @@ static int updateMenu( int key, void ** paramPtr ); static void skipblanks( const char ** cpp ); static const char * extractKernelName( char ** cpp ); +static bool flushKeyboardBuffer(void); +static void moveCursor( int col, int row ); +static void changeCursor( int col, int row, int type, CursorState * cs ); +static void restoreCursor( const CursorState * cs ); +static void printMenuItem( const MenuItem * item, int highlight ); //========================================================================== -void changeCursor( int col, int row, int type, CursorState * cs ) +static void changeCursor( int col, int row, int type, CursorState * cs ) { if (cs) getCursorPositionAndType( &cs->x, &cs->y, &cs->type ); setCursorType( type ); setCursorPosition( col, row, 0 ); } -void moveCursor( int col, int row ) +static void moveCursor( int col, int row ) { setCursorPosition( col, row, 0 ); } -void restoreCursor( const CursorState * cs ) +static void restoreCursor( const CursorState * cs ) { setCursorPosition( cs->x, cs->y, 0 ); setCursorType( cs->type ); @@ -89,7 +104,7 @@ * characters was F8. */ -bool flushKeyboardBuffer(void) +static bool flushKeyboardBuffer(void) { bool status = false; @@ -101,27 +116,30 @@ //========================================================================== -static int countdown( const char * msg, int row, int timeout ) +static int countdown( const char * msg, int row, int timeout, int *optionKey ) { unsigned long time; int ch = 0; int col = strlen(msg) + 1; + flushKeyboardBuffer(); moveCursor( 0, row ); - printf(msg); - + printf("%s",msg); + for ( time = time18(), timeout++; timeout > 0; ) { - if ((ch = readKeyboardStatus())) + if ((ch = readKeyboardStatus())){ + *optionKey = ch; break; - + } // Count can be interrupted by holding down shift, // control or alt key if ( ( readKeyboardShiftFlags() & 0x0F ) != 0 ) { ch = 1; + break; } @@ -130,28 +148,32 @@ time += 18; timeout--; - moveCursor( col, row ); - printf("(%d) ", timeout); + moveCursor( col, row ); + printf("(%d)", timeout); +#ifdef ShowCurrentDate + printf("\n\n\n\nCurrent Date : %s", Date()); +#endif } } - + flushKeyboardBuffer(); - + return ch; } //========================================================================== -char gBootArgs[BOOT_STRING_LEN]; -char * gBootArgsPtr = gBootArgs; -char * gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1; -char booterCommand[BOOT_STRING_LEN]; -char booterParam[BOOT_STRING_LEN]; +static char gBootArgs[BOOT_STRING_LEN]; +static char * gBootArgsPtr = gBootArgs; +static char * gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1; +static char booterCommand[BOOT_STRING_LEN]; +static char booterParam[BOOT_STRING_LEN]; void clearBootArgs(void) { gBootArgsPtr = gBootArgs; - memset(gBootArgs, '\0', BOOT_STRING_LEN); + memset(gBootArgs, '\0', BOOT_STRING_LEN); + } void addBootArg(const char * argStr) @@ -167,12 +189,10 @@ //========================================================================== static void showBootPrompt(int row, bool visible) -{ - extern char bootPrompt[]; -#ifndef OPTION_ROM - extern char bootRescanPrompt[]; -#endif - +{ + char * bootPrompt = (char*)(uint32_t)get_env(envBootPrompt); + char * bootRescanPrompt = (char*)(uint32_t)get_env(envBootRescanPrompt); + changeCursor( 0, row, kCursorTypeUnderline, 0 ); clearScreenRows( row, kScreenLastRow ); @@ -180,14 +200,14 @@ if (visible) { #ifndef OPTION_ROM - if (gEnableCDROMRescan) + if (get_env(envgEnableCDROMRescan)) { - printf( bootRescanPrompt ); + printf( "%s",bootRescanPrompt ); } else #endif { - printf( bootPrompt ); + printf( "%s",bootPrompt ); } } else { printf("Press Enter to start up the foreign OS. "); @@ -237,19 +257,10 @@ //========================================================================== -const MenuItem * gMenuItems = NULL; +static const MenuItem * gMenuItems = NULL; -int gMenuItemCount; -int gMenuRow; -int gMenuHeight; -int gMenuTop; -int gMenuBottom; -int gMenuSelection; -int gMenuStart; -int gMenuEnd; - -void printMenuItem( const MenuItem * item, int highlight ) +static void printMenuItem( const MenuItem * item, int highlight ) { printf(" "); @@ -277,39 +288,45 @@ // in the menu window. gMenuItems = items; - gMenuRow = row; - gMenuHeight = height; - gMenuItemCount = count; - gMenuTop = 0; - gMenuBottom = min( count, height ) - 1; - gMenuSelection = selection; + int MenuTop = 0; + int MenuBottom = min( count, height ) - 1; + int MenuSelection = selection; + int MenuStart = 0; + int MenuEnd = count; //min( count, gui.maxdevices ) - 1; - gMenuStart = 0; - gMenuEnd = count; //min( count, gui.maxdevices ) - 1; - // If the selected item is not visible, shift the list down. - if ( gMenuSelection > gMenuBottom ) + if ( MenuSelection > MenuBottom ) { - gMenuTop += ( gMenuSelection - gMenuBottom ); - gMenuBottom = gMenuSelection; + MenuTop += ( MenuSelection - MenuBottom ); + MenuBottom = MenuSelection; } - if ( gMenuSelection > gMenuEnd ) + if ( MenuSelection > MenuEnd ) { - gMenuStart += ( gMenuSelection - gMenuEnd ); - gMenuEnd = gMenuSelection; + MenuStart += ( MenuSelection - MenuEnd ); + MenuEnd = MenuSelection; } // Draw the visible items. changeCursor( 0, row, kCursorTypeHidden, &cursorState ); - for ( i = gMenuTop; i <= gMenuBottom; i++ ) + for ( i = MenuTop; i <= MenuBottom; i++ ) { - printMenuItem( &items[i], (i == gMenuSelection) ); + printMenuItem( &items[i], (i == MenuSelection) ); } + safe_set_env(envgMenuRow,row); + safe_set_env(envgMenuHeight,height); + safe_set_env(envgMenuItemCount,count); + safe_set_env(envgMenuTop,MenuTop); + safe_set_env(envgMenuBottom,MenuBottom); + safe_set_env(envgMenuSelection,MenuSelection); + safe_set_env(envgMenuStart,MenuStart); + safe_set_env(envgMenuEnd,MenuEnd); + + restoreCursor( &cursorState ); } @@ -318,7 +335,15 @@ static int updateMenu( int key, void ** paramPtr ) { int moved = 0; - + + int MenuTop = (int)get_env(envgMenuTop); + int MenuSelection = (int)get_env(envgMenuSelection); + int MenuRow = (int)get_env(envgMenuRow); + int MenuHeight = (int)get_env(envgMenuHeight); + int MenuBottom = (int)get_env(envgMenuBottom); + int MenuStart = (int)get_env(envgMenuStart); + int MenuEnd = (int)get_env(envgMenuEnd); + union { struct { unsigned int @@ -336,77 +361,88 @@ switch ( key ) { case 0x4800: // Up Arrow - if ( gMenuSelection != gMenuTop ) + { + if ( MenuSelection != MenuTop ) draw.f.selectionUp = 1; - else if ( gMenuTop > 0 ) + else if ( MenuTop > 0 ) draw.f.scrollDown = 1; break; - + } case 0x5000: // Down Arrow - if ( gMenuSelection != gMenuBottom ) + { + if ( MenuSelection != MenuBottom ) draw.f.selectionDown = 1; - else if ( gMenuBottom < (gMenuItemCount - 1) ) + else if ( MenuBottom < (get_env(envgMenuItemCount) - 1) ) draw.f.scrollUp = 1; break; + } default: break; } if ( draw.w ) - { + { if ( draw.f.scrollUp ) { - scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1); - gMenuTop++; gMenuBottom++; - gMenuStart++; gMenuEnd++; + scollPage(0, MenuRow, 40, MenuRow + MenuHeight - 1, 0x07, 1, 1); + MenuTop++; MenuBottom++; + MenuStart++; MenuEnd++; draw.f.selectionDown = 1; } if ( draw.f.scrollDown ) { - scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1); - gMenuTop--; gMenuBottom--; - gMenuStart--; gMenuEnd--; + scollPage(0, MenuRow, 40, MenuRow + MenuHeight - 1, 0x07, 1, -1); + MenuTop--; MenuBottom--; + MenuStart--; MenuEnd--; draw.f.selectionUp = 1; - } - + } + if ( draw.f.selectionUp || draw.f.selectionDown ) { CursorState cursorState; - + // Set cursor at current position, and clear inverse video. - changeCursor( 0, gMenuRow + gMenuSelection - gMenuTop, kCursorTypeHidden, &cursorState ); - printMenuItem( &gMenuItems[gMenuSelection], 0 ); + changeCursor( 0, MenuRow + MenuSelection - MenuTop, kCursorTypeHidden, &cursorState ); + printMenuItem( &gMenuItems[MenuSelection], 0 ); if ( draw.f.selectionUp ) { - gMenuSelection--; - if(( gMenuSelection - gMenuStart) == -1 ) + MenuSelection--; + if(( MenuSelection - MenuStart) == -1 ) { - gMenuStart--; - gMenuEnd--; + MenuStart--; + MenuEnd--; } } else { - gMenuSelection++; - if(( gMenuSelection - ( gMenuEnd - 1) - gMenuStart) > 0 ) + MenuSelection++; + if(( MenuSelection - ( MenuEnd - 1) - MenuStart) > 0 ) { - gMenuStart++; - gMenuEnd++; + MenuStart++; + MenuEnd++; } } - moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop ); - printMenuItem( &gMenuItems[gMenuSelection], 1 ); + moveCursor( 0, MenuRow + MenuSelection - MenuTop ); + printMenuItem( &gMenuItems[MenuSelection], 1 ); restoreCursor( &cursorState ); } - *paramPtr = gMenuItems[gMenuSelection].param; + *paramPtr = gMenuItems[MenuSelection].param; moved = 1; } - + + safe_set_env(envgMenuSelection,MenuSelection); + safe_set_env(envgMenuTop,MenuTop ); + safe_set_env(envgMenuRow,MenuRow); + safe_set_env(envgMenuHeight,MenuHeight); + safe_set_env(envgMenuBottom,MenuBottom); + safe_set_env(envgMenuStart,MenuStart); + safe_set_env(envgMenuEnd,MenuEnd); + return moved; } @@ -490,7 +526,7 @@ setActiveDisplayPage(0); } -char *getMemoryInfoString() +char *getMemoryInfoString(void) { unsigned long i; MemoryRange *mp = bootInfo->memoryMap; @@ -545,11 +581,12 @@ BVRef bvr; BVRef menuBVR; bool showPrompt, newShowPrompt, isCDROM; - + int optionKey; + // Initialize default menu selection entry. - gBootVolume = menuBVR = selectBootVolume(bvChain); + gBootVolume = menuBVR = selectBootVolume(getBvChain()); - if (biosDevIsCDROM(gBIOSDev)) { + if (biosDevIsCDROM((int)get_env(envgBIOSDev))) { isCDROM = true; } else { isCDROM = false; @@ -564,7 +601,7 @@ timeout = multiboot_timeout; } else #endif - if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->bootConfig)) { + if (!getIntForKey(kTimeoutKey, &timeout, DEFAULT_BOOT_CONFIG)) { /* If there is no timeout key in the file use the default timeout which is different for CDs vs. hard disks. However, if not booting a CD and no config file could be loaded set the timeout @@ -577,18 +614,24 @@ if (isCDROM) { timeout = kCDBootTimeout; } else { - timeout = sysConfigValid ? kBootTimeout : 0; + timeout = get_env(envSysConfigValid) ? kBootTimeout : 0; } } + long gBootMode = (long)get_env(envgBootMode); + if (timeout < 0) { gBootMode |= kBootModeQuiet; + safe_set_env(envgBootMode,gBootMode); + } // If the user is holding down a modifier key, enter safe mode. if ((readKeyboardShiftFlags() & 0x0F) != 0) { gBootMode |= kBootModeSafe; + safe_set_env(envgBootMode,gBootMode); + } // Checking user pressed keys @@ -602,6 +645,8 @@ // If user typed F8, abort quiet mode, and display the menu. if (f8press) { gBootMode &= ~kBootModeQuiet; + safe_set_env(envgBootMode,gBootMode); + timeout = 0; } // If user typed 'v' or 'V', boot in verbose mode. @@ -617,10 +662,12 @@ clearScreenRows(0, kScreenLastRow); if (!(gBootMode & kBootModeQuiet)) { // Display banner and show hardware info. - printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024); + char * bootBanner = (char*)(uint32_t)get_env(envBootBanner); + + printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024); } changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0); - verbose("Scanning device %x...", gBIOSDev); + msglog("Scanning device %x...", (uint32_t)get_env(envgBIOSDev)); // When booting from CD, default to hard drive boot when possible. if (isCDROM && firstRun) { @@ -628,20 +675,20 @@ char *prompt = NULL; char *name = NULL; int cnt; - int optionKey; - if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) { + if (getValueForKey(kCDROMPromptKey, &val, &cnt, DEFAULT_BOOT_CONFIG)) { prompt = malloc(cnt + 1); strncat(prompt, val, cnt); } else { name = malloc(80); getBootVolumeDescription(gBootVolume, name, 79, false); - prompt = malloc(256); - sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name); + prompt = malloc(256); + + sprintf(prompt, "Press ENTER to start up from %s, or press any key to enter startup options.", name); free(name); } - if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) { + if (getIntForKey( kCDROMOptionKey, &optionKey, DEFAULT_BOOT_CONFIG )) { // The key specified is a special key. } else { // Default to F8. @@ -652,7 +699,7 @@ // early catch of F8 which means the user wants to set boot options // which we ought to interpret as meaning he wants to boot the CD. if (timeout != 0) { - key = countdown(prompt, kMenuTopRow, timeout); + key = countdown(prompt, kMenuTopRow, timeout, &optionKey); } else { key = optionKey; } @@ -663,51 +710,74 @@ clearScreenRows( kMenuTopRow, kMenuTopRow + 2 ); - // Hit the option key ? - if (key == optionKey) { - gBootMode &= ~kBootModeQuiet; - timeout = 0; - } else { - key = key & 0xFF; - - // Try booting hard disk if user pressed 'h' - if (biosDevIsCDROM(gBIOSDev) && key == 'h') { - BVRef bvr; - - // Look at partitions hosting OS X other than the CD-ROM - for (bvr = bvChain; bvr; bvr=bvr->next) { - if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev) { - gBootVolume = bvr; - } - } - } - goto done; - } + do { + // Hit the option key ? + if (key == optionKey) { + + if (key != 0x1C0D) { + gBootMode &= ~kBootModeQuiet; + safe_set_env(envgBootMode,gBootMode); + timeout = 0; + break; + } + + } + + key = key & 0xFF; + + // Try booting hard disk if user pressed 'h' + if (biosDevIsCDROM((int)get_env(envgBIOSDev)) && key == 'h') { + BVRef bvr; + + // Look at partitions hosting OS X other than the CD-ROM + for (bvr = getBvChain(); bvr; bvr=bvr->next) { + if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != (int)get_env(envgBIOSDev)) { + gBootVolume = bvr; + } + } + } + goto done; + + } while (0); + } - if (gBootMode & kBootModeQuiet) { + if (get_env(envgBootMode) & kBootModeQuiet) { // No input allowed from user. goto done; } - if (firstRun && timeout > 0 && countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0) { - // If the user is holding down a modifier key, - // enter safe mode. - if ((readKeyboardShiftFlags() & 0x0F) != 0) { - gBootMode |= kBootModeSafe; - } - goto done; + if (firstRun && timeout > 0 ) { + + key = countdown("Press ENTER to start up, or press any key to enter startup options.", kMenuTopRow, timeout, &optionKey); + + if (key == 0x1C0D) { + goto done; + + } + else if (key == 0) + { + // If the user is holding down a modifier key, + // enter safe mode. + + if ((readKeyboardShiftFlags() & 0x0F) != 0) { + gBootMode |= kBootModeSafe; + safe_set_env(envgBootMode,gBootMode); + } + goto done; + } } - - if (gDeviceCount) { + int devcnt = (int)get_env(envgDeviceCount); + + if (devcnt) { // Allocate memory for an array of menu items. - menuItems = malloc(sizeof(MenuItem) * gDeviceCount); + menuItems = malloc(sizeof(MenuItem) * devcnt); if (menuItems == NULL) { goto done; } // Associate a menu item for each BVRef. - for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) { + for (bvr=getBvChain(), i=devcnt-1, selectIndex=0; bvr; bvr=bvr->next) { if (bvr->visible) { getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true); menuItems[i].param = (void *) bvr; @@ -726,20 +796,21 @@ nextRow = kMenuTopRow; showPrompt = true; - if (gDeviceCount) { + if (devcnt) { printf("Use \30\31 keys to select the startup volume."); - showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems ); - nextRow += min( gDeviceCount, kMenuMaxItems ) + 3; + showMenu( menuItems, devcnt, selectIndex, kMenuTopRow + 2, kMenuMaxItems ); + nextRow += min( devcnt, kMenuMaxItems ) + 3; } // Show the boot prompt. - showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot); + showPrompt = (devcnt == 0) || (menuBVR->flags & kBVFlagNativeBoot); showBootPrompt( nextRow, showPrompt ); - do { + do { + key = getc(); updateMenu( key, (void **) &menuBVR ); - newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot); + newShowPrompt = (devcnt == 0) || (menuBVR->flags & kBVFlagNativeBoot); if (newShowPrompt != showPrompt) { @@ -748,10 +819,10 @@ } if (showPrompt) - { + { updateBootArgs(key); - } - + } + switch (key) { case kReturnKey: if (*gBootArgs == '?') { @@ -792,9 +863,9 @@ } else if (strcmp(booterCommand, "norescan") == 0) { - if (gEnableCDROMRescan) + if (get_env(envgEnableCDROMRescan)) { - gEnableCDROMRescan = false; + safe_set_env(envgEnableCDROMRescan,false); break; } } @@ -809,7 +880,7 @@ } gBootVolume = menuBVR; setRootVolume(menuBVR); - gBIOSDev = menuBVR->biosdev; + safe_set_env(envgBIOSDev,menuBVR->biosdev); break; case kEscapeKey: @@ -821,16 +892,16 @@ // Clear gBootVolume to restart the loop // if the user enabled rescanning the optical drive. // Otherwise boot the default boot volume. - if (gEnableCDROMRescan) { + if (get_env(envgEnableCDROMRescan)) { gBootVolume = NULL; clearBootArgs(); } break; case kF10Key: - gScanSingleDrive = false; + safe_set_env(envgScanSingleDrive, false); #if UNUSED - scanDisks(gBIOSDev, &bvCount); + scanDisks((int)get_env(envgBIOSDev), &bvCount); #else scanDisks(); #endif @@ -849,7 +920,8 @@ clearScreenRows(kMenuTopRow, kScreenLastRow); changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0); } - shouldboot = false; + safe_set_env(envShouldboot, false); + if (menuItems) { free(menuItems); menuItems = NULL; @@ -888,11 +960,16 @@ return true; } -int ArgCntRemaining; - int -processBootOptions() +processBootOptions(void) { + char *cp_cache = (char*)(uint32_t)get_env(envgBootArgs); + if (cp_cache) + { + bzero(gBootArgs,sizeof(gBootArgs)); + strlcpy(gBootArgs, cp_cache,sizeof(gBootArgs)); + } + const char * cp = gBootArgs; const char * val = 0; const char * kernel; @@ -900,7 +977,8 @@ int userCnt; char * argP; char * configKernelFlags; - + int ArgCntRemaining; + skipblanks( &cp ); // Update the unit and partition number. @@ -942,14 +1020,18 @@ // and use its contents to override default bootConfig. // This is not a mandatory opeartion anymore. - loadOverrideConfig(&bootInfo->overrideConfig); + loadOverrideConfig(); // Load System com.apple.boot.plist config file - loadSystemConfig(&bootInfo->SystemConfig); + loadSystemConfig(); #if virtualM || PCI_FIX // we can simply make an option for this fix addBootArg("npci=0x2000"); + #endif +#if verbose + addBootArg("-v"); +#endif // Use the kernel name specified by the user, or fetch the name // in the config table, or use the default if not specified. @@ -958,18 +1040,24 @@ // overriding the kernel, which causes the kernelcache not // to be used. - gOverrideKernel = false; + safe_set_env(envgOverrideKernel,false); if (( kernel = extractKernelName((char **)&cp) )) { - strlcpy( bootInfo->bootFile, kernel, sizeof(bootInfo->bootFile)+1 ); - gOverrideKernel = true; + strlcpy( bootInfo->bootFile, kernel, sizeof(bootInfo->bootFile) ); + safe_set_env(envgOverrideKernel,true); + } else { - if ( getValueForKey( kKernelNameKey, &val, &cnt, &bootInfo->bootConfig ) ) { - strlcpy( bootInfo->bootFile, val, cnt+1 ); + if ( getValueForKey( kKernelNameKey, &val, &cnt, DEFAULT_BOOT_CONFIG ) ) { + strlcpy( bootInfo->bootFile, val, sizeof(bootInfo->bootFile) ); if (strcmp( bootInfo->bootFile, kDefaultKernel ) != 0) { - gOverrideKernel = true; + safe_set_env(envgOverrideKernel,true); } - } else { - strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile)+1 ); + } else if (gBootVolume->kernelfound == true) { + strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile) ); + } else { + + printf("No kernel found on this volume : hd(%d,%d)\n", BIOS_DEV_UNIT(gBootVolume), gBootVolume->part_no); + sleep(1); + return -1; } } @@ -978,7 +1066,7 @@ // Get config table kernel flags, if not ignored. if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) || - !getValueForKey( kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig )) { + !getValueForKey( kKernelFlagsKey, &val, &cnt, DEFAULT_BOOT_CONFIG )) { val = ""; cnt = 0; } @@ -993,7 +1081,7 @@ if (!getValueForBootKey(cp, kSafeModeFlag, &val, &cnt) && (isSafeMode == false)) { - if (gBootMode & kBootModeSafe) { + if (get_env(envgBootMode) & kBootModeSafe) { copyArgument(0, kSafeModeFlag, strlen(kSafeModeFlag), &argP, &ArgCntRemaining); } } @@ -1022,29 +1110,34 @@ strncpy(&argP[cnt], cp, userCnt); argP[cnt+userCnt] = '\0'; - if(!shouldboot) + if(!get_env(envShouldboot)) { - gVerboseMode = getValueForKey( kVerboseModeFlag, &val, &cnt, &bootInfo->bootConfig ) || - getValueForKey( kSingleUserModeFlag, &val, &cnt, &bootInfo->bootConfig ); + gVerboseMode = getValueForKey( kVerboseModeFlag, &val, &cnt, DEFAULT_BOOT_CONFIG ) || + getValueForKey( kSingleUserModeFlag, &val, &cnt, DEFAULT_BOOT_CONFIG ); - gBootMode = ( getValueForKey( kSafeModeFlag, &val, &cnt, &bootInfo->bootConfig ) ) ? + long gBootMode = ( getValueForKey( kSafeModeFlag, &val, &cnt, DEFAULT_BOOT_CONFIG ) ) ? kBootModeSafe : kBootModeNormal; - - if ( getValueForKey( kIgnoreCachesFlag, &val, &cnt, &bootInfo->bootConfig ) ) { + safe_set_env(envgBootMode,gBootMode); + + + if ( getValueForKey( kIgnoreCachesFlag, &val, &cnt, DEFAULT_BOOT_CONFIG ) ) { gBootMode = kBootModeSafe; + safe_set_env(envgBootMode,gBootMode); + } } - if ( getValueForKey( kMKextCacheKey, &val, &cnt, &bootInfo->bootConfig ) ) + if ( getValueForKey( kMKextCacheKey, &val, &cnt, DEFAULT_BOOT_CONFIG ) ) { - strlcpy(gMKextName, val, cnt + 1); + char * MKextName = (char*)(uint32_t)get_env(envMKextName); + strlcpy(MKextName,val,Cache_len_name); } if (configKernelFlags) { free(configKernelFlags); } - + safe_set_env(envArgCntRemaining,ArgCntRemaining); return 0; } Index: branches/cparm/i386/boot2/Makefile =================================================================== --- branches/cparm/i386/boot2/Makefile (revision 1839) +++ branches/cparm/i386/boot2/Makefile (revision 1840) @@ -9,7 +9,7 @@ include ../MakePaths.dir OPTIM = -Os -Oz -CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror -fstack-protector-all \ +CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror -fno-stack-protector \ -fno-builtin -DSAIO_INTERNAL_USER -static $(OMIT_FRAME_POINTER_CFLAG) \ -mpreferred-stack-boundary=2 -fno-align-functions \ -march=pentium4 -msse2 -mfpmath=sse -msoft-float @@ -39,8 +39,7 @@ # The ordering is important; # boot2.o must be first. -OBJS = boot2.o boot.o graphics.o drivers.o prompt.o options.o lzss.o mboot.o \ - modules.o +OBJS = boot2.o boot.o graphics.o drivers.o prompt.o options.o mboot.o # button.o browser.o scrollbar.o == NOTYET UTILDIR = ../util Index: branches/cparm/i386/modules/NetbookInstaller/NBI.c =================================================================== --- branches/cparm/i386/modules/NetbookInstaller/NBI.c (revision 1839) +++ branches/cparm/i386/modules/NetbookInstaller/NBI.c (revision 1840) @@ -8,10 +8,11 @@ #include #include "libsaio.h" +#include "boot.h" #include "sl.h" -#include "boot.h" #include "bootstruct.h" +#include "platform.h" #include "xml.h" #include "drivers.h" #include "modules.h" @@ -38,18 +39,15 @@ #endif extern long LoadMatchedModules( void ); extern long InitDriverSupport(void); -extern char * gExtensionsSpec; -extern char * gDriverSpec; -extern char * gFileSpec; -extern char * gTempSpec; -extern char * gFileName; +extern long GetDriverGbl(void); #define kEnableNBI "EnableNBIModule" -void NetbookInstaller_start() +void NetbookInstaller_start(void); +void NetbookInstaller_start(void) { bool enable = true; - getBoolForKey(kEnableNBI, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableNBI, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) register_hook_callback("PreBoot", &NBI_PreBoot_hook); @@ -114,7 +112,7 @@ - if (!runNetbookInstaller && getBoolForKey("recovery", &dummyVal, &bootInfo->bootConfig) && dummyVal) + if (!runNetbookInstaller && getBoolForKey("recovery", &dummyVal, DEFAULT_BOOT_CONFIG) && dummyVal) { if(dummyVal) runNetbookInstaller = 2; } @@ -122,13 +120,13 @@ if(runNetbookInstaller) { - replace_function("_LoadDrivers", &NBI_LoadDrivers); + replace_system_function("_LoadDrivers", &NBI_LoadDrivers); if(runNetbookInstaller == 1 ) { if (execute_hook("isRamDiskRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { - replace_function("_md0Ramdisk", &NBI_md0Ramdisk); + replace_function_any("_md0Ramdisk", &NBI_md0Ramdisk); } else { @@ -252,21 +250,24 @@ } } #endif - - if (gMKextName[0] != '\0') + char * MKextName = (char*)(uint32_t)get_env(envMKextName); + + if (MKextName[0] != '\0') { - verbose("LoadDrivers: Loading from [%s]\n", gMKextName); - if ( LoadDriverMKext(gMKextName) != 0 ) + verbose("LoadDrivers: Loading from [%s]\n", MKextName); + if ( LoadDriverMKext(MKextName) != 0 ) { - error("Could not load %s\n", gMKextName); + error("Could not load %s\n", MKextName); return -1; } } else { - strcpy(gExtensionsSpec, dirSpec); - strcat(gExtensionsSpec, "System/Library/"); - FileLoadDrivers(gExtensionsSpec, 0); + char * ExtensionsSpec = (char*)(uint32_t)get_env(envDriverExtSpec); + + strcpy(ExtensionsSpec, dirSpec); + strcat(ExtensionsSpec, "System/Library/"); + FileLoadDrivers(ExtensionsSpec, 0); } } else Index: branches/cparm/i386/modules/NetbookInstaller/Makefile =================================================================== --- branches/cparm/i386/modules/NetbookInstaller/Makefile (revision 1839) +++ branches/cparm/i386/modules/NetbookInstaller/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -NBI_OBJS = NBI.o +NBI_OBJS = NBI.o stack_protector.o SFILES = @@ -76,6 +76,10 @@ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + NBI.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "NBI.c" $(INC) -o "$(OBJROOT)/NBI.o" Index: branches/cparm/i386/modules/RamDiskLoader/ramdisk.h =================================================================== --- branches/cparm/i386/modules/RamDiskLoader/ramdisk.h (revision 1839) +++ branches/cparm/i386/modules/RamDiskLoader/ramdisk.h (revision 1840) @@ -7,8 +7,8 @@ #ifndef __BOOT_RAMDISK_H #define __BOOT_RAMDISK_H +#include "boot.h" #include "drivers.h" -#include "boot.h" //#include "mboot.h" #define RAMDISKCONFIG_FILENAME "rd(0,0)/RAMDisk.plist" @@ -40,6 +40,7 @@ extern void setRAMDiskBTHook(bool mode); extern int mountRAMDisk(const char * param); extern void processRAMDiskCommand(char ** argPtr, const char * cmd); -extern int loadPrebootRAMDisk(); - +extern int loadPrebootRAMDisk(void); +extern void showInfoRAMDisk(void); +extern void umountRAMDisk(void); #endif /* !__BOOT_RAMDISK_H */ Index: branches/cparm/i386/modules/RamDiskLoader/RamDiskLoader.c =================================================================== --- branches/cparm/i386/modules/RamDiskLoader/RamDiskLoader.c (revision 1839) +++ branches/cparm/i386/modules/RamDiskLoader/RamDiskLoader.c (revision 1840) @@ -7,7 +7,6 @@ * */ -#include "boot.h" #include "libsaio.h" #include "bootstruct.h" #include "modules.h" @@ -17,6 +16,14 @@ #define kEnableEDL "EnableRamDiskLoader" +void loadPrebootRAMDisk_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void md0Ramdisk_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void processRAMDiskCommand_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void ramDiskLoadDrivers_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void newRamDisk_BVR_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void p_get_ramdisk_info_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void p_ramdiskReadBytes_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void is_Ram_Disk_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); enum { @@ -54,7 +61,7 @@ break; case 1: // First try a specfic OS version folder ie 10.5 - sprintf(dirSpecExtra, "rd(0,0)/Extra/%s/", &gBootVolume->OSVersion); + sprintf(dirSpecExtra, "rd(0,0)/Extra/%s/", (char*)gBootVolume->OSVersion); if (FileLoadDrivers(dirSpecExtra, 0) != 0) { // Next we'll try the base @@ -64,7 +71,7 @@ break; case 2: // First try a specfic OS version folder ie 10.5 - sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gBootVolume->OSVersion); + sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", (char*)gBootVolume->OSVersion); if (FileLoadDrivers(dirSpecExtra, 0) != 0) { // Next we'll try the base @@ -125,11 +132,11 @@ void is_Ram_Disk_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){} - -void RamDiskLoader_start() +void RamDiskLoader_start(void); +void RamDiskLoader_start(void) { bool enable = true; - getBoolForKey(kEnableEDL, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableEDL, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) { Index: branches/cparm/i386/modules/RamDiskLoader/ramdisk.c =================================================================== --- branches/cparm/i386/modules/RamDiskLoader/ramdisk.c (revision 1839) +++ branches/cparm/i386/modules/RamDiskLoader/ramdisk.c (revision 1840) @@ -4,13 +4,15 @@ * */ -#include "boot.h" +#include "libsaio.h" #include "bootstruct.h" #include "multiboot.h" #include "ramdisk.h" struct multiboot_info * gRAMDiskMI = NULL; +config_file_t ramdiskConfig; + // gRAMDiskVolume holds the bvr for the mounted ramdisk image. BVRef gRAMDiskVolume = NULL; bool gRAMDiskBTAliased = false; @@ -39,7 +41,7 @@ int len; if(getValueForKey(kMD0Image, &override_filename, &len, - &bootInfo->bootConfig)) + DEFAULT_BOOT_CONFIG)) { // Use user specified md0 file sprintf(filename, "%s", override_filename); @@ -124,7 +126,7 @@ } } -void umountRAMDisk() +void umountRAMDisk(void) { if (gRAMDiskMI != NULL) { @@ -221,9 +223,9 @@ // Reading ramdisk configuration. strcpy(dirSpec, RAMDISKCONFIG_FILENAME); - if (loadConfigFile(dirSpec, &bootInfo->ramdiskConfig) == 0) + if (loadConfigFile(dirSpec, &ramdiskConfig) == 0) { - getBoolForKey("BTAlias", &gRAMDiskBTAliased, &bootInfo->ramdiskConfig); + getBoolForKey("BTAlias", &gRAMDiskBTAliased, &ramdiskConfig); } else { @@ -264,7 +266,7 @@ printf("\nalias: %s", gRAMDiskBTAliased ? "enabled" : "disabled"); // Display ramdisk information if available. - if (getValueForKey("Info", &val, &len, &bootInfo->ramdiskConfig)) + if (getValueForKey("Info", &val, &len, &ramdiskConfig)) { printf("\ninfo: %s", val); } @@ -279,7 +281,7 @@ } } -int loadPrebootRAMDisk() +int loadPrebootRAMDisk(void) { mountRAMDisk("bt(0,0)/Extra/Preboot.dmg"); if (gRAMDiskMI != NULL) Index: branches/cparm/i386/modules/RamDiskLoader/Makefile =================================================================== --- branches/cparm/i386/modules/RamDiskLoader/Makefile (revision 1839) +++ branches/cparm/i386/modules/RamDiskLoader/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -RDL_OBJS = ramdisk.o RamDiskLoader.o +RDL_OBJS = ramdisk.o RamDiskLoader.o stack_protector.o SFILES = CFILES = @@ -70,11 +70,16 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/ramdisk.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/ramdisk.o \ $(OBJROOT)/RamDiskLoader.o \ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + RamDiskLoader.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "RamDiskLoader.c" $(INC) -o "$(OBJROOT)/RamDiskLoader.o" Index: branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c =================================================================== --- branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c (revision 1839) +++ branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c (revision 1840) @@ -5,7 +5,6 @@ #include "libsaio.h" #include "modules.h" -#include "boot.h" #include "bootstruct.h" #include "pci.h" #include "device_inject.h" @@ -21,6 +20,7 @@ #endif #define kEnableSATA "EnableSATAModule" +void SATA_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); uint8_t default_SATA_ID[]= { 0x81, 0x26, 0x00, 0x00 @@ -59,10 +59,11 @@ } -void YellowIconFixer_start() +void YellowIconFixer_start(void); +void YellowIconFixer_start(void) { bool enable = true; - getBoolForKey(kEnableSATA, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableSATA, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) { Index: branches/cparm/i386/modules/YellowIconFixer/Makefile =================================================================== --- branches/cparm/i386/modules/YellowIconFixer/Makefile (revision 1839) +++ branches/cparm/i386/modules/YellowIconFixer/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -SATA_OBJS = YellowIconFixer.o +SATA_OBJS = YellowIconFixer.o stack_protector.o SFILES = @@ -71,9 +71,13 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/YellowIconFixer.o -o $(SYMROOT)/$(MODULE_NAME).dylib + $(OBJROOT)/stack_protector.o $(OBJROOT)/YellowIconFixer.o -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + YellowIconFixer.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "YellowIconFixer.c" $(INC) -o "$(OBJROOT)/YellowIconFixer.o" Index: branches/cparm/i386/modules/KextPatcher/kext_patcher.c =================================================================== --- branches/cparm/i386/modules/KextPatcher/kext_patcher.c (revision 1839) +++ branches/cparm/i386/modules/KextPatcher/kext_patcher.c (revision 1840) @@ -11,7 +11,6 @@ #include "libsaio.h" #include "zlib.h" #include "kext_patcher.h" -#include "boot.h" #include "bootstruct.h" #include "pci.h" #include "drivers.h" @@ -170,7 +169,7 @@ const char* hda_codec; int len = 0; - if (getValueForKey(kHDACodec, &hda_codec, &len, &bootInfo->bootConfig)) + if (getValueForKey(kHDACodec, &hda_codec, &len, DEFAULT_BOOT_CONFIG)) { int index = 0; while(len) Index: branches/cparm/i386/modules/KextPatcher/Makefile =================================================================== --- branches/cparm/i386/modules/KextPatcher/Makefile (revision 1839) +++ branches/cparm/i386/modules/KextPatcher/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -KEXT_OBJS = kext_patcher.o inflate.o deflate.o zutil.o inftrees.o inffast.o adler32.o hex_editor.o trees.o +KEXT_OBJS = kext_patcher.o inflate.o deflate.o zutil.o inftrees.o inffast.o adler32.o hex_editor.o trees.o stack_protector.o SFILES = @@ -75,6 +75,10 @@ -weak_library $(SYMROOT)/Symbols.dylib \ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + kext_patcher.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "kext_patcher.c" $(INC) -o "$(OBJROOT)/kext_patcher.o" Index: branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.c =================================================================== --- branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.c (revision 1839) +++ branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.c (revision 1840) @@ -8,7 +8,6 @@ */ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" #include "acpi.h" #include "efi_tables.h" @@ -42,6 +41,14 @@ extern EFI_GUID gEfiAcpiTableGuid; extern EFI_GUID gEfiAcpi20TableGuid; +struct acpi_2_fadt * +patch_fadt(struct acpi_2_fadt *fadt, struct acpi_2_dsdt *new_dsdt, bool UpdateFADT); +struct acpi_2_gas FillGASStruct(uint32_t Address, uint8_t Length); +struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt); +struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt); +void get_acpi_cpu_names(unsigned char* dsdt, uint32_t length); +void *loadACPITable(char *key); +void *loadSSDTTable(int ssdt_number); #define tableSign(table, sgn) (table[0]==sgn[0] && table[1]==sgn[1] && table[2]==sgn[2] && table[3]==sgn[3]) @@ -255,7 +262,7 @@ // Rek: if user specified a full path name then take it in consideration if (getValueForKey(kSSDT, &overriden_pathname, &len, - &bootInfo->bootConfig)) + DEFAULT_BOOT_CONFIG)) { sprintf(filename, "%s-%d.aml", overriden_pathname, ssdt_number); // start searching root } @@ -318,7 +325,7 @@ // Rek: if user specified a full path name then take it in consideration if (getValueForKey(key, &overriden_pathname, &len, - &bootInfo->bootConfig)) + DEFAULT_BOOT_CONFIG)) { sprintf(filename, "%s", overriden_pathname); } @@ -433,7 +440,7 @@ 0x00, 0x00, 0x00, 0x79, 0x00 }; - if (Platform->CPU.Vendor != 0x756E6547) { + if (get_env(envVendor) != CPUID_VENDOR_INTEL) { verbose ("Not an Intel platform: C-States will not be generated !!!\n"); return NULL; } @@ -459,12 +466,12 @@ bool c3_enabled = fadt->C3_Latency < 1000; bool c4_enabled = false; - getBoolForKey(kEnableC4State, &c4_enabled, &bootInfo->bootConfig); + getBoolForKey(kEnableC4State, &c4_enabled, DEFAULT_BOOT_CONFIG); unsigned char cstates_count = 1 + (c2_enabled ? 1 : 0) + ((c3_enabled || c4_enabled) ? 1 : 0); char *Lat = NULL, *Pw = NULL, *tmpstr =NULL; int base = 16; - TagPtr personality = XMLCastDict(XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"C-States")); + TagPtr personality = XMLCastDict(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"C-States")); if ((tmpstr = XMLCastString(XMLGetProperty(personality, (const char*)"Base")))) { @@ -596,12 +603,12 @@ 0x31, 0x03, 0x10, 0x20, /* 1.._ */ }; - if (Platform->CPU.Vendor != 0x756E6547) { + if (get_env(envVendor) != CPUID_VENDOR_INTEL) { verbose ("Not an Intel platform: P-States will not be generated !!!\n"); return NULL; } - if (!(Platform->CPU.Features & CPUID_FEATURE_MSR)) { + if (!(get_env(envFeatures) & CPUID_FEATURE_MSR)) { verbose ("Unsupported CPU: P-States will not be generated !!!\n"); return NULL; } @@ -615,10 +622,10 @@ uint8_t p_states_count = 0; // Retrieving P-States, ported from code by superhai (c) - switch (Platform->CPU.Family) { + switch (get_env(envFamily)) { case 0x06: { - switch (Platform->CPU.Model) + switch (get_env(envModel)) { case CPUID_MODEL_DOTHAN: // ? case CPUID_MODEL_YONAH: // Yonah @@ -705,6 +712,8 @@ vidstep = ((maximum.VID << 2) - (minimum.VID << 2)) / (p_states_count - 1); + uint32_t fsb = (uint32_t)get_env(envFSBFreq) / 1000000; + for (u = 0; u < p_states_count; u++) { i = u - invalid; @@ -730,7 +739,7 @@ uint32_t multiplier = p_states[i].FID & 0x1f; // = 0x08 bool half = p_states[i].FID & 0x40; // = 0x01 bool dfsb = p_states[i].FID & 0x80; // = 0x00 - uint32_t fsb = Platform->CPU.FSBFrequency / 1000000; // = 400 + //uint32_t fsb = Platform->CPU.FSBFrequency / 1000000; // = 400 uint32_t halffsb = (fsb + 1) >> 1; // = 200 uint32_t frequency = (multiplier * fsb); // = 3200 @@ -766,12 +775,12 @@ { uint8_t i; p_states_count = 0; - + uint64_t fsb = (get_env(envFSBFreq) / 1000000); for (i = maximum.Control; i >= minimum.Control; i--) { p_states[p_states_count].Control = i; p_states[p_states_count].CID = p_states[p_states_count].Control << 1; - p_states[p_states_count].Frequency = (Platform->CPU.FSBFrequency / 1000000) * i; + p_states[p_states_count].Frequency = (uint32_t) fsb * i; p_states_count++; } } @@ -798,20 +807,24 @@ struct aml_chunk* name = aml_add_name(scop, "PSS_"); struct aml_chunk* pack = aml_add_package(name); - uint8_t minPSratio = (p_states[p_states_count-1].Frequency / (Platform->CPU.FSBFrequency / 10000000 )); - uint8_t maxPSratio = (p_states[0].Frequency / (Platform->CPU.FSBFrequency / 10000000 )); + uint64_t FSBFreq = get_env(envFSBFreq); - uint8_t cpu_div = Platform->CPU.CurrDiv; + uint8_t minPSratio = (p_states[p_states_count-1].Frequency / (FSBFreq / 10000000 )); + uint8_t maxPSratio = (p_states[0].Frequency / (FSBFreq / 10000000 )); + + uint8_t cpu_div = (uint8_t)get_env(envCurrDiv); + uint8_t cpu_coef = (uint8_t)get_env(envCurrCoef); + uint8_t cpu_ratio = 0; if (cpu_div) - cpu_ratio = (Platform->CPU.CurrCoef * 10) + 5; + cpu_ratio = (cpu_coef * 10) + 5; else - cpu_ratio = Platform->CPU.CurrCoef * 10; + cpu_ratio = cpu_coef * 10; int user_max_ratio = 0; - getIntForKey(kMaxRatio, &user_max_ratio, &bootInfo->bootConfig); + getIntForKey(kMaxRatio, &user_max_ratio, DEFAULT_BOOT_CONFIG); if (user_max_ratio >= minPSratio && maxPSratio >= user_max_ratio) { uint8_t maxcurrdiv = 0, maxcurrcoef = (int)(user_max_ratio / 10); @@ -827,7 +840,7 @@ } int user_min_ratio = 0; - getIntForKey(kMinRatio, &user_min_ratio, &bootInfo->bootConfig); + getIntForKey(kMinRatio, &user_min_ratio, DEFAULT_BOOT_CONFIG); if (user_min_ratio >= minPSratio && cpu_ratio >= user_min_ratio) { uint8_t mincurrdiv = 0, mincurrcoef = (int)(user_min_ratio / 10); @@ -846,7 +859,7 @@ if (maxPSratio >= cpu_ratio && cpu_ratio >= minPSratio) maxPSratio = cpu_ratio; - TagPtr personality = XMLCastDict(XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"P-States")); + TagPtr personality = XMLCastDict(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"P-States")); char* MatchStat = 0; int dropPSS = 0, Pstatus = 0, base = 16; int expert = 0;/* Default: 0 , mean mixed mode | expert mode : 1 , mean add only p-states found in boot.plist*/ @@ -868,6 +881,8 @@ base = mybase; } + uint64_t fsb = (get_env(envFSBFreq) / 10000000 ); + for (i = 0; i < p_states_count; i++) { sprintf(MatchStat, "%d",i); @@ -897,7 +912,7 @@ if (!Frequency || Frequency > p_states[0].Frequency ) continue; - uint8_t curr_ratio = (Frequency / (Platform->CPU.FSBFrequency / 10000000 )); + uint8_t curr_ratio = (uint8_t)(Frequency / fsb); if (curr_ratio > maxPSratio || minPSratio > curr_ratio) goto dropPstate; @@ -996,9 +1011,9 @@ bool msiOff = true; // Restart Fix - if (Platform->CPU.Vendor == 0x756E6547) { /* Intel */ + if (get_env(envVendor) == CPUID_VENDOR_INTEL) { /* Intel */ fix_restart = true; - getBoolForKey(kRestartFix, &fix_restart, &bootInfo->bootConfig); + getBoolForKey(kRestartFix, &fix_restart, DEFAULT_BOOT_CONFIG); } else { verbose ("Not an Intel platform: Restart Fix not applied !!!\n"); @@ -1011,8 +1026,8 @@ if ((UpdateFADT) && (((fadt_file) && (fadt_file->Length < sizeof(struct acpi_2_fadt))) || ((!fadt_file) && (fadt->Length < sizeof(struct acpi_2_fadt))))) { - getBoolForKey(kDisableMSI, &msiOff, &bootInfo->bootConfig) ; - getBoolForKey(kDisableASPM, &aspmOff, &bootInfo->bootConfig); + getBoolForKey(kDisableMSI, &msiOff, DEFAULT_BOOT_CONFIG) ; + getBoolForKey(kDisableASPM, &aspmOff, DEFAULT_BOOT_CONFIG); if (fadt_file) { @@ -1096,38 +1111,38 @@ // Determine system type / PM_Model // Fix System-type if needed (should never happen) - if (Platform->Type > MaxSupportedPMProfile) + if (get_env(envType) > MaxSupportedPMProfile) { if(fadt_mod->PM_Profile <= MaxSupportedPMProfile) - Platform->Type = fadt_mod->PM_Profile; // get the fadt if correct + safe_set_env(envType,fadt_mod->PM_Profile); // get the fadt if correct else - Platform->Type = 1; /* Set a fixed value (Desktop) */ + safe_set_env(envType, 1); /* Set a fixed value (Desktop) */ } // If needed, set System-type from PM_Profile (if valid) else set PM_Profile with a fixed the System-type // Give prior to the FADT pm profile, allow to also control this value with a patched FADT table - if (fadt_mod->PM_Profile != Platform->Type) + if (fadt_mod->PM_Profile != get_env(envType)) { bool val = false; - getBoolForKey("PreferInternalProfileDetect", &val, &bootInfo->bootConfig); // if true Give prior to the profile resolved trought the CPU model + getBoolForKey("PreferInternalProfileDetect", &val, DEFAULT_BOOT_CONFIG); // if true Give prior to the profile resolved trought the CPU model - val = Platform->CPU.isServer ; + val = get_env(envIsServer) ; if (fadt_mod->PM_Profile <= MaxSupportedPMProfile && !val) { - Platform->Type = fadt_mod->PM_Profile; + safe_set_env(envType, fadt_mod->PM_Profile); } else { - fadt_mod->PM_Profile = Platform->Type; + fadt_mod->PM_Profile = (uint8_t)get_env(envType); } } // Set PM_Profile and System-type if user wanted this value to be forced - if ( (value=getStringForKey("SystemType", &bootInfo->bootConfig))!=NULL) { + if ( (value=getStringForKey("SystemType", DEFAULT_BOOT_CONFIG))!=NULL) { if ((Type = (unsigned char) strtoul(value, NULL, 10) ) <= MaxSupportedPMProfile) { - verbose("FADT: changing Preferred_PM_Profile from 0x%02x to 0x%02x\n", fadt->PM_Profile, Type); - fadt_mod->PM_Profile = Platform->Type = Type; - } else verbose("Error: system-type must be 0..6. Defaulting to %d !\n", Platform->Type); + verbose("FADT: changing Preferred_PM_Profile from 0x%02x to 0x%02x\n", fadt->PM_Profile, Type); + safe_set_env(envType,(fadt_mod->PM_Profile = Type)); + } else verbose("Error: system-type must be 0..6. Defaulting to %d !\n", (uint8_t)get_env(envType)); } // Patch FADT to fix restart @@ -1158,12 +1173,11 @@ if ((uint32_t)(&(fadt_mod->X_FIRMWARE_CTRL))-(uint32_t)fadt_mod+8<=fadt_mod->Length) fadt_mod->X_FIRMWARE_CTRL=(uint32_t)fadt->FIRMWARE_CTRL; - Platform->hardware_signature = ((struct acpi_2_facs *)fadt->FIRMWARE_CTRL)->hardware_signature; + + safe_set_env(envHardwareSignature,((struct acpi_2_facs *)fadt->FIRMWARE_CTRL)->hardware_signature); - DBG("setting hardware_signature to %x \n",Platform->hardware_signature); - - - + DBG("setting hardware_signature to %x \n",(uint32_t)get_env(envHardwareSignature)); + // Patch DSDT Address if we have loaded a DSDT table if(new_dsdt) { @@ -1208,24 +1222,24 @@ { bool tmpval; - oem_dsdt=getBoolForKey(kOEMDSDT, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_ssdt=getBoolForKey(kOEMSSDT, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_hpet=getBoolForKey(kOEMHPET, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_sbst=getBoolForKey(kOEMSBST, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_ecdt=getBoolForKey(kOEMECDT, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_asft=getBoolForKey(kOEMASFT, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_dmar=getBoolForKey(kOEMDMAR, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_apic=getBoolForKey(kOEMAPIC, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_mcfg=getBoolForKey(kOEMMCFG, &tmpval, &bootInfo->bootConfig)&&tmpval; + oem_dsdt=getBoolForKey(kOEMDSDT, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_ssdt=getBoolForKey(kOEMSSDT, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_hpet=getBoolForKey(kOEMHPET, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_sbst=getBoolForKey(kOEMSBST, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_ecdt=getBoolForKey(kOEMECDT, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_asft=getBoolForKey(kOEMASFT, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_dmar=getBoolForKey(kOEMDMAR, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_apic=getBoolForKey(kOEMAPIC, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_mcfg=getBoolForKey(kOEMMCFG, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; - gen_csta=getBoolForKey(kGenerateCStates, &tmpval, &bootInfo->bootConfig)&&tmpval; - gen_psta=getBoolForKey(kGeneratePStates, &tmpval, &bootInfo->bootConfig)&&tmpval; + gen_csta=getBoolForKey(kGenerateCStates, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + gen_psta=getBoolForKey(kGeneratePStates, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; - update_acpi=getBoolForKey(kUpdateACPI, &tmpval, &bootInfo->bootConfig)&&tmpval; + update_acpi=getBoolForKey(kUpdateACPI, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; - quick_ssdt=getBoolForKey(kQSSDT, &tmpval, &bootInfo->bootConfig)&&tmpval; + quick_ssdt=getBoolForKey(kQSSDT, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; - speed_step=getBoolForKey(kSpeedstep, &tmpval, &bootInfo->bootConfig)&&tmpval; + speed_step=getBoolForKey(kSpeedstep, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; } @@ -1286,7 +1300,7 @@ } DBG("New ACPI tables Loaded in memory\n"); - TagPtr DropTables_p = XMLCastDict(XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"ACPIDropTables")); + TagPtr DropTables_p = XMLCastDict(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"ACPIDropTables")); // Do the same procedure for both versions of ACPI for (version=0; version<2; version++) { struct acpi_2_rsdp *rsdp_mod, *rsdp_conv=(struct acpi_2_rsdp *)0; @@ -1371,8 +1385,8 @@ rsdt_entries[i-dropoffset]=rsdt_entries[i]; - char table4[4]; - strlcpy(table4, table, sizeof(table4)+1); + char table4[5]; + strlcpy(table4, table, sizeof(table4)); TagPtr match_drop = XMLGetProperty(DropTables_p, (const char*)table4); if ( match_drop ) { char *tmpstr = XMLCastString(match_drop); @@ -1688,8 +1702,8 @@ xsdt_entries[i-dropoffset]=xsdt_entries[i]; - char table4[4]; - strlcpy(table4, table, sizeof(table4)+1); + char table4[5]; + strlcpy(table4, table, sizeof(table4)); TagPtr match_drop = XMLGetProperty(DropTables_p, (const char*)table4); if ( match_drop ) { char *tmpstr = XMLCastString(match_drop); @@ -1996,26 +2010,14 @@ verbose("Patched ACPI version %d\n", version+1); - if (version) - { - /* XXX aserebln why uint32 cast if pointer is uint64 ? */ - acpi20_p = (uint32_t)rsdp_mod; - if (acpi20_p) - Status = addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20"); - } - else - { - /* XXX aserebln why uint32 cast if pointer is uint64 ? */ - acpi10_p = (uint32_t)rsdp_mod; - if (acpi10_p) - Status = addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI"); - } + + Status = Register_Acpi_Efi(rsdp_mod, version+1); + } #if DEBUG_DSDT printf("Press a key to continue... (DEBUG_DSDT)\n"); getc(); #endif - //return (Status == EFI_SUCCESS) ? 1 : 0; return Status ; } Index: branches/cparm/i386/modules/ACPIPatcher/AcpiPatcher.c =================================================================== --- branches/cparm/i386/modules/ACPIPatcher/AcpiPatcher.c (revision 1839) +++ branches/cparm/i386/modules/ACPIPatcher/AcpiPatcher.c (revision 1840) @@ -10,34 +10,26 @@ #include "libsaio.h" #include "modules.h" -#include "boot.h" #include "bootstruct.h" #include "pci_root.h" #include "acpi_patcher.h" #define kEnableAcpi "EnableAcpiModule" - -void AcpiPatcher_setupEfiConfigurationTable_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) -{ - EFI_STATUS *ret = (EFI_STATUS *)arg1; - - // Setup ACPI (mackerintel's patch) - *ret = setupAcpi(); - -} - +void AcpiPatcher_start(void); +void is_ACPI_Patcher_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); void is_ACPI_Patcher_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){} -void AcpiPatcher_start() +void AcpiPatcher_start(void) { bool enable = true; - getBoolForKey(kEnableAcpi, &enable, &bootInfo->bootConfig); + getBoolForKey(kEnableAcpi, &enable, DEFAULT_BOOT_CONFIG); enable = (execute_hook("isACPIRegistred", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS); if (enable) { - register_hook_callback("setupAcpiEfi", &AcpiPatcher_setupEfiConfigurationTable_hook); + replace_system_function("_setup_acpi",&setupAcpi); + register_hook_callback("isACPIRegistred", &is_ACPI_Patcher_Registred_Hook); } Index: branches/cparm/i386/modules/ACPIPatcher/aml_generator.h =================================================================== --- branches/cparm/i386/modules/ACPIPatcher/aml_generator.h (revision 1839) +++ branches/cparm/i386/modules/ACPIPatcher/aml_generator.h (revision 1840) @@ -61,5 +61,13 @@ void aml_add_multiple_value(struct aml_chunk* parent, uint64_t *lst, int num); void aml_add_ressource_t_fxhw(struct aml_chunk* parent, uint64_t *lst); void aml_add_value(struct aml_chunk* parent, uint64_t val); - +unsigned int aml_fill_simple_name(char* buffer, const char* name); +unsigned int aml_fill_name(struct aml_chunk* node, const char* name); +unsigned char aml_get_size_length(unsigned int size); +unsigned int aml_write_byte(unsigned char value, char* buffer, unsigned int offset); +unsigned int aml_write_word(unsigned int value, char* buffer, unsigned int offset); +unsigned int aml_write_dword(unsigned long value, char* buffer, unsigned int offset); +unsigned int aml_write_qword(unsigned long long value, char* buffer, unsigned int offset); +unsigned int aml_write_buffer(const char* value, unsigned int size, char* buffer, unsigned int offset); +unsigned int aml_write_size(unsigned int size, char* buffer, unsigned int offset); #endif /* !__LIBSAIO_AML_GENERATOR_H */ \ No newline at end of file Index: branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.h =================================================================== --- branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.h (revision 1839) +++ branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.h (revision 1840) @@ -54,7 +54,7 @@ #define kOEMFACS "oemFACS" /* acpi_patcher.c */ #endif -extern EFI_STATUS setupAcpi(); +extern EFI_STATUS setupAcpi(void); struct p_state { Index: branches/cparm/i386/modules/ACPIPatcher/Makefile =================================================================== --- branches/cparm/i386/modules/ACPIPatcher/Makefile (revision 1839) +++ branches/cparm/i386/modules/ACPIPatcher/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -ACPI_PATCHER_OBJS = AcpiPatcher.o aml_generator.o acpi_patcher.o +ACPI_PATCHER_OBJS = AcpiPatcher.o aml_generator.o acpi_patcher.o stack_protector.o SFILES = @@ -71,7 +71,8 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/AcpiPatcher.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/AcpiPatcher.o \ $(OBJROOT)/aml_generator.o \ $(OBJROOT)/acpi_patcher.o \ -o $(SYMROOT)/$(MODULE_NAME).dylib @@ -85,6 +86,10 @@ acpi_patcher.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "acpi_patcher.c" $(INC) -o "$(OBJROOT)/acpi_patcher.o" + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + include ../../MakeInc.dir Index: branches/cparm/i386/modules/GUI/picopng.c =================================================================== --- branches/cparm/i386/modules/GUI/picopng.c (revision 1839) +++ branches/cparm/i386/modules/GUI/picopng.c (revision 1840) @@ -39,7 +39,32 @@ png_alloc_node_t *png_alloc_head = NULL; png_alloc_node_t *png_alloc_tail = NULL; +png_alloc_node_t *png_alloc_find_node(void *addr); +void png_alloc_add_node(void *addr, size_t size); +void png_alloc_remove_node(png_alloc_node_t *node); +void *png_alloc_malloc(size_t size); +void *png_alloc_realloc(void *addr, size_t size); +void png_alloc_free(void *addr); +__unused void vector32_cleanup(vector32_t *p); +uint32_t vector32_resize(vector32_t *p, size_t size); +uint32_t vector32_resizev(vector32_t *p, size_t size, uint32_t value); +void vector32_init(vector32_t *p); +vector32_t *vector32_new(size_t size, uint32_t value); +__unused void vector8_cleanup(vector8_t *p); +uint32_t vector8_resize(vector8_t *p, size_t size); +uint32_t vector8_resizev(vector8_t *p, size_t size, uint8_t value); +void vector8_init(vector8_t *p); +vector8_t *vector8_new(size_t size, uint8_t value); +vector8_t *vector8_copy(vector8_t *p); + + + + + + + + png_alloc_node_t *png_alloc_find_node(void *addr) { png_alloc_node_t *node; @@ -111,7 +136,7 @@ free(addr); } -void png_alloc_free_all() +void png_alloc_free_all(void) { while (png_alloc_tail) { void *addr = png_alloc_tail->addr; @@ -255,7 +280,25 @@ vector32_t *tree2d; } HuffmanTree; -HuffmanTree *HuffmanTree_new() +HuffmanTree *HuffmanTree_new(void); +int HuffmanTree_makeFromLengths(HuffmanTree *tree, const vector32_t *bitlen, uint32_t maxbitlen); +int HuffmanTree_decode(const HuffmanTree *tree, bool *decoded, uint32_t *result, size_t *treepos, + uint32_t bit); +uint32_t Zlib_readBitFromStream(size_t *bitp, const uint8_t *bits); +uint32_t Zlib_readBitsFromStream(size_t *bitp, const uint8_t *bits, size_t nbits); +void Inflator_generateFixedTrees(HuffmanTree *tree, HuffmanTree *treeD); +uint32_t Inflator_huffmanDecodeSymbol(const uint8_t *in, size_t *bp, const HuffmanTree *codetree, + size_t inlength); +void Inflator_getTreeInflateDynamic(HuffmanTree *tree, HuffmanTree *treeD, const uint8_t *in, + size_t *bp, size_t inlength); +void Inflator_inflateHuffmanBlock(vector8_t *out, const uint8_t *in, size_t *bp, size_t *pos, + size_t inlength, uint32_t btype); +void Inflator_inflateNoCompression(vector8_t *out, const uint8_t *in, size_t *bp, size_t *pos, + size_t inlength); +void Inflator_inflate(vector8_t *out, const vector8_t *in, size_t inpos); +int Zlib_decompress(vector8_t *out, const vector8_t *in); + +HuffmanTree *HuffmanTree_new(void) { HuffmanTree *tree = png_alloc_malloc(sizeof (HuffmanTree)); tree->tree2d = NULL; @@ -614,6 +657,22 @@ int PNG_error; +uint32_t PNG_readBitFromReversedStream(size_t *bitp, const uint8_t *bits); +uint32_t PNG_readBitsFromReversedStream(size_t *bitp, const uint8_t *bits, uint32_t nbits); +void PNG_setBitOfReversedStream(size_t *bitp, uint8_t *bits, uint32_t bit); +uint32_t PNG_read32bitInt(const uint8_t *buffer); +int PNG_checkColorValidity(uint32_t colorType, uint32_t bd); +uint32_t PNG_getBpp(const PNG_info_t *info); +void PNG_readPngHeader(PNG_info_t *info, const uint8_t *in, size_t inlength); +int PNG_paethPredictor(int a, int b, int c); +void PNG_unFilterScanline(uint8_t *recon, const uint8_t *scanline, const uint8_t *precon, + size_t bytewidth, uint32_t filterType, size_t length); +void PNG_adam7Pass(uint8_t *out, uint8_t *linen, uint8_t *lineo, const uint8_t *in, uint32_t w, + size_t passleft, size_t passtop, size_t spacex, size_t spacey, size_t passw, size_t passh, + uint32_t bpp); +int PNG_convert(const PNG_info_t *info, vector8_t *out, const uint8_t *in); +PNG_info_t *PNG_info_new(void); + uint32_t PNG_readBitFromReversedStream(size_t *bitp, const uint8_t *bits) { uint32_t result = (bits[*bitp >> 3] >> (7 - (*bitp & 0x7))) & 1; @@ -892,7 +951,7 @@ return 0; } -PNG_info_t *PNG_info_new() +PNG_info_t *PNG_info_new(void) { PNG_info_t *info = png_alloc_malloc(sizeof (PNG_info_t)); uint32_t i; Index: branches/cparm/i386/modules/GUI/graphic_utils.h =================================================================== --- branches/cparm/i386/modules/GUI/graphic_utils.h (revision 1839) +++ branches/cparm/i386/modules/GUI/graphic_utils.h (revision 1840) @@ -9,11 +9,11 @@ #ifndef GRAPHIC_UTILS_H #define GRAPHIC_UTILS_H -#include "boot.h" +#include "libsaio.h" -char *getVBEInfoString(); -extern void printVBEModeInfo(); +char *getVBEInfoString(void); +void printVBEModeInfo(void); typedef union { struct { @@ -64,6 +64,50 @@ // Flips the R and B components of all pixels in the given pixmap void flipRB(pixmap_t *p); +int getNumberArrayFromProperty( const char * propKey, + unsigned long numbers[], + unsigned long maxArrayCount ); + +#if UNUSED +int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate ); +#else +int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel); +#endif + +void getGraphicModeParams(unsigned long params[]); +char *getVBEModeInfoString(void); + +void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data); + +void drawCheckerBoard(void); + +int +convertImage( unsigned short width, + unsigned short height, + const unsigned char *imageData, + unsigned char **newImageData ); + +void drawDataRectangle( unsigned short x, + unsigned short y, + unsigned short width, + unsigned short height, + unsigned char * data ); + +void drawColorRectangle( unsigned short x, + unsigned short y, + unsigned short width, + unsigned short height, + unsigned char colorIndex ); + +#if UNUSED +void setVideoMode(int mode, int drawgraphics); +#else +void setVideoMode(int mode); +#endif +char * decodeRLE( const void * rleData, int rleBlocks, int outBytes ); + + + // Utility function to get pixel at (x,y) in a pixmap #define pixel(p,x,y) ((p)->pixels[(x) + (y) * (p)->width]) Index: branches/cparm/i386/modules/GUI/gui.c =================================================================== --- branches/cparm/i386/modules/GUI/gui.c (revision 1839) +++ branches/cparm/i386/modules/GUI/gui.c (revision 1840) @@ -15,7 +15,7 @@ /* * cparm : add volume version detection */ - +#include "platform.h" #include "gui.h" #include "GUI_appleboot.h" #include "vers.h" @@ -34,9 +34,26 @@ #define DBG(x...) #endif +enum { + kBackspaceKey = 0x08, + kTabKey = 0x09, + kReturnKey = 0x0d, + kEscapeKey = 0x1b, + kUpArrowkey = 0x4800, + kDownArrowkey = 0x5000, + kASCIIKeyMask = 0x7f, + kF5Key = 0x3f00, + kF10Key = 0x4400 +}; + +static config_file_t themeConfig; // theme.plist + themeList_t* themeList = NULL; +static void (*showHelp)(void) = NULL; +static char *(*getMemoryInfoString)(void) = NULL; + gui_t gui; // gui structure font_t font_small; font_t font_console; @@ -119,8 +136,6 @@ int lasttime = 0; // we need this for animating maybe -extern int gDeviceCount; - /* * ATTENTION: the enum and the following array images[] MUST match !!! */ @@ -132,6 +147,8 @@ iDeviceGeneric_o, iDeviceHFS, iDeviceHFS_o, + iDeviceHFS_ML, + iDeviceHFS_ML_o, iDeviceHFS_Lion, iDeviceHFS_Lion_o, iDeviceHFS_SL, @@ -142,6 +159,8 @@ iDeviceHFS_Tiger_o, iDeviceHFSRAID, iDeviceHFSRAID_o, + iDeviceHFSRAID_ML, + iDeviceHFSRAID_ML_o, iDeviceHFSRAID_Lion, iDeviceHFSRAID_Lion_o, iDeviceHFSRAID_SL, @@ -203,7 +222,9 @@ {.name = "device_generic_o", .image = NULL}, {.name = "device_hfsplus", .image = NULL}, - {.name = "device_hfsplus_o", .image = NULL}, + {.name = "device_hfsplus_o", .image = NULL}, + {.name = "device_hfsplus_ml", .image = NULL}, + {.name = "device_hfsplus_ml_o", .image = NULL}, {.name = "device_hfsplus_lion", .image = NULL}, {.name = "device_hfsplus_lion_o", .image = NULL}, {.name = "device_hfsplus_sl", .image = NULL}, @@ -215,6 +236,8 @@ {.name = "device_hfsraid", .image = NULL}, {.name = "device_hfsraid_o", .image = NULL}, + {.name = "device_hfsraid_ml", .image = NULL}, + {.name = "device_hfsraid_ml_o", .image = NULL}, {.name = "device_hfsraid_lion", .image = NULL}, {.name = "device_hfsraid_lion_o", .image = NULL}, {.name = "device_hfsraid_sl", .image = NULL}, @@ -269,11 +292,8 @@ {.name = "font_small", .image = NULL}, }; -int imageCnt = 0; +//int imageCnt = 0; -extern int gDeviceCount; -extern int selectIndex; - char prompt[BOOT_STRING_LEN]; int prompt_pos=0; @@ -298,6 +318,26 @@ unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0}; // here we store the used screen resolution +static void moveCursor( int col, int row ) +{ + setCursorPosition( col, row, 0 ); +} +//========================================================================== + +/* Flush keyboard buffer; returns TRUE if any of the flushed + * characters was F8. + */ + +static bool flushKeyboardBuffer(void) +{ + bool status = false; + + while ( readKeyboardStatus() ) { + if (bgetc() == 0x4200) status = true; + } + return status; +} + static int getImageIndexByName(const char *name) { int i; @@ -474,6 +514,8 @@ LOADPNG(src, device_hfsplus, iDeviceGeneric); LOADPNG(src, device_hfsplus_o, iDeviceHFS); + LOADPNG(src, device_hfsplus_ml, iDeviceHFS_ML); + LOADPNG(src, device_hfsplus_ml_o, iDeviceHFS_ML_o); LOADPNG(src, device_hfsplus_lion, iDeviceHFS_Lion); LOADPNG(src, device_hfsplus_lion_o, iDeviceHFS_Lion_o); LOADPNG(src, device_hfsplus_sl, iDeviceHFS_SL); @@ -485,6 +527,8 @@ LOADPNG(src, device_hfsraid, iDeviceGeneric); LOADPNG(src, device_hfsraid_o, iDeviceHFSRAID); + LOADPNG(src, device_hfsraid_ml, iDeviceHFSRAID_ML); + LOADPNG(src, device_hfsraid_ml_o, iDeviceHFSRAID_ML_o); LOADPNG(src, device_hfsraid_lion, iDeviceHFSRAID_Lion); LOADPNG(src, device_hfsraid_lion_o, iDeviceHFSRAID_Lion_o); LOADPNG(src, device_hfsraid_sl, iDeviceHFSRAID_SL); @@ -704,9 +748,10 @@ uint32_t color; // color value formatted RRGGBB int val, len; const char *string; - + int devcnt = (int)get_env(envgDeviceCount); + if(getIntForKey("devices_max_visible", &val, theme )) - gui.maxdevices = MIN( val, gDeviceCount ); + gui.maxdevices = MIN( val, devcnt ); if(getIntForKey("devices_iconspacing", &val, theme )) gui.devicelist.iconspacing = val; @@ -721,7 +766,7 @@ switch (gui.layout) { case VerticalLayout: - gui.devicelist.height = ((images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing) * MIN(gui.maxdevices, gDeviceCount) + (images[iDeviceScrollPrev].image->height + images[iDeviceScrollNext].image->height) + gui.devicelist.iconspacing); + gui.devicelist.height = ((images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing) * MIN(gui.maxdevices, devcnt) + (images[iDeviceScrollPrev].image->height + images[iDeviceScrollNext].image->height) + gui.devicelist.iconspacing); gui.devicelist.width = (images[iSelection].image->width + gui.devicelist.iconspacing); if(getDimensionForKey("devices_pos_x", &pixel, theme, gui.screen.width , images[iSelection].image->width ) ) @@ -733,7 +778,7 @@ case HorizontalLayout: default: - gui.devicelist.width = ((images[iSelection].image->width + gui.devicelist.iconspacing) * MIN(gui.maxdevices, gDeviceCount) + (images[iDeviceScrollPrev].image->width + images[iDeviceScrollNext].image->width) + gui.devicelist.iconspacing); + gui.devicelist.width = ((images[iSelection].image->width + gui.devicelist.iconspacing) * MIN(gui.maxdevices, devcnt) + (images[iDeviceScrollPrev].image->width + images[iDeviceScrollNext].image->width) + gui.devicelist.iconspacing); gui.devicelist.height = (images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing); if(getDimensionForKey("devices_pos_x", &pixel, theme, gui.screen.width , gui.devicelist.width ) ) @@ -1056,21 +1101,23 @@ bool theme_ran= false; bool theme_name_set= false; - getBoolForKey(kGUIKey, &dummybool, &bootInfo->bootConfig); + getBoolForKey(kGUIKey, &dummybool, DEFAULT_BOOT_CONFIG); if (!dummybool) { return 1; } + getMemoryInfoString = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_getMemoryInfoString"); + showHelp = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_showHelp"); + + getBoolForKey("RandomTheme", &theme_ran, DEFAULT_BOOT_CONFIG); - getBoolForKey("RandomTheme", &theme_ran, &bootInfo->bootConfig); - { long flags; long time; long ret = -1; int len; - theme_name_set = getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig ); + theme_name_set = getValueForKey( "Theme", &theme_name, &len, DEFAULT_BOOT_CONFIG ); if (theme_ran) { @@ -1129,7 +1176,13 @@ ret = randomTheme(dirsrc, &theme_name); - if (ret) printf("randomTheme Failed !! \n"); + if (ret) printf("randomTheme Failed !! \n"); +#if DEBUG_GUI + else + { + DBG("Theme successfuly Choosen randomly !! \n"); + } +#endif } if (ret) @@ -1174,13 +1227,13 @@ sprintf(dirspec, "%s/%s/theme.plist", dirsrc ,theme_name); - if (loadConfigFile(dirspec, &bootInfo->themeConfig) != 0) { + if (loadConfigFile(dirspec, &themeConfig) != 0) { #ifdef EMBED_THEME if (strlen(theme_name) == 0) { config_file_t *config; - config = &bootInfo->themeConfig; + config = &themeConfig; if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0) { DBG("Unable to load embed theme plist datas.\n"); @@ -1200,10 +1253,10 @@ if (execute_hook("getResolution_hook", &screen_params[0], &screen_params[1], &screen_params[2], NULL, NULL, NULL) != EFI_SUCCESS) { // parse display size parameters - if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0) { + if (getIntForKey("screen_width", &val, &themeConfig) && val > 0) { screen_params[0] = val; } - if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && val > 0) { + if (getIntForKey("screen_height", &val, &themeConfig) && val > 0) { screen_params[1] = val; } } @@ -1228,7 +1281,7 @@ // load graphics otherwise fail and return if (loadGraphics(dirsrc) == 0) { - loadThemeValues(&bootInfo->themeConfig); + loadThemeValues(&themeConfig); colorFont(&font_small, gui.screen.font_small_color); colorFont(&font_console, gui.screen.font_console_color); @@ -1248,6 +1301,8 @@ gui.logo.draw = true; drawBackground(); // lets copy the screen into the back buffer + memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 ); + #if UNUSED setVideoMode( GRAPHICS_MODE, 0 ); #else @@ -1299,6 +1354,9 @@ if (device->flags & kBVFlagBooter) { switch (device->OSVersion[3]) { + case '8': + devicetype = is_image_loaded(iDeviceHFSRAID_ML) ? iDeviceHFSRAID_ML : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric; + break; case '7': devicetype = is_image_loaded(iDeviceHFSRAID_Lion) ? iDeviceHFSRAID_Lion : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric; break; @@ -1321,6 +1379,9 @@ { switch (device->OSVersion[3]) { + case '8': + devicetype = is_image_loaded(iDeviceHFS_ML) ? iDeviceHFS_ML : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric; + break; case '7': devicetype = is_image_loaded(iDeviceHFS_Lion) ? iDeviceHFS_Lion : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric; break; @@ -1394,7 +1455,7 @@ } -void drawDeviceList (int start, int end, int selection) +void drawDeviceList (int start, int end, int selection, MenuItem * menuItems) { int i; position_t p, p_prev, p_next; @@ -1404,7 +1465,9 @@ fillPixmapWithColor( gui.devicelist.pixmap, gui.devicelist.bgcolor); makeRoundedCorners( gui.devicelist.pixmap); - + + int devcnt = (int)get_env(envgDeviceCount); + switch (gui.layout) { @@ -1489,7 +1552,7 @@ blend( images[iDeviceScrollPrev].image, gui.devicelist.pixmap, centeredAt( images[iDeviceScrollPrev].image, p_prev ) ); // draw next indicator - if( end < gDeviceCount - 1 ) + if( end < devcnt - 1 ) blend( images[iDeviceScrollNext].image, gui.devicelist.pixmap, centeredAt( images[iDeviceScrollNext].image, p_next ) ); gui.redraw = true; @@ -2467,7 +2530,7 @@ int oldScreenWidth, oldScreenHeight; uint16_t x, y; bool legacy_logo = false; - getBoolForKey("Legacy Logo", &legacy_logo, &bootInfo->bootConfig); + getBoolForKey("Legacy Logo", &legacy_logo, DEFAULT_BOOT_CONFIG); if (legacy_logo == false) { usePngImage = true; @@ -2480,12 +2543,12 @@ if (execute_hook("getResolution_hook", &screen_params[0], &screen_params[1], &screen_params[2], NULL, NULL, NULL) != EFI_SUCCESS) { // parse screen size parameters - if (getIntForKey("boot_width", &pos, &bootInfo->themeConfig) && pos > 0) { + if (getIntForKey("boot_width", &pos, &themeConfig) && pos > 0) { screen_params[0] = pos; } else { screen_params[0] = DEFAULT_SCREEN_WIDTH; } - if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig) && pos > 0) { + if (getIntForKey("boot_height", &pos, &themeConfig) && pos > 0) { screen_params[1] = pos; } else { screen_params[1] = DEFAULT_SCREEN_HEIGHT; @@ -2513,7 +2576,7 @@ #endif } - if (getValueForKey("-checkers", &dummyVal, &length, &bootInfo->bootConfig)) { + if (getValueForKey("-checkers", &dummyVal, &length, DEFAULT_BOOT_CONFIG)) { drawCheckerBoard(); } else { // Fill the background to 75% grey (same as BootX). @@ -2546,7 +2609,7 @@ } } -int GUI_initGraphicsMode () +int GUI_initGraphicsMode (void) { unsigned long params[4]; int count; @@ -2583,7 +2646,7 @@ } -int GUI_countdown( const char * msg, int row, int timeout ) +int GUI_countdown( const char * msg, int row, int timeout , int *optionKey) { unsigned long time; register int ch = 0; @@ -2624,8 +2687,10 @@ lasttime=time18(); } - if ((ch = readKeyboardStatus())) + if ((ch = readKeyboardStatus())){ + *optionKey = ch; break; + } // Count can be interrupted by holding down shift, // control or alt key @@ -2660,3 +2725,5 @@ return ch; } + + Index: branches/cparm/i386/modules/GUI/picopng.h =================================================================== --- branches/cparm/i386/modules/GUI/picopng.h (revision 1839) +++ branches/cparm/i386/modules/GUI/picopng.h (revision 1840) @@ -29,7 +29,7 @@ } PNG_info_t; PNG_info_t *PNG_decode(const uint8_t *in, uint32_t size); -void png_alloc_free_all(); +void png_alloc_free_all(void); extern int PNG_error; Index: branches/cparm/i386/modules/GUI/GUI_module.c =================================================================== --- branches/cparm/i386/modules/GUI/GUI_module.c (revision 1839) +++ branches/cparm/i386/modules/GUI/GUI_module.c (revision 1840) @@ -9,7 +9,7 @@ #include "libsaio.h" -#include "options.h" +#include "platform.h" #include "graphic_utils.h" #include "embedded.h" @@ -18,11 +18,66 @@ #include "modules.h" +enum { + kMenuTopRow = 5, + kMenuMaxItems = 10, + kScreenLastRow = 24 +}; + +enum { + kBackspaceKey = 0x08, + kTabKey = 0x09, + kReturnKey = 0x0d, + kEscapeKey = 0x1b, + kUpArrowkey = 0x4800, + kDownArrowkey = 0x5000, + kASCIIKeyMask = 0x7f, + kF5Key = 0x3f00, + kF10Key = 0x4400 +}; +/* + * Flags to the booter or kernel + */ +#define kVerboseModeFlag "-v" +#define kSafeModeFlag "-x" +#define kIgnoreCachesFlag "-f" +#define kSingleUserModeFlag "-s" +#define kIgnorePrelinkKern "-F" +#define kIgnoreBootFileFlag "-B" + +/* + * Booter behavior control + */ +#define kBootTimeout -1 +#define kCDBootTimeout 8 + +/* + * A global set by boot() to record the device that the booter + * was loaded from. + */ +#define Cache_len_name 512 + +/* + * Boot Modes + */ +enum { + kBootModeNormal = 0, + kBootModeSafe = 1, + kBootModeSecure = 2, + kBootModeQuiet = 4 +}; +typedef struct { + int x; + int y; + int type; +} CursorState; + /* Kabyl: BooterLog */ #define BOOTER_LOG_SIZE (128 * 1024) #define SAFE_LOG_SIZE 134 -bool useGUI = true; +static bool useGUI = true; +static int selectIndex = 0; void GUI_Kernel_Start_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); @@ -31,6 +86,8 @@ static void GUI_updateBootArgs( int key ); void GUI_clearBootArgs(void); +void GUI_addBootArg(const char * argStr); + static void GUI_showBootPrompt(int row, bool visible); static void GUI_showMenu( const MenuItem * items, int count, int selection, int row, int height ); static int GUI_updateMenu( int key, void ** paramPtr ); @@ -52,9 +109,55 @@ extern char *msgbuf; extern char *cursor; +static void (*showTextBuffer)(char *, int ) = NULL; +static char *(*getMemoryInfoString)(void) = NULL; +static BVRef (*getBvChain)(void) = NULL; +static void (*lspci)(void) = NULL; +static void (*printMemoryInfo)(void) = NULL; +static void (*showHelp)(void) = NULL; +static void (*showTextFile)(const char * ) = NULL; +static void (*showMessage)(char * ) = NULL; +static const MenuItem * gMenuItems = NULL; +static MenuItem * menuItems = NULL; +static char gBootArgs[BOOT_STRING_LEN]; +static char * gBootArgsPtr = gBootArgs; +static char * gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1; +static char booterCommand[BOOT_STRING_LEN]; +static char booterParam[BOOT_STRING_LEN]; +static void printMenuItem( const MenuItem * item, int highlight ) +{ + printf(" "); + + if ( highlight ) + putca(' ', 0x70, strlen(item->name) + 4); + else + putca(' ', 0x07, 40); + + printf(" %40s\n", item->name); +} +//========================================================================== + +static void changeCursor( int col, int row, int type, CursorState * cs ) +{ + if (cs) getCursorPositionAndType( &cs->x, &cs->y, &cs->type ); + setCursorType( type ); + setCursorPosition( col, row, 0 ); +} + +static void moveCursor( int col, int row ) +{ + setCursorPosition( col, row, 0 ); +} + +static void restoreCursor( const CursorState * cs ) +{ + setCursorPosition( cs->x, cs->y, 0 ); + setCursorType( cs->type ); +} + char GUI_bootRescanPrompt[] = "Press Enter to start up Darwin/x86 with no options, or you can:\n" " Press F5 after you swapped the media. The drive will be rescanned.\n" @@ -106,7 +209,7 @@ if(!gVerboseMode) { // Disable outputs, they will still show in the boot log. - replace_function("_printf", &GUI_verbose); + replace_system_function("_printf", &GUI_verbose); //drawBootGraphics(); } @@ -118,7 +221,7 @@ { // Start and display the gui msglog("* Attempting to Display GUI\n"); - + if (initGUI()) { @@ -129,24 +232,37 @@ } else { - replace_function("_initGraphicsMode", &GUI_initGraphicsMode); - replace_function("_getBootOptions", &GUI_getBootOptions); - replace_function("_clearBootArgs", &GUI_clearBootArgs); - replace_function("_showHelp", &GUI_showHelp); + //replace_system_function("_initGraphicsMode", &GUI_initGraphicsMode); + replace_system_function("_getBootOptions", &GUI_getBootOptions); + replace_system_function("_clearBootArgs", &GUI_clearBootArgs); + replace_system_function("_addBootArg", &GUI_addBootArg); + + replace_system_function("_showHelp", &GUI_showHelp); - replace_function("_printf", &GUI_printf); - replace_function("_verbose", &GUI_verbose); - replace_function("_error", &GUI_error); - replace_function("_stop", &GUI_stop); - replace_function("_showMessage", &GUI_showMessage); + replace_system_function("_printf", &GUI_printf); + replace_system_function("_verbose", &GUI_verbose); + replace_system_function("_error", &GUI_error); + replace_system_function("_stop", &GUI_stop); + replace_system_function("_showMessage", &GUI_showMessage); + - - // Hoot for the boot screen + // Hook for the boot screen register_hook_callback("GUI_ExecKernel", &GUI_ExecKernel_hook); register_hook_callback("GUI_PreBoot", &GUI_PreBoot_hook); + + getBvChain = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_getBvChain"); + getMemoryInfoString = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_getMemoryInfoString"); + + printMemoryInfo = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_printMemoryInfo"); + lspci = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_lspci"); + showHelp = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_showHelp"); + showTextFile = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_showTextFile"); + showMessage = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_showMessage"); + showTextBuffer = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_showTextBuffer"); + safe_set_env(envgBootArgs,(uint32_t)gBootArgs); + msglog("* GUI successfully Displayed\n"); - } } @@ -168,6 +284,14 @@ static int GUI_updateMenu( int key, void ** paramPtr ) { int moved = 0; + + int MenuTop = (int)get_env(envgMenuTop); + int MenuSelection = (int)get_env(envgMenuSelection); + int MenuRow = (int)get_env(envgMenuRow); + int MenuHeight = (int)get_env(envgMenuHeight); + int MenuBottom = (int)get_env(envgMenuBottom); + int MenuStart = (int)get_env(envgMenuStart); + int MenuEnd = (int)get_env(envgMenuEnd); union { struct { @@ -202,18 +326,18 @@ if ( key == previous ) { - if ( gMenuSelection > gMenuTop ) + if ( MenuSelection > MenuTop ) draw.f.selectionUp = 1; - else if ( gMenuTop > 0 ) + else if ( MenuTop > 0 ) draw.f.scrollDown = 1; } else if ( key == subsequent ) { - if ( gMenuSelection != gMenuBottom) + if ( MenuSelection != MenuBottom) draw.f.selectionDown = 1; - else if ( gMenuBottom < ( gMenuItemCount - 1 ) ) + else if ( MenuBottom < ( get_env(envgMenuItemCount) - 1 ) ) draw.f.scrollUp = 1; } @@ -233,8 +357,9 @@ gui.menu.draw = false; else { - shouldboot = ( res != DO_NOT_BOOT ); - + bool shouldboot = ( res != DO_NOT_BOOT ); + safe_set_env(envShouldboot, shouldboot); + if ( shouldboot ) gui.menu.draw = false; @@ -242,25 +367,26 @@ { case BOOT_NORMAL: gVerboseMode = false; - gBootMode = kBootModeNormal; + safe_set_env(envgBootMode, kBootModeNormal); + break; case BOOT_VERBOSE: gVerboseMode = true; - gBootMode = kBootModeNormal; - addBootArg(kVerboseModeFlag); + safe_set_env(envgBootMode, kBootModeNormal); + GUI_addBootArg(kVerboseModeFlag); break; case BOOT_IGNORECACHE: gVerboseMode = false; - gBootMode = kBootModeNormal; - addBootArg(kIgnoreCachesFlag); + safe_set_env(envgBootMode, kBootModeNormal); + GUI_addBootArg(kIgnoreCachesFlag); break; case BOOT_SINGLEUSER: gVerboseMode = true; - gBootMode = kBootModeNormal; - addBootArg(kSingleUserModeFlag); + safe_set_env(envgBootMode, kBootModeNormal); + GUI_addBootArg(kSingleUserModeFlag); break; default: break; @@ -274,22 +400,22 @@ switch ( key ) { case 0x4800: // Up Arrow - if ( gMenuSelection != gMenuTop ) + if ( MenuSelection != MenuTop ) { draw.f.selectionUp = 1; } - else if ( gMenuTop > 0 ) + else if ( MenuTop > 0 ) { draw.f.scrollDown = 1; } break; case 0x5000: // Down Arrow - if ( gMenuSelection != gMenuBottom ) + if ( MenuSelection != MenuBottom ) { draw.f.selectionDown = 1; } - else if ( gMenuBottom < (gMenuItemCount - 1) ) + else if ( MenuBottom < (get_env(envgMenuItemCount) - 1) ) { draw.f.scrollUp = 1; } @@ -303,17 +429,17 @@ { if ( draw.f.scrollUp ) { - scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1); - gMenuTop++; gMenuBottom++; - gMenuStart++; gMenuEnd++; + scollPage(0, MenuRow, 40, MenuRow + MenuHeight - 1, 0x07, 1, 1); + MenuTop++; MenuBottom++; + MenuStart++; MenuEnd++; draw.f.selectionDown = 1; } if ( draw.f.scrollDown ) { - scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1); - gMenuTop--; gMenuBottom--; - gMenuStart--; gMenuEnd--; + scollPage(0, MenuRow, 40, MenuRow + MenuHeight - 1, 0x07, 1, -1); + MenuTop--; MenuBottom--; + MenuStart--; MenuEnd--; draw.f.selectionUp = 1; } @@ -326,46 +452,54 @@ if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { - changeCursor( 0, (gMenuRow + gMenuSelection - gMenuTop), kCursorTypeHidden, &cursorState ); - printMenuItem( &gMenuItems[gMenuSelection], 0 ); + changeCursor( 0, (MenuRow + MenuSelection - MenuTop), kCursorTypeHidden, &cursorState ); + printMenuItem( &gMenuItems[MenuSelection], 0 ); } if ( draw.f.selectionUp ) { - gMenuSelection--; - if(( gMenuSelection - gMenuStart) == -1 ) + MenuSelection--; + if(( MenuSelection - MenuStart) == -1 ) { - gMenuStart--; - gMenuEnd--; + MenuStart--; + MenuEnd--; } } else { - gMenuSelection++; - if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 ) + MenuSelection++; + if(( MenuSelection - ( gui.maxdevices - 1) - MenuStart) > 0 ) { - gMenuStart++; - gMenuEnd++; + MenuStart++; + MenuEnd++; } } if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { - moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop ); - printMenuItem( &gMenuItems[gMenuSelection], 1 ); + moveCursor( 0, MenuRow + MenuSelection - MenuTop ); + printMenuItem( &gMenuItems[MenuSelection], 1 ); restoreCursor( &cursorState ); } else { - drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection); + drawDeviceList (MenuStart, MenuEnd, MenuSelection, menuItems); } } - *paramPtr = gMenuItems[gMenuSelection].param; + *paramPtr = gMenuItems[MenuSelection].param; moved = 1; } - + + safe_set_env(envgMenuSelection,MenuSelection); + safe_set_env(envgMenuTop,MenuTop ); + safe_set_env(envgMenuRow,MenuRow); + safe_set_env(envgMenuHeight,MenuHeight); + safe_set_env(envgMenuBottom,MenuBottom); + safe_set_env(envgMenuStart,MenuStart); + safe_set_env(envgMenuEnd,MenuEnd); + return moved; } @@ -384,48 +518,53 @@ // in the menu window. gMenuItems = items; - gMenuRow = row; - gMenuHeight = height; - gMenuItemCount = count; - gMenuTop = 0; - gMenuBottom = min( count, height ) - 1; - gMenuSelection = selection; + int MenuTop = 0; + int MenuBottom = min( count, height ) - 1; + int MenuSelection = selection; + int MenuStart = 0; + int MenuEnd = count; //min( count, gui.maxdevices ) - 1; - gMenuStart = 0; - gMenuEnd = min( count, gui.maxdevices ) - 1; - // If the selected item is not visible, shift the list down. - if ( gMenuSelection > gMenuBottom ) + if ( MenuSelection > MenuBottom ) { - gMenuTop += ( gMenuSelection - gMenuBottom ); - gMenuBottom = gMenuSelection; + MenuTop += ( MenuSelection - MenuBottom ); + MenuBottom = MenuSelection; } - if ( gMenuSelection > gMenuEnd ) + if ( MenuSelection > MenuEnd ) { - gMenuStart += ( gMenuSelection - gMenuEnd ); - gMenuEnd = gMenuSelection; + MenuStart += ( MenuSelection - MenuEnd ); + MenuEnd = MenuSelection; } // Draw the visible items. if( bootArgs->Video.v_display == GRAPHICS_MODE ) { - drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection); + drawDeviceList(MenuStart, MenuEnd, MenuSelection, menuItems); } else { changeCursor( 0, row, kCursorTypeHidden, &cursorState ); - for ( i = gMenuTop; i <= gMenuBottom; i++ ) + for ( i = MenuTop; i <= MenuBottom; i++ ) { - printMenuItem( &items[i], (i == gMenuSelection) ); + printMenuItem( &items[i], (i == MenuSelection) ); } restoreCursor( &cursorState ); } + + safe_set_env(envgMenuRow,row); + safe_set_env(envgMenuHeight,height); + safe_set_env(envgMenuItemCount,count); + safe_set_env(envgMenuTop,MenuTop); + safe_set_env(envgMenuBottom,MenuBottom); + safe_set_env(envgMenuSelection,MenuSelection); + safe_set_env(envgMenuStart,MenuStart); + safe_set_env(envgMenuEnd,MenuEnd); } @@ -481,7 +620,7 @@ static void GUI_showBootPrompt(int row, bool visible) { - extern char bootPrompt[]; + char * bootPrompt = (char*)(uint32_t)get_env(envBootPrompt); if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { @@ -489,13 +628,13 @@ clearScreenRows( row, kScreenLastRow ); } - clearBootArgs(); + GUI_clearBootArgs(); if (visible) { if (bootArgs->Video.v_display == VGA_TEXT_MODE) { - if (gEnableCDROMRescan) + if (get_env(envgEnableCDROMRescan)) { printf( GUI_bootRescanPrompt ); } @@ -518,7 +657,6 @@ } } - void GUI_clearBootArgs(void) { gBootArgsPtr = gBootArgs; @@ -530,6 +668,15 @@ } } +void GUI_addBootArg(const char * argStr) +{ + if ( (gBootArgsPtr + strlen(argStr) + 1) < gBootArgsEnd) + { + *gBootArgsPtr++ = ' '; + strcat(gBootArgs, argStr); + gBootArgsPtr += strlen(argStr); + } +} int GUI_getBootOptions(bool firstRun) { @@ -543,11 +690,13 @@ BVRef bvr; BVRef menuBVR; bool showPrompt, newShowPrompt, isCDROM; - + int optionKey; + int devcnt = (int)get_env(envgDeviceCount); + // Initialize default menu selection entry. - gBootVolume = menuBVR = selectBootVolume(bvChain); + gBootVolume = menuBVR = selectBootVolume(getBvChain()); - if (biosDevIsCDROM(gBIOSDev)) + if (biosDevIsCDROM((int)get_env(envgBIOSDev))) { isCDROM = true; } @@ -555,7 +704,7 @@ { isCDROM = false; } - + // ensure we're in graphics mode if gui is setup if (gui.initialised && bootArgs->Video.v_display == VGA_TEXT_MODE) { @@ -567,10 +716,10 @@ } // Clear command line boot arguments - clearBootArgs(); + GUI_clearBootArgs(); // Allow user to override default timeout. - if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->bootConfig)) + if (!getIntForKey(kTimeoutKey, &timeout, DEFAULT_BOOT_CONFIG)) { /* If there is no timeout key in the file use the default timeout which is different for CDs vs. hard disks. However, if not booting @@ -587,20 +736,26 @@ } else { - timeout = sysConfigValid ? kBootTimeout : 0; + timeout = get_env(envSysConfigValid) ? kBootTimeout : 0; } } - + + long gBootMode = get_env(envgBootMode); + if (timeout < 0) { gBootMode |= kBootModeQuiet; + safe_set_env(envgBootMode,gBootMode); + } // If the user is holding down a modifier key, enter safe mode. if ((readKeyboardShiftFlags() & 0x0F) != 0) { - //gBootMode |= kBootModeSafe; + gBootMode |= kBootModeSafe; + safe_set_env(envgBootMode,gBootMode); + } // Checking user pressed keys @@ -616,17 +771,19 @@ if (f8press) { gBootMode &= ~kBootModeQuiet; + safe_set_env(envgBootMode,gBootMode); + timeout = 0; } // If user typed 'v' or 'V', boot in verbose mode. if ((gBootMode & kBootModeQuiet) && firstRun && vpress) { - addBootArg(kVerboseModeFlag); + GUI_addBootArg(kVerboseModeFlag); } // If user typed 's' or 'S', boot in single user mode. if ((gBootMode & kBootModeQuiet) && firstRun && spress) { - addBootArg(kSingleUserModeFlag); + GUI_addBootArg(kSingleUserModeFlag); } if (bootArgs->Video.v_display == VGA_TEXT_MODE) @@ -635,12 +792,13 @@ clearScreenRows(0, kScreenLastRow); if (!(gBootMode & kBootModeQuiet)) { + char * bootBanner = (char*)(uint32_t)get_env(envBootBanner); // Display banner and show hardware info. printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024); printf(getVBEInfoString()); } changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0); - verbose("Scanning device %x...", gBIOSDev); + msglog("Scanning device %x...", (uint32_t)get_env(envgBIOSDev)); } // When booting from CD, default to hard drive boot when possible. @@ -650,9 +808,8 @@ char *prompt = NULL; char *name = NULL; int cnt; - int optionKey; - if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) + if (getValueForKey(kCDROMPromptKey, &val, &cnt, DEFAULT_BOOT_CONFIG)) { prompt = malloc(cnt + 1); strncat(prompt, val, cnt); @@ -662,11 +819,11 @@ name = malloc(80); getBootVolumeDescription(gBootVolume, name, 79, false); prompt = malloc(256); - sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name); + sprintf(prompt, "Press ENTER to start up from %s, or press any key to enter startup options.", name); free(name); } - if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) + if (getIntForKey( kCDROMOptionKey, &optionKey, DEFAULT_BOOT_CONFIG )) { // The key specified is a special key. } @@ -680,7 +837,7 @@ // early catch of F8 which means the user wants to set boot options // which we ought to interpret as meaning he wants to boot the CD. if (timeout != 0) { - key = GUI_countdown(prompt, kMenuTopRow, timeout); + key = GUI_countdown(prompt, kMenuTopRow, timeout, &optionKey); } else { @@ -694,32 +851,35 @@ clearScreenRows( kMenuTopRow, kMenuTopRow + 2 ); - // Hit the option key ? - if (key == optionKey) - { - gBootMode &= ~kBootModeQuiet; - timeout = 0; - } - else - { - key = key & 0xFF; - - // Try booting hard disk if user pressed 'h' - if (biosDevIsCDROM(gBIOSDev) && key == 'h') - { - BVRef bvr; - - // Look at partitions hosting OS X other than the CD-ROM - for (bvr = bvChain; bvr; bvr=bvr->next) - { - if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev) - { - gBootVolume = bvr; - } - } - } - goto done; - } + do { + // Hit the option key ? + if (key == optionKey) { + + if (key != 0x1C0D) { + gBootMode &= ~kBootModeQuiet; + safe_set_env(envgBootMode,gBootMode); + timeout = 0; + break; + } + + } + + key = key & 0xFF; + + // Try booting hard disk if user pressed 'h' + if (biosDevIsCDROM((int)get_env(envgBIOSDev)) && key == 'h') { + BVRef bvr; + + // Look at partitions hosting OS X other than the CD-ROM + for (bvr = getBvChain(); bvr; bvr=bvr->next) { + if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != (int)get_env(envgBIOSDev)) { + gBootVolume = bvr; + } + } + } + goto done; + + } while (0); } if (gBootMode & kBootModeQuiet) @@ -728,28 +888,38 @@ goto done; } - if (firstRun && timeout > 0 && GUI_countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0) - { - // If the user is holding down a modifier key, - // enter safe mode. - if ((readKeyboardShiftFlags() & 0x0F) != 0) - { - gBootMode |= kBootModeSafe; - } - goto done; + if (firstRun && timeout > 0 ) { + + key = GUI_countdown("Press ENTER to start up, or press any key to enter startup options.", kMenuTopRow, timeout, &optionKey); + + if (key == 0x1C0D) { + goto done; + + } + else if (key == 0) + { + // If the user is holding down a modifier key, + // enter safe mode. + + if ((readKeyboardShiftFlags() & 0x0F) != 0) { + gBootMode |= kBootModeSafe; + safe_set_env(envgBootMode,gBootMode); + } + goto done; + } } - - if (gDeviceCount) + + if (devcnt) { // Allocate memory for an array of menu items. - menuItems = malloc(sizeof(MenuItem) * gDeviceCount); + menuItems = malloc(sizeof(MenuItem) * devcnt); if (menuItems == NULL) { goto done; } // Associate a menu item for each BVRef. - for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) + for (bvr=getBvChain(), i=devcnt-1, selectIndex=0; bvr; bvr=bvr->next) { if (bvr->visible) { @@ -758,6 +928,7 @@ if (bvr == menuBVR) { selectIndex = i; + safe_set_env(envSelectIndex, selectIndex); } i--; } @@ -776,9 +947,11 @@ bool showBootBanner = true; // Check if "Boot Banner"=N switch is present in config file. - getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig); + getBoolForKey(kBootBannerKey, &showBootBanner, DEFAULT_BOOT_CONFIG); if (showBootBanner) { + char * bootBanner = (char*)(uint32_t)get_env(envBootBanner); + // Display banner and show hardware info. gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024); } @@ -797,18 +970,18 @@ nextRow = kMenuTopRow; showPrompt = true; - if (gDeviceCount) + if (devcnt) { if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { printf("Use \30\31 keys to select the startup volume."); } - GUI_showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems ); - nextRow += min( gDeviceCount, kMenuMaxItems ) + 3; + GUI_showMenu( menuItems, devcnt, selectIndex, kMenuTopRow + 2, kMenuMaxItems ); + nextRow += min( devcnt, kMenuMaxItems ) + 3; } // Show the boot prompt. - showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot); + showPrompt = (devcnt == 0) || (menuBVR->flags & kBVFlagNativeBoot); GUI_showBootPrompt( nextRow, showPrompt ); do { @@ -821,7 +994,7 @@ } key = getc(); GUI_updateMenu( key, (void **) &menuBVR ); - newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot); + newShowPrompt = (devcnt == 0) || (menuBVR->flags & kBVFlagNativeBoot); if (newShowPrompt != showPrompt) { @@ -891,11 +1064,11 @@ } else if (strcmp(booterCommand, "norescan") == 0) { - if (gEnableCDROMRescan) - { - gEnableCDROMRescan = false; - break; - } + if (get_env(envgEnableCDROMRescan)) + { + safe_set_env(envgEnableCDROMRescan,false); + break; + } } else { @@ -907,11 +1080,11 @@ } gBootVolume = menuBVR; setRootVolume(menuBVR); - gBIOSDev = menuBVR->biosdev; + safe_set_env(envgBIOSDev,menuBVR->biosdev); break; case kEscapeKey: - clearBootArgs(); + GUI_clearBootArgs(); break; case kF5Key: @@ -919,22 +1092,21 @@ // Clear gBootVolume to restart the loop // if the user enabled rescanning the optical drive. // Otherwise boot the default boot volume. - if (gEnableCDROMRescan) - { + if (get_env(envgEnableCDROMRescan)) { gBootVolume = NULL; - clearBootArgs(); + GUI_clearBootArgs(); } break; case kF10Key: - gScanSingleDrive = false; + safe_set_env(envgScanSingleDrive, false); #if UNUSED - scanDisks(gBIOSDev, &bvCount); + scanDisks((int)get_env(envgBIOSDev), &bvCount); #else scanDisks(); #endif gBootVolume = NULL; - clearBootArgs(); + GUI_clearBootArgs(); break; case kTabKey: @@ -952,7 +1124,9 @@ #endif setCursorPosition(0, 0, 0); clearScreenRows(0, kScreenLastRow); - + + char * bootBanner = (char*)(uint32_t)get_env(envBootBanner); + // Display banner and show hardware info. printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024); printf(getVBEInfoString()); @@ -963,14 +1137,14 @@ nextRow = kMenuTopRow; showPrompt = true; - if (gDeviceCount) + if (devcnt) { printf("Use \30\31 keys to select the startup volume."); - GUI_showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems); - nextRow += min(gDeviceCount, kMenuMaxItems) + 3; + GUI_showMenu(menuItems, devcnt, selectIndex, kMenuTopRow + 2, kMenuMaxItems); + nextRow += min(devcnt, kMenuMaxItems) + 3; } - showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot); + showPrompt = (devcnt == 0) || (menuBVR->flags & kBVFlagNativeBoot); GUI_showBootPrompt(nextRow, showPrompt); //changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 ); } @@ -1000,7 +1174,7 @@ clearScreenRows(kMenuTopRow, kScreenLastRow); changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0); } - shouldboot = false; + safe_set_env(envShouldboot, false); gui.menu.draw = false; if (menuItems) { Index: branches/cparm/i386/modules/GUI/gui.h =================================================================== --- branches/cparm/i386/modules/GUI/gui.h (revision 1839) +++ branches/cparm/i386/modules/GUI/gui.h (revision 1840) @@ -14,19 +14,18 @@ #ifndef __BOOT2_GUI_H #define __BOOT2_GUI_H -#include "boot.h" +#include "libsaio.h" #include "bootstruct.h" -#include "graphics.h" #include "graphic_utils.h" #include "picopng.h" -#include "options.h" +//#include "options.h" -void showTextBuffer(char *buf, int size); -int GUI_initGraphicsMode (); -int GUI_countdown( const char * msg, int row, int timeout ); +int GUI_initGraphicsMode (void); +int GUI_countdown( const char * msg, int row, int timeout , int *optionKey); #define kGUIKey "GUI" #define kBootBannerKey "Boot Banner" +#define envSelectIndex "GUISelIdx" #define CHARACTERS_COUNT 223 @@ -44,6 +43,12 @@ #define MENU_SHOW_VIDEO_INFO 5 #define MENU_SHOW_HELP 6 +typedef struct { + char name[80]; + void * param; +} MenuItem; + + enum { HorizontalLayout = 0, VerticalLayout = 1, @@ -142,7 +147,7 @@ void drawLogo(); -void drawDeviceList(int start, int end, int selection); +void drawDeviceList (int start, int end, int selection, MenuItem * menuItems); void showInfoBox(char *title, char *text); Index: branches/cparm/i386/modules/GUI/graphic_utils.c =================================================================== --- branches/cparm/i386/modules/GUI/graphic_utils.c (revision 1839) +++ branches/cparm/i386/modules/GUI/graphic_utils.c (revision 1840) @@ -3,19 +3,68 @@ * Prashant Vaibhav (C) 12/12/2008 * Chameleon */ -#include "boot.h" +#include "libsaio.h" +#include "bootstruct.h" #include "graphic_utils.h" -#include "graphics.h" +#include "appleClut8.h" #include "vbe.h" #include "gui.h" #define VIDEO(x) (bootArgs->Video.v_ ## x) #define MIN(x, y) ((x) < (y) ? (x) : (y)) +static unsigned long lookUpCLUTIndex( unsigned char index, + unsigned char depth ); +static int +setVESATextMode( unsigned short cols, + unsigned short rows, + unsigned char bitsPerPixel ); +static void setupPalette( VBEPalette * p, const unsigned char * g ); +static unsigned long lookUpCLUTIndex( unsigned char index, + unsigned char depth ); +static unsigned short +getVESAModeWithProperties( unsigned short width, + unsigned short height, + unsigned char bitsPerPixel, + unsigned short attributesSet, + unsigned short attributesClear, + VBEModeInfoBlock * outModeInfo, + unsigned short * vesaVersion ); +//========================================================================== +// LookUpCLUTIndex -#ifdef OPTION_ROM +static unsigned long lookUpCLUTIndex( unsigned char index, + unsigned char depth ) +{ + long result, red, green, blue; + + red = appleClut8[index * 3 + 0]; + green = appleClut8[index * 3 + 1]; + blue = appleClut8[index * 3 + 2]; + + switch (depth) { + case 16 : + result = ((red & 0xF8) << 7) | + ((green & 0xF8) << 2) | + ((blue & 0xF8) >> 3); + result |= (result << 16); + break; + + case 32 : + result = (red << 16) | (green << 8) | blue; + break; + + default : + result = index | (index << 8); + result |= (result << 16); + break; + } + + return result; +} + int convertImage( unsigned short width, unsigned short height, @@ -75,13 +124,11 @@ data += width * pixelBytes; } } -#endif - //========================================================================== // void -printVBEModeInfo() +printVBEModeInfo(void) { VBEInfoBlock vbeInfo; unsigned short * modePtr; @@ -142,7 +189,7 @@ -char *getVBEModeInfoString() +char *getVBEModeInfoString(void) { VBEInfoBlock vbeInfo; unsigned short * modePtr; @@ -299,7 +346,7 @@ } } -void drawCheckerBoard() +void drawCheckerBoard(void) { uint32_t *vram = (uint32_t *) VIDEO(baseAddr); uint16_t x, y; @@ -313,6 +360,468 @@ } } +//========================================================================== +// getNumberArrayFromProperty + +int +getNumberArrayFromProperty( const char * propKey, + unsigned long numbers[], + unsigned long maxArrayCount ) +{ + char * propStr; + unsigned long count = 0; + + propStr = newStringForKey( (char *) propKey , DEFAULT_BOOT_CONFIG ); + if ( propStr ) + { + char * delimiter = propStr; + char * p = propStr; + + while ( count < maxArrayCount && *p != '\0' ) + { + unsigned long val = strtoul( p, &delimiter, 10 ); + if ( p != delimiter ) + { + numbers[count++] = val; + p = delimiter; + } + while ( ( *p != '\0' ) && !isdigit(*p) ) + p++; + } + + free( propStr ); + } + + return count; +} + +//========================================================================== +// Simple decompressor for boot images encoded in RLE format. + +char * decodeRLE( const void * rleData, int rleBlocks, int outBytes ) +{ + char *out, *cp; + + struct RLEBlock { + unsigned char count; + unsigned char value; + } * bp = (struct RLEBlock *) rleData; + + out = cp = malloc( outBytes ); + if ( out == NULL ) return NULL; + + while ( rleBlocks-- ) + { + memset( cp, bp->value, bp->count ); + cp += bp->count; + bp++; + } + + return out; +} + +static void * stosl(void * dst, long val, long len) +{ + asm volatile ( "rep; stosl" + : "=c" (len), "=D" (dst) + : "0" (len), "1" (dst), "a" (val) + : "memory" ); + + return dst; +} + +void drawColorRectangle( unsigned short x, + unsigned short y, + unsigned short width, + unsigned short height, + unsigned char colorIndex ) +{ + long pixelBytes; + long color = lookUpCLUTIndex( colorIndex, VIDEO(depth) ); + char * vram; + + pixelBytes = VIDEO(depth) / 8; + vram = (char *) VIDEO(baseAddr) + + VIDEO(rowBytes) * y + pixelBytes * x; + + width = MIN(width, VIDEO(width) - x); + height = MIN(height, VIDEO(height) - y); + + while ( height-- ) + { + int rem = ( pixelBytes * width ) % 4; + if ( rem ) bcopy( &color, vram, rem ); + stosl( vram + rem, color, pixelBytes * width / 4 ); + vram += VIDEO(rowBytes); + } +} + + + +//========================================================================== +// getVESAModeWithProperties +// +// Return the VESA mode that matches the properties specified. +// If a mode is not found, then return the "best" available mode. + +static unsigned short +getVESAModeWithProperties( unsigned short width, + unsigned short height, + unsigned char bitsPerPixel, + unsigned short attributesSet, + unsigned short attributesClear, + VBEModeInfoBlock * outModeInfo, + unsigned short * vesaVersion ) +{ + VBEInfoBlock vbeInfo; + unsigned short * modePtr; + VBEModeInfoBlock modeInfo; + unsigned char modeBitsPerPixel; + unsigned short matchedMode = modeEndOfList; + int err; + + // Clear output mode info. + + //bzero( outModeInfo, sizeof(*outModeInfo) ); + bzero( outModeInfo, sizeof(VBEModeInfoBlock) ); + + // Get VBE controller info containing the list of supported modes. + + //bzero( &vbeInfo, sizeof(vbeInfo) ); + bzero( &vbeInfo, sizeof(VBEInfoBlock) ); + + strcpy( (char*)&vbeInfo, "VBE2" ); + err = getVBEInfo( &vbeInfo ); + if ( err != errSuccess ) + { + return modeEndOfList; + } + + // Report the VESA major/minor version number. + + if (vesaVersion) *vesaVersion = vbeInfo.VESAVersion; + + // Loop through the mode list, and find the matching mode. + + for ( modePtr = VBEDecodeFP( unsigned short *, vbeInfo.VideoModePtr ); + *modePtr != modeEndOfList; modePtr++ ) + { + // Get mode information. + + //bzero( &modeInfo, sizeof(modeInfo) ); + bzero( &modeInfo, sizeof(VBEModeInfoBlock) ); + + err = getVBEModeInfo( *modePtr, &modeInfo ); + if ( err != errSuccess ) + { + continue; + } + +#if DEBUG + printf("Mode %x: %dx%dx%d mm:%d attr:%x\n", + *modePtr, modeInfo.XResolution, modeInfo.YResolution, + modeInfo.BitsPerPixel, modeInfo.MemoryModel, + modeInfo.ModeAttributes); +#endif + + // Filter out unwanted modes based on mode attributes. + + if ( ( ( modeInfo.ModeAttributes & attributesSet ) != attributesSet ) + || ( ( modeInfo.ModeAttributes & attributesClear ) != 0 ) ) + { + continue; + } + + // Pixel depth in bits. + + modeBitsPerPixel = modeInfo.BitsPerPixel; + + if ( ( modeBitsPerPixel == 4 ) && ( modeInfo.MemoryModel == 0 ) ) + { + // Text mode, 16 colors. + } + else if ( ( modeBitsPerPixel == 8 ) && ( modeInfo.MemoryModel == 4 ) ) + { + // Packed pixel, 256 colors. + } + else if ( ( ( modeBitsPerPixel == 16 ) || ( modeBitsPerPixel == 15 ) ) + && ( modeInfo.MemoryModel == 6 ) + && ( modeInfo.RedMaskSize == 5 ) + && ( modeInfo.GreenMaskSize == 5 ) + && ( modeInfo.BlueMaskSize == 5 ) ) + { + // Direct color, 16 bpp (1:5:5:5). + modeInfo.BitsPerPixel = modeBitsPerPixel = 16; + } + else if ( ( modeBitsPerPixel == 32 ) + && ( modeInfo.MemoryModel == 6 ) + && ( modeInfo.RedMaskSize == 8 ) + && ( modeInfo.GreenMaskSize == 8 ) + && ( modeInfo.BlueMaskSize == 8 ) ) + { + // Direct color, 32 bpp (8:8:8:8). + } + else + { + continue; // Not a supported mode. + } + + // Modes larger than the specified dimensions are skipped. + + if ( ( modeInfo.XResolution > width ) || + ( modeInfo.YResolution > height ) ) + { + continue; + } + + // Perfect match, we're done looking. + + if ( ( modeInfo.XResolution == width ) && + ( modeInfo.YResolution == height ) && + ( modeBitsPerPixel == bitsPerPixel ) ) + { + matchedMode = *modePtr; + //bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) ); + bcopy( &modeInfo, outModeInfo, sizeof(VBEModeInfoBlock) ); + + break; + } + + // Save the next "best" mode in case a perfect match is not found. + + if ( modeInfo.XResolution == outModeInfo->XResolution && + modeInfo.YResolution == outModeInfo->YResolution && + modeBitsPerPixel <= outModeInfo->BitsPerPixel ) + { + continue; // Saved mode has more depth. + } + if ( modeInfo.XResolution < outModeInfo->XResolution || + modeInfo.YResolution < outModeInfo->YResolution || + modeBitsPerPixel < outModeInfo->BitsPerPixel ) + { + continue; // Saved mode has more resolution. + } + + matchedMode = *modePtr; + bcopy( &modeInfo, outModeInfo, sizeof(VBEModeInfoBlock) ); + + } + + return matchedMode; +} + +//========================================================================== +// setVESATextMode + +static int +setVESATextMode( unsigned short cols, + unsigned short rows, + unsigned char bitsPerPixel ) +{ + VBEModeInfoBlock minfo; + unsigned short mode = modeEndOfList; + + if ( (cols != 80) || (rows != 25) ) // not 80x25 mode + { + mode = getVESAModeWithProperties( cols, rows, bitsPerPixel, + maColorModeBit | + maModeIsSupportedBit, + maGraphicsModeBit, + &minfo, NULL ); + } + + if ( ( mode == modeEndOfList ) || ( setVBEMode(mode, NULL) != errSuccess ) ) + { + video_mode( 2 ); // VGA BIOS, 80x25 text mode. + minfo.XResolution = 80; + minfo.YResolution = 25; + } + + // Update KernBootStruct using info provided by the selected + // VESA mode. + + bootArgs->Video.v_display = VGA_TEXT_MODE; + bootArgs->Video.v_baseAddr = 0xb8000; + bootArgs->Video.v_width = minfo.XResolution; + bootArgs->Video.v_height = minfo.YResolution; + bootArgs->Video.v_depth = 8; + bootArgs->Video.v_rowBytes = 0x8000; + + return errSuccess; // always return success +} + +//========================================================================== +// setVideoMode +// +// Set the video mode to VGA_TEXT_MODE or GRAPHICS_MODE. +#if UNUSED +void +setVideoMode( int mode, int drawgraphics) +#else +void +setVideoMode( int mode) +#endif +{ + unsigned long params[4]; + int count; + int err = errSuccess; + + if ( mode == GRAPHICS_MODE ) + { + if ( (err=GUI_initGraphicsMode ()) == errSuccess ) { + if (gVerboseMode) { + // Tell the kernel to use text mode on a linear frame buffer display + setBootArgsVideoMode(FB_TEXT_MODE); + + } else { + setBootArgsVideoMode(GRAPHICS_MODE); + + } + } + } + + if ( (mode == VGA_TEXT_MODE) || (err != errSuccess) ) + { + count = getNumberArrayFromProperty( kTextModeKey, params, 2 ); + if ( count < 2 ) + { + params[0] = 80; // Default text mode is 80x25. + params[1] = 25; + } + + setVESATextMode( params[0], params[1], 4 ); + setBootArgsVideoMode(VGA_TEXT_MODE); + } + +} + +//========================================================================== +// setupPalette + +static void setupPalette( VBEPalette * p, const unsigned char * g ) +{ + int i; + unsigned char * source = (unsigned char *) g; + + for (i = 0; i < 256; i++) + { + (*p)[i] = 0; + (*p)[i] |= ((unsigned long)((*source++) >> 2)) << 16; // Red + (*p)[i] |= ((unsigned long)((*source++) >> 2)) << 8; // Green + (*p)[i] |= ((unsigned long)((*source++) >> 2)); // Blue + + } +} + + +//========================================================================== +// setVESAGraphicsMode +#if UNUSED +int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate ) +#else +int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel) +#endif +{ + VBEModeInfoBlock minfo; + unsigned short mode; + unsigned short vesaVersion; + int err = errFuncNotSupported; + + do { + mode = getVESAModeWithProperties( width, height, bitsPerPixel, + maColorModeBit | + maModeIsSupportedBit | + maGraphicsModeBit | + maLinearFrameBufferAvailBit, + 0, + &minfo, &vesaVersion ); + if ( mode == modeEndOfList ) + { + break; + } +#if UNUSED + // + // FIXME : generateCRTCTiming() causes crash. + // + + // if ( (vesaVersion >> 8) >= 3 && refreshRate >= 60 && + // (gBootMode & kBootModeSafe) == 0 ) + // { + // VBECRTCInfoBlock timing; + // + // // Generate CRTC timing for given refresh rate. + // + // generateCRTCTiming( minfo.XResolution, minfo.YResolution, + // refreshRate, kCRTCParamRefreshRate, + // &timing ); + // + // // Find the actual pixel clock supported by the hardware. + // + // getVBEPixelClock( mode, &timing.PixelClock ); + // + // // Re-compute CRTC timing based on actual pixel clock. + // + // generateCRTCTiming( minfo.XResolution, minfo.YResolution, + // timing.PixelClock, kCRTCParamPixelClock, + // &timing ); + // + // // Set the video mode and use specified CRTC timing. + // + // err = setVBEMode( mode | kLinearFrameBufferBit | + // kCustomRefreshRateBit, &timing ); + // } + // else + // { + // // Set the mode with default refresh rate. + // + // err = setVBEMode( mode | kLinearFrameBufferBit, NULL ); + // } +#endif + // Set the mode with default refresh rate. + + err = setVBEMode( mode | kLinearFrameBufferBit, NULL ); + + if ( err != errSuccess ) + { + break; + } + + // Set 8-bit color palette. + + if ( minfo.BitsPerPixel == 8 ) + { + VBEPalette palette; + setupPalette( &palette, appleClut8 ); + if ((err = setVBEPalette(palette)) != errSuccess) + { + break; + } + } + + // Is this required for buggy Video BIOS implementations? + // On which adapter? + + if ( minfo.BytesPerScanline == 0 ) + minfo.BytesPerScanline = ( minfo.XResolution * + minfo.BitsPerPixel ) >> 3; + + // Update KernBootStruct using info provided by the selected + // VESA mode. + + setBootArgsVideoMode(GRAPHICS_MODE); + + bootArgs->Video.v_width = minfo.XResolution; + bootArgs->Video.v_height = minfo.YResolution; + bootArgs->Video.v_depth = minfo.BitsPerPixel; + bootArgs->Video.v_rowBytes = minfo.BytesPerScanline; + bootArgs->Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr); + + } + while ( 0 ); + + return err; +} + void getGraphicModeParams(unsigned long params[]) { params[3] = 0; @@ -341,7 +850,7 @@ //========================================================================== // getVBEInfoString -char *getVBEInfoString() +char *getVBEInfoString(void) { VBEInfoBlock vbeInfo; int err, small; Index: branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c =================================================================== --- branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c (revision 1839) +++ branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c (revision 1840) @@ -7,9 +7,8 @@ #include "kernel_patcher.h" #include "platform.h" #include "modules.h" -extern PlatformInfo_t* Platform; -long long symbol_handler(char* symbolName, long long addr, char is64); +long long symbol_handler(char* module, char* symbolName, long long addr, char is64); patchRoutine_t* patches = NULL; kernSymbols_t* kernelSymbols = NULL; @@ -33,9 +32,11 @@ //static void patch_lapic_interrupt(void* kernelData); void patch_kernel(void* kernelData, void* arg2, void* arg3, void *arg4, void* arg5, void* arg6); +void kernel_patcher_ignore_cache(void* arg1, void* arg2, void* arg3, void *arg4, void* arg5, void* arg6); void kernel_patcher_ignore_cache(void* arg1, void* arg2, void* arg3, void *arg4, void* arg5, void* arg6){} -void KernelPatcher_start() +void KernelPatcher_start(void); +void KernelPatcher_start(void) { register_kernel_patch(patch_cpuid_set_info_all, KERNEL_ANY, CPUID_MODEL_UNKNOWN); @@ -65,7 +66,7 @@ register_hook_callback("ExecKernel", &patch_kernel); - replace_function("_getKernelCachePath", &kernel_patcher_ignore_cache); + replace_system_function("_getKernelCachePath", &kernel_patcher_ignore_cache); } /* @@ -77,16 +78,15 @@ // AKA, don't at 64bit patches if it's a 32bit only machine patchRoutine_t* entry; - // TODO: verify Platform->CPU.Model is populated this early in bootup // Check to ensure that the patch is valid on this machine // If it is not, exit early form this function - if(cpus != Platform->CPU.Model) + if(cpus != get_env(envModel)) { if(cpus != CPUID_MODEL_ANY) { if(cpus == CPUID_MODEL_UNKNOWN) { - switch(Platform->CPU.Model) + switch(get_env(envModel)) { case 13: case CPUID_MODEL_YONAH: @@ -226,12 +226,12 @@ static int locate_symbols(void* kernelData) { char is64 = 1; - parse_mach(kernelData, NULL, symbol_handler); + parse_mach("VirtualXnuSyms",kernelData, NULL, symbol_handler); //handle_symtable((UInt32)kernelData, symtableData, &symbol_handler, determineKernelArchitecture(kernelData) == KERNEL_64); return 1 << is64; } -long long symbol_handler(char* symbolName, long long addr, char is64) +long long symbol_handler(char* module, char* symbolName, long long addr, char is64) { // Locate the symbol in the list, if it exists, update it's address kernSymbols_t *symbol = lookup_kernel_symbol(symbolName); @@ -250,7 +250,7 @@ **/ static void patch_cpuid_set_info_all(void* kernelData) { - switch(Platform->CPU.Model) + switch(get_env(envModel)) { case CPUID_MODEL_ATOM: if(determineKernelArchitecture(kernelData) == KERNEL_32) @@ -267,7 +267,7 @@ default: { // AnV: Extra cpuid fix for spoofing Nehalem CPU for i5/i9 - switch(Platform->CPU.Family) + switch(get_env(envFamily)) { case 0x1E: /* Intel i5 */ case 0x2C: /* Intel i9 */ Index: branches/cparm/i386/modules/KernelPatcher/Makefile =================================================================== --- branches/cparm/i386/modules/KernelPatcher/Makefile (revision 1839) +++ branches/cparm/i386/modules/KernelPatcher/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -KERN_OBJS = kernel_patcher.o +KERN_OBJS = kernel_patcher.o stack_protector.o SFILES = @@ -69,12 +69,18 @@ -no_uuid \ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ - $(OBJROOT)/kernel_patcher.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/kernel_patcher.o \ -macosx_version_min 10.6 \ -weak_library $(SYMROOT)/Symbols.dylib \ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + + kernel_patcher.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "kernel_patcher.c" $(INC) -o "$(OBJROOT)/kernel_patcher.o" Index: branches/cparm/i386/modules/Networking/Networking.c =================================================================== --- branches/cparm/i386/modules/Networking/Networking.c (revision 1839) +++ branches/cparm/i386/modules/Networking/Networking.c (revision 1840) @@ -5,7 +5,6 @@ #include "libsaio.h" #include "modules.h" -#include "boot.h" #include "bootstruct.h" #include "pci.h" #include "device_inject.h" @@ -27,6 +26,9 @@ static void set_wifi_airport(pci_dt_t *wlan_dev); static int devprop_add_network_template(struct DevPropDevice *device, uint16_t vendor_id); + +void Networking_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); + uint32_t builtin_set = 0; void Networking_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) @@ -38,7 +40,7 @@ // LAN bool do_eth_devprop = true; - getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig); + getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, DEFAULT_BOOT_CONFIG); if (do_eth_devprop) { @@ -49,7 +51,7 @@ { // WIFI bool do_wifi_devprop = true; - getBoolForKey(kEnableWifi, &do_wifi_devprop, &bootInfo->bootConfig); + getBoolForKey(kEnableWifi, &do_wifi_devprop, DEFAULT_BOOT_CONFIG); if (do_wifi_devprop) set_wifi_airport(current); @@ -58,10 +60,11 @@ } -void Networking_start() +void Networking_start(void); +void Networking_start(void) { bool enable = true; - getBoolForKey(kEnableNetworking, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableNetworking, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) { register_hook_callback("PCIDevice", &Networking_hook); Index: branches/cparm/i386/modules/Networking/Makefile =================================================================== --- branches/cparm/i386/modules/Networking/Makefile (revision 1839) +++ branches/cparm/i386/modules/Networking/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -NET_OBJS = Networking.o +NET_OBJS = Networking.o stack_protector.o SFILES = @@ -71,10 +71,13 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/Networking.o -o $(SYMROOT)/$(MODULE_NAME).dylib + $(OBJROOT)/stack_protector.o $(OBJROOT)/Networking.o -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + - Networking.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "Networking.c" $(INC) -o "$(OBJROOT)/Networking.o" Index: branches/cparm/i386/modules/GraphicsEnabler/gma.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/gma.c (revision 1839) +++ branches/cparm/i386/modules/GraphicsEnabler/gma.c (revision 1840) @@ -123,21 +123,21 @@ devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1)); devprop_add_value(device, "device_type", (uint8_t*)"display", 8); - if ((model == (char *)"Mobile GMA950") || - (model == (char *)"Mobile GMA3150")) + if ((strcmp(model, "Mobile GMA950") == 0) || + (strcmp(model, "Mobile GMA3150") == 0)) { devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4); devprop_add_value(device, "built-in", &BuiltIn, 1); devprop_add_value(device, "class-code", ClassFix, 4); } - else if ((model == (char *)"Desktop GMA950") || - (model == (char *)"Desktop GMA3150")) + else if ((strcmp(model, "Desktop GMA950")== 0) || + (strcmp(model, "Desktop GMA3150") == 0)) { BuiltIn = 0x01; devprop_add_value(device, "built-in", &BuiltIn, 1); devprop_add_value(device, "class-code", ClassFix, 4); } - else if (model == (char *)"GMAX3100") + else if ( strcmp(model, "GMAX3100") == 0 ) { devprop_add_value(device, "AAPL,HasPanel",GMAX3100_vals[0], 4); devprop_add_value(device, "AAPL,SelfRefreshSupported",GMAX3100_vals[1], 4); @@ -163,7 +163,7 @@ devprop_add_value(device, "AAPL01,Stretch",GMAX3100_vals[21], 4); devprop_add_value(device, "class-code", ClassFix, 4); } - else if (model == (char *)"Intel HD Graphics 3000") + else if (strcmp(model, "Intel HD Graphics 3000") == 0) { devprop_add_value(device, "AAPL,os-info", HD3000_os_info, 20); } Index: branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c (revision 1839) +++ branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c (revision 1840) @@ -17,11 +17,12 @@ #define kGraphicsEnabler "EnableGFXModule" void GraphicsEnabler_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void GraphicsEnabler_start(void); -void GraphicsEnabler_start() +void GraphicsEnabler_start(void) { bool enable = true; - getBoolForKey(kGraphicsEnabler, &enable, &bootInfo->bootConfig); + getBoolForKey(kGraphicsEnabler, &enable, DEFAULT_BOOT_CONFIG); if (enable) Index: branches/cparm/i386/modules/GraphicsEnabler/nvidia.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 1839) +++ branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 1840) @@ -49,7 +49,6 @@ */ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" #include "pci.h" #include "platform.h" @@ -977,7 +976,7 @@ //printf("group channel 1\n"); channel1 |= ( 0x1 << entries[i].index); entries[i].type = TYPE_GROUPED; - if((entries[i-1].type == 0x0)) { + if(entries[i-1].type == 0x0) { channel1 |= ( 0x1 << entries[i-1].index); entries[i-1].type = TYPE_GROUPED; } @@ -992,7 +991,7 @@ //printf("group channel 2 : %d\n", i); channel2 |= ( 0x1 << entries[i].index); entries[i].type = TYPE_GROUPED; - if((entries[i-1].type == 0x0)) { + if(entries[i-1].type == 0x0) { channel2 |= ( 0x1 << entries[i-1].index); entries[i-1].type = TYPE_GROUPED; } @@ -1166,6 +1165,13 @@ return vram_size; } +typedef struct _dcfg_t { + uint8_t val0; + uint8_t val1; + uint8_t val2; + uint8_t val3; +} dcfg_t; + bool setup_nvidia_devprop(pci_dt_t *nvda_dev) { struct DevPropDevice *device; @@ -1187,13 +1193,17 @@ char *model; const char *value; bool doit; - - uint8_t default_dcfg_0[] = {0xff, 0xff, 0xff, 0xff}; - uint8_t default_dcfg_1[] = {0xff, 0xff, 0xff, 0xff}; -#define DCFG0_LEN ( sizeof(default_dcfg_0) / sizeof(uint8_t) ) -#define DCFG1_LEN ( sizeof(default_dcfg_1) / sizeof(uint8_t) ) + static const dcfg_t default_dcfg [] = { + {0xff,0xff,0xff,0xff}, + }; +#define DCFG_LEN sizeof(default_dcfg) + dcfg_t default_dcfg_0; + dcfg_t default_dcfg_1; + bool dcfg0_set = false; + bool dcfg1_set = false; + devicepath = get_pci_dev_path(nvda_dev); bar[0] = pci_config_read32(nvda_dev->dev.addr, 0x10 ); regs = (uint8_t *) (bar[0] & ~0x0f); @@ -1216,7 +1226,7 @@ rom = malloc(NVIDIA_ROM_SIZE); sprintf(nvFilename, "/Extra/%04x_%04x.rom", (uint16_t)nvda_dev->vendor_id, (uint16_t)nvda_dev->device_id); - if (getBoolForKey(kUseNvidiaROM, &doit, &bootInfo->bootConfig) && doit) { + if (getBoolForKey(kUseNvidiaROM, &doit, DEFAULT_BOOT_CONFIG) && doit) { verbose("Looking for nvidia video bios file %s\n", nvFilename); nvBiosOveride = load_nvidia_bios_file(nvFilename, rom, NVIDIA_ROM_SIZE); if (nvBiosOveride > 0) { @@ -1272,6 +1282,7 @@ printf("ERROR: nVidia ROM Patching Failed!\n"); return false; } + DBG("nvidia rom successfully patched\n"); rom_pci_header = (struct pci_rom_pci_header_t*)(rom + *(uint16_t *)&rom[24]); @@ -1284,7 +1295,9 @@ printf("nVidia incorrect PCI ROM signature: 0x%x\n", rom_pci_header->signature); } } + DBG("nvidia model : %s\n",model); + if (!string) { string = devprop_create_string(); } @@ -1334,7 +1347,7 @@ sprintf(biosVersion, "%s", (nvBiosOveride > 0) ? nvFilename : version_str); sprintf(kNVCAP, "NVCAP_%04x", nvda_dev->device_id); - if (getValueForKey(kNVCAP, &value, &len, &bootInfo->bootConfig) && len == NVCAP_LEN * 2) { + if (getValueForKey(kNVCAP, &value, &len, DEFAULT_BOOT_CONFIG) && len == NVCAP_LEN * 2) { uint8_t new_NVCAP[NVCAP_LEN]; if (hex2bin(value, new_NVCAP, NVCAP_LEN) == 0) { @@ -1343,31 +1356,34 @@ } } - if (getValueForKey(kDcfg0, &value, &len, &bootInfo->bootConfig) && len == DCFG0_LEN * 2) - { - uint8_t new_dcfg0[DCFG0_LEN]; - - if (hex2bin(value, new_dcfg0, DCFG0_LEN) == 0) - { - memcpy(default_dcfg_0, new_dcfg0, DCFG0_LEN); - + if (getValueForKey(kDcfg0, &value, &len, DEFAULT_BOOT_CONFIG) && len == DCFG_LEN * 2) + { + if (hex2bin(value, (uint8_t*)&default_dcfg_0, DCFG_LEN) == 0) + { + dcfg0_set = true; verbose("@0,display-cfg: %02x%02x%02x%02x\n", - default_dcfg_0[0], default_dcfg_0[1], default_dcfg_0[2], default_dcfg_0[3]); + default_dcfg_0.val0, default_dcfg_0.val1, default_dcfg_0.val2, default_dcfg_0.val3); } } - if (getValueForKey(kDcfg1, &value, &len, &bootInfo->bootConfig) && len == DCFG1_LEN * 2) - { - uint8_t new_dcfg1[DCFG1_LEN]; - - if (hex2bin(value, new_dcfg1, DCFG1_LEN) == 0) - { - memcpy(default_dcfg_1, new_dcfg1, DCFG1_LEN); - + if (getValueForKey(kDcfg1, &value, &len, DEFAULT_BOOT_CONFIG) && len == DCFG_LEN * 2) + { + if (hex2bin(value, (uint8_t*)&default_dcfg_1, DCFG_LEN) == 0) + { + dcfg1_set = true; verbose("@1,display-cfg: %02x%02x%02x%02x\n", - default_dcfg_1[0], default_dcfg_1[1], default_dcfg_1[2], default_dcfg_1[3]); + default_dcfg_1.val0, default_dcfg_1.val1, default_dcfg_1.val2, default_dcfg_1.val3); } } + + if (dcfg0_set == false) + { + memcpy(&default_dcfg_0, default_dcfg,DCFG_LEN ); + } + if (dcfg1_set == false) + { + memcpy(&default_dcfg_1, default_dcfg,DCFG_LEN ); + } #if DEBUG_NVCAP printf("NVCAP: %02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x\n", @@ -1377,16 +1393,15 @@ default_NVCAP[12], default_NVCAP[13], default_NVCAP[14], default_NVCAP[15], default_NVCAP[16], default_NVCAP[17], default_NVCAP[18], default_NVCAP[19]); #endif - devprop_add_nvidia_template(device); devprop_add_value(device, "NVCAP", default_NVCAP, NVCAP_LEN); devprop_add_value(device, "VRAM,totalsize", (uint8_t*)&videoRam, 4); devprop_add_value(device, "model", (uint8_t*)model, strlen(model) + 1); devprop_add_value(device, "rom-revision", (uint8_t*)biosVersion, strlen(biosVersion) + 1); - devprop_add_value(device, "@0,display-cfg", default_dcfg_0, DCFG0_LEN); - devprop_add_value(device, "@1,display-cfg", default_dcfg_1, DCFG1_LEN); - if (getBoolForKey(kVBIOS, &doit, &bootInfo->bootConfig) && doit) { + devprop_add_value(device, "@0,display-cfg", (uint8_t*)&default_dcfg_0, DCFG_LEN); + devprop_add_value(device, "@1,display-cfg", (uint8_t*)&default_dcfg_1, DCFG_LEN); + if (getBoolForKey(kVBIOS, &doit, DEFAULT_BOOT_CONFIG) && doit) { devprop_add_value(device, "vbios", rom, (nvBiosOveride > 0) ? nvBiosOveride : (uint32_t)(rom[2] * 512)); } Index: branches/cparm/i386/modules/GraphicsEnabler/Makefile =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/Makefile (revision 1839) +++ branches/cparm/i386/modules/GraphicsEnabler/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -GRAPHICS_ENABLER_OBJS = nvidia.o ati.o gma.o GraphicsEnabler.o +GRAPHICS_ENABLER_OBJS = nvidia.o ati.o gma.o GraphicsEnabler.o stack_protector.o SFILES = @@ -70,15 +70,18 @@ -no_uuid \ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/nvidia.o \ $(OBJROOT)/ati.o \ - $(OBJROOT)/nvidia.o \ $(OBJROOT)/gma.o \ $(OBJROOT)/GraphicsEnabler.o \ -macosx_version_min 10.6 \ -o $(SYMROOT)/$(MODULE_NAME).dylib - - + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + GraphicsEnabler.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "GraphicsEnabler.c" $(INC) -o "$(OBJROOT)/GraphicsEnabler.o" Index: branches/cparm/i386/modules/GraphicsEnabler/ati.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/ati.c (revision 1839) +++ branches/cparm/i386/modules/GraphicsEnabler/ati.c (revision 1840) @@ -5,7 +5,7 @@ * */ -#include "boot.h" +#include "libsaio.h" #include "bootstruct.h" #include "pci.h" #include "platform.h" @@ -19,6 +19,7 @@ #define RegRead32(reg) (Reg32(reg)) #define RegWrite32(reg, value) (Reg32(reg) = value) + typedef enum { kNul, kStr, @@ -818,7 +819,15 @@ {FLAGTRUE, false, NULL, NULL, NULVAL } }; +bool radeon_card_posted(void); +bool read_disabled_vbios(void); +bool read_vbios(bool from_pci); +void get_vram_size(void); +bool load_vbios_file(const char *key, uint16_t vendor_id, uint16_t device_id, uint32_t subsys_id); +void free_val(value_t *val); +void devprop_add_list(dev_prop_t devprop_list[]); + bool get_bootdisplay_val(value_t *val) { static uint32_t v = 0; @@ -1071,7 +1080,7 @@ char file_name[24]; bool do_load = false; - getBoolForKey(key, &do_load, &bootInfo->bootConfig); + getBoolForKey(key, &do_load, DEFAULT_BOOT_CONFIG); if (!do_load) return false; @@ -1345,7 +1354,7 @@ get_vram_size(); - getBoolForKey(kATYbinimage, &add_vbios, &bootInfo->bootConfig); + getBoolForKey(kATYbinimage, &add_vbios, DEFAULT_BOOT_CONFIG); if (add_vbios) { @@ -1371,7 +1380,7 @@ // atN = 0; // Check AtiConfig key for a framebuffer name, - card->cfg_name = getStringForKey(kAtiConfig, &bootInfo->bootConfig); + card->cfg_name = getStringForKey(kAtiConfig, DEFAULT_BOOT_CONFIG); // if none, if (!card->cfg_name) { @@ -1390,7 +1399,7 @@ } // Check AtiPorts key for nr of ports, - card->ports = getIntForKey(kAtiPorts, &n_ports, &bootInfo->bootConfig); + card->ports = getIntForKey(kAtiPorts, &n_ports, DEFAULT_BOOT_CONFIG); // if a value bigger than 0 ?? is found, (do we need >= 0 ?? that's null FB on card_configs) if (n_ports > 0) { Index: branches/cparm/i386/modules/SMBiosGetters/mysmbios.c =================================================================== --- branches/cparm/i386/modules/SMBiosGetters/mysmbios.c (revision 1839) +++ branches/cparm/i386/modules/SMBiosGetters/mysmbios.c (revision 1840) @@ -6,7 +6,7 @@ */ -#include "boot.h" +#include "libsaio.h" #include "bootstruct.h" #include "smbios_getters.h" @@ -22,7 +22,6 @@ #define DBG(x...) #endif -#define SMBPlist &bootInfo->smbiosConfig /* ASSUMPTION: 16KB should be enough for the whole thing */ #define SMB_ALLOC_SIZE 16384 @@ -321,25 +320,30 @@ SMBStructHeader *new; } SMBStructPtrs; -struct { +typedef struct { const char *vendor; const char *version; const char *releaseDate; -} defaultBIOSInfo; +} defaultBIOSInfo_t; -struct { +defaultBIOSInfo_t defaultBIOSInfo; + +typedef struct { const char *manufacturer; const char *productName; const char *version; const char *serialNumber; const char *family; -} defaultSystemInfo; +} defaultSystemInfo_t; -struct { +defaultSystemInfo_t defaultSystemInfo; + +typedef struct { const char *manufacturer; const char *product; -} defaultBaseBoard; +} defaultBaseBoard_t; +defaultBaseBoard_t defaultBaseBoard; typedef struct { uint8_t type; @@ -488,8 +492,12 @@ static void addSMBEndOfTable(SMBStructPtrs *structPtr); static void setSMBStruct(SMBStructPtrs *structPtr); static void setupNewSMBIOSTable(SMBEntryPoint *eps, SMBStructPtrs *structPtr); +const char* sm_search_str(const SMStrEntryPair* sm_defaults, const char * key); +const char* sm_get_random_productNumber(void); +const char* sm_get_random_week(void); +const char* sm_get_random_year(void); +const char* sm_get_random_country(void); - const char *getDefaultSMBproductName(void) { setDefaultSMBData(); @@ -518,7 +526,7 @@ return ""; } -const char* sm_get_random_productNumber() +const char* sm_get_random_productNumber(void) { static char str[4] = {0x00,0x00,0x00,0x00}; if(str[0] == 0) @@ -551,7 +559,7 @@ return str; } -const char* sm_get_random_week() +const char* sm_get_random_week(void) { static char str[4] = {0x00,0x00,0x00,0x00}; if(str[0] == 0) @@ -580,7 +588,7 @@ return str; } -const char* sm_get_random_year() +const char* sm_get_random_year(void) { static char str[2] = {0x00,0x00}; if(str[0] == 0) @@ -606,7 +614,7 @@ return str; } -const char* sm_get_random_country() +const char* sm_get_random_country(void) { static char str[3] = {0x00,0x00,0x00}; if(str[0] == 0) @@ -635,17 +643,17 @@ const SMStrEntryPair* sm_defaults; const SMStrEntryPair* sm_chosen; - if (platformIsServer() == true) + if (get_env(envIsServer)) { sm_defaults=sm_xserve_defaults; - } else if (platformIsMobile() == true) { - if (getCPUnCores() > 1) { + } else if (get_env(envIsMobile)) { + if (get_env(envNoCores) > 1) { sm_defaults=sm_macbookpro_defaults; } else { sm_defaults=sm_macbook_defaults; } } else { - switch (getCPUnCores()) + switch (get_env(envNoCores)) { case 1: sm_defaults=sm_macmini_defaults; @@ -655,11 +663,11 @@ break; default: { - switch (getCPUFamily()) + switch (get_env(envFamily)) { case 0x06: { - switch (getCPUModel()) + switch (get_env(envModel)) { case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm) case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) ??? @@ -702,7 +710,7 @@ const char *str; int size; - if (getValueForKey("SMproductname", &str, &size, &bootInfo->smbiosConfig)) + if (getValueForKey("SMproductname", &str, &size, DEFAULT_SMBIOS_CONFIG)) { if (strstr (str, "MacPro5")) { @@ -756,7 +764,7 @@ bzero (fake_serial,sizeof(fake_serial)); bool randomSerial = false; - getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig) ; + getBoolForKey(kSMBIOSRandomSerial, &randomSerial, DEFAULT_BOOT_CONFIG) ; if ( randomSerial ) // useless strlcpy (fake_serial,sm_get_random_country(), strlen(sm_get_random_country())+1); @@ -818,12 +826,12 @@ if (value) { - if (getIntForKey(key, (int *)&(value->dword), SMBPlist)) + if (getIntForKey(key, (int *)&(value->dword), DEFAULT_SMBIOS_CONFIG)) return true; } else { - if (getValueForKey(key, string, &len, SMBPlist)) + if (getValueForKey(key, string, &len, DEFAULT_SMBIOS_CONFIG)) return true; } @@ -897,7 +905,7 @@ case kSMBString: { bool randomSerial = false; - getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig); + getBoolForKey(kSMBIOSRandomSerial, &randomSerial, DEFAULT_BOOT_CONFIG); if (SMBSetters[idx].keyString) { @@ -906,7 +914,7 @@ string = *(SMBSetters[idx].defaultValue); break; } - else if (getValueForKey(SMBSetters[idx].keyString, &string, &len, SMBPlist)) + else if (getValueForKey(SMBSetters[idx].keyString, &string, &len, DEFAULT_SMBIOS_CONFIG)) break; else if (structPtr->orig->type == kSMBTypeMemoryDevice) // MemoryDevice only @@ -930,7 +938,7 @@ //case kSMBQWord: /*if (SMBSetters[idx].keyString) { - if (getIntForKey(SMBSetters[idx].keyString, (int *)&(value->dword), SMBPlist)) + if (getIntForKey(SMBSetters[idx].keyString, (int *)&(value->dword), DEFAULT_SMBIOS_CONFIG)) return true; else if (structPtr->orig->type == kSMBTypeMemoryDevice) // MemoryDevice only @@ -939,7 +947,7 @@ }*/ if (SMBSetters[idx].keyString) { - parsed = getIntForKey(SMBSetters[idx].keyString, &val, SMBPlist); + parsed = getIntForKey(SMBSetters[idx].keyString, &val, DEFAULT_SMBIOS_CONFIG); if (!parsed) if (structPtr->orig->type == kSMBTypeMemoryDevice) // MemoryDevice only parsed = getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, NULL, (returnType *)&val); @@ -1012,11 +1020,11 @@ { SMBOemProcessorBusSpeed *p = (SMBOemProcessorBusSpeed *)structPtr->new; - switch (getCPUFamily()) + switch (get_env(envFamily)) { case 0x06: { - switch (getCPUModel()) + switch (get_env(envModel)) { case 0x19: // Intel Core i5 650 @3.20 Ghz case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm) @@ -1184,14 +1192,14 @@ if (!structPtr) return NULL; - buffer = malloc(SMB_ALLOC_SIZE); + buffer = (uint8_t *)malloc(SMB_ALLOC_SIZE); if (!buffer) return NULL; bzero(buffer, SMB_ALLOC_SIZE); structPtr->new = (SMBStructHeader *)buffer; - getBoolForKey(kSMBIOSdefaults, &setSMB, &bootInfo->bootConfig); + getBoolForKey(kSMBIOSdefaults, &setSMB, DEFAULT_BOOT_CONFIG); if (setSMB) setDefaultSMBData(); @@ -1246,28 +1254,32 @@ SMBStructHeader *structHeader = (SMBStructHeader *)structPtr; int dimmnbr = 0; - Platform->DMI.MaxMemorySlots = 0; - Platform->DMI.CntMemorySlots = 0; - Platform->DMI.MemoryModules = 0; + int MaxMemorySlots = 0; // number of memory slots polulated by SMBIOS + int CntMemorySlots = 0; // number of memory slots counted + int MemoryModules = 0; + + static RamSlotInfo_t RamDimm[MAX_RAM_SLOTS]; + for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));) { switch (structHeader->type) { case kSMBTypeSystemInformation: - Platform->UUID = ((SMBSystemInformation *)structHeader)->uuid; + safe_set_env(envUUID,(uint32_t)((SMBSystemInformation *)structHeader)->uuid); break; case kSMBTypePhysicalMemoryArray: - Platform->DMI.MaxMemorySlots += ((SMBPhysicalMemoryArray *)structHeader)->numMemoryDevices; + MaxMemorySlots += ((SMBPhysicalMemoryArray *)structHeader)->numMemoryDevices; break; case kSMBTypeMemoryDevice: - Platform->DMI.CntMemorySlots++; + CntMemorySlots++; if (((SMBMemoryDevice *)structHeader)->memorySize != 0) - Platform->DMI.MemoryModules++; + MemoryModules++; if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0) - Platform->RAM.DIMM[dimmnbr].Frequency = ((SMBMemoryDevice *)structHeader)->memorySpeed; + + RamDimm[dimmnbr].Frequency = ((SMBMemoryDevice *)structHeader)->memorySpeed; dimmnbr++; break; default: @@ -1282,5 +1294,11 @@ structHeader = (SMBStructHeader *)structPtr; } + safe_set_env(envDMIMaxMemorySlots, MaxMemorySlots); + safe_set_env(envDMICntMemorySlots, CntMemorySlots); + safe_set_env(envDMIMemModules, MemoryModules); + safe_set_env_copy(envRamDimm, RamDimm, sizeof(RamDimm)); + + } Index: branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c =================================================================== --- branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c (revision 1839) +++ branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c (revision 1840) @@ -22,7 +22,7 @@ bool getProcessorInformationExternalClock(returnType *value) { - value->word = Platform->CPU.FSBFrequency/1000000; + value->word = (uint16_t)(get_env(envFSBFreq)/1000000); return true; } @@ -31,27 +31,27 @@ // Note: it seems that AppleSMBIOS use the maximum clock to set the cpu clock // that is showed in "About this mac" or in the System Information. // in my opinion the current clock should be used for this. - // value->word = Platform->CPU.TSCFrequency/1000000; + // value->word = get_env(envTSCFreq)/1000000; - value->word = Platform->CPU.CPUFrequency/1000000; + value->word = (uint16_t)(get_env(envCPUFreq)/1000000); return true; } bool getProcessorInformationCurrentClock(returnType *value) { - value->word = Platform->CPU.CPUFrequency/1000000; + value->word = (uint16_t)(get_env(envCPUFreq)/1000000); return true; } bool getSMBOemProcessorBusSpeed(returnType *value) { - if (Platform->CPU.Vendor == 0x756E6547) // Intel + if (get_env(envVendor) == CPUID_VENDOR_INTEL) { - switch (Platform->CPU.Family) + switch (get_env(envFamily)) { case 0x06: { - switch (Platform->CPU.Model) + switch (get_env(envModel)) { case CPUID_MODEL_BANIAS: // Banias 0x09 case CPUID_MODEL_DOTHAN: // Dothan 0x0D @@ -60,7 +60,7 @@ case CPUID_MODEL_PENRYN: // Penryn 0x17 case CPUID_MODEL_ATOM: // Atom 45nm 0x1C return false; - + case 0x19: // Intel Core i5 650 @3.20 Ghz case CPUID_MODEL_NEHALEM: // Intel Core i7 LGA1366 (45nm) case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm) @@ -95,7 +95,7 @@ qpimult = pci_config_read32(PCIADDR(nhm_bus, 2, 1), 0x50); qpimult &= 0x7F; DBG("qpimult %d\n", qpimult); - qpibusspeed = (qpimult * 2 * (Platform->CPU.FSBFrequency/1000000)); + qpibusspeed = (qpimult * 2 * (get_env(envFSBFreq)/1000000)); // Rek: rounding decimals to match original mac profile info if (qpibusspeed%100 != 0)qpibusspeed = ((qpibusspeed+50)/100)*100; DBG("qpibusspeed %d\n", qpibusspeed); @@ -115,11 +115,12 @@ static uint16_t simpleGetSMBOemProcessorType(void) { - if (Platform->CPU.NoCores >= 4) + uint8_t ncores = (uint8_t)get_env(envNoCores); + if (ncores >= 4) { return 0x0501; // Quad-Core Xeon } - if (((Platform->CPU.NoCores == 1) || (Platform->CPU.NoCores == 2)) && !(platformCPUExtFeature(CPUID_EXTFEATURE_EM64T))) + if (((ncores == 1) || (ncores == 2)) && !(get_env(envExtFeatures)& CPUID_EXTFEATURE_EM64T)) { return 0x0201; // Core Solo / Duo }; @@ -130,22 +131,24 @@ bool getSMBOemProcessorType(returnType *value) { static bool done = false; - + value->word = simpleGetSMBOemProcessorType(); - - if (Platform->CPU.Vendor == 0x756E6547) // Intel + + char * BrandString = (char*)get_env_ptr(envBrandString); + + if (get_env(envVendor) == CPUID_VENDOR_INTEL) { if (!done) { - verbose("CPU is %s, family 0x%x, model 0x%x\n", Platform->CPU.BrandString, Platform->CPU.Family, Platform->CPU.Model); + verbose("CPU is %s, family 0x%x, model 0x%x\n", BrandString, (uint32_t)get_env(envFamily), (uint32_t)get_env(envModel)); done = true; } - switch (Platform->CPU.Family) + switch (get_env(envFamily)) { case 0x06: { - switch (Platform->CPU.Model) + switch (get_env(envModel)) { case CPUID_MODEL_BANIAS: // Banias case CPUID_MODEL_DOTHAN: // Dothan @@ -154,44 +157,44 @@ case CPUID_MODEL_PENRYN: // Penryn case CPUID_MODEL_ATOM: // Intel Atom (45nm) return true; - + case CPUID_MODEL_NEHALEM: // Intel Core i7 LGA1366 (45nm) - if (strstr(Platform->CPU.BrandString, "Core(TM) i7")) + if (strstr(BrandString, "Core(TM) i7")) value->word = 0x0701; // Core i7 return true; - + case CPUID_MODEL_FIELDS: // Lynnfield, Clarksfield, Jasper - if (strstr(Platform->CPU.BrandString, "Core(TM) i5")) + if (strstr(BrandString, "Core(TM) i5")) value->word = 0x601; // Core i5 else value->word = 0x701; // Core i7 return true; - + case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) (Havendale, Auburndale) - if (strstr(Platform->CPU.BrandString, "Core(TM) i5")) + if (strstr(BrandString, "Core(TM) i5")) value->word = 0x601; // Core i5 else value->word = 0x0701; // Core i7 return true; - + case CPUID_MODEL_SANDYBRIDGE: case CPUID_MODEL_DALES_32NM: // Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale) - if (strstr(Platform->CPU.BrandString, "Core(TM) i3")) - value->word = 0x901; // Core i3 - else if (strstr(Platform->CPU.BrandString, "Core(TM) i5")) - value->word = 0x601; // Core i5 - else if (strstr(Platform->CPU.BrandString, "Core(TM) i7")) - value->word = 0x0701; // Core i7 + if (strstr(BrandString, "Core(TM) i3")) + value->word = 0x901; // Core i3 + else if (strstr(BrandString, "Core(TM) i5")) + value->word = 0x601; // Core i5 + else if (strstr(BrandString, "Core(TM) i7")) + value->word = 0x0701; // Core i7 /*else - value->word = simpleGetSMBOemProcessorType();*/ + value->word = simpleGetSMBOemProcessorType();*/ return true; - + case CPUID_MODEL_JAKETOWN: case CPUID_MODEL_WESTMERE: // Intel Core i7 LGA1366 (32nm) 6 Core (Gulftown, Westmere-EP, Westmere-WS) case CPUID_MODEL_WESTMERE_EX: // Intel Core i7 LGA1366 (45nm) 6 Core ??? value->word = 0x0501; // Core i7 return true; - + case 0x19: // Intel Core i5 650 @3.20 Ghz value->word = 0x601; // Core i5 return true; @@ -212,15 +215,18 @@ static int idx = -1; if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { int map; - + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + idx++; if (idx < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[idx]; - if (Platform->RAM.DIMM[map].InUse && Platform->RAM.DIMM[map].Type != 0) + map = DmiDimm[idx]; + if (RamDimm[map].InUse && RamDimm[map].Type != 0) { - DBG("RAM Detected Type = %d\n", Platform->RAM.DIMM[map].Type); - value->byte = Platform->RAM.DIMM[map].Type; + DBG("RAM Detected Type = %d\n", RamDimm[map].Type); + value->byte = RamDimm[map].Type; return true; } } @@ -234,15 +240,18 @@ static int idx = -1; if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { int map; - + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + idx++; if (idx < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[idx]; - if (Platform->RAM.DIMM[map].InUse && Platform->RAM.DIMM[map].Frequency != 0) + map = DmiDimm[idx]; + if (RamDimm[map].InUse && RamDimm[map].Frequency != 0) { - DBG("RAM Detected Freq = %d Mhz\n", Platform->RAM.DIMM[map].Frequency); - value->dword = Platform->RAM.DIMM[map].Frequency; + DBG("RAM Detected Freq = %d Mhz\n", RamDimm[map].Frequency); + value->dword = RamDimm[map].Frequency; return true; } } @@ -256,15 +265,18 @@ static int idx = -1; if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { int map; - + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + idx++; if (idx < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[idx]; - if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].Vendor) > 0) + map = DmiDimm[idx]; + if (RamDimm[map].InUse && strlen(RamDimm[map].Vendor) > 0) { - DBG("RAM Detected Vendor[%d]='%s'\n", idx, Platform->RAM.DIMM[map].Vendor); - value->string = Platform->RAM.DIMM[map].Vendor; + DBG("RAM Detected Vendor[%d]='%s'\n", idx, RamDimm[map].Vendor); + value->string = RamDimm[map].Vendor; return true; } } @@ -272,22 +284,25 @@ value->string = "N/A"; return true; } - + bool getSMBMemoryDeviceSerialNumber(returnType *value) { static int idx = -1; if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { int map; - + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + idx++; if (idx < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[idx]; - if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].SerialNo) > 0) + map = DmiDimm[idx]; + if (RamDimm[map].InUse && strlen(RamDimm[map].SerialNo) > 0) { DBG("name = %s, map=%d, RAM Detected SerialNo[%d]='%s'\n", name ? name : "", - map, idx, Platform->RAM.DIMM[map].SerialNo); - value->string = Platform->RAM.DIMM[map].SerialNo; + map, idx, RamDimm[map].SerialNo); + value->string = RamDimm[map].SerialNo; return true; } } @@ -301,15 +316,18 @@ static int idx = -1; if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { int map; - + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + idx++; if (idx < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[idx]; - if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].PartNo) > 0) + map = DmiDimm[idx]; + if (RamDimm[map].InUse && strlen(RamDimm[map].PartNo) > 0) { - DBG("Ram Detected PartNo[%d]='%s'\n", idx, Platform->RAM.DIMM[map].PartNo); - value->string = Platform->RAM.DIMM[map].PartNo; + DBG("Ram Detected PartNo[%d]='%s'\n", idx, RamDimm[map].PartNo); + value->string = RamDimm[map].PartNo; return true; } } Index: branches/cparm/i386/modules/SMBiosGetters/SMBiosGetters.c =================================================================== --- branches/cparm/i386/modules/SMBiosGetters/SMBiosGetters.c (revision 1839) +++ branches/cparm/i386/modules/SMBiosGetters/SMBiosGetters.c (revision 1840) @@ -1,32 +1,39 @@ /* * Copyright 2011 cparm . All rights reserved. */ -#include "boot.h" +#include "libsaio.h" #include "bootstruct.h" -#include "libsaio.h" #include "modules.h" #include "Platform.h" #include "efi.h" #include "mysmbios.h" #define kEnableSMBIOSGetters "EnableSMBIOSGetters" +void getSmbiosPatched_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void getProductName_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void getboardproduct_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void is_SMB_Getters_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); - void getSmbiosPatched_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) { readSMBIOSInfo(getSmbiosOriginal()); execute_hook("ScanMemory", NULL, NULL, NULL, NULL, NULL, NULL); SMBEntryPoint *patched_smb = setupSMBIOSTable(getSmbiosOriginal()); - + if (patched_smb != NULL) - smbios_p = ((uint64_t)((uint32_t)patched_smb)); + //smbios_p = ((uint64_t)((uint32_t)patched_smb)); + Register_Smbios_Efi(patched_smb); + else { verbose("Error: Could not get patched SMBIOS, fallback to original SMBIOS !!\n"); - struct SMBEntryPoint *smbios_o = getSmbiosOriginal(); - smbios_p = ((uint64_t)((uint32_t)smbios_o)); + //struct SMBEntryPoint *smbios_o = getSmbiosOriginal(); + //smbios_p = ((uint64_t)((uint32_t)smbios_o)); + + Register_Smbios_Efi(getSmbiosOriginal()); + } } @@ -37,12 +44,16 @@ int len = 0; const char *val = 0; - if (getValueForKey("SMproductname", &val, &len, &bootInfo->smbiosConfig)) { - gPlatformName = (char *)val; + if (getValueForKey("SMproductname", &val, &len, DEFAULT_SMBIOS_CONFIG)) { + //gPlatformName = (char *)val; + SetgPlatformName(val); + } else { - gPlatformName = (char *)getDefaultSMBproductName(); + //gPlatformName = (char *)getDefaultSMBproductName(); + SetgPlatformName(getDefaultSMBproductName()); + } - + } void getboardproduct_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) @@ -51,20 +62,24 @@ int len = 0; const char *val = 0; - if (getValueForKey("SMboardproduct", &val, &len, &bootInfo->smbiosConfig)) { - gboardproduct = (char *)val; + if (getValueForKey("SMboardproduct", &val, &len, DEFAULT_SMBIOS_CONFIG)) { + //gboardproduct = (char *)val; + Setgboardproduct(val); + } else { - gboardproduct = (char *)getDefaultSMBBoardProduct(); - } + //gboardproduct = (char *)getDefaultSMBBoardProduct(); + Setgboardproduct(getDefaultSMBBoardProduct()); + } } void is_SMB_Getters_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){} -void SMBiosGetters_start() +void SMBiosGetters_start(void); +void SMBiosGetters_start(void) { bool enable = true; - getBoolForKey(kEnableSMBIOSGetters, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableSMBIOSGetters, &enable, DEFAULT_BOOT_CONFIG) ; enable = (execute_hook("isSMBIOSRegistred", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS); Index: branches/cparm/i386/modules/SMBiosGetters/Makefile =================================================================== --- branches/cparm/i386/modules/SMBiosGetters/Makefile (revision 1839) +++ branches/cparm/i386/modules/SMBiosGetters/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -SMBiosGetters_OBJS = SMBiosGetters.o mysmbios.o smbios_decode.o smbios_getters.o +SMBiosGetters_OBJS = SMBiosGetters.o mysmbios.o smbios_decode.o smbios_getters.o stack_protector.o SFILES = @@ -70,7 +70,8 @@ -no_uuid \ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ - $(OBJROOT)/SMBiosGetters.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/SMBiosGetters.o \ $(OBJROOT)/mysmbios.o \ $(OBJROOT)/smbios_getters.o \ $(OBJROOT)/smbios_decode.o \ @@ -78,6 +79,10 @@ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + SMBiosGetters.o: gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "SMBiosGetters.c" $(INC) -o "$(OBJROOT)/SMBiosGetters.o" Index: branches/cparm/i386/modules/HibernateEnabler/resume.c =================================================================== --- branches/cparm/i386/modules/HibernateEnabler/resume.c (revision 1839) +++ branches/cparm/i386/modules/HibernateEnabler/resume.c (revision 1840) @@ -7,12 +7,12 @@ * */ +#include "libsa.h" #include "saio_internal.h" -#include "libsa.h" #include "IOHibernatePrivate.h" #include "memory.h" #include "bootstruct.h" -#include "boot.h" +#include "platform.h" #include "pci.h" #include "resume.h" #include "graphic_utils.h" @@ -24,24 +24,28 @@ getmemorylimit(void); static void WakeKernel(IOHibernateImageHeader * header); + static unsigned long getmemorylimit(void) { - int line; - int i; - MemoryRange *mp = bootInfo->memoryMap; - - // Activate and clear page 1 - line = 1; - for (i = 0; i < bootInfo->memoryMapCount; i++) - { - if((mp->type == 1) && ((unsigned long)mp->base == 0x100000)) + int line; + int i; + + MemoryRange *mp = (MemoryRange*)(uint32_t)get_env(envMemoryMap); + int MemMapCnt = (int)get_env(envMemoryMapCnt); + + // Activate and clear page 1 + line = 1; + + for (i = 0; i < MemMapCnt; i++) { - return (unsigned long)(mp->base + mp->length); + if((mp->type == 1) && ((unsigned long)mp->base == 0x100000)) + { + return (unsigned long)(mp->base + mp->length); + } + mp++; } - mp++; - } - return 0x10000000; + return 0x10000000; } static void WakeKernel(IOHibernateImageHeader * header) @@ -123,37 +127,37 @@ newSP = header->restore1StackOffset + (header->restore1CodePhysPage << 12); src = (unsigned long *) (((u_int32_t) &header->fileExtentMap[0]) - + header->fileExtentMapSize); + + header->fileExtentMapSize); sum = 0; for (page = 0; page < count; page++) - { - compressedSize = 4096; - - lowHalf = 1; - highHalf = 0; - - for (cnt = 0; cnt < compressedSize; cnt += 0x20) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - dst[4] = src[4]; - dst[5] = src[5]; - dst[6] = src[6]; - dst[7] = src[7]; - for (byteCnt = 0; byteCnt < 0x20; byteCnt++) { - lowHalf += ((u_int8_t *) dst)[byteCnt]; - highHalf += lowHalf; - } - src += 8; - dst += 8; - } - - lowHalf %= 65521L; - highHalf %= 65521L; - sum += (highHalf << 16) | lowHalf; + { + compressedSize = 4096; + + lowHalf = 1; + highHalf = 0; + + for (cnt = 0; cnt < compressedSize; cnt += 0x20) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + dst[4] = src[4]; + dst[5] = src[5]; + dst[6] = src[6]; + dst[7] = src[7]; + for (byteCnt = 0; byteCnt < 0x20; byteCnt++) { + lowHalf += ((u_int8_t *) dst)[byteCnt]; + highHalf += lowHalf; } + src += 8; + dst += 8; + } + + lowHalf %= 65521L; + highHalf %= 65521L; + sum += (highHalf << 16) | lowHalf; + } header->actualRestore1Sum = sum; startprog (proc, header); @@ -174,34 +178,34 @@ imageSize = header->image1Size; codeSize = header->restore1PageCount << 12; if (kIOHibernateHeaderSignature != header->signature) - { - printf ("Incorrect image signature, expected version 10.7\n"); - getchar(); - return; - } + { + printf ("Incorrect image signature, expected version 10.7\n"); + getchar(); + return; + } if (header->encryptStart) - { - printf ("Resuming from Encrypted image is unsupported.\n" - "Uncheck \"Use secure virtual memory\" in \"Security\" pane on system preferences.\n" - "Press any key to proceed with normal boot.\n"); - getchar(); - return; - } + { + printf ("Resuming from Encrypted image is unsupported.\n" + "Uncheck \"Use secure virtual memory\" in \"Security\" pane on system preferences.\n" + "Press any key to proceed with normal boot.\n"); + getchar(); + return; + } // depends on NVRAM #if 0 - { - uint32_t machineSignature; - size = GetProp(gChosenPH, kIOHibernateMachineSignatureKey, - (char *)&machineSignature, sizeof(machineSignature)); - if (size != sizeof(machineSignature)) machineSignature = 0; - if (machineSignature != header->machineSignature) - break; - } + { + uint32_t machineSignature; + size = GetProp(gChosenPH, kIOHibernateMachineSignatureKey, + (char *)&machineSignature, sizeof(machineSignature)); + if (size != sizeof(machineSignature)) machineSignature = 0; + if (machineSignature != header->machineSignature) + break; + } #endif allocSize = imageSize + ((4095 + sizeof(hibernate_graphics_t)) & ~4095); - mem_base = getmemorylimit() - allocSize;//TODO: lower this + mem_base = (long)(getmemorylimit() - allocSize);//TODO: lower this printf("mem_base %x\n", mem_base); @@ -212,62 +216,62 @@ buffer = (long)(header + 1); if (header->previewSize) - { - uint64_t preview_offset = header->fileExtentMapSize - sizeof(header->fileExtentMap) + codeSize; - uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize]; - - ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader107), preview_offset+header->previewSize); - drawPreview ((void *)(long)(buffer+preview_offset + header->previewPageListSize), &(progressSaveUnder[0][0])); - previewTotalSectors = (imageSize-(preview_offset+header->previewSize))/512; - previewLoadedSectors = 0; - previewSaveunder = &(progressSaveUnder[0][0]); - if (preview_offset+header->previewSizepreviewSize), - sizeof(IOHibernateImageHeader107)+preview_offset+header->previewSize, - imageSize-(preview_offset+header->previewSize)); - previewTotalSectors = 0; - previewLoadedSectors = 0; - previewSaveunder = 0; + { + uint64_t preview_offset = header->fileExtentMapSize - sizeof(header->fileExtentMap) + codeSize; + uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize]; + + ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader107), preview_offset+header->previewSize); + drawPreview ((void *)(long)(buffer+preview_offset + header->previewPageListSize), &(progressSaveUnder[0][0])); + previewTotalSectors = (int)(imageSize-(preview_offset+header->previewSize))/512; + previewLoadedSectors = 0; + previewSaveunder = &(progressSaveUnder[0][0]); + if (preview_offset+header->previewSizepreviewSize), + sizeof(IOHibernateImageHeader107)+preview_offset+header->previewSize, + imageSize-(preview_offset+header->previewSize)); + previewTotalSectors = 0; + previewLoadedSectors = 0; + previewSaveunder = 0; #if 0 - /* AsereBLN: - check_vga_nvidia() didn't work as expected (recursion level > 0 & return value). - Unforutnaltely I cannot find a note why to switch back to text mode for nVidia cards only - and because it check_vga_nvidia does not work (cards normally are behind a bridge) I will - remove it completely */ - setVideoMode( VGA_TEXT_MODE, 0 ); + /* AsereBLN: + check_vga_nvidia() didn't work as expected (recursion level > 0 & return value). + Unforutnaltely I cannot find a note why to switch back to text mode for nVidia cards only + and because it check_vga_nvidia does not work (cards normally are behind a bridge) I will + remove it completely */ + setVideoMode( VGA_TEXT_MODE, 0 ); #endif - } + } else - ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader107), imageSize); + ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader107), imageSize); + + // Depends on NVRAM +#if 0 + if (header->encryptStart) { + // decryption data + static const unsigned char first_iv[AES_BLOCK_SIZE] + = { 0xa3, 0x63, 0x65, 0xa9, 0x0b, 0x71, 0x7b, 0x1c, + 0xdf, 0x9e, 0x5f, 0x32, 0xd7, 0x61, 0x63, 0xda }; + hibernate_cryptvars_t _cryptvars; + hibernate_cryptvars_t * cryptvars = &_cryptvars; - // Depends on NVRAM -#if 0 - if (header->encryptStart) { - // decryption data - static const unsigned char first_iv[AES_BLOCK_SIZE] - = { 0xa3, 0x63, 0x65, 0xa9, 0x0b, 0x71, 0x7b, 0x1c, - 0xdf, 0x9e, 0x5f, 0x32, 0xd7, 0x61, 0x63, 0xda }; - hibernate_cryptvars_t _cryptvars; - hibernate_cryptvars_t * cryptvars = &_cryptvars; - - aes_decrypt_key(&decryptkey, - decryptkeysize, - &cryptvars->ctx.decrypt); - - // set the vector for the following decryptions - bcopy(((uint8_t *) header) + header->image1Size - AES_BLOCK_SIZE, - &cryptvars->aes_iv[0], AES_BLOCK_SIZE); - - // decrypt the buffer - uint32_t len = (uint32_t)(header->image1Size - header->encryptStart); - aes_decrypt_cbc(((uint8_t *) header) + header->encryptStart, - &first_iv[0], - len >> 4, - ((uint8_t *) header) + header->encryptStart, - &cryptvars->ctx.decrypt); - bzero(&cryptvars->aes_iv[0], sizeof(cryptvars)); - bzero(&decryptkey, sizeof(decryptkey)); - } + aes_decrypt_key(&decryptkey, + decryptkeysize, + &cryptvars->ctx.decrypt); + + // set the vector for the following decryptions + bcopy(((uint8_t *) header) + header->image1Size - AES_BLOCK_SIZE, + &cryptvars->aes_iv[0], AES_BLOCK_SIZE); + + // decrypt the buffer + uint32_t len = (uint32_t)(header->image1Size - header->encryptStart); + aes_decrypt_cbc(((uint8_t *) header) + header->encryptStart, + &first_iv[0], + len >> 4, + ((uint8_t *) header) + header->encryptStart, + &cryptvars->ctx.decrypt); + bzero(&cryptvars->aes_iv[0], sizeof(cryptvars)); + bzero(&decryptkey, sizeof(decryptkey)); + } #endif WakeKernel107(header); @@ -281,7 +285,7 @@ IOHibernateImageHeader * header = &_header; long buffer; - if(gBootVolume->OSVersion[3] == '7') + if(gBootVolume->OSVersion[3] >= '7') // TODO: unlocked, but please check the compatibility with the 10.8 { HibernateBoot107(image_filename); return; @@ -289,7 +293,7 @@ size = ReadFileAtOffset (image_filename, header, 0, sizeof(IOHibernateImageHeader)); printf("header read size %x\n", size); - + imageSize = header->image1Size; codeSize = header->restore1PageCount << 12; if (kIOHibernateHeaderSignature != header->signature) @@ -305,7 +309,7 @@ getc (); return; } -// depends on NVRAM + // depends on NVRAM #if 0 { uint32_t machineSignature; @@ -316,16 +320,16 @@ break; } #endif - + allocSize = imageSize + ((4095 + sizeof(hibernate_graphics_t)) & ~4095); - - mem_base = getmemorylimit() - allocSize;//TODO: lower this - - printf("mem_base %x\n", mem_base); - + + mem_base = (long)(getmemorylimit() - allocSize);//TODO: lower this + + printf("mem_base %ld\n", mem_base); + bcopy(header, (void *) mem_base, sizeof(IOHibernateImageHeader)); header = (IOHibernateImageHeader *) mem_base; - + imageSize -= sizeof(IOHibernateImageHeader); buffer = (long)(header + 1); @@ -333,7 +337,7 @@ { uint64_t preview_offset = header->fileExtentMapSize - sizeof(header->fileExtentMap) + codeSize; uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize]; - + ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader), preview_offset+header->previewSize); drawPreview ((void *)(long)(buffer+preview_offset + header->previewPageListSize), &(progressSaveUnder[0][0])); previewTotalSectors = (imageSize-(preview_offset+header->previewSize))/512; @@ -348,10 +352,10 @@ previewSaveunder = 0; #if 0 /*AsereBLN: - check_vga_nvidia() didn''t work as expected (recursion level > 0 & return value). - Unforutnaltely I cannot find a note why to switch back to text mode for nVidia cards only - and because it check_vga_nvidia does not work (cards normally are behind a bridge) I will - remove it completely*/ + check_vga_nvidia() didn''t work as expected (recursion level > 0 & return value). + Unforutnaltely I cannot find a note why to switch back to text mode for nVidia cards only + and because it check_vga_nvidia does not work (cards normally are behind a bridge) I will + remove it completely*/ #if UNUSED setVideoMode(VGA_TEXT_MODE, 0); #else @@ -363,25 +367,25 @@ else ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader), imageSize); -// Depends on NVRAM + // Depends on NVRAM #if 0 if (header->encryptStart) { // decryption data static const unsigned char first_iv[AES_BLOCK_SIZE] = { 0xa3, 0x63, 0x65, 0xa9, 0x0b, 0x71, 0x7b, 0x1c, - 0xdf, 0x9e, 0x5f, 0x32, 0xd7, 0x61, 0x63, 0xda }; + 0xdf, 0x9e, 0x5f, 0x32, 0xd7, 0x61, 0x63, 0xda }; hibernate_cryptvars_t _cryptvars; hibernate_cryptvars_t * cryptvars = &_cryptvars; aes_decrypt_key(&decryptkey, decryptkeysize, &cryptvars->ctx.decrypt); - + // set the vector for the following decryptions bcopy(((uint8_t *) header) + header->image1Size - AES_BLOCK_SIZE, - &cryptvars->aes_iv[0], AES_BLOCK_SIZE); - + &cryptvars->aes_iv[0], AES_BLOCK_SIZE); + // decrypt the buffer uint32_t len = (uint32_t)(header->image1Size - header->encryptStart); aes_decrypt_cbc(((uint8_t *) header) + header->encryptStart, Index: branches/cparm/i386/modules/HibernateEnabler/graphic_utils.h =================================================================== --- branches/cparm/i386/modules/HibernateEnabler/graphic_utils.h (revision 1839) +++ branches/cparm/i386/modules/HibernateEnabler/graphic_utils.h (revision 1840) @@ -16,4 +16,15 @@ void spinActivityIndicator_hook(void *arg1, void *arg2, void *arg3, void *arg4, void* arg5, void* arg6); +void updateProgressBar(uint8_t * saveunder, int32_t firstBlob, int32_t select); + +void +loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or); +#if UNUSED +void +setVideoMode( int mode, int drawgraphics); +#else +void +setVideoMode( int mode); +#endif #endif//H_GRAPHIC_UTILS_H Index: branches/cparm/i386/modules/HibernateEnabler/HibernateEnabler.c =================================================================== --- branches/cparm/i386/modules/HibernateEnabler/HibernateEnabler.c (revision 1839) +++ branches/cparm/i386/modules/HibernateEnabler/HibernateEnabler.c (revision 1840) @@ -15,12 +15,14 @@ #define kForceWake "ForceWake" /* boot.c */ #define kWakeImage "WakeImage" /* boot.c */ #define kEnableHibernate "EnableHibernateModule" +void HibernateEnabler_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void HibernateEnabler_start(void); void HibernateEnabler_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) { bool tryresume,tryresumedefault, forceresume; - if (!getBoolForKey (kWake, &tryresume, &bootInfo->bootConfig)) + if (!getBoolForKey (kWake, &tryresume, DEFAULT_BOOT_CONFIG)) { tryresume = true; tryresumedefault = true; @@ -30,7 +32,7 @@ tryresumedefault = false; } - if (!getBoolForKey (kForceWake, &forceresume, &bootInfo->bootConfig)) + if (!getBoolForKey (kForceWake, &forceresume, DEFAULT_BOOT_CONFIG)) { forceresume = false; } @@ -46,7 +48,7 @@ int len, ret = -1; long flags, sleeptime; BVRef bvr; - if (!getValueForKey(kWakeImage, &val, &len, &bootInfo->bootConfig)) + if (!getValueForKey(kWakeImage, &val, &len, DEFAULT_BOOT_CONFIG)) val="/private/var/vm/sleepimage"; // Do this first to be sure that root volume is mounted @@ -74,10 +76,10 @@ } -void HibernateEnabler_start() +void HibernateEnabler_start(void) { bool enable = true; - getBoolForKey(kEnableHibernate, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableHibernate, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) { Index: branches/cparm/i386/modules/HibernateEnabler/graphic_utils.c =================================================================== --- branches/cparm/i386/modules/HibernateEnabler/graphic_utils.c (revision 1839) +++ branches/cparm/i386/modules/HibernateEnabler/graphic_utils.c (revision 1840) @@ -3,19 +3,33 @@ * Prashant Vaibhav (C) 12/12/2008 * Chameleon */ - +#include "libsaio.h" +#include "bootstruct.h" #include "graphic_utils.h" -#include "graphics.h" #include "IOHibernatePrivate.h" #include "bmdecompress.h" +#include "vbe.h" +#include "appleClut8.h" -#define VIDEO(x) (bootArgs->Video.v_ ## x) -//#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#ifndef offsetof +#define offsetof(st, m) \ +((size_t) ( (char *)&((st *)(0))->m - (char *)0 )) +#endif +#define VIDEO(x) (getBootArgsVideoPtrAtOffset(offsetof(Boot_Video,v_##x))) + + +#define MIN(x, y) ((x) < (y) ? (x) : (y)) + int previewTotalSectors = 0; uint8_t *previewSaveunder = 0; int previewLoadedSectors = 0; +#if UNUSED +static int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate ); +#else +static int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel); +#endif void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or) @@ -66,6 +80,509 @@ } } +//========================================================================== +// getNumberArrayFromProperty + +static int +getNumberArrayFromProperty( const char * propKey, + unsigned long numbers[], + unsigned long maxArrayCount ) +{ + char * propStr; + unsigned long count = 0; + + propStr = newStringForKey( (char *) propKey , DEFAULT_BOOT_CONFIG ); + if ( propStr ) + { + char * delimiter = propStr; + char * p = propStr; + + while ( count < maxArrayCount && *p != '\0' ) + { + unsigned long val = strtoul( p, &delimiter, 10 ); + if ( p != delimiter ) + { + numbers[count++] = val; + p = delimiter; + } + while ( ( *p != '\0' ) && !isdigit(*p) ) + p++; + } + + free( propStr ); + } + + return count; +} + +static int initGraphicsMode () +{ + unsigned long params[4]; + int count; + + params[3] = 0; + count = getNumberArrayFromProperty( kGraphicsModeKey, params, 4 ); + + // Try to find a resolution if "Graphics Mode" setting is not available. + if ( count < 3 ) + { + params[0] = DEFAULT_SCREEN_WIDTH; + params[1] = DEFAULT_SCREEN_HEIGHT; + params[2] = 32; + } + + // Map from pixel format to bits per pixel. + + if ( params[2] == 256 ) params[2] = 8; + if ( params[2] == 555 ) params[2] = 16; + if ( params[2] == 888 ) params[2] = 32; +#if UNUSED + return setVESAGraphicsMode( params[0], params[1], params[2], params[3] ); +#else + return setVESAGraphicsMode( params[0], params[1], params[2] ); +#endif +} + +//========================================================================== +// setupPalette + +static void setupPalette( VBEPalette * p, const unsigned char * g ) +{ + int i; + unsigned char * source = (unsigned char *) g; + + for (i = 0; i < 256; i++) + { + (*p)[i] = 0; + (*p)[i] |= ((unsigned long)((*source++) >> 2)) << 16; // Red + (*p)[i] |= ((unsigned long)((*source++) >> 2)) << 8; // Green + (*p)[i] |= ((unsigned long)((*source++) >> 2)); // Blue + + } +} + +//========================================================================== +// getVESAModeWithProperties +// +// Return the VESA mode that matches the properties specified. +// If a mode is not found, then return the "best" available mode. + +static unsigned short +getVESAModeWithProperties( unsigned short width, + unsigned short height, + unsigned char bitsPerPixel, + unsigned short attributesSet, + unsigned short attributesClear, + VBEModeInfoBlock * outModeInfo, + unsigned short * vesaVersion ) +{ + VBEInfoBlock vbeInfo; + unsigned short * modePtr; + VBEModeInfoBlock modeInfo; + unsigned char modeBitsPerPixel; + unsigned short matchedMode = modeEndOfList; + int err; + + // Clear output mode info. + + //bzero( outModeInfo, sizeof(*outModeInfo) ); + bzero( outModeInfo, sizeof(VBEModeInfoBlock) ); + + // Get VBE controller info containing the list of supported modes. + + //bzero( &vbeInfo, sizeof(vbeInfo) ); + bzero( &vbeInfo, sizeof(VBEInfoBlock) ); + + strcpy( (char*)&vbeInfo, "VBE2" ); + err = getVBEInfo( &vbeInfo ); + if ( err != errSuccess ) + { + return modeEndOfList; + } + + // Report the VESA major/minor version number. + + if (vesaVersion) *vesaVersion = vbeInfo.VESAVersion; + + // Loop through the mode list, and find the matching mode. + + for ( modePtr = VBEDecodeFP( unsigned short *, vbeInfo.VideoModePtr ); + *modePtr != modeEndOfList; modePtr++ ) + { + // Get mode information. + + //bzero( &modeInfo, sizeof(modeInfo) ); + bzero( &modeInfo, sizeof(VBEModeInfoBlock) ); + + err = getVBEModeInfo( *modePtr, &modeInfo ); + if ( err != errSuccess ) + { + continue; + } + +#if DEBUG + printf("Mode %x: %dx%dx%d mm:%d attr:%x\n", + *modePtr, modeInfo.XResolution, modeInfo.YResolution, + modeInfo.BitsPerPixel, modeInfo.MemoryModel, + modeInfo.ModeAttributes); +#endif + + // Filter out unwanted modes based on mode attributes. + + if ( ( ( modeInfo.ModeAttributes & attributesSet ) != attributesSet ) + || ( ( modeInfo.ModeAttributes & attributesClear ) != 0 ) ) + { + continue; + } + + // Pixel depth in bits. + + modeBitsPerPixel = modeInfo.BitsPerPixel; + + if ( ( modeBitsPerPixel == 4 ) && ( modeInfo.MemoryModel == 0 ) ) + { + // Text mode, 16 colors. + } + else if ( ( modeBitsPerPixel == 8 ) && ( modeInfo.MemoryModel == 4 ) ) + { + // Packed pixel, 256 colors. + } + else if ( ( ( modeBitsPerPixel == 16 ) || ( modeBitsPerPixel == 15 ) ) + && ( modeInfo.MemoryModel == 6 ) + && ( modeInfo.RedMaskSize == 5 ) + && ( modeInfo.GreenMaskSize == 5 ) + && ( modeInfo.BlueMaskSize == 5 ) ) + { + // Direct color, 16 bpp (1:5:5:5). + modeInfo.BitsPerPixel = modeBitsPerPixel = 16; + } + else if ( ( modeBitsPerPixel == 32 ) + && ( modeInfo.MemoryModel == 6 ) + && ( modeInfo.RedMaskSize == 8 ) + && ( modeInfo.GreenMaskSize == 8 ) + && ( modeInfo.BlueMaskSize == 8 ) ) + { + // Direct color, 32 bpp (8:8:8:8). + } + else + { + continue; // Not a supported mode. + } + + // Modes larger than the specified dimensions are skipped. + + if ( ( modeInfo.XResolution > width ) || + ( modeInfo.YResolution > height ) ) + { + continue; + } + + // Perfect match, we're done looking. + + if ( ( modeInfo.XResolution == width ) && + ( modeInfo.YResolution == height ) && + ( modeBitsPerPixel == bitsPerPixel ) ) + { + matchedMode = *modePtr; + //bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) ); + bcopy( &modeInfo, outModeInfo, sizeof(VBEModeInfoBlock) ); + + break; + } + + // Save the next "best" mode in case a perfect match is not found. + + if ( modeInfo.XResolution == outModeInfo->XResolution && + modeInfo.YResolution == outModeInfo->YResolution && + modeBitsPerPixel <= outModeInfo->BitsPerPixel ) + { + continue; // Saved mode has more depth. + } + if ( modeInfo.XResolution < outModeInfo->XResolution || + modeInfo.YResolution < outModeInfo->YResolution || + modeBitsPerPixel < outModeInfo->BitsPerPixel ) + { + continue; // Saved mode has more resolution. + } + + matchedMode = *modePtr; + bcopy( &modeInfo, outModeInfo, sizeof(VBEModeInfoBlock) ); + + } + + return matchedMode; +} + +//========================================================================== +// setVESAGraphicsMode +#if UNUSED +static int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate ) +#else +static int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel) +#endif +{ + VBEModeInfoBlock minfo; + unsigned short mode; + unsigned short vesaVersion; + int err = errFuncNotSupported; + + do { + mode = getVESAModeWithProperties( width, height, bitsPerPixel, + maColorModeBit | + maModeIsSupportedBit | + maGraphicsModeBit | + maLinearFrameBufferAvailBit, + 0, + &minfo, &vesaVersion ); + if ( mode == modeEndOfList ) + { + break; + } +#if UNUSED + // + // FIXME : generateCRTCTiming() causes crash. + // + + // if ( (vesaVersion >> 8) >= 3 && refreshRate >= 60 && + // (gBootMode & kBootModeSafe) == 0 ) + // { + // VBECRTCInfoBlock timing; + // + // // Generate CRTC timing for given refresh rate. + // + // generateCRTCTiming( minfo.XResolution, minfo.YResolution, + // refreshRate, kCRTCParamRefreshRate, + // &timing ); + // + // // Find the actual pixel clock supported by the hardware. + // + // getVBEPixelClock( mode, &timing.PixelClock ); + // + // // Re-compute CRTC timing based on actual pixel clock. + // + // generateCRTCTiming( minfo.XResolution, minfo.YResolution, + // timing.PixelClock, kCRTCParamPixelClock, + // &timing ); + // + // // Set the video mode and use specified CRTC timing. + // + // err = setVBEMode( mode | kLinearFrameBufferBit | + // kCustomRefreshRateBit, &timing ); + // } + // else + // { + // // Set the mode with default refresh rate. + // + // err = setVBEMode( mode | kLinearFrameBufferBit, NULL ); + // } +#endif + // Set the mode with default refresh rate. + + err = setVBEMode( mode | kLinearFrameBufferBit, NULL ); + + if ( err != errSuccess ) + { + break; + } + + // Set 8-bit color palette. + + if ( minfo.BitsPerPixel == 8 ) + { + VBEPalette palette; + setupPalette( &palette, appleClut8 ); + if ((err = setVBEPalette(palette)) != errSuccess) + { + break; + } + } + + // Is this required for buggy Video BIOS implementations? + // On which adapter? + + if ( minfo.BytesPerScanline == 0 ) + minfo.BytesPerScanline = ( minfo.XResolution * + minfo.BitsPerPixel ) >> 3; + + // Update KernBootStruct using info provided by the selected + // VESA mode. + Boot_Video Video; /* Video Information */ + + + Video.v_display = GRAPHICS_MODE; + Video.v_width = minfo.XResolution; + Video.v_height = minfo.YResolution; + Video.v_depth = minfo.BitsPerPixel; + Video.v_rowBytes = minfo.BytesPerScanline; + Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr); + + + setBootArgsVideoStruct(&Video); + + } + while ( 0 ); + + return err; +} + +//========================================================================== +// setVESATextMode + +static int +setVESATextMode( unsigned short cols, + unsigned short rows, + unsigned char bitsPerPixel ) +{ + VBEModeInfoBlock minfo; + unsigned short mode = modeEndOfList; + + if ( (cols != 80) || (rows != 25) ) // not 80x25 mode + { + mode = getVESAModeWithProperties( cols, rows, bitsPerPixel, + maColorModeBit | + maModeIsSupportedBit, + maGraphicsModeBit, + &minfo, NULL ); + } + + if ( ( mode == modeEndOfList ) || ( setVBEMode(mode, NULL) != errSuccess ) ) + { + video_mode( 2 ); // VGA BIOS, 80x25 text mode. + minfo.XResolution = 80; + minfo.YResolution = 25; + } + + // Update KernBootStruct using info provided by the selected + // VESA mode. + Boot_Video Video; /* Video Information */ + + + Video.v_display = VGA_TEXT_MODE; + Video.v_width = 0xb8000; + Video.v_height = minfo.XResolution; + Video.v_depth = minfo.YResolution; + Video.v_rowBytes = 8; + Video.v_baseAddr = 0x8000; + + setBootArgsVideoStruct(&Video); + + + return errSuccess; // always return success +} + +//========================================================================== +// setVideoMode +// +// Set the video mode to VGA_TEXT_MODE or GRAPHICS_MODE. +#if UNUSED +void +setVideoMode( int mode, int drawgraphics) +#else +void +setVideoMode( int mode) +#endif +{ + unsigned long params[4]; + int count; + int err = errSuccess; + + if ( mode == GRAPHICS_MODE ) + { + if ( (err=initGraphicsMode ()) == errSuccess ) { + if (gVerboseMode) { + // Tell the kernel to use text mode on a linear frame buffer display + setBootArgsVideoMode(FB_TEXT_MODE); + } else { + setBootArgsVideoMode(GRAPHICS_MODE); + } + } + } + + if ( (mode == VGA_TEXT_MODE) || (err != errSuccess) ) + { + count = getNumberArrayFromProperty( kTextModeKey, params, 2 ); + if ( count < 2 ) + { + params[0] = 80; // Default text mode is 80x25. + params[1] = 25; + } + + setVESATextMode( params[0], params[1], 4 ); + setBootArgsVideoMode(VGA_TEXT_MODE); + + } + +} + +//========================================================================== +// LookUpCLUTIndex + +static unsigned long lookUpCLUTIndex( unsigned char index, + unsigned char depth ) +{ + long result, red, green, blue; + + red = appleClut8[index * 3 + 0]; + green = appleClut8[index * 3 + 1]; + blue = appleClut8[index * 3 + 2]; + + switch (depth) { + case 16 : + result = ((red & 0xF8) << 7) | + ((green & 0xF8) << 2) | + ((blue & 0xF8) >> 3); + result |= (result << 16); + break; + + case 32 : + result = (red << 16) | (green << 8) | blue; + break; + + default : + result = index | (index << 8); + result |= (result << 16); + break; + } + + return result; +} + +static void * stosl(void * dst, long val, long len) +{ + asm volatile ( "rep; stosl" + : "=c" (len), "=D" (dst) + : "0" (len), "1" (dst), "a" (val) + : "memory" ); + + return dst; +} + +static void drawColorRectangle( unsigned short x, + unsigned short y, + unsigned short width, + unsigned short height, + unsigned char colorIndex ) +{ + long pixelBytes; + long color = lookUpCLUTIndex( colorIndex, VIDEO(depth) ); + char * vram; + + pixelBytes = VIDEO(depth) / 8; + vram = (char *) VIDEO(baseAddr) + + VIDEO(rowBytes) * y + pixelBytes * x; + + width = MIN(width, VIDEO(width) - x); + height = MIN(height, VIDEO(height) - y); + + while ( height-- ) + { + int rem = ( pixelBytes * width ) % 4; + if ( rem ) bcopy( &color, vram, rem ); + stosl( vram + rem, color, pixelBytes * width / 4 ); + vram += VIDEO(rowBytes); + } +} + DECLARE_IOHIBERNATEPROGRESSALPHA void drawPreview(void *src, uint8_t * saveunder) Index: branches/cparm/i386/modules/Keymapper/Keylayout.c =================================================================== --- branches/cparm/i386/modules/Keymapper/Keylayout.c (revision 1839) +++ branches/cparm/i386/modules/Keymapper/Keylayout.c (revision 1840) @@ -26,8 +26,9 @@ #define kKeyboardLayout "KeyboardLayout" struct keyboard_layout *current_layout = NULL; +int getchar_replacement(void); -int getchar_replacement() { +int getchar_replacement(void) { int code = bgetc(); int status = readKeyboardShiftFlags(); uint8_t scancode = code >> 8; @@ -121,19 +122,13 @@ return 0; } -uint32_t Keylayout_real_start() +uint32_t Keylayout_real_start(void) { char layoutPath[512]; const char *val; int len; -#ifdef TRUNK -#define Config chameleonConfig -#else -#define Config bootConfig -#endif - - if (getValueForKey("KeyLayout", &val, &len, &bootInfo->Config)) + if (getValueForKey("KeyLayout", &val, &len, DEFAULT_BOOT_CONFIG)) { sprintf(layoutPath, "/Extra/Keymaps/%s", val); // Add the extension if needed @@ -147,21 +142,12 @@ return 0; } -#ifdef TRUNK - if (!replace_function("_getchar", &getchar_replacement)) + + if (replace_system_function("_getc", &getchar_replacement) != EFI_SUCCESS ) { - printf("no function getchar() to replace. Keylayout will not be used ! \n"); - - return 0; - } - -#else - if (replace_function("_getc", &getchar_replacement) != EFI_SUCCESS ) - { printf("no function getc() to replace. Keylayout will not be used ! \n"); return 0; } -#endif return 1; @@ -169,8 +155,8 @@ return 0; } - -void Keylayout_start() +void Keylayout_start(void); +void Keylayout_start(void) { Keylayout_real_start(); } \ No newline at end of file Index: branches/cparm/i386/modules/Keymapper/Keylayout.h =================================================================== --- branches/cparm/i386/modules/Keymapper/Keylayout.h (revision 1839) +++ branches/cparm/i386/modules/Keymapper/Keylayout.h (revision 1840) @@ -26,6 +26,6 @@ uint16_t keyboard_map_shift_alt[KEYBOARD_MAP_SIZE]; }; -extern uint32_t Keylayout_real_start(); +extern uint32_t Keylayout_real_start(void); #endif Index: branches/cparm/i386/modules/Keymapper/Makefile =================================================================== --- branches/cparm/i386/modules/Keymapper/Makefile (revision 1839) +++ branches/cparm/i386/modules/Keymapper/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -KEY_MAPPER_OBJS = Keymapper.o Keylayout.o +KEY_MAPPER_OBJS = Keymapper.o Keylayout.o stack_protector.o SFILES = CFILES = @@ -70,7 +70,8 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/Keymapper.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/Keymapper.o \ $(OBJROOT)/Keylayout.o \ -o $(SYMROOT)/$(MODULE_NAME).dylib @@ -79,7 +80,11 @@ Keymapper.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "Keymapper.c" $(INC) -o "$(OBJROOT)/Keymapper.o" - +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + +Keylayout.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "Keylayout.c" $(INC) -o "$(OBJROOT)/Keylayout.o" include ../../MakeInc.dir Index: branches/cparm/i386/modules/Keymapper/Keymapper.c =================================================================== --- branches/cparm/i386/modules/Keymapper/Keymapper.c (revision 1839) +++ branches/cparm/i386/modules/Keymapper/Keymapper.c (revision 1840) @@ -16,9 +16,9 @@ #define kEnableKeyMap "EnableKeyMapper" static int AZERTY_switch(int c); void Keymapper_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); -int Keymapper_getc(); +int Keymapper_getc(void); -int Keymapper_getc() +int Keymapper_getc(void) { int c = bgetc(); @@ -203,7 +203,7 @@ // Check for xml map in the config file if (match_map == NULL) - match_map = XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"KeyboardMap"); + match_map = XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"KeyboardMap"); if (match_map) { @@ -222,7 +222,7 @@ if (map_kb_type == NULL) { TagPtr match_type; - if ((match_type = XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"KeyboardType"))) + if ((match_type = XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"KeyboardType"))) map_kb_type = XMLCastString(match_type); else map_kb_type = "NONE"; // Default to QWERTY @@ -237,16 +237,12 @@ } -void Keymapper_start() +void Keymapper_start(void); +void Keymapper_start(void) { -#ifdef TRUNK -#define Config chameleonConfig -#else -#define Config bootConfig -#endif bool enable = true; - getBoolForKey(kEnableKeyMap, &enable, &bootInfo->Config) ; + getBoolForKey(kEnableKeyMap, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) { @@ -256,13 +252,13 @@ } #ifdef TRUNK - if (!replace_function("_getchar", &Keymapper_getc)) + if (!replace_system_function("_getchar", &Keymapper_getc)) { printf("no function getchar() to replace. Keymapper will not be used ! \n"); } #else - if (replace_function("_getc", &Keymapper_getc) != EFI_SUCCESS) + if (replace_system_function("_getc", &Keymapper_getc) != EFI_SUCCESS) { printf("no function getc() to replace. Keymapper will not be used ! \n"); } Index: branches/cparm/i386/modules/USBFix/USBFix.c =================================================================== --- branches/cparm/i386/modules/USBFix/USBFix.c (revision 1839) +++ branches/cparm/i386/modules/USBFix/USBFix.c (revision 1840) @@ -10,9 +10,13 @@ #define kEnableUSBMod "EnableUSBModule" -extern int usb_loop(); +extern int usb_loop(void); extern void notify_usb_dev(pci_dt_t *pci_dev); +void USBFix_pci_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void USBFix_start_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); + + void USBFix_pci_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) { pci_dt_t* current = arg1; @@ -27,10 +31,11 @@ usb_loop(); } -void USBFix_start() +void USBFix_start(void); +void USBFix_start(void) { bool enable = true; - getBoolForKey(kEnableUSBMod, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableUSBMod, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) { register_hook_callback("PCIDevice", &USBFix_pci_hook); Index: branches/cparm/i386/modules/USBFix/usb.c =================================================================== --- branches/cparm/i386/modules/USBFix/usb.c (revision 1839) +++ branches/cparm/i386/modules/USBFix/usb.c (revision 1840) @@ -8,7 +8,6 @@ */ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" #include "pci.h" @@ -63,20 +62,21 @@ } // Loop through the list and call the apropriate patch function -int usb_loop() +int usb_loop(void); +int usb_loop(void) { int retVal = 1; bool fix_ehci = true, fix_uhci = true, fix_usb = true, fix_legacy = true; - if (getBoolForKey(kUSBBusFix, &fix_usb, &bootInfo->bootConfig)) + if (getBoolForKey(kUSBBusFix, &fix_usb, DEFAULT_BOOT_CONFIG)) { fix_ehci = fix_uhci = fix_legacy = fix_usb; // Disable all if none set } else { - getBoolForKey(kEHCIacquire, &fix_ehci, &bootInfo->bootConfig); - getBoolForKey(kUHCIreset, &fix_uhci, &bootInfo->bootConfig); - getBoolForKey(kLegacyOff, &fix_legacy, &bootInfo->bootConfig); + getBoolForKey(kEHCIacquire, &fix_ehci, DEFAULT_BOOT_CONFIG); + getBoolForKey(kUHCIreset, &fix_uhci, DEFAULT_BOOT_CONFIG); + getBoolForKey(kLegacyOff, &fix_legacy, DEFAULT_BOOT_CONFIG); } DBG("\n"); @@ -200,7 +200,7 @@ uint8_t legacy[8]; bool alwaysHardBIOSReset = false; - if (!getBoolForKey(kEHCIhard, &alwaysHardBIOSReset, &bootInfo->bootConfig)) { + if (!getBoolForKey(kEHCIhard, &alwaysHardBIOSReset, DEFAULT_BOOT_CONFIG)) { alwaysHardBIOSReset = true; } Index: branches/cparm/i386/modules/USBFix/Makefile =================================================================== --- branches/cparm/i386/modules/USBFix/Makefile (revision 1839) +++ branches/cparm/i386/modules/USBFix/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -USB_OBJS = USBFix.o usb.o +USB_OBJS = USBFix.o usb.o stack_protector.o SFILES = @@ -70,12 +70,17 @@ -no_uuid \ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ - $(OBJROOT)/USBFix.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/USBFix.o \ $(OBJROOT)/usb.o \ -macosx_version_min 10.6 \ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + USBFix.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "USBFix.c" $(INC) -o "$(OBJROOT)/USBFix.o" Index: branches/cparm/i386/modules/HPET/HPET.c =================================================================== --- branches/cparm/i386/modules/HPET/HPET.c (revision 1839) +++ branches/cparm/i386/modules/HPET/HPET.c (revision 1840) @@ -5,7 +5,6 @@ #include "libsaio.h" #include "modules.h" -#include "boot.h" #include "bootstruct.h" #include "pci.h" #include "hpet.h" @@ -23,8 +22,8 @@ static void force_enable_hpet_intel(pci_dt_t *lpc_dev); static void force_enable_hpet_via(pci_dt_t *lpc_dev); static void force_enable_hpet(pci_dt_t *lpc_dev); +void HPET_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); - void HPET_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) { pci_dt_t* current = arg1; @@ -35,10 +34,11 @@ force_enable_hpet(current); } -void HPET_start() +void HPET_start(void); +void HPET_start(void) { bool enable = true; - getBoolForKey(EnableHPETModule, &enable, &bootInfo->bootConfig); + getBoolForKey(EnableHPETModule, &enable, DEFAULT_BOOT_CONFIG); if (enable) register_hook_callback("PCIDevice", &HPET_hook); Index: branches/cparm/i386/modules/HPET/Makefile =================================================================== --- branches/cparm/i386/modules/HPET/Makefile (revision 1839) +++ branches/cparm/i386/modules/HPET/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -HPET_OBJS = HPET.o +HPET_OBJS = HPET.o stack_protector.o SFILES = @@ -71,9 +71,13 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/HPET.o -o $(SYMROOT)/$(MODULE_NAME).dylib + $(OBJROOT)/stack_protector.o $(OBJROOT)/HPET.o -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + HPET.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "HPET.c" $(INC) -o "$(OBJROOT)/HPET.o" Index: branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c =================================================================== --- branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c (revision 1839) +++ branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c (revision 1840) @@ -3,7 +3,6 @@ */ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" #include "acpi.h" #include "efi_tables.h" @@ -275,11 +274,16 @@ {"YM", "China /Konfiguriert" } }; +const char* sm_search_str(const SMStrEntryPair* sm_defaults, const char * key); +const char* sm_get_random_productNumber(void); +const char* sm_get_random_week(void); +const char* sm_get_random_year(void); +const char* sm_get_random_country(void); const char* sm_search_str(const SMStrEntryPair* sm_defaults, const char * key) { int i; - + for (i=0; sm_defaults[i].key[0]; i++) { if (!strcmp (sm_defaults[i].key, key)) { return sm_defaults[i].value; @@ -292,7 +296,7 @@ return ""; } -const char* sm_get_random_productNumber() +const char* sm_get_random_productNumber(void) { static char str[4] = {0x00,0x00,0x00,0x00}; if(str[0] == 0) @@ -320,12 +324,12 @@ strcat (str, tmp); DBG ("fake_productNumber: %s\n",str); - + } return str; } -const char* sm_get_random_week() +const char* sm_get_random_week(void) { static char str[4] = {0x00,0x00,0x00,0x00}; if(str[0] == 0) @@ -347,14 +351,14 @@ sprintf(tmp,"%d",rand_week); strlcpy (str, tmp, sizeof(tmp)+1); } - + DBG ("fake_week: %s\n",str); } return str; } -const char* sm_get_random_year() +const char* sm_get_random_year(void) { static char str[2] = {0x00,0x00}; if(str[0] == 0) @@ -380,7 +384,7 @@ return str; } -const char* sm_get_random_country() +const char* sm_get_random_country(void) { static char str[3] = {0x00,0x00,0x00}; if(str[0] == 0) @@ -391,9 +395,9 @@ struct ran_obj* random_country_obj = random_init(0,(sizeof(sm_country_list) / sizeof(sm_country_list[0]))-1); rand_country = random(random_country_obj); random_free(random_country_obj); - + strlcpy (str, sm_country_list[rand_country].code,strlen(sm_country_list[rand_country].code)+1); - + DBG ("fake_country: %s (%s)\n",str,sm_country_list[rand_country].info); } @@ -405,18 +409,18 @@ const SMStrEntryPair* sm_defaults; const SMStrEntryPair* sm_chosen; static bool serial_done = false; - - if (Platform->CPU.isServer == true) + + if (get_env(envIsServer)) { sm_defaults=sm_xserve_defaults; - } else if (Platform->CPU.isMobile == true) { - if (Platform->CPU.NoCores > 1) { + } else if (get_env(envIsMobile)) { + if (get_env(envNoCores) > 1) { sm_defaults=sm_macbookpro_defaults; } else { sm_defaults=sm_macbook_defaults; } } else { - switch (Platform->CPU.NoCores) + switch (get_env(envNoCores)) { case 1: sm_defaults=sm_macmini_defaults; @@ -426,11 +430,11 @@ break; default: { - switch (Platform->CPU.Family) + switch (get_env(envFamily)) { case 0x06: { - switch (Platform->CPU.Model) + switch (get_env(envModel)) { case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm) case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) ??? @@ -472,7 +476,7 @@ const char *str; int size; - if (getValueForKey("SMproductname", &str, &size, &bootInfo->smbiosConfig)) + if (getValueForKey("SMproductname", &str, &size, DEFAULT_SMBIOS_CONFIG)) { if (strstr (str, "MacPro5")) { @@ -528,9 +532,9 @@ if (!serial_done) { bzero (fake_serial,sizeof(fake_serial)); - + bool randomSerial = false; - getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig) ; + getBoolForKey(kSMBIOSRandomSerial, &randomSerial, DEFAULT_BOOT_CONFIG) ; if ( randomSerial ) // useless strlcpy (fake_serial,sm_get_random_country(), strlen(sm_get_random_country())+1); @@ -557,12 +561,12 @@ serial_done = true; if ( randomSerial ) - msglog ("fake_serial: %s\n",fake_serial); - + msglog ("fake_serial: %s\n",fake_serial); + } return fake_serial; - + } return sm_search_str(sm_chosen, key); @@ -571,23 +575,23 @@ static int sm_get_fsb(const char *name, int table_num) { - return Platform->CPU.FSBFrequency/1000000; + return (int)(get_env(envFSBFreq) /1000000); } static int sm_get_cpu (const char *name, int table_num) { - return Platform->CPU.CPUFrequency/1000000; + return (int)(get_env(envCPUFreq) /1000000); } static int sm_get_bus_speed (const char *name, int table_num) { - if (Platform->CPU.Vendor == 0x756E6547) // Intel + if (get_env(envVendor) == CPUID_VENDOR_INTEL) { - switch (Platform->CPU.Family) + switch (get_env(envFamily)) { case 0x06: { - switch (Platform->CPU.Model) + switch (get_env(envModel)) { case CPUID_MODEL_BANIAS: // Banias 0x09 case CPUID_MODEL_DOTHAN: // Dothan 0x0D @@ -597,22 +601,22 @@ case CPUID_MODEL_ATOM: // Atom 45nm 0x1C return 0; // TODO: populate bus speed for these processors -// case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm) -// if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) -// return 2500; // Core i5 -// return 4800; // Core i7 + // case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm) + // if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) + // return 2500; // Core i5 + // return 4800; // Core i7 -// case CPUID_MODEL_NEHALEM: // Intel Core i7 LGA1366 (45nm) -// case CPUID_MODEL_NEHALEM_EX: -// case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) ??? -// return 4800; // GT/s / 1000 -// + // case CPUID_MODEL_NEHALEM: // Intel Core i7 LGA1366 (45nm) + // case CPUID_MODEL_NEHALEM_EX: + // case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) ??? + // return 4800; // GT/s / 1000 + // case CPUID_MODEL_WESTMERE_EX: // Intel Core i7 LGA1366 (45nm) 6 Core ??? return 0; // TODO: populate bus speed for these processors -// case 0x19: // Intel Core i5 650 @3.20 Ghz -// return 2500; // why? Intel spec says 2.5GT/s - + // case 0x19: // Intel Core i5 650 @3.20 Ghz + // return 2500; // why? Intel spec says 2.5GT/s + case 0x19: // Intel Core i5 650 @3.20 Ghz case CPUID_MODEL_NEHALEM: // Intel Core i7 LGA1366 (45nm) case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm) @@ -645,7 +649,7 @@ qpimult = pci_config_read32(PCIADDR(nhm_bus, 2, 1), 0x50); qpimult &= 0x7F; DBG("qpimult %d\n", qpimult); - qpibusspeed = (qpimult * 2 * (Platform->CPU.FSBFrequency/1000000)); + qpibusspeed = (qpimult * 2 * (get_env(envFSBFreq) /1000000)); // Rek: rounding decimals to match original mac profile info if (qpibusspeed%100 != 0)qpibusspeed = ((qpibusspeed+50)/100)*100; DBG("qpibusspeed %d\n", qpibusspeed); @@ -660,11 +664,12 @@ static int sm_get_simplecputype() { - if (Platform->CPU.NoCores >= 4) + uint8_t ncores = get_env(envNoCores); + if (ncores >= 4) { return 0x0501; // Quad-Core Xeon } - if (((Platform->CPU.NoCores == 1) || (Platform->CPU.NoCores == 2)) && !(platformCPUExtFeature(CPUID_EXTFEATURE_EM64T))) + if (((ncores == 1) || (ncores == 2)) && !(get_env(envExtFeatures) & CPUID_EXTFEATURE_EM64T)) { return 0x0201; // Core Solo / Duo } @@ -675,19 +680,20 @@ static int sm_get_cputype (const char *name, int table_num) { static bool done = false; - - if (Platform->CPU.Vendor == 0x756E6547) // Intel + + char * BrandString= (char*)get_env_ptr(envBrandString); + if (get_env(envVendor) == CPUID_VENDOR_INTEL) // Intel { if (!done) { - verbose("CPU is %s, family 0x%x, model 0x%x\n", Platform->CPU.BrandString, Platform->CPU.Family, Platform->CPU.Model); + verbose("CPU is %s, family 0x%x, model 0x%x\n", BrandString, (uint32_t)get_env(envFamily), (uint32_t)get_env(envModel)); done = true; } - switch (Platform->CPU.Family) + switch (get_env(envFamily)) { case 0x06: { - switch (Platform->CPU.Model) + switch (get_env(envModel)) { case CPUID_MODEL_BANIAS: // Banias case CPUID_MODEL_DOTHAN: // Dothan @@ -698,28 +704,28 @@ return sm_get_simplecputype(); case CPUID_MODEL_NEHALEM: // Intel Core i7 LGA1366 (45nm) - if (strstr(Platform->CPU.BrandString, "Core(TM) i7")) + if (strstr(BrandString, "Core(TM) i7")) return 0x0701; // Core i7 return sm_get_simplecputype(); - + case CPUID_MODEL_FIELDS: // Lynnfield, Clarksfield, Jasper - if (strstr(Platform->CPU.BrandString, "Core(TM) i5")) + if (strstr(BrandString, "Core(TM) i5")) return 0x601; // Core i5 return 0x701; // Core i7 case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) (Havendale, Auburndale) - if (strstr(Platform->CPU.BrandString, "Core(TM) i5")) + if (strstr(BrandString, "Core(TM) i5")) return 0x601; // Core i5 return 0x0701; // Core i7 case CPUID_MODEL_SANDYBRIDGE: // Sandybridge case CPUID_MODEL_DALES_32NM: // Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale) - if (strstr(Platform->CPU.BrandString, "Core(TM) i3")) + if (strstr(BrandString, "Core(TM) i3")) return 0x901; // Core i3 - if (strstr(Platform->CPU.BrandString, "Core(TM) i5")) + if (strstr(BrandString, "Core(TM) i5")) return 0x601; // Core i5 - if (strstr(Platform->CPU.BrandString, "Core(TM) i7")) + if (strstr(BrandString, "Core(TM) i7")) return 0x0701; // Core i7 return sm_get_simplecputype(); @@ -741,16 +747,20 @@ static int sm_get_memtype (const char *name, int table_num) { if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { - int map; - - if (table_num < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[table_num]; - if (Platform->RAM.DIMM[map].InUse && Platform->RAM.DIMM[map].Type != 0) { - DBG("RAM Detected Type = %d\n", Platform->RAM.DIMM[map].Type); - return Platform->RAM.DIMM[map].Type; - } + int map; + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + + + if (table_num < MAX_RAM_SLOTS) { + map = DmiDimm[table_num]; + if (RamDimm[map].InUse && RamDimm[map].Type != 0) { + DBG("RAM Detected Type = %d\n", RamDimm[map].Type); + return RamDimm[map].Type; + } + } } - } return SMB_MEM_TYPE_DDR2; } @@ -758,48 +768,57 @@ static int sm_get_memspeed (const char *name, int table_num) { if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { - int map; - - if (table_num < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[table_num]; - if (Platform->RAM.DIMM[map].InUse && Platform->RAM.DIMM[map].Frequency != 0) { - DBG("RAM Detected Freq = %d Mhz\n", Platform->RAM.DIMM[map].Frequency); - return Platform->RAM.DIMM[map].Frequency; - } + int map; + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + + if (table_num < MAX_RAM_SLOTS) { + map = DmiDimm[table_num]; + if (RamDimm[map].InUse && RamDimm[map].Frequency != 0) { + DBG("RAM Detected Freq = %d Mhz\n", RamDimm[map].Frequency); + return RamDimm[map].Frequency; + } + } } - } return 800; } static const char *sm_get_memvendor (const char *name, int table_num) { if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { - int map; - - if (table_num < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[table_num]; - if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].Vendor) > 0) { - DBG("RAM Detected Vendor[%d]='%s'\n", table_num, Platform->RAM.DIMM[map].Vendor); - return Platform->RAM.DIMM[map].Vendor; - } + int map; + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + + if (table_num < MAX_RAM_SLOTS) { + map = DmiDimm[table_num]; + if (RamDimm[map].InUse && strlen(RamDimm[map].Vendor) > 0) { + DBG("RAM Detected Vendor[%d]='%s'\n", table_num, RamDimm[map].Vendor); + return RamDimm[map].Vendor; + } + } } - } return "N/A"; } - + static const char *sm_get_memserial (const char *name, int table_num) { if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { - int map; - - if (table_num < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[table_num]; - if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].SerialNo) > 0) { - DBG("name = %s, map=%d, RAM Detected SerialNo[%d]='%s'\n", name ? name : "", - map, table_num, Platform->RAM.DIMM[map].SerialNo); - return Platform->RAM.DIMM[map].SerialNo; - } - } + int map; + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + + if (table_num < MAX_RAM_SLOTS) { + map = DmiDimm[table_num]; + if (RamDimm[map].InUse && strlen(RamDimm[map].SerialNo) > 0) { + DBG("name = %s, map=%d, RAM Detected SerialNo[%d]='%s'\n", name ? name : "", + map, table_num, RamDimm[map].SerialNo); + return RamDimm[map].SerialNo; + } + } } return "N/A"; } @@ -807,16 +826,19 @@ static const char *sm_get_mempartno (const char *name, int table_num) { if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) { - int map; - - if (table_num < MAX_RAM_SLOTS) { - map = Platform->DMI.DIMM[table_num]; - if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].PartNo) > 0) { - DBG("Ram Detected PartNo[%d]='%s'\n", table_num, Platform->RAM.DIMM[map].PartNo); - return Platform->RAM.DIMM[map].PartNo; - } + int map; + + int * DmiDimm = (int*)get_env_ptr(envDmiDimm); + RamSlotInfo_t * RamDimm = (RamSlotInfo_t*)get_env_ptr(envRamDimm); + + if (table_num < MAX_RAM_SLOTS) { + map = DmiDimm[table_num]; + if (RamDimm[map].InUse && strlen(RamDimm[map].PartNo) > 0) { + DBG("Ram Detected PartNo[%d]='%s'\n", table_num, RamDimm[map].PartNo); + return RamDimm[map].PartNo; + } + } } - } return "N/A"; } @@ -872,11 +894,11 @@ int i, j; int tablespresent[256]; bool do_auto=true; - + bzero(tablespresent, sizeof(tablespresent)); - - getBoolForKey(kSMBIOSdefaults, &do_auto, &bootInfo->bootConfig); - + + getBoolForKey(kSMBIOSdefaults, &do_auto, DEFAULT_BOOT_CONFIG); + ret = (struct SMBEntryPoint *)AllocateKernelMemory(sizeof(struct SMBEntryPoint)); if (origsmbios) { smbiostables = (char *)origsmbios->dmi.tableAddress; @@ -885,7 +907,7 @@ smbiostables = NULL; origsmbiosnum = 0; } - + // _SM_ ret->anchor[0] = 0x5f; ret->anchor[1] = 0x53; @@ -910,18 +932,18 @@ ret->dmi.structureCount = 0; // will be calculated later in this function ret->dmi.bcdRevision = 0x21; tablesptr = smbiostables; - + bool randomSerial = false; - getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig); + getBoolForKey(kSMBIOSRandomSerial, &randomSerial, DEFAULT_BOOT_CONFIG); - // add stringlen of overrides to original stringlen, update maxStructure size adequately, - // update structure count and tablepresent[type] with count of type. + // add stringlen of overrides to original stringlen, update maxStructure size adequately, + // update structure count and tablepresent[type] with count of type. if (smbiostables) { for (i=0; ilength; stringsptr = tablesptr; for (; tablesptr[0]!=0 || tablesptr[1]!=0; tablesptr++); @@ -934,7 +956,7 @@ const char *str; int size; char altname[40]; - + sprintf(altname, "%s_%d",smbios_properties[j].name, tablespresent[cur->type] + 1); if (smbios_properties[j].table_type == cur->type && smbios_properties[j].value_type == SMSTRING && @@ -943,9 +965,9 @@ stringlen += strlen(smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[cur->type])) + 1; } else if (smbios_properties[j].table_type == cur->type && - smbios_properties[j].value_type == SMSTRING && - (getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig) || - getValueForKey(altname,&str, &size, &bootInfo->smbiosConfig))) + smbios_properties[j].value_type == SMSTRING && + (getValueForKey(smbios_properties[j].name, &str, &size, DEFAULT_SMBIOS_CONFIG) || + getValueForKey(altname,&str, &size, DEFAULT_SMBIOS_CONFIG))) { stringlen += size + 1; } else if (smbios_properties[j].table_type == cur->type && @@ -967,14 +989,14 @@ tablespresent[cur->type]++; } } - // Add eventually table types whose detected count would be < required count, and update ret header with: - // new stringlen addons, structure count, and tablepresent[type] count adequately + // Add eventually table types whose detected count would be < required count, and update ret header with: + // new stringlen addons, structure count, and tablepresent[type] count adequately for (i=0; ismbiosConfig)) { + if (!getIntForKey(buffer, &numnec, DEFAULT_SMBIOS_CONFIG)) { numnec = -1; } if (numnec==-1 && do_auto && smbios_table_descriptions[i].numfunc) { @@ -986,7 +1008,7 @@ const char *str; int size; char altname[40]; - + sprintf(altname, "%s_%d",smbios_properties[j].name, tablespresent[smbios_table_descriptions[i].type] + 1); if (smbios_properties[j].table_type == smbios_table_descriptions[i].type && smbios_properties[j].value_type==SMSTRING && @@ -995,9 +1017,9 @@ stringlen += strlen(smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[smbios_table_descriptions[i].type])) + 1; } else if (smbios_properties[j].table_type == smbios_table_descriptions[i].type && - smbios_properties[j].value_type == SMSTRING && - (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) || - getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig))) + smbios_properties[j].value_type == SMSTRING && + (getValueForKey(altname, &str, &size, DEFAULT_SMBIOS_CONFIG) || + getValueForKey(smbios_properties[j].name, &str, &size, DEFAULT_SMBIOS_CONFIG))) { stringlen += size + 1; } else if (smbios_properties[j].table_type == smbios_table_descriptions[i].type && @@ -1039,14 +1061,14 @@ bool do_auto=true; static bool done = false; // IMPROVEME: called twice via getSmbios(), but only the second call can get all necessary info ! - + bool randomSerial = false; - getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig); + getBoolForKey(kSMBIOSRandomSerial, &randomSerial, DEFAULT_BOOT_CONFIG); bzero(tablespresent, sizeof(tablespresent)); bzero(handles, sizeof(handles)); - - getBoolForKey(kSMBIOSdefaults, &do_auto, &bootInfo->bootConfig); + + getBoolForKey(kSMBIOSdefaults, &do_auto, DEFAULT_BOOT_CONFIG); newsmbios->dmi.tableAddress = (uint32_t)AllocateKernelMemory(newsmbios->dmi.tableLength); if (origsmbios) { @@ -1058,25 +1080,25 @@ } tablesptr = smbiostables; newtablesptr = (char *)newsmbios->dmi.tableAddress; - - // if old smbios exists then update new smbios with old smbios original content first + + // if old smbios exists then update new smbios with old smbios original content first if (smbiostables) { for (i=0; ihandle) / 8] |= 1 << ((oldcur->handle) % 8); - - // copy table length from old table to new table but not the old strings + + // copy table length from old table to new table but not the old strings memcpy(newcur,oldcur, oldcur->length); - + tablesptr += oldcur->length; stringsptr = tablesptr; newtablesptr += oldcur->length; - - // calculate the number of strings in the old content + + // calculate the number of strings in the old content for (;tablesptr[0]!=0 || tablesptr[1]!=0; tablesptr++) { if (tablesptr[0] == 0) { nstrings++; @@ -1086,105 +1108,105 @@ nstrings++; } tablesptr += 2; - - // copy the old strings to new table + + // copy the old strings to new table memcpy(newtablesptr, stringsptr, tablesptr-stringsptr); - + // point to next possible space for a string (deducting the second 0 char at the end) newtablesptr += tablesptr - stringsptr - 1; - if (nstrings == 0) { // if no string was found rewind to the first 0 char of the 0,0 terminator + if (nstrings == 0) { // if no string was found rewind to the first 0 char of the 0,0 terminator newtablesptr--; } - - // now for each property in the table update the overrides if any (auto or user) + + // now for each property in the table update the overrides if any (auto or user) for (j=0; jtype] + 1); if (smbios_properties[j].table_type == newcur->type) { switch (smbios_properties[j].value_type) { - case SMSTRING: - if (smbios_properties[j].auto_str && randomSerial && (!strcmp ("SMserial", smbios_properties[j].name))) - { - str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]); - size = strlen(str); - memcpy(newtablesptr, str, size); - newtablesptr[size] = 0; - newtablesptr += size + 1; - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; + case SMSTRING: + if (smbios_properties[j].auto_str && randomSerial && (!strcmp ("SMserial", smbios_properties[j].name))) + { + str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]); + size = strlen(str); + memcpy(newtablesptr, str, size); + newtablesptr[size] = 0; + newtablesptr += size + 1; + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; + + } else if (getValueForKey(altname, &str, &size, DEFAULT_SMBIOS_CONFIG) || + getValueForKey(smbios_properties[j].name, &str, &size, DEFAULT_SMBIOS_CONFIG)) + { + memcpy(newtablesptr, str, size); + newtablesptr[size] = 0; + newtablesptr += size + 1; + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; + } else if (do_auto && smbios_properties[j].auto_str) { + str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]); + size = strlen(str); + memcpy(newtablesptr, str, size); + newtablesptr[size] = 0; + newtablesptr += size + 1; + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; + } + break; - } else if (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) || - getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig)) - { - memcpy(newtablesptr, str, size); - newtablesptr[size] = 0; - newtablesptr += size + 1; - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; - } else if (do_auto && smbios_properties[j].auto_str) { - str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]); - size = strlen(str); - memcpy(newtablesptr, str, size); - newtablesptr[size] = 0; - newtablesptr += size + 1; - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; - } - break; - - case SMOWORD: - if (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) || - getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig)) - { - int k=0, t=0, kk=0; - const char *ptr = str; - memset(((char*)newcur) + smbios_properties[j].offset, 0, 16); - while (ptr-str=2 && ptr[0]=='0' && (ptr[1]=='x' || ptr[1]=='X')) { - ptr += 2; - } - for (;ptr-str='0' && *ptr<='9') { - (t=(t<<4)|(*ptr-'0')),kk++; - } - if (*ptr>='a' && *ptr<='f') { - (t=(t<<4)|(*ptr-'a'+10)),kk++; - } - if (*ptr>='A' && *ptr<='F') { - (t=(t<<4)|(*ptr-'A'+10)),kk++; - } - if (kk == 2) { - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset + k)) = t; - k++; - kk = 0; - t = 0; - } - } - } - break; - - case SMBYTE: - if (getIntForKey(altname, &num, &bootInfo->smbiosConfig) || - getIntForKey(smbios_properties[j].name, &num, &bootInfo->smbiosConfig)) - { - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = num; - } else if (do_auto && smbios_properties[j].auto_int) { - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]); - } - break; - - case SMWORD: - if (getIntForKey(altname, &num, &bootInfo->smbiosConfig) || - getIntForKey(smbios_properties[j].name, &num, &bootInfo->smbiosConfig)) - { - *((uint16_t*)(((char*)newcur) + smbios_properties[j].offset)) = num; - } else if (do_auto && smbios_properties[j].auto_int) { - *((uint16_t*)(((char*)newcur) + smbios_properties[j].offset)) = smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]); - } - break; + case SMOWORD: + if (getValueForKey(altname, &str, &size, DEFAULT_SMBIOS_CONFIG) || + getValueForKey(smbios_properties[j].name, &str, &size, DEFAULT_SMBIOS_CONFIG)) + { + int k=0, t=0, kk=0; + const char *ptr = str; + memset(((char*)newcur) + smbios_properties[j].offset, 0, 16); + while (ptr-str=2 && ptr[0]=='0' && (ptr[1]=='x' || ptr[1]=='X')) { + ptr += 2; + } + for (;ptr-str='0' && *ptr<='9') { + (t=(t<<4)|(*ptr-'0')),kk++; + } + if (*ptr>='a' && *ptr<='f') { + (t=(t<<4)|(*ptr-'a'+10)),kk++; + } + if (*ptr>='A' && *ptr<='F') { + (t=(t<<4)|(*ptr-'A'+10)),kk++; + } + if (kk == 2) { + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset + k)) = t; + k++; + kk = 0; + t = 0; + } + } + } + break; + + case SMBYTE: + if (getIntForKey(altname, &num, DEFAULT_SMBIOS_CONFIG) || + getIntForKey(smbios_properties[j].name, &num, DEFAULT_SMBIOS_CONFIG)) + { + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = num; + } else if (do_auto && smbios_properties[j].auto_int) { + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]); + } + break; + + case SMWORD: + if (getIntForKey(altname, &num, DEFAULT_SMBIOS_CONFIG) || + getIntForKey(smbios_properties[j].name, &num, DEFAULT_SMBIOS_CONFIG)) + { + *((uint16_t*)(((char*)newcur) + smbios_properties[j].offset)) = num; + } else if (do_auto && smbios_properties[j].auto_int) { + *((uint16_t*)(((char*)newcur) + smbios_properties[j].offset)) = smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]); + } + break; } } } @@ -1197,14 +1219,14 @@ tablespresent[newcur->type]++; } } - - // for each eventual complementary table not present in the original smbios, do the overrides + + // for each eventual complementary table not present in the original smbios, do the overrides for (i=0; ismbiosConfig)) { + if (!getIntForKey(buffer, &numnec, DEFAULT_SMBIOS_CONFIG)) { numnec = -1; } if (numnec == -1 && do_auto && smbios_table_descriptions[i].numfunc) { @@ -1213,7 +1235,7 @@ while (tablespresent[smbios_table_descriptions[i].type] < numnec) { struct smbios_table_header *newcur = (struct smbios_table_header *) newtablesptr; int nstrings = 0; - + memset(newcur,0, smbios_table_descriptions[i].len); while (handles[(nexthandle)/8] & (1 << ((nexthandle) % 8))) { nexthandle++; @@ -1228,90 +1250,90 @@ int size; int num; char altname[40]; - + sprintf(altname, "%s_%d", smbios_properties[j].name, tablespresent[newcur->type] + 1); if (smbios_properties[j].table_type == newcur->type) { switch (smbios_properties[j].value_type) { - case SMSTRING: - if (smbios_properties[j].auto_str && randomSerial && (!strcmp ("SMserial", smbios_properties[j].name))) - { - str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]); - size = strlen(str); - memcpy(newtablesptr, str, size); - newtablesptr[size] = 0; - newtablesptr += size + 1; - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; + case SMSTRING: + if (smbios_properties[j].auto_str && randomSerial && (!strcmp ("SMserial", smbios_properties[j].name))) + { + str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]); + size = strlen(str); + memcpy(newtablesptr, str, size); + newtablesptr[size] = 0; + newtablesptr += size + 1; + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; - } else if (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) || - getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig)) - { - memcpy(newtablesptr, str, size); - newtablesptr[size] = 0; - newtablesptr += size + 1; - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; - } else if (do_auto && smbios_properties[j].auto_str) { - str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]); - size = strlen(str); - memcpy(newtablesptr, str, size); - newtablesptr[size] = 0; - newtablesptr += size + 1; - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; - } - break; - - case SMOWORD: - if (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) || - getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig)) - { - int k=0, t=0, kk=0; - const char *ptr = str; - - memset(((char*)newcur) + smbios_properties[j].offset, 0, 16); - while (ptr-str=2 && ptr[0]=='0' && (ptr[1]=='x' || ptr[1]=='X')) { - ptr += 2; - } - for (;ptr-str='0' && *ptr<='9') { - (t=(t<<4)|(*ptr-'0')),kk++; - } - if (*ptr>='a' && *ptr<='f') { - (t=(t<<4)|(*ptr-'a'+10)),kk++; - } - if (*ptr>='A' && *ptr<='F') { - (t=(t<<4)|(*ptr-'A'+10)),kk++; - } - if (kk == 2) { - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset + k)) = t; - k++; - kk = 0; - t = 0; - } - } - } - break; - - case SMBYTE: - if (getIntForKey(altname, &num, &bootInfo->smbiosConfig) || - getIntForKey(smbios_properties[j].name, &num, &bootInfo->smbiosConfig)) - { - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = num; - } else if (do_auto && smbios_properties[j].auto_int) { - *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]); - } - break; - - case SMWORD: - if (getIntForKey(altname, &num, &bootInfo->smbiosConfig) || - getIntForKey(smbios_properties[j].name, &num, &bootInfo->smbiosConfig)) - { - *((uint16_t*)(((char*)newcur) + smbios_properties[j].offset)) = num; - } else if (do_auto && smbios_properties[j].auto_int) { - *((uint16_t*)(((char*)newcur)+smbios_properties[j].offset)) = smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]); - } - break; + } else if (getValueForKey(altname, &str, &size, DEFAULT_SMBIOS_CONFIG) || + getValueForKey(smbios_properties[j].name, &str, &size, DEFAULT_SMBIOS_CONFIG)) + { + memcpy(newtablesptr, str, size); + newtablesptr[size] = 0; + newtablesptr += size + 1; + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; + } else if (do_auto && smbios_properties[j].auto_str) { + str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]); + size = strlen(str); + memcpy(newtablesptr, str, size); + newtablesptr[size] = 0; + newtablesptr += size + 1; + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings; + } + break; + + case SMOWORD: + if (getValueForKey(altname, &str, &size, DEFAULT_SMBIOS_CONFIG) || + getValueForKey(smbios_properties[j].name, &str, &size, DEFAULT_SMBIOS_CONFIG)) + { + int k=0, t=0, kk=0; + const char *ptr = str; + + memset(((char*)newcur) + smbios_properties[j].offset, 0, 16); + while (ptr-str=2 && ptr[0]=='0' && (ptr[1]=='x' || ptr[1]=='X')) { + ptr += 2; + } + for (;ptr-str='0' && *ptr<='9') { + (t=(t<<4)|(*ptr-'0')),kk++; + } + if (*ptr>='a' && *ptr<='f') { + (t=(t<<4)|(*ptr-'a'+10)),kk++; + } + if (*ptr>='A' && *ptr<='F') { + (t=(t<<4)|(*ptr-'A'+10)),kk++; + } + if (kk == 2) { + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset + k)) = t; + k++; + kk = 0; + t = 0; + } + } + } + break; + + case SMBYTE: + if (getIntForKey(altname, &num, DEFAULT_SMBIOS_CONFIG) || + getIntForKey(smbios_properties[j].name, &num, DEFAULT_SMBIOS_CONFIG)) + { + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = num; + } else if (do_auto && smbios_properties[j].auto_int) { + *((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]); + } + break; + + case SMWORD: + if (getIntForKey(altname, &num, DEFAULT_SMBIOS_CONFIG) || + getIntForKey(smbios_properties[j].name, &num, DEFAULT_SMBIOS_CONFIG)) + { + *((uint16_t*)(((char*)newcur) + smbios_properties[j].offset)) = num; + } else if (do_auto && smbios_properties[j].auto_int) { + *((uint16_t*)(((char*)newcur)+smbios_properties[j].offset)) = smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]); + } + break; } } } @@ -1324,8 +1346,8 @@ tablespresent[smbios_table_descriptions[i].type]++; } } - - // calculate new checksums + + // calculate new checksums newsmbios->dmi.checksum = 0; newsmbios->dmi.checksum = 256 - checksum8(&newsmbios->dmi, sizeof(newsmbios->dmi)); newsmbios->checksum = 0; @@ -1465,52 +1487,52 @@ struct SMBEntryPoint *getSmbiosPatched(struct SMBEntryPoint *orig) { struct SMBEntryPoint *patched = NULL; // cached - + patched = smbios_dry_run(orig); - if(patched==NULL) { - printf("Could not create new SMBIOS !!\n"); - pause(); - } - else { - smbios_real_run(orig, patched); - } - - - return patched; - + if(patched==NULL) { + printf("Could not create new SMBIOS !!\n"); + pause(); + } + else { + smbios_real_run(orig, patched); + } + + + return patched; + } /* -char* getSmbiosProductName() -{ - struct SMBEntryPoint *smbios; - SMBSystemInformation *p; - char* tempString; - int tmpLen; - - smbios = getSmbiosOriginal(); - if (smbios==NULL) return NULL; - - p = (SMBSystemInformation*) FindFirstDmiTableOfType(1, 0x19); // Type 1: (3.3.2) System Information - if (p==NULL) return NULL; - - - tempString = (char*)smbiosStringAtIndex((DMIHeader*)p, p->productName, &tmpLen); - tempString[tmpLen] = 0; - - gSMBIOSBoardModel = malloc(tmpLen + 1); - if(gSMBIOSBoardModel) - { - strncpy(gSMBIOSBoardModel, tempString, tmpLen); - Node* node = DT__FindNode("/", false); - DT__AddProperty(node, "orig-model", tmpLen, gSMBIOSBoardModel); - } - verbose("Actual model name is '%s'\n", tempString); - return tempString; -} -*/ + char* getSmbiosProductName() + { + struct SMBEntryPoint *smbios; + SMBSystemInformation *p; + char* tempString; + int tmpLen; + + smbios = getSmbiosOriginal(); + if (smbios==NULL) return NULL; + + p = (SMBSystemInformation*) FindFirstDmiTableOfType(1, 0x19); // Type 1: (3.3.2) System Information + if (p==NULL) return NULL; + + + tempString = (char*)smbiosStringAtIndex((DMIHeader*)p, p->productName, &tmpLen); + tempString[tmpLen] = 0; + + gSMBIOSBoardModel = malloc(tmpLen + 1); + if(gSMBIOSBoardModel) + { + strncpy(gSMBIOSBoardModel, tempString, tmpLen); + Node* node = DT__FindNode("/", false); + DT__AddProperty(node, "orig-model", tmpLen, gSMBIOSBoardModel); + } + verbose("Actual model name is '%s'\n", tempString); + return tempString; + } + */ -void scan_memory(PlatformInfo_t *p) +void scan_memory(void) { int i=0; struct DMIHeader * dmihdr = NULL; @@ -1519,19 +1541,25 @@ struct DMIPhysicalMemoryArray* physMemArray; // 16 struct DMIMemoryDevice* memDev[MAX_RAM_SLOTS]; //17 + int MaxMemorySlots = 0; // number of memory slots polulated by SMBIOS + /* We mainly don't use obsolete tables 5,6 because most of computers don't handle it anymore */ - Platform->DMI.MemoryModules = 0; + int MemoryModules = 0; + /* Now lets peek info rom table 16,17 as for some bios, table 5 & 6 are not used */ physMemArray = (struct DMIPhysicalMemoryArray*) FindFirstDmiTableOfType(16, 4); - Platform->DMI.MaxMemorySlots = physMemArray ? physMemArray->numberOfMemoryDevices : 0; - + + MaxMemorySlots = physMemArray ? physMemArray->numberOfMemoryDevices : 0; + i = 0; + static RamSlotInfo_t RamDimm[MAX_RAM_SLOTS]; // Information about each slot + for(dmihdr = FindFirstDmiTableOfType(17, 4); dmihdr; dmihdr = FindNextDmiTableOfType(17, 4) ) { memDev[i] = (struct DMIMemoryDevice*) dmihdr; - if (memDev[i]->size !=0 ) Platform->DMI.MemoryModules++; - if (memDev[i]->speed>0) Platform->RAM.DIMM[i].Frequency = memDev[i]->speed; // take it here for now but we'll check spd and dmi table 6 as well + if (memDev[i]->size !=0 ) MemoryModules++; + if (memDev[i]->speed>0) RamDimm[i].Frequency = memDev[i]->speed; // take it here for now but we'll check spd and dmi table 6 as well i++; } // for table 6, we only have a look at the current speed @@ -1540,10 +1568,15 @@ dmihdr; dmihdr = FindNextDmiTableOfType(6, 4) ) { memInfo[i] = (struct DMIMemoryModuleInfo*) dmihdr; - if (memInfo[i]->currentSpeed > Platform->RAM.DIMM[i].Frequency) - Platform->RAM.DIMM[i].Frequency = memInfo[i]->currentSpeed; // favor real overclocked speed if any + if (memInfo[i]->currentSpeed > RamDimm[i].Frequency) + RamDimm[i].Frequency = memInfo[i]->currentSpeed; // favor real overclocked speed if any i++; } + + safe_set_env(envDMIMaxMemorySlots, MaxMemorySlots); + safe_set_env(envDMIMemModules, MemoryModules); + safe_set_env_copy(envRamDimm, RamDimm, sizeof(RamDimm)); + #if 0 dumpAllTablesOfType(17); getc(); Index: branches/cparm/i386/modules/SMBiosPatcher/SMBiosPatcher.c =================================================================== --- branches/cparm/i386/modules/SMBiosPatcher/SMBiosPatcher.c (revision 1839) +++ branches/cparm/i386/modules/SMBiosPatcher/SMBiosPatcher.c (revision 1840) @@ -1,9 +1,8 @@ /* * Copyright 2011 cparm. All rights reserved. */ -#include "boot.h" +#include "libsaio.h" #include "bootstruct.h" -#include "libsaio.h" #include "modules.h" #include "Platform.h" #include "smbios_patcher.h" @@ -22,6 +21,10 @@ #endif #define kEnableSMBIOSPatcher "EnableSMBIOSPatcher" +void getSmbiosPatched_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void getProductName_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void getboardproduct_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void is_SMB_Patcher_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); void getSmbiosPatched_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) @@ -31,20 +34,20 @@ getSmbiosTableStructure(getSmbiosOriginal()); // generate tables entry list for fast table finding if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) - scan_memory(Platform); + scan_memory(); execute_hook("ScanMemory", NULL, NULL, NULL, NULL, NULL, NULL); patched_smb = getSmbiosPatched(getSmbiosOriginal()); if (patched_smb) - smbios_p = ((uint64_t)((uint32_t)patched_smb)); + Register_Smbios_Efi(patched_smb); else { verbose("Error: Could not get patched SMBIOS, fallback to original SMBIOS !!\n"); - struct SMBEntryPoint *smbios_o = getSmbiosOriginal(); - smbios_p = ((uint64_t)((uint32_t)smbios_o)); + Register_Smbios_Efi(getSmbiosOriginal()); + } } @@ -55,11 +58,11 @@ int len = 0; const char *val = 0; - if (getValueForKey("SMproductname", &val, &len, &bootInfo->smbiosConfig)) { - gPlatformName = (char *)val; + if (getValueForKey("SMproductname", &val, &len, DEFAULT_SMBIOS_CONFIG)) { + SetgPlatformName(val); } else { const char *productName = sm_get_defstr("SMproductname", 0); - gPlatformName = (char *)productName; + SetgPlatformName(productName); } DBG("SMBIOS Product name: %s\n",productName); @@ -72,21 +75,24 @@ int len = 0; const char *val = 0; - if (getValueForKey("SMboardproduct", &val, &len, &bootInfo->smbiosConfig)) { - gboardproduct = (char *)val; + if (getValueForKey("SMboardproduct", &val, &len, DEFAULT_SMBIOS_CONFIG)) { + + Setgboardproduct(val); + } else { const char *productBoard = sm_get_defstr("SMboardproduct", 0); - gboardproduct = (char *)productBoard; + Setgboardproduct(productBoard); } } void is_SMB_Patcher_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){} -void SMBiosPatcher_start() +void SMBiosPatcher_start(void); +void SMBiosPatcher_start(void) { bool enable = true; - getBoolForKey(kEnableSMBIOSPatcher, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableSMBIOSPatcher, &enable, DEFAULT_BOOT_CONFIG) ; enable = (execute_hook("isSMBIOSRegistred", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS); Index: branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.h =================================================================== --- branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.h (revision 1839) +++ branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.h (revision 1840) @@ -43,7 +43,7 @@ int (*numfunc)(int tablen); }; -extern void scan_memory(PlatformInfo_t *); +extern void scan_memory(void); extern const char* sm_get_defstr(const char * key, int table_num); extern struct SMBEntryPoint *getSmbiosPatched(struct SMBEntryPoint *orig); //extern char* getSmbiosProductName(); Index: branches/cparm/i386/modules/SMBiosPatcher/Makefile =================================================================== --- branches/cparm/i386/modules/SMBiosPatcher/Makefile (revision 1839) +++ branches/cparm/i386/modules/SMBiosPatcher/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -SMBiosPatcher_OBJS = SMBiosPatcher.o smbios_patcher.o +SMBiosPatcher_OBJS = SMBiosPatcher.o smbios_patcher.o stack_protector.o SFILES = @@ -71,11 +71,16 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/SMBiosPatcher.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/SMBiosPatcher.o \ $(OBJROOT)/smbios_patcher.o \ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + SMBiosPatcher.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "SMBiosPatcher.c" $(INC) -o "$(OBJROOT)/SMBiosPatcher.o" Index: branches/cparm/i386/modules/Resolution/Resolution.c =================================================================== --- branches/cparm/i386/modules/Resolution/Resolution.c (revision 1839) +++ branches/cparm/i386/modules/Resolution/Resolution.c (revision 1840) @@ -10,11 +10,11 @@ #define kEnableResolution "EnableResolutionModule" - -void Resolution_start() +void Resolution_start(void); +void Resolution_start(void) { bool enable = true; - getBoolForKey(kEnableResolution, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableResolution, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) { register_hook_callback("getResolution_hook", &getResolutionHook); Index: branches/cparm/i386/modules/Resolution/edid.c =================================================================== --- branches/cparm/i386/modules/Resolution/edid.c (revision 1839) +++ branches/cparm/i386/modules/Resolution/edid.c (revision 1840) @@ -12,7 +12,6 @@ #include "edid.h" #include "vbe.h" #include "graphics.h" -#include "boot.h" void getResolutionHook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) { @@ -24,12 +23,12 @@ int val; static UInt32 xResolution, yResolution, bpResolution; - if(getIntForKey(kScreenWidth, &val, &bootInfo->bootConfig)) + if(getIntForKey(kScreenWidth, &val, DEFAULT_BOOT_CONFIG)) { xResolution = val; } - if(getIntForKey(kScreenHeight, &val, &bootInfo->bootConfig)) + if(getIntForKey(kScreenHeight, &val, DEFAULT_BOOT_CONFIG)) { yResolution = val; } @@ -64,7 +63,7 @@ } -char* readEDID() +char* readEDID(void) { SInt16 last_reported = -1; UInt8 edidInfo[EDID_BLOCK_SIZE]; Index: branches/cparm/i386/modules/Resolution/915resolution.h =================================================================== --- branches/cparm/i386/modules/Resolution/915resolution.h (revision 1839) +++ branches/cparm/i386/modules/Resolution/915resolution.h (revision 1840) @@ -225,5 +225,13 @@ void unlock_vbios(vbios_map*); void relock_vbios(vbios_map*); void set_mode(vbios_map*, UInt32, UInt32, UInt32, UInt32, UInt32); +int getMode(edid_mode *mode); +char detect_ati_bios_type(vbios_map * map); +char detect_bios_type(vbios_map * map, char modeline, int entry_size); +vbios_resolution_type3 * map_type3_resolution(vbios_map * map, UInt16 res); +vbios_resolution_type2 * map_type2_resolution(vbios_map * map, UInt16 res); +vbios_resolution_type1 * map_type1_resolution(vbios_map * map, UInt16 res); +chipset_type get_chipset(UInt32 id); +UInt32 get_chipset_id(void); #endif //__RESOLUTION_H Index: branches/cparm/i386/modules/Resolution/edid.h =================================================================== --- branches/cparm/i386/modules/Resolution/edid.h (revision 1839) +++ branches/cparm/i386/modules/Resolution/edid.h (revision 1840) @@ -14,6 +14,6 @@ #define kScreenWidth "ScreenWidth" #define kScreenHeight "ScreenHeight" -char* readEDID(); +char* readEDID(void); void getResolution(UInt32* x, UInt32* y, UInt32* bp); void getResolutionHook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); \ No newline at end of file Index: branches/cparm/i386/modules/Resolution/Makefile =================================================================== --- branches/cparm/i386/modules/Resolution/Makefile (revision 1839) +++ branches/cparm/i386/modules/Resolution/Makefile (revision 1840) @@ -44,7 +44,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -RESOLUTION_OBJS = Resolution.o edid.o 915resolution.o +RESOLUTION_OBJS = Resolution.o edid.o 915resolution.o stack_protector.o SFILES = @@ -70,12 +70,17 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/edid.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/edid.o \ $(OBJROOT)/915resolution.o \ $(OBJROOT)/Resolution.o \ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + Resolution.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "Resolution.c" $(INC) -o "$(OBJROOT)/Resolution.o" Index: branches/cparm/i386/modules/CPUfreq/CPUfreq.c =================================================================== --- branches/cparm/i386/modules/CPUfreq/CPUfreq.c (revision 1839) +++ branches/cparm/i386/modules/CPUfreq/CPUfreq.c (revision 1840) @@ -1,9 +1,8 @@ /* * Copyright 2010,2011 valv, cparm . All rights reserved. */ -#include "boot.h" +#include "libsaio.h" #include "bootstruct.h" -#include "libsaio.h" #include "modules.h" #include "Platform.h" #include "cpu.h" @@ -12,18 +11,31 @@ #define MSR_FSB_FREQ 0x000000cd #define AMD_10H_11H_CONFIG 0xc0010064 #define kEnableCPUfreq "EnableCPUfreqModule" +void CPUfreq_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); void CPUfreq_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) { int bus_ratio; uint64_t msr , fsbFrequency , cpuFrequency , minfsb , maxfsb ; - - if ((Platform->CPU.Vendor == 0x756E6547 /* Intel */) && ((Platform->CPU.Family == 0x06) || (Platform->CPU.Family == 0x0f))) + + uint8_t Model = (uint8_t)get_env(envModel); + uint32_t Vendor = (uint32_t)get_env(envVendor); + uint8_t Family = (uint8_t)get_env(envFamily); + + uint8_t MaxCoef = (uint8_t)get_env(envMaxCoef); + uint8_t MaxDiv = (uint8_t)get_env(envMaxDiv); + uint8_t CurrDiv = (uint8_t)get_env(envCurrDiv); + uint64_t FSBFrequency = get_env(envFSBFreq); + uint8_t CurrCoef = (uint8_t)get_env(envCurrCoef); + uint64_t CPUFrequency = get_env(envCPUFreq); + + + if ((Vendor == CPUID_VENDOR_INTEL ) && ((Family == 0x06) || (Family == 0x0f))) { - if ((Platform->CPU.Family == 0x06 && Platform->CPU.Model >= 0x0c) || (Platform->CPU.Family == 0x0f && Platform->CPU.Model >= 0x03)) + if ((Family == 0x06 && Model >= 0x0c) || (Family == 0x0f && Model >= 0x03)) { - if (Platform->CPU.Family == 0x06) + if (Family == 0x06) { bus_ratio = 0; @@ -37,7 +49,7 @@ uint16_t idlo; uint8_t crlo, crhi = 0; - switch (Platform->CPU.Model) { + switch (Model) { case CPUID_MODEL_YONAH: // Core Duo/Solo, Pentium M DC case CPUID_MODEL_MEROM: // Core Xeon, Core 2 DC, 65nm case 0x16: // Celeron, Core 2 SC, 65nm @@ -45,7 +57,7 @@ case CPUID_MODEL_ATOM: // Atom :) case 0x27: // Atom Lincroft, 45nm { - getBoolForKey(kFixFSB, &fix_fsb, &bootInfo->bootConfig); + getBoolForKey(kFixFSB, &fix_fsb, DEFAULT_BOOT_CONFIG); if (fix_fsb) { @@ -83,26 +95,28 @@ { fsbFrequency = 200000000; } - Platform->CPU.FSBFrequency = fsbFrequency; + safe_set_env(envFSBFreq, fsbFrequency); } - if (getIntForKey("MaxBusRatio", &bus_ratio, &bootInfo->bootConfig)) + if (getIntForKey("MaxBusRatio", &bus_ratio, DEFAULT_BOOT_CONFIG)) { msr = rdmsr64(MSR_IA32_PERF_STATUS); idlo = (msr >> 48) & 0xffff; crlo = (idlo >> 8) & 0xff; //printf("CPUfreq: MinCoef: 0x%x\n",crlo); - - if (Platform->CPU.MaxCoef) + + + + if (MaxCoef) { - if (Platform->CPU.MaxDiv) + if (MaxDiv) { - crhi = (Platform->CPU.MaxCoef * 10) + 5; + crhi = (MaxCoef * 10) + 5; } else { - crhi = Platform->CPU.MaxCoef * 10; + crhi = MaxCoef * 10; } } if (crlo == 0 || crhi == crlo) goto out; @@ -118,27 +132,28 @@ if (fdiv > 0) currdiv = 1; - Platform->CPU.CurrCoef = currcoef; - Platform->CPU.CurrDiv = currdiv; + safe_set_env(envCurrCoef,currcoef); + safe_set_env(envCurrDiv,currdiv); + } } out: - if (Platform->CPU.CurrDiv) + if (CurrDiv) { - cpuFrequency = (Platform->CPU.FSBFrequency * ((Platform->CPU.CurrCoef * 2) + 1) / 2); + cpuFrequency = (FSBFrequency * ((CurrCoef * 2) + 1) / 2); } else { - cpuFrequency = (Platform->CPU.FSBFrequency * Platform->CPU.CurrCoef); + cpuFrequency = (FSBFrequency * CurrCoef); } - Platform->CPU.CPUFrequency = cpuFrequency; - verbose("CPU: FSBFreq changed to: %dMHz\n", Platform->CPU.FSBFrequency / 1000000); - verbose("CPU: CPUFreq changed to: %dMHz\n", Platform->CPU.CPUFrequency / 1000000); - //verbose("CPUfreq: FSB Fix applied !\n"); + safe_set_env(envCPUFreq,cpuFrequency); + + verbose("CPU: FSBFreq changed to: %dMHz\n", (uint32_t)(get_env(envFSBFreq) / 1000000)); + verbose("CPU: CPUFreq changed to: %dMHz\n", (uint32_t)(get_env(envCPUFreq) / 1000000)); break; } @@ -149,72 +164,73 @@ } } } - else if(Platform->CPU.Vendor == 0x68747541 /* AMD */ && Platform->CPU.Family == 0x0f) // valv: work in progress + else if(Vendor == CPUID_VENDOR_AMD && Family == 0x0f) // valv: work in progress { - verbose("CPU: "); - // valv: mobility check - if ((strstr(Platform->CPU.BrandString, "obile") == 0) || (strstr(Platform->CPU.BrandString, "Atom") == 0)) - { - Platform->CPU.isMobile = true; - } - verbose("%s\n", Platform->CPU.BrandString); + uint8_t ExtFamily = get_env(envExtFamily); + uint64_t TSCFrequency = get_env(envTSCFreq); + uint8_t bus_ratio_current = 0; - if(Platform->CPU.ExtFamily == 0x00 /* K8 */) + if(ExtFamily == 0x00 /* K8 */) { msr = rdmsr64(K8_FIDVID_STATUS); bus_ratio_current = (msr & 0x3f) / 2 + 4; - Platform->CPU.CurrDiv = (msr & 0x01) * 2; + CurrDiv = (msr & 0x01) * 2; if (bus_ratio_current) { - if (Platform->CPU.CurrDiv) + if (CurrDiv) { - Platform->CPU.FSBFrequency = ((Platform->CPU.TSCFrequency * Platform->CPU.CurrDiv) / bus_ratio_current); // ? + safe_set_env(envFSBFreq,((TSCFrequency * CurrDiv)/bus_ratio_current)); // ? } else { - Platform->CPU.FSBFrequency = (Platform->CPU.TSCFrequency / bus_ratio_current); + safe_set_env(envFSBFreq, (TSCFrequency/bus_ratio_current) ); } //fsbFrequency = (tscFrequency / bus_ratio_max); // ? } } - else if(Platform->CPU.ExtFamily >= 0x01 /* K10+ */) + else if(ExtFamily >= 0x01 /* K10+ */) { msr = rdmsr64(AMD_10H_11H_CONFIG); bus_ratio_current = ((msr) & 0x3F); - Platform->CPU.CurrDiv = (2 << ((msr >> 6) & 0x07)) / 2; - Platform->CPU.FSBFrequency = (Platform->CPU.CPUFrequency / bus_ratio_current); + safe_set_env(envCurrDiv,((2 << ((msr >> 6) & 0x07)) / 2)); + + safe_set_env(envFSBFreq,(CPUFrequency/bus_ratio_current)); + } - if (!Platform->CPU.FSBFrequency) + if (!get_env(envFSBFreq)) { - Platform->CPU.FSBFrequency = (DEFAULT_FSB * 1000); + safe_set_env(envFSBFreq,(DEFAULT_FSB * 1000)); verbose("0 ! using the default value for FSB !\n"); } - Platform->CPU.CurrCoef = bus_ratio_current / 10; - Platform->CPU.CPUFrequency = Platform->CPU.TSCFrequency; + + safe_set_env(envCurrCoef, (bus_ratio_current / 10)); + + safe_set_env(envCPUFreq,TSCFrequency); - verbose("CPU (AMD): FSBFreq: %dMHz\n", Platform->CPU.FSBFrequency / 1000000); - verbose("CPU (AMD): CPUFreq: %dMHz\n", Platform->CPU.CPUFrequency / 1000000); - verbose("CPU (AMD): CurrCoef: 0x%x\n", Platform->CPU.CurrCoef); - verbose("CPU (AMD): CurrDiv: 0x%x\n", Platform->CPU.CurrDiv); + verbose("CPU (AMD): FSBFreq: %dMHz\n", (uint32_t)(get_env(envFSBFreq) / 1000000)); + verbose("CPU (AMD): CPUFreq: %dMHz\n", (uint32_t)(get_env(envCPUFreq) / 1000000)); + verbose("CPU (AMD): CurrCoef: 0x%x\n", (uint32_t)(get_env(envCurrCoef))); + verbose("CPU (AMD): CurrDiv: 0x%x\n", (uint32_t)(get_env(envCurrDiv))); } } -void CPUfreq_start() +void CPUfreq_start(void); +void CPUfreq_start(void) { bool enable = true; - getBoolForKey(kEnableCPUfreq, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableCPUfreq, &enable, DEFAULT_BOOT_CONFIG) ; if (enable) { - if (Platform->CPU.Features & CPUID_FEATURE_MSR) + if (get_env(envFeatures) & CPUID_FEATURE_MSR) { register_hook_callback("PreBoot", &CPUfreq_hook); } Index: branches/cparm/i386/modules/CPUfreq/Makefile =================================================================== --- branches/cparm/i386/modules/CPUfreq/Makefile (revision 1839) +++ branches/cparm/i386/modules/CPUfreq/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -CPUfreq_OBJS = CPUfreq.o +CPUfreq_OBJS = CPUfreq.o stack_protector.o SFILES = @@ -71,10 +71,12 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/CPUfreq.o -o $(SYMROOT)/$(MODULE_NAME).dylib + $(OBJROOT)/stack_protector.o $(OBJROOT)/CPUfreq.o -o $(SYMROOT)/$(MODULE_NAME).dylib - - + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + CPUfreq.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "CPUfreq.c" $(INC) -o "$(OBJROOT)/CPUfreq.o" Index: branches/cparm/i386/modules/Memory/dram_controllers.h =================================================================== --- branches/cparm/i386/modules/Memory/dram_controllers.h (revision 1839) +++ branches/cparm/i386/modules/Memory/dram_controllers.h (revision 1840) @@ -18,7 +18,7 @@ #include "libsaio.h" -void scan_dram_controller(); +void scan_dram_controller(pci_dt_t *dram_dev); struct mem_controller_t { uint16_t vendor; Index: branches/cparm/i386/modules/Memory/spd.c =================================================================== --- branches/cparm/i386/modules/Memory/spd.c (revision 1839) +++ branches/cparm/i386/modules/Memory/spd.c (revision 1840) @@ -88,10 +88,13 @@ outb(base + SMBHSTDAT, 0xff); rdtsc(l1, h1); + + uint64_t tsc = get_env(envTSCFreq); + while ( inb(base + SMBHSTSTS) & 0x01) // wait until read { rdtsc(l2, h2); - t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (Platform->CPU.TSCFrequency / 100); + t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (tsc / 100); if (t > 5) return 0xFF; // break } @@ -105,7 +108,7 @@ while (!( inb(base + SMBHSTSTS) & 0x02)) // wait til command finished { rdtsc(l2, h2); - t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (Platform->CPU.TSCFrequency / 100); + t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (tsc / 100); if (t > 5) break; // break after 5ms } @@ -279,15 +282,26 @@ DBG("Scanning SMBus [%04x:%04x], mmio: 0x%x, ioport: 0x%x, hostc: 0x%x\n", smbus_dev->vendor_id, smbus_dev->device_id, mmio, base, hostc); - getBoolForKey("DumpSPD", &dump, &bootInfo->bootConfig); - bool fullBanks = // needed at least for laptops - Platform->DMI.MemoryModules == Platform->DMI.MaxMemorySlots; - // Search MAX_RAM_SLOTS slots + getBoolForKey("DumpSPD", &dump, DEFAULT_BOOT_CONFIG); + bool fullBanks ; // needed at least for laptops + + int DMIMaxMemorySlots = (int)get_env(envDMIMaxMemorySlots); + int DMIMemModules = (int)get_env(envDMIMemModules); + + fullBanks = (bool)(DMIMemModules == DMIMaxMemorySlots) ; + + // Search MAX_RAM_SLOTS slots char spdbuf[MAX_SPD_SIZE]; + RamSlotInfo_t *RamDIMM = get_env_ptr(envRamDimm); + + static int DmiDIMM[MAX_RAM_SLOTS]; // Information and SPD mapping for each slot + + uint64_t RamFrequency = get_env(envRamFrequency); + for (i = 0; i < MAX_RAM_SLOTS; i++){ DBG("Scanning slot %d\n", i); - slot = &Platform->RAM.DIMM[i]; + slot = &RamDIMM[i]; spd_size = smb_read_byte_intel(base, 0x50 + i, 0); // Check spd is present if (spd_size && (spd_size != 0xff) ) { @@ -331,8 +345,8 @@ if (slot->Frequency<(uint32_t)speed) slot->Frequency = speed; // pci memory controller if available, is more reliable - if (Platform->RAM.Frequency > 0) { - uint32_t freq = (uint32_t)Platform->RAM.Frequency / 500000; + if ( RamFrequency > 0) { + uint32_t freq = (uint32_t)(RamFrequency / 500000); // now round off special cases uint32_t fmod100 = freq %100; switch(fmod100) { @@ -360,13 +374,16 @@ #endif } // laptops sometimes show slot 0 and 2 with slot 1 empty when only 2 slots are presents so: - Platform->DMI.DIMM[i]= - i>0 && Platform->RAM.DIMM[1].InUse==false && fullBanks && Platform->DMI.MaxMemorySlots==2 ? + DmiDIMM[i]= + i>0 && RamDIMM[1].InUse==false && fullBanks && (DMIMaxMemorySlots==2) ? mapping[i] : i; // for laptops case, mapping setup would need to be more generic than this slot->spd = NULL; } // for + + safe_set_env_copy(envDmiDimm, DmiDIMM, sizeof(DmiDIMM)); + } static struct smbus_controllers_t smbus_controllers[] = { Index: branches/cparm/i386/modules/Memory/Memory.c =================================================================== --- branches/cparm/i386/modules/Memory/Memory.c (revision 1839) +++ branches/cparm/i386/modules/Memory/Memory.c (revision 1840) @@ -11,7 +11,6 @@ #include "dram_controllers.h" #include "spd.h" #include "mem.h" -#include "boot.h" #include "bootstruct.h" #include "modules.h" @@ -23,15 +22,17 @@ void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void is_Memory_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); void is_Memory_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){} -void Memory_start() +void Memory_start(void); +void Memory_start(void) { bool enable = true; - getBoolForKey(kEnableMemory, &enable, &bootInfo->bootConfig); + getBoolForKey(kEnableMemory, &enable, DEFAULT_BOOT_CONFIG); if (pci_config_read16(PCIADDR(0, 0x00, 0), 0x00) != 0x8086) enable = false; Index: branches/cparm/i386/modules/Memory/dram_controllers.c =================================================================== --- branches/cparm/i386/modules/Memory/dram_controllers.c (revision 1839) +++ branches/cparm/i386/modules/Memory/dram_controllers.c (revision 1840) @@ -168,10 +168,10 @@ DBG("mch_ratio %d\n", mch_ratio); - // Compute RAM Frequency - Platform->RAM.Frequency = (Platform->CPU.FSBFrequency * mch_ratio) / 100000; + // Compute RAM Frequency + safe_set_env(envRamFrequency, ((get_env(envFSBFreq) * mch_ratio) / 100000)); - DBG("ram_fsb %d\n", Platform->RAM.Frequency); + DBG("ram_fsb %d\n", (uint32_t)get_env(envRamFrequency)); } @@ -241,7 +241,9 @@ } // Compute RAM Frequency - Platform->RAM.Frequency = (Platform->CPU.FSBFrequency * mch_ratio) / 100000; + safe_set_env(envRamFrequency, ((get_env(envFSBFreq) * mch_ratio) / 100000)); + + DBG("ram_fsb %d\n", (uint32_t)get_env(envRamFrequency)); } @@ -255,7 +257,9 @@ mch_ratio = (mc_dimm_clk_ratio & 0x1F); // Compute RAM Frequency - Platform->RAM.Frequency = Platform->CPU.FSBFrequency * mch_ratio / 2; + safe_set_env(envRamFrequency, ((get_env(envFSBFreq) * mch_ratio) / 2)); + + DBG("ram_fsb %d\n", (uint32_t)get_env(envRamFrequency)); } /* @@ -300,24 +304,24 @@ Misc_Register = *ptr & 0xFFFFFFFF; // 965 Series only support DDR2 - Platform->RAM.Type = SMB_MEM_TYPE_DDR2; + safe_set_env(envRamType,SMB_MEM_TYPE_DDR2); // CAS Latency (tCAS) - Platform->RAM.CAS = ((ODT_Control_Register >> 17) & 7) + 3; - + safe_set_env(envRamCas,((ODT_Control_Register >> 17) & 7) + 3); + // RAS-To-CAS (tRCD) - Platform->RAM.TRC = (Read_Register >> 16) & 0xF; - + safe_set_env(envRamTrc,(Read_Register >> 16) & 0xF); + // RAS Precharge (tRP) - Platform->RAM.TRP = (ACT_Register >> 13) & 0xF; - + safe_set_env(envRamTrp,(ACT_Register >> 13) & 0xF); + // RAS Active to precharge (tRAS) - Platform->RAM.RAS = (Precharge_Register >> 11) & 0x1F; + safe_set_env(envRamRas,(Precharge_Register >> 11) & 0x1F); if ((c0ckectrl >> 20 & 0xF) && (c1ckectrl >> 20 & 0xF)) - Platform->RAM.Channels = SMB_MEM_CHANNEL_DUAL; + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_DUAL); else - Platform->RAM.Channels = SMB_MEM_CHANNEL_SINGLE; + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_SINGLE); } // Get im965 Memory Timings @@ -347,24 +351,24 @@ Precharge_Register = *ptr & 0xFFFFFFFF; // Series only support DDR2 - Platform->RAM.Type = SMB_MEM_TYPE_DDR2; - + safe_set_env(envRamType,SMB_MEM_TYPE_DDR2); + // CAS Latency (tCAS) - Platform->RAM.CAS = ((ODT_Control_Register >> 23) & 7) + 3; - + safe_set_env(envRamCas,((ODT_Control_Register >> 23) & 7) + 3); + // RAS-To-CAS (tRCD) - Platform->RAM.TRC = ((Precharge_Register >> 5) & 7) + 2; - + safe_set_env(envRamTrc,((Precharge_Register >> 5) & 7) + 2); + // RAS Precharge (tRP) - Platform->RAM.TRP= (Precharge_Register & 7) + 2; - + safe_set_env(envRamTrp,(Precharge_Register & 7) + 2); + // RAS Active to precharge (tRAS) - Platform->RAM.RAS = (Precharge_Register >> 21) & 0x1F; - + safe_set_env(envRamRas,(Precharge_Register >> 21) & 0x1F); + if ((c0ckectrl >> 20 & 0xF) && (c1ckectrl >> 20 & 0xF)) - Platform->RAM.Channels = SMB_MEM_CHANNEL_DUAL; + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_DUAL); else - Platform->RAM.Channels = SMB_MEM_CHANNEL_SINGLE; + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_SINGLE); } // Get P35 Memory Timings @@ -423,30 +427,30 @@ // Determine DDR-II or DDR-III if (Memory_Check & 1) - Platform->RAM.Type = SMB_MEM_TYPE_DDR2; + safe_set_env(envRamType,SMB_MEM_TYPE_DDR2); else - Platform->RAM.Type = SMB_MEM_TYPE_DDR3; + safe_set_env(envRamType,SMB_MEM_TYPE_DDR3); // CAS Latency (tCAS) if(dram_dev->device_id > 0x2E00) - Platform->RAM.CAS = ((ODT_Control_Register >> 8) & 0x3F) - 6; + safe_set_env(envRamCas,((ODT_Control_Register >> 8) & 0x3F) - 6); else - Platform->RAM.CAS = ((ODT_Control_Register >> 8) & 0x3F) - 9; + safe_set_env(envRamCas,((ODT_Control_Register >> 8) & 0x3F) - 9); // RAS-To-CAS (tRCD) - Platform->RAM.TRC = (Read_Register >> 17) & 0xF; - + safe_set_env(envRamTrc,(Read_Register >> 17) & 0xF); + // RAS Precharge (tRP) - Platform->RAM.TRP = (ACT_Register >> 13) & 0xF; + safe_set_env(envRamTrp,(ACT_Register >> 13) & 0xF); // RAS Active to precharge (tRAS) - Platform->RAM.RAS = Precharge_Register & 0x3F; - + safe_set_env(envRamRas,(Precharge_Register & 0x3F)); + // Channel configuration if (((c0ckectrl >> 20) & 0xF) && ((c1ckectrl >> 20) & 0xF)) - Platform->RAM.Channels = SMB_MEM_CHANNEL_DUAL; - else - Platform->RAM.Channels = SMB_MEM_CHANNEL_SINGLE; + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_DUAL); + else + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_SINGLE); } // Get Nehalem Memory Timings @@ -460,8 +464,8 @@ mc_control = (mc_control >> 8) & 0x7; // DDR-III - Platform->RAM.Type = SMB_MEM_TYPE_DDR3; - + safe_set_env(envRamType,SMB_MEM_TYPE_DDR3); + // Get the first valid channel if(mc_control & 1) fvc_bn = 4; @@ -475,24 +479,24 @@ mc_channel_mrs_value = pci_config_read32(PCIADDR(nhm_bus, fvc_bn, 0), 0x70); // CAS Latency (tCAS) - Platform->RAM.CAS = ((mc_channel_mrs_value >> 4) & 0xF ) + 4; - + safe_set_env(envRamCas,((mc_channel_mrs_value >> 4) & 0xF ) + 4); + // RAS-To-CAS (tRCD) - Platform->RAM.TRC = (mc_channel_bank_timing >> 9) & 0xF; - + safe_set_env(envRamTrc,(mc_channel_bank_timing >> 9) & 0xF); + // RAS Active to precharge (tRAS) - Platform->RAM.RAS = (mc_channel_bank_timing >> 4) & 0x1F; - + safe_set_env(envRamRas,(mc_channel_bank_timing >> 4) & 0x1F); + // RAS Precharge (tRP) - Platform->RAM.TRP = mc_channel_bank_timing & 0xF; - + safe_set_env(envRamTrp,mc_channel_bank_timing & 0xF); + // Single , Dual or Triple Channels if (mc_control == 1 || mc_control == 2 || mc_control == 4 ) - Platform->RAM.Channels = SMB_MEM_CHANNEL_SINGLE; + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_SINGLE); else if (mc_control == 7) - Platform->RAM.Channels = SMB_MEM_CHANNEL_TRIPLE; + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_TRIPLE); else - Platform->RAM.Channels = SMB_MEM_CHANNEL_DUAL; + safe_set_env(envRamChannels, SMB_MEM_CHANNEL_DUAL); } static struct mem_controller_t dram_controllers[] = { @@ -562,11 +566,11 @@ dram_controllers[i].poll_speed(dram_dev); verbose("Frequency detected: %d MHz (%d) %s Channel \n\tCAS:%d tRC:%d tRP:%d RAS:%d (%d-%d-%d-%d)\n", - (uint32_t)Platform->RAM.Frequency / 1000000, - (uint32_t)Platform->RAM.Frequency / 500000, - memory_channel_types[Platform->RAM.Channels] - ,Platform->RAM.CAS, Platform->RAM.TRC, Platform->RAM.TRP, Platform->RAM.RAS - ,Platform->RAM.CAS, Platform->RAM.TRC, Platform->RAM.TRP, Platform->RAM.RAS + (uint32_t)get_env(envRamFrequency) / 1000000, + (uint32_t)get_env(envFSBFreq) / 500000, + memory_channel_types[get_env(envRamChannels)] + ,(uint32_t)get_env(envRamCas),(uint32_t) get_env(envRamTrc), (uint32_t)get_env(envRamTrp),(uint32_t) get_env(envRamRas) + ,(uint32_t)get_env(envRamCas),(uint32_t) get_env(envRamTrc),(uint32_t) get_env(envRamTrp), (uint32_t)get_env(envRamRas) ); #if DEBUG_DRAM getc(); Index: branches/cparm/i386/modules/Memory/Makefile =================================================================== --- branches/cparm/i386/modules/Memory/Makefile (revision 1839) +++ branches/cparm/i386/modules/Memory/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -MEMORY_OBJS = dram_controllers.o mem.o spd.o Memory.o +MEMORY_OBJS = dram_controllers.o mem.o spd.o Memory.o stack_protector.o SFILES = @@ -70,7 +70,8 @@ -no_uuid \ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ - $(OBJROOT)/dram_controllers.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/dram_controllers.o \ $(OBJROOT)/mem.o \ $(OBJROOT)/spd.o \ $(OBJROOT)/Memory.o \ @@ -78,6 +79,10 @@ -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + dram_controllers.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "dram_controllers.c" $(INC) -o "$(OBJROOT)/dram_controllers.o" Index: branches/cparm/i386/modules/ACPICodec/acpi_codec.h =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpi_codec.h (revision 1839) +++ branches/cparm/i386/modules/ACPICodec/acpi_codec.h (revision 1840) @@ -56,7 +56,7 @@ #define kOEMFACS "oemFACS" /* acpi_codec.c */ #endif -extern EFI_STATUS setupAcpi(); +extern EFI_STATUS setupAcpi(void); struct p_state { Index: branches/cparm/i386/modules/ACPICodec/acpi_codec.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 1839) +++ branches/cparm/i386/modules/ACPICodec/acpi_codec.c (revision 1840) @@ -36,7 +36,6 @@ */ #include "libsaio.h" -#include "boot.h" #include "bootstruct.h" #include "acpi.h" #include "acpidecode.h" @@ -81,11 +80,6 @@ #define pstate_power_support 1 #endif -extern EFI_STATUS addConfigurationTable(); - -extern EFI_GUID gEfiAcpiTableGuid; -extern EFI_GUID gEfiAcpi20TableGuid; - #if DEBUG_ACPI static void print_nameseg(U32 i); #endif @@ -157,6 +151,7 @@ static bool is_sandybridge(void); static bool is_jaketown(void); static U32 get_bclk(void); +static void GetMaxRatio(U32 * max_non_turbo_ratio); //static U32 computePstateRatio(const U32 max, const U32 min, const U32 turboEnabled, const U32 numStates, const U32 pstate); //static U32 computeNumPstates(const U32 max, const U32 min, const U32 turboEnabled, const U32 pssLimit); @@ -180,7 +175,7 @@ //#define ULONG_MAX_32 4294967295UL #define __RES(s, u) \ -static inline unsigned u \ +inline unsigned u \ resolve_##s(unsigned u defaultentry, char *str, int base) \ { \ unsigned u entry = defaultentry; \ @@ -275,7 +270,7 @@ { if (new_table_list[index] != 0ul) { - + U32 current_sig = *(U32 *) (table_array[index]->Signature); if ((current_sig != NAMESEG(ACPI_SIG_FACS) /* not supported */ ) && (current_sig != NAMESEG(ACPI_SIG_XSDT)) @@ -333,7 +328,7 @@ { U32 index; U32 num_tables; - + DBG("Attempting to generate RSDT from XSDT \n"); num_tables= get_num_tables64(xsdt); @@ -373,7 +368,7 @@ printf("\n"); #endif bool unsafe = false; - getBoolForKey(kUnsafeACPI, &unsafe, &bootInfo->bootConfig); + getBoolForKey(kUnsafeACPI, &unsafe, DEFAULT_BOOT_CONFIG); if (!unsafe) { @@ -388,9 +383,9 @@ } } - + { - if ((*(U32 *) ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Signature == NAMESEG(ACPI_SIG_FADT))) + if (*(U32 *) ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Signature == NAMESEG(ACPI_SIG_FADT)) { ACPI_TABLE_FADT *fadt=(ACPI_TABLE_FADT *)((U32)ptr); @@ -426,7 +421,7 @@ continue; } } - + { rsdt_conv->TableOffsetEntry[index] = (U32)ptr; #if DEBUG_ACPI @@ -434,7 +429,7 @@ printf(" table converted and added succesfully\n"); #endif } - + } DBG("RSDT_CONV : Original checksum %d\n", rsdt_conv->Header.Checksum); SetChecksum(&rsdt_conv->Header); @@ -447,7 +442,7 @@ { U32 index; U32 num_tables; - + DBG("Attempting to generate XSDT from RSDT \n"); num_tables= get_num_tables(rsdt); @@ -472,45 +467,45 @@ for (index=0;indexSignature)); - printf("\n"); + printf("* Processing : "); + print_nameseg(*(U32*) (table_array[index]->Signature)); + printf("\n"); #endif - bool unsafe = false; - getBoolForKey(kUnsafeACPI, &unsafe, &bootInfo->bootConfig); - - if (!unsafe) - { - if (GetChecksum(table_array[index], table_array[index]->Length) != 0) - { + bool unsafe = false; + getBoolForKey(kUnsafeACPI, &unsafe, DEFAULT_BOOT_CONFIG); + + if (!unsafe) + { + if (GetChecksum(table_array[index], table_array[index]->Length) != 0) + { #if DEBUG_ACPI - printf("Warning : Invalide checksum, ignored !!!\n",index); + printf("Warning : Invalide checksum, ignored !!!\n",index); #endif - continue; - } - } - - } - - { - if ((*(U32 *) (table_array[index]->Signature) == NAMESEG(ACPI_SIG_FADT))) - { - ACPI_TABLE_FADT *FacpPointer = ((ACPI_TABLE_FADT*)table_array[index]); - ACPI_TABLE_FADT *fadt_mod = (ACPI_TABLE_FADT *)patch_fadt(FacpPointer,((ACPI_TABLE_DSDT*)FacpPointer->Dsdt),true); - if (fadt_mod == (void*)0ul) - { - printf("Error: Failed to patch (& update) FADT Table, fallback to original fadt pointer\n"); - fadt_mod = FacpPointer; - } - xsdt_conv->TableOffsetEntry[index] = ((U64)((U32)fadt_mod)); - - continue; - } - } - - xsdt_conv->TableOffsetEntry[index] = ((U64)((U32)table_array[index])); + continue; + } + } + + } + + { + if (*(U32 *) (table_array[index]->Signature) == NAMESEG(ACPI_SIG_FADT)) + { + ACPI_TABLE_FADT *FacpPointer = ((ACPI_TABLE_FADT*)table_array[index]); + ACPI_TABLE_FADT *fadt_mod = (ACPI_TABLE_FADT *)patch_fadt(FacpPointer,((ACPI_TABLE_DSDT*)FacpPointer->Dsdt),true); + if (fadt_mod == (void*)0ul) + { + printf("Error: Failed to patch (& update) FADT Table, fallback to original fadt pointer\n"); + fadt_mod = FacpPointer; + } + xsdt_conv->TableOffsetEntry[index] = ((U64)((U32)fadt_mod)); + + continue; + } + } + + xsdt_conv->TableOffsetEntry[index] = ((U64)((U32)table_array[index])); } DBG("XSDT_CONV : Original checksum %d\n", xsdt_conv->Header.Checksum); SetChecksum(&xsdt_conv->Header); @@ -521,24 +516,24 @@ static void MakeAcpiSgn(void) { - + char * DefaultplatformName = NULL; Model32 = 0; - if (DefaultplatformName = readDefaultPlatformName()) + if ((DefaultplatformName = readDefaultPlatformName())) { Model32 = OSSwapHostToBigInt32(adler32( (unsigned char *) DefaultplatformName, strlen(DefaultplatformName))); } - uuid32 = 0; - - const char *uuidStr = getStringFromUUID(Platform->sysid); + uuid32 = 0; + const char *uuidStr = getStringFromUUID((int8_t*)(uint32_t)get_env(envSysId)); + if (strlen(uuidStr)) { uuid32 = OSSwapHostToBigInt32(adler32( (unsigned char *) uuidStr, UUID_STR_LEN )); } - + } static void *loadACPITable(U32 *new_table_list, char *dirspec, char *filename ) @@ -548,7 +543,7 @@ DBG("Searching for %s file ...\n", filename); // Check booting partition - + sprintf(acpi_file, "%s%s",dirspec, filename); HFSLoadVerbose = 0; @@ -561,7 +556,7 @@ } void *tableAddr=(void*)malloc(file_size (fd)); - + if (tableAddr) { if (read (fd, tableAddr, file_size (fd))!=file_size (fd)) @@ -599,7 +594,7 @@ return (void*)0ul; } } - + if (checkOem == true) { @@ -620,12 +615,12 @@ return (void*)0ul; } -continue_loading: + continue_loading: if (GetChecksum(header, header->Length) == 0) { DBG("Found valid AML file : %s ", filename); - printf("[ %s ] read and stored at: %x", acpi_file, tableAddr); + verbose("[ %s ] read and stored at: %x", acpi_file, tableAddr); printf("\n"); return tableAddr; } @@ -671,7 +666,7 @@ U8 *current, *end; ACPI_TABLE_HEADER *header; struct acpi_namespace ns; - + if ((cpu_map_error == 1) || (DsdtPointer == (void*)0ul)) return 1; else if (cpu_map_count > 0) @@ -765,12 +760,12 @@ static bool is_sandybridge(void) { - return getCPUModel() == CPUID_MODEL_SANDYBRIDGE; + return get_env(envModel) == CPUID_MODEL_SANDYBRIDGE; } static bool is_jaketown(void) { - return getCPUModel() == CPUID_MODEL_JAKETOWN; + return get_env(envModel) == CPUID_MODEL_JAKETOWN; } static U32 get_bclk(void) @@ -778,27 +773,27 @@ return (is_jaketown() || is_sandybridge()) ? 100 : 133; } /* -//----------------------------------------------------------------------------- -static U32 computePstateRatio(const U32 max, const U32 min, const U32 turboEnabled, const U32 numStates, const U32 pstate) -{ - U32 ratiorange = max-min; - U32 numGaps = numStates-1-turboEnabled; - U32 adjPstate = pstate-turboEnabled; - return (pstate == 0) ? (max + turboEnabled) : - (ratiorange == 0) ? max : - max-(((adjPstate*ratiorange)+(numGaps/2))/numGaps); -} -//----------------------------------------------------------------------------- -static U32 computeNumPstates(const U32 max, const U32 min, const U32 turboEnabled, const U32 pssLimit) -{ - U32 ratiorange, maxStates, numStates; - - ratiorange = max - min + 1; - maxStates = ratiorange + (turboEnabled ? 1 : 0); - numStates = (pssLimit < maxStates) ? pssLimit : maxStates; - return (numStates < 2) ? 0 : numStates; -} -*/ + //----------------------------------------------------------------------------- + static U32 computePstateRatio(const U32 max, const U32 min, const U32 turboEnabled, const U32 numStates, const U32 pstate) + { + U32 ratiorange = max-min; + U32 numGaps = numStates-1-turboEnabled; + U32 adjPstate = pstate-turboEnabled; + return (pstate == 0) ? (max + turboEnabled) : + (ratiorange == 0) ? max : + max-(((adjPstate*ratiorange)+(numGaps/2))/numGaps); + } + //----------------------------------------------------------------------------- + static U32 computeNumPstates(const U32 max, const U32 min, const U32 turboEnabled, const U32 pssLimit) + { + U32 ratiorange, maxStates, numStates; + + ratiorange = max - min + 1; + maxStates = ratiorange + (turboEnabled ? 1 : 0); + numStates = (pssLimit < maxStates) ? pssLimit : maxStates; + return (numStates < 2) ? 0 : numStates; + } + */ #if BUILD_ACPI_TSS || pstate_power_support static U64 divU64byU64(U64 n, U64 d, U64 * rem) { @@ -917,31 +912,32 @@ } //----------------------------------------------------------------------------- -void GetMaxRatio(U32 * max_non_turbo_ratio) +static void GetMaxRatio(U32 * max_non_turbo_ratio) { U32 index; U32 max_ratio=0; U32 frequency=0; U32 multiplier = 0; + char *BrandString; // Verify CPUID brand string function is supported - if (Platform->CPU.cpuid_max_ext < 80000004) + if (get_env(envCPUIDMaxExt) < 80000004) { *max_non_turbo_ratio = max_ratio; return; } - + BrandString = (char *)(U32)get_env_ptr(envBrandString); // -2 to prevent buffer overrun because looking for y in yHz, so z is +2 from y for (index=0; index<48-2; index++) { // format is either “x.xxyHz” or “xxxxyHz”, where y=M,G,T and x is digits // Search brand string for “yHz” where y is M, G, or T // Set multiplier so frequency is in MHz - if ( Platform->CPU.BrandString[index+1] == 'H' && Platform->CPU.BrandString[index+2] == 'z') + if ( BrandString[index+1] == 'H' && BrandString[index+2] == 'z') { - if (Platform->CPU.BrandString[index] == 'M') + if (BrandString[index] == 'M') multiplier = 1; - else if (Platform->CPU.BrandString[index] == 'G') + else if (BrandString[index] == 'G') multiplier = 1000; - else if (Platform->CPU.BrandString[index] == 'T') + else if (BrandString[index] == 'T') multiplier = 1000000; } if (multiplier > 0 && index >= 4 /* who can i call that, buffer underflow :-) ??*/) @@ -950,25 +946,25 @@ // index is at position of y in “x.xxyHz” // Compute frequency (in MHz) from brand string - if (Platform->CPU.BrandString[index-3] == '.') + if (BrandString[index-3] == '.') { // If format is “x.xx” - if (isdigit(Platform->CPU.BrandString[index-4]) && isdigit(Platform->CPU.BrandString[index-2]) && - isdigit(Platform->CPU.BrandString[index-1])) + if (isdigit(BrandString[index-4]) && isdigit(BrandString[index-2]) && + isdigit(BrandString[index-1])) { - frequency = (U32)(Platform->CPU.BrandString[index-4] - '0') * multiplier; - frequency += (U32)(Platform->CPU.BrandString[index-2] - '0') * (multiplier / 10); - frequency += (U32)(Platform->CPU.BrandString[index-1] - '0') * (multiplier / 100); + frequency = (U32)(BrandString[index-4] - '0') * multiplier; + frequency += (U32)(BrandString[index-2] - '0') * (multiplier / 10); + frequency += (U32)(BrandString[index-1] - '0') * (multiplier / 100); } } else { // If format is xxxx - if (isdigit(Platform->CPU.BrandString[index-4]) && isdigit(Platform->CPU.BrandString[index-3]) && - isdigit(Platform->CPU.BrandString[index-2]) && isdigit(Platform->CPU.BrandString[index-1])) + if (isdigit(BrandString[index-4]) && isdigit(BrandString[index-3]) && + isdigit(BrandString[index-2]) && isdigit(BrandString[index-1])) { - frequency = (U32)(Platform->CPU.BrandString[index-4] - '0') * 1000; - frequency += (U32)(Platform->CPU.BrandString[index-3] - '0') * 100; - frequency += (U32)(Platform->CPU.BrandString[index-2] - '0') * 10; - frequency += (U32)(Platform->CPU.BrandString[index-1] - '0'); + frequency = (U32)(BrandString[index-4] - '0') * 1000; + frequency += (U32)(BrandString[index-3] - '0') * 100; + frequency += (U32)(BrandString[index-2] - '0') * 10; + frequency += (U32)(BrandString[index-1] - '0'); frequency *= multiplier; } @@ -987,20 +983,20 @@ //----------------------------------------------------------------------------- static void collect_cpu_info(CPU_DETAILS * cpu) { - + #if BUILD_ACPI_TSS || pstate_power_support - cpu->turbo_available = Platform->CPU.dynamic_acceleration; + cpu->turbo_available = (U32)get_env(envDynamicAcceleration); { U32 temp32 = 0; U64 temp64= 0; int tdp; - if (getIntForKey("TDP", &tdp, &bootInfo->bootConfig)) + if (getIntForKey("TDP", &tdp, DEFAULT_BOOT_CONFIG)) { temp32 = (U32) (tdp*8) ; int tdc; - if (getIntForKey("TDC", &tdc, &bootInfo->bootConfig)) + if (getIntForKey("TDC", &tdc, DEFAULT_BOOT_CONFIG)) { temp32 = (U32) (temp32) | tdc<<16 ; @@ -1036,11 +1032,11 @@ #endif - switch (getCPUFamily()) + switch (get_env(envFamily)) { case 0x06: { - switch (getCPUModel()) + switch (get_env(envModel)) { case CPUID_MODEL_DOTHAN: case CPUID_MODEL_YONAH: // Yonah @@ -1049,25 +1045,25 @@ case CPUID_MODEL_ATOM: // Intel Atom (45nm) { - cpu->core_c1_supported = ((Platform->CPU.sub_Cstates >> 4) & 0xf) ? 1 : 0; - cpu->core_c4_supported = ((Platform->CPU.sub_Cstates >> 16) & 0xf) ? 1 : 0; + cpu->core_c1_supported = ((get_env(envSubCstates) >> 4) & 0xf) ? 1 : 0; + cpu->core_c4_supported = ((get_env(envSubCstates) >> 16) & 0xf) ? 1 : 0; - if (getCPUModel() == CPUID_MODEL_ATOM) + if (get_env(envModel) == CPUID_MODEL_ATOM) { - cpu->core_c2_supported = cpu->core_c3_supported = ((Platform->CPU.sub_Cstates >> 8) & 0xf) ? 1 : 0; - cpu->core_c6_supported = ((Platform->CPU.sub_Cstates >> 12) & 0xf) ? 1 : 0; - + cpu->core_c2_supported = cpu->core_c3_supported = ((get_env(envSubCstates) >> 8) & 0xf) ? 1 : 0; + cpu->core_c6_supported = ((get_env(envSubCstates) >> 12) & 0xf) ? 1 : 0; + } else { - cpu->core_c3_supported = ((Platform->CPU.sub_Cstates >> 12) & 0xf) ? 1 : 0; - cpu->core_c2_supported = ((Platform->CPU.sub_Cstates >> 8) & 0xf) ? 1 : 0; + cpu->core_c3_supported = ((get_env(envSubCstates) >> 12) & 0xf) ? 1 : 0; + cpu->core_c2_supported = ((get_env(envSubCstates) >> 8) & 0xf) ? 1 : 0; cpu->core_c6_supported = 0; - + } - + cpu->core_c7_supported = 0; - + #if BETA GetMaxRatio(&cpu->max_ratio_as_mfg); U64 msr = rdmsr64(MSR_IA32_PERF_STATUS); @@ -1077,15 +1073,15 @@ cpu->max_ratio_as_cfg = (U32) (idhi >> 8) & 0xff; #else - if (Platform->CPU.MaxCoef) + if (get_env(envMaxCoef)) { - if (Platform->CPU.MaxDiv) + if (get_env(envMaxDiv)) { - cpu->max_ratio_as_cfg = cpu->max_ratio_as_mfg = (U32) (Platform->CPU.MaxCoef * 10) + 5; + cpu->max_ratio_as_cfg = cpu->max_ratio_as_mfg = (U32) (get_env(envMaxCoef) * 10) + 5; } else { - cpu->max_ratio_as_cfg = cpu->max_ratio_as_mfg = (U32) Platform->CPU.MaxCoef * 10; + cpu->max_ratio_as_cfg = cpu->max_ratio_as_mfg = (U32) get_env(envMaxCoef) * 10; } } #endif @@ -1103,10 +1099,10 @@ case CPUID_MODEL_JAKETOWN: { - cpu->core_c1_supported = ((Platform->CPU.sub_Cstates >> 4) & 0xf) ? 1 : 0; - cpu->core_c3_supported = ((Platform->CPU.sub_Cstates >> 8) & 0xf) ? 1 : 0; - cpu->core_c6_supported = ((Platform->CPU.sub_Cstates >> 12) & 0xf) ? 1 : 0; - cpu->core_c7_supported = ((Platform->CPU.sub_Cstates >> 16) & 0xf) ? 1 : 0; + cpu->core_c1_supported = ((get_env(envSubCstates) >> 4) & 0xf) ? 1 : 0; + cpu->core_c3_supported = ((get_env(envSubCstates) >> 8) & 0xf) ? 1 : 0; + cpu->core_c6_supported = ((get_env(envSubCstates) >> 12) & 0xf) ? 1 : 0; + cpu->core_c7_supported = ((get_env(envSubCstates) >> 16) & 0xf) ? 1 : 0; cpu->core_c2_supported = 0; cpu->core_c4_supported = 0; @@ -1131,11 +1127,11 @@ default: break; } - - cpu->mwait_supported = (Platform->CPU.extensions & (1UL << 0)) ? 1 : 0; - cpu->invariant_apic_timer_flag = Platform->CPU.invariant_APIC_timer; - + cpu->mwait_supported = (get_env(envExtensions) & (1UL << 0)) ? 1 : 0; + + cpu->invariant_apic_timer_flag = (U32)get_env(envInvariantAPICTimer); + #if DEBUG_ACPI printf("CPU INFO : \n"); #if BETA @@ -1152,20 +1148,20 @@ printf("core_c6_supported : %d\n",cpu->core_c6_supported); printf("core_c7_supported : %d\n",cpu->core_c7_supported); printf("mwait_supported : %d\n",cpu->mwait_supported); - + #if BUILD_ACPI_TSS || pstate_power_support if (is_sandybridge() || is_jaketown()) { - + printf("package_power_limit : %d\n",cpu->package_power_limit); printf("package_power_sku_unit : %d\n",cpu->package_power_sku_unit); - + } #endif DBG("invariant_apic_timer_flag : %d\n",cpu->invariant_apic_timer_flag); - + #endif } @@ -1219,64 +1215,64 @@ } #else /* + //----------------------------------------------------------------------------- + static U32 BuildCoreIPstateInfo(CPU_DETAILS * cpu) + { + // Build P-state table info based on verified options + + // Compute the number of p-states based on the ratio range + cpu->pkg_pstates.num_pstates = computeNumPstates(cpu->max_ratio_as_cfg, cpu->min_ratio, cpu->turbo_available, MAX_PSTATES); + + if (!cpu->pkg_pstates.num_pstates) + { + return (0); + } + + // Compute pstate data + { + #ifdef pstate_power_support + U32 TDP = compute_tdp(cpu); + #endif + + U32 index; + for (index=0; index < cpu->pkg_pstates.num_pstates; index ++) + { + PSTATE * pstate = &cpu->pkg_pstates.pstate[index]; + + // Set ratio + pstate->ratio = computePstateRatio(cpu->max_ratio_as_cfg, cpu->min_ratio, cpu->turbo_available, cpu->pkg_pstates.num_pstates, index); + + // Compute frequency based on ratio + if ((index != 0) || (cpu->turbo_available == 0)) + pstate->frequency = pstate->ratio * get_bclk(); + else + pstate->frequency = ((pstate->ratio - 1) * get_bclk()) + 1; + + #ifdef pstate_power_support + // Compute power based on ratio and other data + if (pstate->ratio >= cpu->max_ratio_as_mfg) + // Use max power in mW + pstate->power = TDP * 1000; + else + { + pstate->power = compute_pstate_power(cpu, pstate->ratio, TDP); + + // Convert to mW + pstate->power*= 1000; + } + #else + pstate->power = 0; + #endif + } + } + + return (1); + } + */ //----------------------------------------------------------------------------- -static U32 BuildCoreIPstateInfo(CPU_DETAILS * cpu) -{ - // Build P-state table info based on verified options - - // Compute the number of p-states based on the ratio range - cpu->pkg_pstates.num_pstates = computeNumPstates(cpu->max_ratio_as_cfg, cpu->min_ratio, cpu->turbo_available, MAX_PSTATES); - - if (!cpu->pkg_pstates.num_pstates) - { - return (0); - } - - // Compute pstate data - { -#ifdef pstate_power_support - U32 TDP = compute_tdp(cpu); -#endif - - U32 index; - for (index=0; index < cpu->pkg_pstates.num_pstates; index ++) - { - PSTATE * pstate = &cpu->pkg_pstates.pstate[index]; - - // Set ratio - pstate->ratio = computePstateRatio(cpu->max_ratio_as_cfg, cpu->min_ratio, cpu->turbo_available, cpu->pkg_pstates.num_pstates, index); - - // Compute frequency based on ratio - if ((index != 0) || (cpu->turbo_available == 0)) - pstate->frequency = pstate->ratio * get_bclk(); - else - pstate->frequency = ((pstate->ratio - 1) * get_bclk()) + 1; - -#ifdef pstate_power_support - // Compute power based on ratio and other data - if (pstate->ratio >= cpu->max_ratio_as_mfg) - // Use max power in mW - pstate->power = TDP * 1000; - else - { - pstate->power = compute_pstate_power(cpu, pstate->ratio, TDP); - - // Convert to mW - pstate->power*= 1000; - } -#else - pstate->power = 0; -#endif - } - } - - return (1); -} -*/ -//----------------------------------------------------------------------------- static U32 BuildPstateInfo(CPU_DETAILS * cpu) { - + struct p_state p_states[32]; U8 p_states_count = 0; { @@ -1285,11 +1281,11 @@ #endif struct p_state maximum, minimum; // Retrieving P-States, ported from code by superhai (c) - switch (Platform->CPU.Family) + switch (get_env(envFamily)) { case 0x06: { - switch (Platform->CPU.Model) + switch (get_env(envModel)) { case CPUID_MODEL_DOTHAN: case CPUID_MODEL_YONAH: // Yonah @@ -1334,7 +1330,7 @@ wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (maximum.FID << 8) | maximum.VID); intel_waitforsts(); } - + if (minimum.VID == maximum.VID) { U64 msr; @@ -1353,7 +1349,7 @@ wrmsr64(MSR_IA32_PERF_CONTROL, (msr & 0xFFFFFFFFFFFF0000ULL) | (maximum.FID << 8) | maximum.VID); intel_waitforsts(); } - + minimum.CID = ((minimum.FID & 0x1F) << 1) >> cpu_dynamic_fsb; // Sanity check @@ -1376,6 +1372,8 @@ vidstep = ((maximum.VID << 2) - (minimum.VID << 2)) / (p_states_count - 1); + U32 fsb = (U32)get_env(envFSBFreq) / 1000000; + for (u = 0; u < p_states_count; u++) { i = u - invalid; @@ -1401,7 +1399,7 @@ U32 multiplier = p_states[i].FID & 0x1f; // = 0x08 bool half = p_states[i].FID & 0x40; // = 0x01 bool dfsb = p_states[i].FID & 0x80; // = 0x00 - U32 fsb = Platform->CPU.FSBFrequency / 1000000; // = 400 + //U32 fsb = (U32)get_env(envFSBFreq) / 1000000; // = 400 U32 halffsb = (fsb + 1) >> 1; // = 200 U32 frequency = (multiplier * fsb); // = 3200 @@ -1438,12 +1436,12 @@ { U8 i; p_states_count = 0; - + U32 fsb = (U32)(get_env(envFSBFreq) / 1000000) ; for (i = maximum.Control; i >= minimum.Control; i--) { p_states[p_states_count].Control = i; p_states[p_states_count].CID = p_states[p_states_count].Control << 1; - p_states[p_states_count].Frequency = (Platform->CPU.FSBFrequency / 1000000) * i; + p_states[p_states_count].Frequency = (U32)fsb * i; p_states_count++; if (p_states_count >= MAX_PSTATES) { // was 32 @@ -1454,21 +1452,21 @@ } } } - + /* - U32 sta = BuildCoreIPstateInfo(cpu); - if (sta) - { - DBG("_PSS PGK generated successfully\n"); - return (1); - - } - else - { - verbose("CoreI _PSS Generation failed !!\n"); - return (0); - } - */ + U32 sta = BuildCoreIPstateInfo(cpu); + if (sta) + { + DBG("_PSS PGK generated successfully\n"); + return (1); + + } + else + { + verbose("CoreI _PSS Generation failed !!\n"); + return (0); + } + */ break; } default: @@ -1485,23 +1483,25 @@ // Generating Pstate PKG if (p_states_count) { - U8 minPSratio = (p_states[p_states_count-1].Frequency / (Platform->CPU.FSBFrequency / 10000000 )); - U8 maxPSratio = (p_states[0].Frequency / (Platform->CPU.FSBFrequency / 10000000 )); + U32 fsb = (U32)get_env(envFSBFreq); + U8 minPSratio = (p_states[p_states_count-1].Frequency / (fsb / 10000000 )); + U8 maxPSratio = (p_states[0].Frequency / (fsb / 10000000 )); U8 cpu_ratio = 0; { - U8 cpu_div = Platform->CPU.CurrDiv; - + U8 cpu_div = (U8)get_env(envCurrDiv); + U8 cpu_coef = (U8)get_env(envCurrCoef); + if (cpu_div) - cpu_ratio = (Platform->CPU.CurrCoef * 10) + 5; + cpu_ratio = (cpu_coef * 10) + 5; else - cpu_ratio = Platform->CPU.CurrCoef * 10; + cpu_ratio = cpu_coef * 10; } { int user_max_ratio = 0; - getIntForKey(kMaxRatio, &user_max_ratio, &bootInfo->bootConfig); + getIntForKey(kMaxRatio, &user_max_ratio, DEFAULT_BOOT_CONFIG); if (user_max_ratio >= minPSratio && maxPSratio >= user_max_ratio) { @@ -1520,7 +1520,7 @@ { int user_min_ratio = 0; - getIntForKey(kMinRatio, &user_min_ratio, &bootInfo->bootConfig); + getIntForKey(kMinRatio, &user_min_ratio, DEFAULT_BOOT_CONFIG); if (user_min_ratio >= minPSratio && cpu_ratio >= user_min_ratio) { @@ -1543,7 +1543,7 @@ if (maxPSratio >= cpu_ratio && cpu_ratio >= minPSratio) maxPSratio = cpu_ratio; { - TagPtr personality = XMLCastDict(XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"P-States")); + TagPtr personality = XMLCastDict(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"P-States")); // TODO: fix me int base = 16; U8 expert = 0; /* Default: 0 , mean mixed mode * expert mode : 1 , mean add only p-states found in boot.plist @@ -1582,7 +1582,8 @@ #ifdef pstate_power_support U32 TDP = compute_tdp(cpu); #endif - U32 i; + U32 i; + U32 fsb = (U32)get_env(envFSBFreq); for (i = 0; i < p_states_count; i++) { char *Lat1 = NULL, *clk = NULL, *Pw = NULL, *Lat2 = NULL, *Ctrl = NULL ; @@ -1605,7 +1606,7 @@ } else if (expert) continue; } - + unsigned long Frequency = 0x00000000; if (!expert || !personality) Frequency = p_states[i].Frequency; @@ -1615,11 +1616,11 @@ if (!Frequency || Frequency > p_states[0].Frequency ) continue; - U8 curr_ratio = (Frequency / (Platform->CPU.FSBFrequency / 10000000 )); + U8 curr_ratio = (Frequency / (fsb / 10000000 )); { - U8 fixed_ratio = (Frequency / (Platform->CPU.FSBFrequency / 1000000 ))*10; + U8 fixed_ratio = (Frequency / (fsb / 1000000 ))*10; U8 diff = curr_ratio - fixed_ratio ; if (diff) @@ -1638,7 +1639,7 @@ if (curr_ratio > maxPSratio || minPSratio > curr_ratio) goto dropPstate; - + { PSTATE * pstate = &cpu->pkg_pstates.pstate[Pstatus]; @@ -1673,13 +1674,13 @@ pstate->status = Pstatus+1; // Status DBG("state :: frequency :%d power: %d translatency: %d bmlatency: %d control: %d status: %d ratio :%d :: registred !! \n",pstate->frequency,pstate->power, - pstate->translatency,pstate->bmlatency,pstate->control,pstate->status,pstate->ratio ); + pstate->translatency,pstate->bmlatency,pstate->control,pstate->status,pstate->ratio ); } Pstatus++; continue; - + dropPstate: DBG("state with cpu frequency :%d and ratio :%d will be dropped\n",p_states[i].Frequency,curr_ratio); dropPSS++; @@ -1711,7 +1712,7 @@ static U32 BuildCstateInfo(CPU_DETAILS * cpu, U32 pmbase) { { - TagPtr personality = XMLCastDict(XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"C-States")); + TagPtr personality = XMLCastDict(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"C-States")); // TODO :fix me if (personality) { @@ -1804,7 +1805,7 @@ } } } - + { static const ACPI_GENERIC_ADDRESS mwait_gas[] = { {GAS_TYPE_FFH,1,2,1,0x00}, // processor C1 @@ -1885,14 +1886,14 @@ bool tmpval; - if (getBoolForKey(kEnableC2State, &tmpval, &bootInfo->bootConfig)) + if (getBoolForKey(kEnableC2State, &tmpval, DEFAULT_BOOT_CONFIG)) { c2_enabled = tmpval; } - - if (!getIntForKey("C3StateOption", &c3_enabled, &bootInfo->bootConfig)) + + if (!getIntForKey("C3StateOption", &c3_enabled, DEFAULT_BOOT_CONFIG)) { - c3_enabled = (getBoolForKey(kEnableC3State, &tmpval, &bootInfo->bootConfig)&&tmpval) ? 3 : 0; + c3_enabled = (getBoolForKey(kEnableC3State, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval) ? 3 : 0; } if (c3_enabled == 6) { @@ -1900,10 +1901,10 @@ } else { - c4_enabled = (getBoolForKey(kEnableC4State, &tmpval, &bootInfo->bootConfig)&&tmpval) ? 1 : 0; + c4_enabled = (getBoolForKey(kEnableC4State, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval) ? 1 : 0; } - c6_enabled = (getBoolForKey(kEnableC6State, &tmpval, &bootInfo->bootConfig)&&tmpval) ? 1 : 0; - c7_enabled = (getBoolForKey(kEnableC7State, &tmpval, &bootInfo->bootConfig)&&tmpval) ? 1 : 0; + c6_enabled = (getBoolForKey(kEnableC6State, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval) ? 1 : 0; + c7_enabled = (getBoolForKey(kEnableC7State, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval) ? 1 : 0; } cpu->pkg_mwait_cstates.num_cstates = 0; @@ -1914,7 +1915,7 @@ cpu->pkg_mwait_cstates.num_cstates++; } if (((cpu->core_c3_supported || cpu->core_c2_supported) && (c2_enabled)) && ((c3_enabled == 2) || - ((c3_enabled == 4) && cpu->invariant_apic_timer_flag))) + ((c3_enabled == 4) && cpu->invariant_apic_timer_flag))) { cpu->pkg_mwait_cstates.cstate[cpu->pkg_mwait_cstates.num_cstates] = mwait_cstate[cstate_2_index[CPU_C3_ACPI_C2]]; cpu->pkg_mwait_cstates.gas[cpu->pkg_mwait_cstates.num_cstates] = mwait_gas[cstate_2_index[CPU_C3_ACPI_C2]]; @@ -1963,7 +1964,7 @@ cpu->pkg_io_cstates.num_cstates++; } if ((cpu->core_c3_supported || cpu->core_c2_supported) && (c2_enabled || (c3_enabled == 2) || - ((c3_enabled == 4) && cpu->invariant_apic_timer_flag))) + ((c3_enabled == 4) && cpu->invariant_apic_timer_flag))) { cpu->pkg_io_cstates.cstate[cpu->pkg_io_cstates.num_cstates] = io_cstate[cstate_2_index[CPU_C3_ACPI_C2]]; cpu->pkg_io_cstates.gas[cpu->pkg_io_cstates.num_cstates] = io_gas[cstate_2_index[CPU_C3_ACPI_C2]]; @@ -2057,7 +2058,7 @@ for (num_cpu = 0; num_cpu < cpu_map_count; num_cpu ++) { // Check if fine or coarse grained clock modulation is available - if (Platform->CPU.fine_grain_clock_mod) + if (get_env(envFineGrainClockMod)) { // Fine grain thermal throttling is available num_tstates = 15; @@ -2079,8 +2080,8 @@ cpu->pkg_tstates.tstate[index].power = 1000 * (compute_tdp(cpu) * (num_tstates - index)) / num_tstates; } } - + } return (1); } @@ -2396,7 +2397,7 @@ { bool tmpval; - oem_apic=getBoolForKey(kOEMAPIC, &tmpval, &bootInfo->bootConfig)&&tmpval; + oem_apic=getBoolForKey(kOEMAPIC, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; } if (oem_apic == true) @@ -2424,7 +2425,7 @@ return(0); } } - + // Create buffer for MADT //U8 memory_for_madt[2 * 1024]; // seems to bug with xcode4, need to found out what is going on (not enough memory in the stack ?) U8 *memory_for_madt = (U8*)AllocateKernelMemory(2 * 1024); @@ -2463,13 +2464,15 @@ static U32 ProcessSsdt(U32 * new_table_list, ACPI_TABLE_DSDT *dsdt, MADT_INFO * madt_info, bool enable_cstates, bool enable_pstates, bool enable_tstates ) { DBG("Processing SSDT\n"); - - if (Platform->CPU.Vendor != 0x756E6547) { + + // Check we are on an intel platform + if (get_env(envVendor) != CPUID_VENDOR_INTEL) { verbose ("Not an Intel platform: SSDT will not be generated !!!\n"); return(0); } - if (!(Platform->CPU.Features & CPUID_FEATURE_MSR)) { + // Check for the msr feature flag + if (!(get_env(envFeatures) & CPUID_FEATURE_MSR)) { verbose ("Unsupported CPU: SSDT will not be generated !!!\n"); return(0); } @@ -2489,7 +2492,7 @@ printf(" please increase the RESERVED_AERA\n"); return(0); } - + // Create buffer for SSDT //U8 memory_for_ssdt[20 * 1024]; // seems to bug with xcode4, need to found out what is going on (not enough memory in the stack ?) U8 *memory_for_ssdt =(U8*)AllocateKernelMemory(20 * 1024); @@ -3597,7 +3600,7 @@ // (3.7) Update length in CPUn Scope // (4) Update length and checksum in SSDT Definition Block DBG("Attempting to build SSDT\n"); - + U32 pstates_enabled = 0; U32 cstates_enabled = 0; CPU_DETAILS cpu; @@ -3613,7 +3616,7 @@ // (1) Setup pointers to SSDT memory location void * current = buffer; void * end = (U8 *)buffer + bufferSize; - + // Confirm a valid SSDT buffer was provided if (!buffer) { @@ -3649,22 +3652,22 @@ if (enable_cstates && pmbase) { DBG("Building Cstate Info\n"); - + cstates_enabled = BuildCstateInfo(&cpu, pmbase); if (cstates_enabled) { - getBoolForKey(KEnableMwait, &enable_mwait, &bootInfo->bootConfig); + getBoolForKey(KEnableMwait, &enable_mwait, DEFAULT_BOOT_CONFIG); } } if (enable_pstates) { DBG("Building Pstate Info\n"); - + pstates_enabled = BuildPstateInfo(&cpu); if (pstates_enabled) { - const char *str = getStringForKey(KAcpiCoordType, &bootInfo->bootConfig); + const char *str = getStringForKey(KAcpiCoordType, DEFAULT_BOOT_CONFIG); U8 tmp = (U8)strtoul(str, NULL,16); if ((tmp == ACPI_COORD_TYPE_SW_ALL) || (tmp == ACPI_COORD_TYPE_SW_ANY) || (tmp == ACPI_COORD_TYPE_HW_ALL) ) { @@ -3733,7 +3736,7 @@ // Build MWOS variable used to store state of MWAIT OS setup option current = buildNamedDword(current, NAMESEG("MWOS"), (U32)(enable_mwait&&cpu.mwait_supported)); - + // (3.3) Create _OSC and/or _PDC Methods { // Build _PDC method @@ -3815,7 +3818,7 @@ return(0); } } - + // (3.5) Create C-state related structures if (cstates_enabled == 1) { @@ -3867,7 +3870,7 @@ // (3.6.4) Create _TSD Method { LAPIC_INFO * lapic = &madt_info.lapic[lapic_index]; - + // Use core_apic_id as domain U32 domain = lapic->core_apic_id; @@ -3886,7 +3889,7 @@ // (4) Update length and checksum in SSDT Definition Block { DBG("Updating length and checksum in SSDT Definition Block\n"); - + SsdtPointer->Header.Length = (U8 *)current - (U8 *)SsdtPointer; SetChecksum(&SsdtPointer->Header); } @@ -3921,7 +3924,7 @@ memcpy(facs_mod, FacsPointer , FacsPointer->Length); facs_mod->Length = sizeof(ACPI_TABLE_FACS); - + if (FacsPointer->Length < sizeof(ACPI_TABLE_FACS)) { facs_mod->FirmwareWakingVector = 0; @@ -3939,15 +3942,15 @@ { facs_mod->XFirmwareWakingVector = (U64)facs_mod->FirmwareWakingVector; } - + facs_mod->Version = 2; /* ACPI 1.0: 0, ACPI 2.0/3.0: 1, ACPI 4.0: 2 */ } - + return facs_mod; } #endif - + static ACPI_GENERIC_ADDRESS FillGASStruct(U32 Address, U8 Length) { ACPI_GENERIC_ADDRESS TmpGAS; @@ -3977,12 +3980,12 @@ bool fadt_rev2_needed = false; bool fix_restart = false; const char * value; - + // Restart Fix - if (platformIsIntel()) /* Intel */ + if (get_env(envVendor) == CPUID_VENDOR_INTEL) { fix_restart = true; - getBoolForKey(kRestartFix, &fix_restart, &bootInfo->bootConfig); + getBoolForKey(kRestartFix, &fix_restart, DEFAULT_BOOT_CONFIG); } else { verbose ("Not an Intel platform: Restart Fix disabled !!!\n"); @@ -3990,22 +3993,22 @@ if (fix_restart) fadt_rev2_needed = true; - + // Allocate new fadt table if (UpdateFADT) { - if (fadt->Header.Length < 0xF4) - { - fadt_mod=(ACPI_TABLE_FADT *)AllocateKernelMemory(0xF4); - if (!fadt_mod) - { - printf("Unable to allocate kernel memory for fadt mod\n"); - return (void*)0ul; - } - bzero(fadt_mod, 0xF4); - memcpy(fadt_mod, fadt, fadt->Header.Length); - fadt_mod->Header.Length = 0xF4; - + if (fadt->Header.Length < 0xF4) + { + fadt_mod=(ACPI_TABLE_FADT *)AllocateKernelMemory(0xF4); + if (!fadt_mod) + { + printf("Unable to allocate kernel memory for fadt mod\n"); + return (void*)0ul; + } + bzero(fadt_mod, 0xF4); + memcpy(fadt_mod, fadt, fadt->Header.Length); + fadt_mod->Header.Length = 0xF4; + } else { @@ -4017,8 +4020,8 @@ } memcpy(fadt_mod, fadt, fadt->Header.Length); } - + //fadt_mod->Header.Revision = 0x04; // FADT rev 4 fadt_mod->ResetRegister = FillGASStruct(0, 0); fadt_mod->ResetValue = 0; @@ -4038,7 +4041,7 @@ { fadt_mod->Header.Revision = 0x04; // FADT rev 4 verbose("Converted ACPI V%d FADT to ACPI V4 FADT\n", fadt->Header.Revision); - + } } else @@ -4091,7 +4094,7 @@ fadt_mod->Header.Revision = 0x01; verbose("Warning: ACPI FADT length was < 0x74 which is the minimum for the ACPI FADT V1 specification, \n", fadt->Header.Revision ); verbose(" trying to convert it to Version 1. \n"); - + } else { @@ -4110,53 +4113,54 @@ // Determine system type / PM_Model // Fix System-type if needed (should never happen) - if (Platform->Type > MaxSupportedPMProfile) + if (get_env(envType) > MaxSupportedPMProfile) { if(fadt_mod->PreferredProfile <= MaxSupportedPMProfile) - Platform->Type = fadt_mod->PreferredProfile; // get the fadt if correct + safe_set_env(envType,fadt_mod->PreferredProfile);// get the fadt if correct else - Platform->Type = 1; /* Set a fixed value (Desktop) */ + safe_set_env(envType,1); /* Set a fixed value (Desktop) */ } // If needed, set System-type from PM_Profile (if valid) else set PM_Profile with a fixed the System-type // Give prior to the FADT pm profile, allow to also control this value with a patched FADT table - if (fadt_mod->PreferredProfile != Platform->Type) + if (fadt_mod->PreferredProfile != get_env(envType)) { bool val = false; - getBoolForKey("PreferInternalProfileDetect", &val, &bootInfo->bootConfig); // if true Give prior to the profile resolved trought the CPU model + getBoolForKey("PreferInternalProfileDetect", &val, DEFAULT_BOOT_CONFIG); // if true Give prior to the profile resolved trought the CPU model - val = platformIsServer() ; + val = get_env(envIsServer) ; if (fadt_mod->PreferredProfile <= MaxSupportedPMProfile && !val) { - Platform->Type = fadt_mod->PreferredProfile; + safe_set_env(envType,fadt_mod->PreferredProfile); } else { - fadt_mod->PreferredProfile = Platform->Type; + fadt_mod->PreferredProfile = (U8)get_env(envType); } } // Set PM_Profile and System-type if user wanted this value to be forced - if ( (value=getStringForKey("SystemType", &bootInfo->bootConfig))!=NULL) + if ( (value=getStringForKey("SystemType", DEFAULT_BOOT_CONFIG))!=NULL) { if ((Type = (unsigned char) strtoul(value, NULL, 10) ) <= MaxSupportedPMProfile) { if (fadt_mod->PreferredProfile != Type) { verbose("FADT: changing Preferred_PM_Profile from %d to %d\n", fadt->PreferredProfile, Type); - fadt_mod->PreferredProfile = Platform->Type = Type; + + safe_set_env(envType,(fadt_mod->PreferredProfile = Type)); } else { DBG("FADT: Preferred_PM_Profile was already set to %d, no need to be changed\n",Type); } - } else printf("Error: system-type must be 0..6. Defaulting to %d !\n", Platform->Type); + } else printf("Error: system-type must be 0..6. Defaulting to %d !\n", (U8)get_env(envType)); } - getBoolForKey(KIntelFADT, &intelfadtspec, &bootInfo->bootConfig); + getBoolForKey(KIntelFADT, &intelfadtspec, DEFAULT_BOOT_CONFIG); if ((pmbase == 0) && (cpu_map_error == 0) && (intelfadtspec == true)) { ACPI_TABLE_DSDT *DsdtPointer ; @@ -4183,7 +4187,7 @@ fadt_mod->Flags|= 0x400; int type = PCI_RESET_TYPE; - getIntForKey(KResetType, &type, &bootInfo->bootConfig); + getIntForKey(KResetType, &type, DEFAULT_BOOT_CONFIG); if (type == KEYBOARD_RESET_TYPE) { //Azi: keyboard reset; http://forum.voodooprojects.org/index.php/topic,1056.msg9802.html#msg9802 @@ -4197,7 +4201,7 @@ } verbose("FADT: Restart Fix applied (Type : %s) !\n", (type == 0) ? "PCI": "KEYBOARD"); } - + if (fadt_mod->Header.Revision >= 3) { @@ -4207,35 +4211,36 @@ //fadt_mod->XFacs= (U64)((U32)generate_facs(true)); fadt_mod->XFacs=(U64)fadt->Facs; - + } else { fadt_mod->XFacs=(U64)fadt->XFacs; } - + if(new_dsdt != (void*)0ul) - fadt_mod->XDsdt=((U64)(U32)new_dsdt); + fadt_mod->XDsdt=((U64)(U32)new_dsdt); else if (UpdateFADT) - fadt_mod->XDsdt=(U64)fadt_mod->Dsdt; + fadt_mod->XDsdt=(U64)fadt_mod->Dsdt; - Platform->hardware_signature = ((ACPI_TABLE_FACS *)((U32)fadt_mod->XFacs))->HardwareSignature; - + safe_set_env(envHardwareSignature,((ACPI_TABLE_FACS *)((U32)fadt_mod->XFacs))->HardwareSignature); + + } else { - Platform->hardware_signature = ((ACPI_TABLE_FACS *)fadt_mod->Facs)->HardwareSignature; - + safe_set_env(envHardwareSignature,((ACPI_TABLE_FACS *)fadt_mod->Facs)->HardwareSignature); + } - - DBG("setting hardware_signature to %x \n",Platform->hardware_signature); - - + DBG("setting hardware_signature to %x \n",(U32)get_env(envHardwareSignature)); + + + if (pmbase && (intelfadtspec == true)) ProcessFadt(fadt_mod, pmbase); // The checksum correction will be done by ProcessFadt else @@ -4246,7 +4251,7 @@ static U32 process_xsdt (ACPI_TABLE_RSDP *rsdp_mod , U32 *new_table_list) { - TagPtr DropTables_p = XMLCastDict(XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"ACPIDropTables")); + TagPtr DropTables_p = XMLCastDict(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"ACPIDropTables")); // TODO: fix me U32 new_table = 0ul; U8 new_table_index = 0, table_added = 0; ACPI_TABLE_XSDT *xsdt = (void*)0ul, *xsdt_mod = (void*)0ul; @@ -4292,7 +4297,7 @@ } bool unsafe = false; - getBoolForKey(kUnsafeACPI, &unsafe, &bootInfo->bootConfig); + getBoolForKey(kUnsafeACPI, &unsafe, DEFAULT_BOOT_CONFIG); if (!unsafe) { @@ -4305,15 +4310,13 @@ continue; } } - + } xsdt_mod->TableOffsetEntry[index-dropoffset]=ptr; - - char tableSig[4]; - - strlcpy(tableSig, (char*)((U32)ptr), sizeof(tableSig)+1); - + + char * tableSig = newStringWithLength((char*)((U32)ptr), 4); + DBG("** Processing %s,", tableSig ); DBG(" @%x, Length=%d\n", (U32)ptr, @@ -4323,7 +4326,7 @@ bool oem = false; char oemOption[OEMOPT_SIZE]; sprintf(oemOption, "oem%s",tableSig ); - if (getBoolForKey(oemOption, &oem, &bootInfo->bootConfig) && oem) // This method don't work for DSDT and FACS + if (getBoolForKey(oemOption, &oem, DEFAULT_BOOT_CONFIG) && oem) // This method don't work for DSDT and FACS { DBG(" %s required\n", oemOption); @@ -4358,7 +4361,8 @@ continue; } } - + + free(tableSig); } @@ -4420,12 +4424,12 @@ verbose("XSDT not found or XSDT incorrect\n"); } return (1); - + } static U32 process_rsdt(ACPI_TABLE_RSDP *rsdp_mod , bool gen_xsdt, U32 *new_table_list) { - TagPtr DropTables_p = XMLCastDict(XMLGetProperty(bootInfo->bootConfig.dictionary, (const char*)"ACPIDropTables")); + TagPtr DropTables_p = XMLCastDict(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"ACPIDropTables")); // TODO: fix me U32 new_table = 0ul; U8 new_table_index = 0, table_added = 0; U32 dropoffset=0, index; @@ -4433,7 +4437,7 @@ ACPI_TABLE_XSDT *xsdt_conv = (void *)0ul; rsdt=(ACPI_TABLE_RSDT *)acpi_tables.RsdtPointer; - + rsdt_mod=(ACPI_TABLE_RSDT *)AllocateKernelMemory(rsdt->Header.Length); if (!rsdt_mod) @@ -4458,11 +4462,11 @@ for (index = 0; index < num_tables; index++) { - + { bool unsafe = false; - getBoolForKey(kUnsafeACPI, &unsafe, &bootInfo->bootConfig); + getBoolForKey(kUnsafeACPI, &unsafe, DEFAULT_BOOT_CONFIG); if (!unsafe) { @@ -4479,10 +4483,8 @@ rsdt_mod->TableOffsetEntry[index-dropoffset]=rsdt->TableOffsetEntry[index]; - char tableSig[4]; + char * tableSig = newStringWithLength((char*)(rsdt->TableOffsetEntry[index]), 4); - strlcpy(tableSig, (char*)(rsdt->TableOffsetEntry[index]), sizeof(tableSig)+1); - DBG("** Processing %s,", tableSig ); DBG(" @%x, Length=%d\n", (U32)table_array[index], @@ -4492,7 +4494,7 @@ bool oem = false; char oemOption[OEMOPT_SIZE]; sprintf(oemOption, "oem%s",tableSig ); - if (getBoolForKey(oemOption, &oem, &bootInfo->bootConfig) && oem) // This method don't work for DSDT and FACS + if (getBoolForKey(oemOption, &oem, DEFAULT_BOOT_CONFIG) && oem) // This method don't work for DSDT and FACS { DBG(" %s required\n", oemOption); @@ -4502,7 +4504,7 @@ continue; } } - + { TagPtr match_drop = XMLGetProperty(DropTables_p, (const char*)tableSig); if ( match_drop ) @@ -4527,7 +4529,8 @@ continue; } } - //} + + free(tableSig); } DBG("\n"); @@ -4579,7 +4582,7 @@ #else update_rsdp_with_xsdt(rsdp_mod, xsdt_conv); #endif - + } } @@ -4606,7 +4609,7 @@ ACPI_TABLE_FADT *fadt_file = (void *)0ul; // a Pointer to the (non-patched) fadt file ACPI_TABLE_FADT *FacpPointer = (void *)0ul; // a Pointer to the non-patched FACP table, it can be a file or the FACP table found in the RSDT/XSDT ACPI_TABLE_RSDP *rsdp_mod = (void *)0ul, *rsdp_conv = (void *)0ul; - + U32 rsdplength; bool update_acpi=false, gen_xsdt=false; @@ -4615,7 +4618,7 @@ bool gen_ssdt=false; // will force to generate ssdt even if gen_csta and gen_psta = false bool gen_tsta=false; bool oem_dsdt=false, oem_fadt=false; - + // Find original rsdp if (!FindAcpiTables(&acpi_tables)) { @@ -4633,22 +4636,22 @@ } bool tmpval; - oem_dsdt=getBoolForKey(kOEMDSDT, &tmpval, &bootInfo->bootConfig)&&tmpval; - oem_fadt=getBoolForKey(kOEMFADT, &tmpval, &bootInfo->bootConfig)&&tmpval; - - gen_csta=getBoolForKey(kGenerateCStates, &tmpval, &bootInfo->bootConfig)&&tmpval; - gen_psta=getBoolForKey(kGeneratePStates, &tmpval, &bootInfo->bootConfig)&&tmpval; - gen_ssdt=getBoolForKey(KForceSSDT, &tmpval, &bootInfo->bootConfig)&&tmpval; - update_acpi=getBoolForKey(kUpdateACPI, &tmpval, &bootInfo->bootConfig)&&tmpval; + oem_dsdt=getBoolForKey(kOEMDSDT, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + oem_fadt=getBoolForKey(kOEMFADT, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + + gen_csta=getBoolForKey(kGenerateCStates, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + gen_psta=getBoolForKey(kGeneratePStates, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + gen_ssdt=getBoolForKey(KForceSSDT, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + update_acpi=getBoolForKey(kUpdateACPI, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; - speed_step=getBoolForKey(kSpeedstep, &tmpval, &bootInfo->bootConfig)&&tmpval; - turbo_enabled=(U32)getBoolForKey(kCoreTurbo, &tmpval, &bootInfo->bootConfig)&&tmpval; + speed_step=getBoolForKey(kSpeedstep, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; + turbo_enabled=(U32)getBoolForKey(kCoreTurbo, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; #if BUILD_ACPI_TSS - gen_tsta=(U32)getBoolForKey(kGenerateTStates, &tmpval, &bootInfo->bootConfig)&&tmpval; + gen_tsta=(U32)getBoolForKey(kGenerateTStates, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; #endif - checkOem=getBoolForKey(kOnlySignedAml, &tmpval, &bootInfo->bootConfig)&&tmpval; + checkOem=getBoolForKey(kOnlySignedAml, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; } - + { char* name; long flags; @@ -4686,14 +4689,14 @@ } } } - + if (acpidir_found == true) { if (checkOem == true) { MakeAcpiSgn(); } - + struct dirstuff* moduleDir = opendir(dirspec); while(readdir(moduleDir, (const char**)&name, &flags, &time) >= 0) { @@ -4711,7 +4714,7 @@ { continue; } - + DBG("* Attempting to load acpi table: %s\n", name); if ( (new_table_list[i]=(U32)loadACPITable(new_table_list,dirspec,name))) { @@ -4725,12 +4728,12 @@ break; } } - + } #if DEBUG_ACPI else { - + printf("Ignoring %s\n", name); } #endif @@ -4751,9 +4754,9 @@ } #if HARDCODED_DSDT - do { + do { #include "dsdt_PRLSACPI.h" - + U8 index = 0; if ((get_new_table_in_list(new_table_list, NAMESEG("DSDT"), &new_table_index)) != (void*)0ul ) @@ -4765,7 +4768,7 @@ U8 empty = get_0ul_index_in_list(new_table_list, false); if (empty != ACPI_TABLE_LIST_FULL_NON_RESERVED) { - index = empty; + index = empty; } else { @@ -4800,7 +4803,7 @@ gen_psta= true; gen_csta= true; } - + ACPI_TABLE_RSDP *rsdp=(ACPI_TABLE_RSDP *)acpi_tables.RsdPointer; @@ -4827,7 +4830,7 @@ rsdplength=(Revision == 2)?rsdp->Length:ACPI_RSDP_REV0_SIZE; DBG("RSDP Revision %d found @%x. Length=%d\n",Revision,rsdp,rsdplength); - + if (gen_xsdt) { rsdp_mod=rsdp_conv; @@ -4841,7 +4844,7 @@ memcpy(rsdp_mod, rsdp, rsdplength); } - + if ((fadt_file = (ACPI_TABLE_FADT *)get_new_table_in_list(new_table_list, NAMESEG("FACP"), &new_table_index)) != (void *)0ul) { @@ -4878,7 +4881,7 @@ { fadt_mod = patch_fadt(FacpPointer, (oem_dsdt == false) ? new_dsdt : (void*)0ul , (acpi_tables.FacpPointer64 != (void *)0ul )); - + if (fadt_mod != (void*)0ul) { DsdtPtr = ((fadt_mod->Header.Revision >= 3) && (fadt_mod->XDsdt != 0)) ? (ACPI_TABLE_DSDT*)((U32)fadt_mod->XDsdt):(ACPI_TABLE_DSDT*)fadt_mod->Dsdt; @@ -4931,7 +4934,7 @@ } } - + } else { @@ -4942,14 +4945,14 @@ (ACPI_TABLE_FADT *)acpi_tables.FacpPointer64 : (ACPI_TABLE_FADT *)acpi_tables.FacpPointer; DsdtPtr = ((fadt_mod->Header.Revision >= 3) && (fadt_mod->XDsdt != 0)) ? (ACPI_TABLE_DSDT*)((U32)fadt_mod->XDsdt) - :(ACPI_TABLE_DSDT*)fadt_mod->Dsdt; + :(ACPI_TABLE_DSDT*)fadt_mod->Dsdt; } - + { MADT_INFO madt_info; bool strip_madt = true; - getBoolForKey(kSTRIPAPIC, &strip_madt, &bootInfo->bootConfig); + getBoolForKey(kSTRIPAPIC, &strip_madt, DEFAULT_BOOT_CONFIG); if ((strip_madt == false) || (!buildMADT(new_table_list, DsdtPtr, &madt_info ))) { @@ -4960,7 +4963,7 @@ { bool tmpval; - oem_apic=getBoolForKey(kOEMAPIC, &tmpval, &bootInfo->bootConfig)&&tmpval; + oem_apic=getBoolForKey(kOEMAPIC, &tmpval, DEFAULT_BOOT_CONFIG)&&tmpval; } if ((madt_file = (ACPI_TABLE_MADT *)get_new_table_in_list(new_table_list, NAMESEG("APIC"), &new_table_index)) != (void *)0ul) @@ -4974,7 +4977,7 @@ MadtPointer = (acpi_tables.MadtPointer64 != (void*)0ul) ? (ACPI_TABLE_MADT *)acpi_tables.MadtPointer64 : (ACPI_TABLE_MADT *)acpi_tables.MadtPointer; ProcessMadtInfo(MadtPointer, &madt_info); - + } if (gen_ssdt || gen_csta || gen_psta || gen_tsta) @@ -4997,13 +5000,13 @@ printf("Error: Incorect ACPI RSD PTR or not found \n"); return EFI_UNSUPPORTED; } - + if ((GetChecksum(rsdp_mod, sizeof(ACPI_TABLE_RSDP)) == 0) && (Revision == 2) && (rsdplength == sizeof(ACPI_TABLE_RSDP))) { process_xsdt(rsdp_mod, new_table_list); - + } else { @@ -5012,7 +5015,7 @@ if ((rsdp_mod != (void *)0ul) && (rsdp_mod->Length >= ACPI_RSDP_REV0_SIZE) ) { process_rsdt(rsdp_mod, false, new_table_list); - + } else { @@ -5020,7 +5023,7 @@ return EFI_UNSUPPORTED; } } - + out: // Correct the checksum of RSDP @@ -5042,20 +5045,8 @@ verbose("ACPI Revision %d successfully patched\n", Revision); - if (Revision == 2) - { - rsd_p = ((U64)((U32)rsdp_mod)); - if (rsd_p) - Status = addConfigurationTable(&gEfiAcpi20TableGuid, &rsd_p, "ACPI_20"); - } - else - { - rsd_p = ((U64)((U32)rsdp_mod)); - if (rsd_p) - Status = addConfigurationTable(&gEfiAcpiTableGuid, &rsd_p, "ACPI"); - - } - + Status = Register_Acpi_Efi(rsdp_mod, Revision); + #if DEBUG_ACPI==2 printf("Press a key to continue... (DEBUG_ACPI)\n"); getc(); Index: branches/cparm/i386/modules/ACPICodec/ACPICodec.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/ACPICodec.c (revision 1839) +++ branches/cparm/i386/modules/ACPICodec/ACPICodec.c (revision 1840) @@ -5,35 +5,29 @@ #include "libsaio.h" #include "modules.h" -#include "boot.h" #include "bootstruct.h" #include "pci_root.h" #include "acpi_codec.h" #define kEnableAcpi "EnableAcpiModule" -void ACPICodec_setupEfiConfigurationTable_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) -{ - EFI_STATUS *ret = (EFI_STATUS *)arg1; - - // Setup ACPI (mackerintel's patch) - *ret = setupAcpi(); - -} +void is_ACPI_Codec_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void ACPICodec_start(void); void is_ACPI_Codec_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){} -void ACPICodec_start() +void ACPICodec_start(void) { bool enable = true; - getBoolForKey(kEnableAcpi, &enable, &bootInfo->bootConfig) ; + getBoolForKey(kEnableAcpi, &enable, DEFAULT_BOOT_CONFIG) ; enable = (execute_hook("isACPIRegistred", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS); if (enable) { - register_hook_callback("setupAcpiEfi", &ACPICodec_setupEfiConfigurationTable_hook); + replace_system_function("_setup_acpi",&setupAcpi); + register_hook_callback("isACPIRegistred", &is_ACPI_Codec_Registred_Hook); - + } } \ No newline at end of file Index: branches/cparm/i386/modules/ACPICodec/Makefile =================================================================== --- branches/cparm/i386/modules/ACPICodec/Makefile (revision 1839) +++ branches/cparm/i386/modules/ACPICodec/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -ACPI_CODEC_OBJS = ACPICodec.o acpicode.o acpidecode.o acpi_codec.o +ACPI_CODEC_OBJS = ACPICodec.o acpicode.o acpidecode.o acpi_codec.o stack_protector.o SFILES = @@ -71,12 +71,16 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/acpicode.o \ + $(OBJROOT)/stack_protector.o \ + $(OBJROOT)/acpicode.o \ $(OBJROOT)/acpidecode.o \ $(OBJROOT)/ACPICodec.o \ $(OBJROOT)/acpi_codec.o \ -o $(SYMROOT)/$(MODULE_NAME).dylib - + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + ACPICodec.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "ACPICodec.c" $(INC) -o "$(OBJROOT)/ACPICodec.o" Index: branches/cparm/i386/modules/HelloWorld/HelloWorld.c =================================================================== --- branches/cparm/i386/modules/HelloWorld/HelloWorld.c (revision 1839) +++ branches/cparm/i386/modules/HelloWorld/HelloWorld.c (revision 1840) @@ -6,6 +6,9 @@ #include "libsaio.h" #include "modules.h" +void helloWorld2(void* binary, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); +void helloWorld(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6); + void helloWorld2(void* binary, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6) { printf("Hello world from ExecKernel hook. Binary located at 0x%X\n", binary); @@ -20,7 +23,8 @@ } -void HelloWorld_start() +void HelloWorld_start(void); +void HelloWorld_start(void) { register_hook_callback("ExecKernel", &helloWorld2); register_hook_callback("PreBoot", &helloWorld); Index: branches/cparm/i386/modules/HelloWorld/Makefile =================================================================== --- branches/cparm/i386/modules/HelloWorld/Makefile (revision 1839) +++ branches/cparm/i386/modules/HelloWorld/Makefile (revision 1840) @@ -45,7 +45,7 @@ VPATH = $(OBJROOT):$(SYMROOT) -HELLO_WORLD_OBJS = HelloWorld.o +HELLO_WORLD_OBJS = HelloWorld.o stack_protector.o SFILES = @@ -71,9 +71,13 @@ -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ -final_output $(MODULE_NAME) \ -macosx_version_min 10.6 \ - $(OBJROOT)/HelloWorld.o -o $(SYMROOT)/$(MODULE_NAME).dylib + $(OBJROOT)/stack_protector.o $(OBJROOT)/HelloWorld.o -o $(SYMROOT)/$(MODULE_NAME).dylib + +stack_protector.o: + $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o" + HelloWorld.o: $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "HelloWorld.c" $(INC) -o "$(OBJROOT)/HelloWorld.o" Index: branches/cparm/i386/modules/Makefile =================================================================== --- branches/cparm/i386/modules/Makefile (revision 1839) +++ branches/cparm/i386/modules/Makefile (revision 1840) @@ -26,7 +26,7 @@ VPATH = $(OBJROOT):$(SYMROOT) # The order of building is important. -SUBDIRS = KernelPatcher GUI GraphicsEnabler HPET USBFix Memory Networking ACPICodec ACPIPatcher NetbookInstaller CPUfreq Keymapper RamDiskLoader HibernateEnabler SMBiosPatcher SMBiosGetters YellowIconFixer HelloWorld +SUBDIRS = HelloWorld KernelPatcher USBFix Networking HPET NetbookInstaller CPUfreq Keymapper YellowIconFixer ACPICodec ACPIPatcher GraphicsEnabler Memory RamDiskLoader SMBiosPatcher SMBiosGetters GUI HibernateEnabler all embedtheme tags debug install installhdrs: @rm -rf $(OBJROOT) @mkdir $(OBJROOT) Index: branches/cparm/i386/libsa/libsa.h =================================================================== --- branches/cparm/i386/libsa/libsa.h (revision 1839) +++ branches/cparm/i386/libsa/libsa.h (revision 1840) @@ -31,11 +31,9 @@ #include #include #include -#if 0 -#include "C_Exception.h" -#endif -#include "quad.h" +#include +#include "quad.h" /* * This macro casts away the qualifier from the variable * @@ -58,6 +56,11 @@ #define ispunct(c) (c == '.' || c == '-') //Azi: TODO - add more ponctuation characters as needed; at least these two, i need for PartNo. /* + * lzss.c + */ +extern int decompress_lzss(u_int8_t *dst, u_int8_t *src, u_int32_t srclen); + +/* * string.c */ @@ -103,7 +106,9 @@ extern uint8_t checksum8( void * start, unsigned int length ); extern unsigned long adler32( unsigned char * buffer, long length ); - +extern void * bsearch(register const void *key,const void *base0,size_t nmemb,register size_t size,register int (*compar)(const void *, const void *)); +extern int rand (void); +extern void srand (unsigned int seed); /* * strtol.c */ @@ -137,27 +142,4 @@ extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t)); extern void * malloc(size_t size); -/* - * rand.c - * - * rand & srand implementation for chameleon by Cadet-petit Armel - */ - - -extern int rand (void); -extern void srand (unsigned int seed); - - -/* - * C_Exception.c - * - */ -extern void exception_init (void (*exception_err_fn)(char *, int)); - -/* - * getsegbyname.c - */ -//extern struct segment_command * -// getsegbynamefromheader(struct mach_header * mhp, char * segname); - #endif /* !__BOOT_LIBSA_H */ Index: branches/cparm/i386/libsa/string.c =================================================================== --- branches/cparm/i386/libsa/string.c (revision 1839) +++ branches/cparm/i386/libsa/string.c (revision 1840) @@ -200,6 +200,13 @@ return (const char *) (in - 1); } +void * +memmove(void *dst, const void *src, size_t ulen) +{ + bcopy(src, dst, ulen); + return dst; +} + int ptol(const char *str) { @@ -572,7 +579,7 @@ } /*- - * For memcmp. + * For memcmp, bsearch. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -619,4 +626,46 @@ } while (--n != 0); } return (0); +} + +/* + * Perform a binary search. + * + * The code below is a bit sneaky. After a comparison fails, we + * divide the work in half by moving either left or right. If lim + * is odd, moving left simply involves halving lim: e.g., when lim + * is 5 we look at item 2, so we change lim to 2 so that we will + * look at items 0 & 1. If lim is even, the same applies. If lim + * is odd, moving right again involes halving lim, this time moving + * the base up one item past p: e.g., when lim is 5 we change base + * to item 3 and make lim 2 so that we will look at items 3 and 4. + * If lim is even, however, we have to shrink it by one before + * halving: e.g., when lim is 4, we still looked at item 2, so we + * have to make lim 3, then halve, obtaining 1, so that we will only + * look at item 3. + */ +void * +bsearch(key, base0, nmemb, size, compar) +register const void *key; +const void *base0; +size_t nmemb; +register size_t size; +register int (*compar)(const void *, const void *); +{ + register const char *base = base0; + register size_t lim; + register int cmp; + register const void *p; + + for (lim = nmemb; lim != 0; lim >>= 1) { + p = base + (lim >> 1) * size; + cmp = (*compar)(key, p); + if (cmp == 0) + return ((void *)(uintptr_t)p); + if (cmp > 0) { /* key > p: move right */ + base = (const char *)p + size; + lim--; + } /* else move left */ + } + return (NULL); } \ No newline at end of file Index: branches/cparm/i386/libsa/qsort.c =================================================================== --- branches/cparm/i386/libsa/qsort.c (revision 1839) +++ branches/cparm/i386/libsa/qsort.c (revision 1840) @@ -55,7 +55,7 @@ */ #include -#include +#include "libsa.h" static inline char *med3 __P((char *, char *, char *, int (*)())); static inline void swapfunc __P((char *, char *, int, int)); Index: branches/cparm/i386/libsa/prf.c =================================================================== --- branches/cparm/i386/libsa/prf.c (revision 1839) +++ branches/cparm/i386/libsa/prf.c (revision 1840) @@ -95,6 +95,12 @@ unsigned int *adx, void (*putfn_p)(), void *putfn_arg + ); +int prf( + char *fmt, + unsigned int *adx, + void (*putfn_p)(), + void *putfn_arg ) { int b, c, len =0; Index: branches/cparm/i386/libsa/lzss.c =================================================================== --- branches/cparm/i386/libsa/lzss.c (revision 0) +++ branches/cparm/i386/libsa/lzss.c (revision 1840) @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 2.0 (the "License"). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. + * + * The Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/************************************************************** + LZSS.C -- A Data Compression Program +*************************************************************** + 4/6/1989 Haruhiko Okumura + Use, distribute, and modify this program freely. + Please send me your improved versions. + PC-VAN SCIENCE + NIFTY-Serve PAF01022 + CompuServe 74050,1022 + +**************************************************************/ +/* + * lzss.c - Package for decompressing lzss compressed objects + * + * Copyright (c) 2003 Apple Computer, Inc. + * + * DRI: Josh de Cesare + */ + +#include "sl.h" + +#define N 4096 /* size of ring buffer - must be power of 2 */ +#define F 18 /* upper limit for match_length */ +#define THRESHOLD 2 /* encode string into position and length + if match_length is greater than this */ +//#define NIL N /* index for root of binary search trees */ + +int +decompress_lzss(u_int8_t *dst, u_int8_t *src, u_int32_t srclen) +{ + /* ring buffer of size N, with extra F-1 bytes to aid string comparison */ + u_int8_t text_buf[N + F - 1]; + u_int8_t *dststart = dst; + u_int8_t *srcend = src + srclen; + int i, j, k, r, c; + unsigned int flags; + + dst = dststart; + srcend = src + srclen; + for (i = 0; i < N - F; i++) + text_buf[i] = ' '; + r = N - F; + flags = 0; + for ( ; ; ) { + if (((flags >>= 1) & 0x100) == 0) { + if (src < srcend) c = *src++; else break; + flags = c | 0xFF00; /* uses higher byte cleverly */ + } /* to count eight */ + if (flags & 1) { + if (src < srcend) c = *src++; else break; + *dst++ = c; + text_buf[r++] = c; + r &= (N - 1); + } else { + if (src < srcend) i = *src++; else break; + if (src < srcend) j = *src++; else break; + i |= ((j & 0xF0) << 4); + j = (j & 0x0F) + THRESHOLD; + for (k = 0; k <= j; k++) { + c = text_buf[(i + k) & (N - 1)]; + *dst++ = c; + text_buf[r++] = c; + r &= (N - 1); + } + } + } + + return dst - dststart; +} Index: branches/cparm/i386/libsa/Makefile =================================================================== --- branches/cparm/i386/libsa/Makefile (revision 1839) +++ branches/cparm/i386/libsa/Makefile (revision 1840) @@ -8,7 +8,7 @@ INSTALL_MD_DIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/machdep/i386 OPTIM = -Os -Oz -CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror -fstack-protector-all \ +CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror -fno-stack-protector \ -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ -mpreferred-stack-boundary=2 -fno-align-functions \ -march=pentium4 -msse2 -mfpmath=sse -msoft-float @@ -28,12 +28,12 @@ SA_OBJS = qdivrem.o umoddi3.o udivdi3.o divdi3.o moddi3.o bzero.o bcopy.o prf.o printf.o zalloc.o\ string.o strtol.o \ - setjmp.o qsort.o efi_tables.o + setjmp.o qsort.o efi_tables.o lzss.o SFILES = setjmp.s bzero.s bcopy.s CFILES = qdivrem.c umoddi3.c udivdi3.c divdi3.c moddi3.c prf.c printf.c zalloc.c \ string.c strtol.c \ - qsort.c efi_tables.c + qsort.c efi_tables.c lzss.c HFILES = memory.h EXPORTED_HFILES = libsa.h memory.h Index: branches/cparm/CREDITS =================================================================== --- branches/cparm/CREDITS (revision 1839) +++ branches/cparm/CREDITS (revision 1840) @@ -47,3 +47,4 @@ scorpius ErmaC scrax +dmazar Index: branches/cparm/README =================================================================== --- branches/cparm/README (revision 1839) +++ branches/cparm/README (revision 1840) @@ -1,3 +1,3 @@ Chameleon is a Darwin/XNU boot loader based on Apple's boot-132. -WARNING: THIS PROJECT IS NOT COMPATIBLE WITH XCODE4 \ No newline at end of file +WARNING: THIS PROJECT IS NOT FULLY COMPATIBLE WITH XCODE4 \ No newline at end of file